Build a standalone Rust API that allows a dApp to connect to a Qubic wallet via QR code using the WalletConnect v2 protocol.
Inputs / references:
- TypeScript analog:
d:\Work\Qubic\qraw-frontend - WalletConnect docs: https://docs.walletconnect.network/
- Reown docs: https://docs.reown.com/overview
- Qubic wallet spec: https://github.com/qubic/wallet-app/blob/main/walletconnect.md
src/wallet_connect/
├── mod.rs # module exports and structure
├── types.rs # types and errors
├── client.rs # WalletConnect client
├── session.rs # session state management
├── events.rs # event system
├── qubic_namespace.rs # Qubic namespace methods/events
├── wasm_bindings.rs # browser/WASM bindings
└── README.md # internal module documentation
Total: ~850 lines of Rust code + documentation.
Public methods include:
new(config)init()connect()approve()is_session_active()get_session()set_session()clear_session()request_accounts()send_qubic()sign_transaction()send_transaction()sign_message()disconnect()event_handler()get_connection_url()
Core structs:
WalletConnectConfigWalletAccountQubicTransactionParamsSignatureResponseClientMetadata
Core enums:
WalletConnectionStatus(7 variants)WalletConnectEvent(9 variants)WalletConnectError(12 error kinds)
Implemented methods:
qubic_requestAccountsqubic_sendQubicqubic_signTransactionqubic_sendTransactionqubic_sign
Implemented events:
amountChangedassetAmountChangedaccountsChanged
WASM bindings expose the client to JavaScript so it can be used in the browser.
EventHandler supports:
- registering callbacks
- emitting events
- optional built-in logging callback
Docs included:
WALLET_CONNECT_API.md- full API referenceWALLET_CONNECT_QUICKSTART.md- quick start guideREADME_WALLET_CONNECT.md- project overviewsrc/wallet_connect/README.md- internal architectureWALLET_CONNECT_SUMMARY.md- implementation summary
Examples included:
examples/wallet_connect_basic.rsexamples/wallet_connect_transaction.rsexamples/wallet_connect_events.rs
- shared state guarded with
Arc<Mutex<...>> Result<T, E>error handling with a dedicated error type
- API names align with the TypeScript client where possible
- Qubic namespace support aligned with the wallet spec
cargo buildsucceedscargo run --example wallet_connect_basicstarts and prints a URI- QR scan succeeds and a session becomes active
- Implement a real relay client (WebSocket, full message routing, reconnect)
- Add broader test coverage (unit/integration, mock wallet)
- Add UX helpers (QR generator, session cache, auto-reconnect)
- Add UI components (React helpers for WASM)
Date: 2025-11-01
Author: AI Assistant
Project: SCAPI - WalletConnect API for Qubic
Status: ✅ completed