/** * Represents a WalletConnect session proposal from a dApp. * * When a dApp wants to connect via WalletConnect, it sends a session proposal * containing its metadata and the blockchain namespaces it requires or optionally * supports. The host (native app) uses this to display a pairing confirmation UI * and decide which chains/methods/events to approve. */ export type WCSessionProposal = { /** Unique identifier for this proposal, used when approving or rejecting */ id: number; params: { /** Information about the dApp requesting the connection */ proposer: { metadata: { /** Human-readable name of the dApp (e.g. "Uniswap") */ name: string; /** Short description of the dApp */ description: string; /** Homepage URL of the dApp */ url: string; /** Icon URLs for the dApp, used in the pairing confirmation UI */ icons: string[]; }; }; /** * Namespaces the dApp requires — the session will fail if these * cannot be satisfied (e.g. `{ eip155: { chains: ["eip155:1"], ... } }`) */ requiredNamespaces?: Record; /** * Namespaces the dApp optionally supports — the session can still be * established even if these are not fully satisfied */ optionalNamespaces?: Record; }; }; /** * Describes the capabilities of a single blockchain namespace in WalletConnect. * * A namespace groups chains of the same family (e.g. `eip155` for EVM chains, * `solana` for Solana chains) together with the JSON-RPC methods and events * that the dApp wants to use on those chains. */ export type WCNamespace = { /** CAIP-2 chain identifiers (e.g. `["eip155:1", "eip155:137"]`) */ chains?: string[]; /** JSON-RPC methods the dApp wants to call (e.g. `["eth_sendTransaction", "personal_sign"]`) */ methods: string[]; /** Events the dApp wants to listen to (e.g. `["chainChanged", "accountsChanged"]`) */ events: string[]; }; /** * Represents an incoming signing or transaction request from a connected dApp. * * After a WalletConnect session is established, the dApp can send requests * (e.g. sign a message, send a transaction). This type carries the request * payload from the webview to the native layer so it can be shown in a * confirmation UI or processed directly. */ export type WCSessionRequest = { /** Unique identifier for this request, used when responding */ id: number; /** Session topic identifying which connected dApp sent this request */ topic: string; params: { /** The JSON-RPC request payload */ request: { /** JSON-RPC method name (e.g. `"personal_sign"`, `"solana_signTransaction"`) */ method: string; /** Method-specific parameters */ params: unknown[]; }; /** CAIP-2 chain the request targets (e.g. `"eip155:1"`, `"solana:5eykt4..."`) */ chainId: string; }; }; /** * Represents an active WalletConnect session with a connected dApp. * * Once a session proposal is approved, the session is established and persisted. * Each session tracks the connected peer's metadata, the approved namespaces * (including which accounts are exposed), and an expiry timestamp. */ export type WCSession = { /** Unique topic identifier for this session, used for all subsequent communication */ topic: string; /** Information about the connected dApp */ peer: { metadata: { /** Human-readable name of the connected dApp */ name: string; /** Short description of the connected dApp */ description: string; /** Homepage URL of the connected dApp */ url: string; /** Icon URLs for the connected dApp */ icons: string[]; }; }; /** * Approved namespaces with the accounts exposed to the dApp. * Keys are namespace identifiers (e.g. `"eip155"`, `"solana"`). * Each value extends {@link WCNamespace} with an `accounts` array * of CAIP-10 account IDs (e.g. `["eip155:1:0xabc..."]`). */ namespaces: Record; /** Unix timestamp (seconds) when this session expires */ expiry: number; }; /** * State synchronized from the webview to the native layer for the global * wallet connectivity module. * * The webview controller pushes this state whenever sessions change, allowing * the native app to reactively update its UI (e.g. show connected dApps). */ export type GlobalWalletModuleState = { /** Map of active WC sessions keyed by their topic identifier */ sessions: Record; /** Whether the WalletKit singleton and WC event listeners have been initialized */ initialized: boolean; }; /** * Message contract between the native host and the webview for global wallet * WalletConnect connectivity. * * The native app uses request messages (`initGlobalWallet`, `pairWithWC`, etc.) * to drive the WalletConnect lifecycle that runs inside the webview. The webview * uses event messages (`onSessionProposal`, `onSessionRequest`, `onSessionDelete`) * to notify the native layer of WC events so it can display native confirmation * UIs or update state. */ export type GlobalWalletModuleMessages = { /** * Initialize the WalletKit singleton and start listening for WC session * events. Must be called before any other global wallet operation. */ initGlobalWallet: () => Promise; /** * Pair with a dApp using a WalletConnect URI obtained from a QR code scan * or deep link. Triggers a session proposal from the dApp. * @param params.uri - The WalletConnect pairing URI (e.g. `"wc:abc123..."`) */ pairWithWC: (params: { uri: string; }) => Promise; /** * Approve or reject a pending session proposal. * Called after the native app shows the pairing confirmation UI to the user. * @param params.confirm - `true` to approve, `false` to reject */ confirmPairing: (params: { confirm: boolean; }) => Promise; /** * Disconnect a specific WC session, removing it from active sessions * and notifying the connected dApp. * @param params.topic - The session topic to disconnect */ disconnectWCSession: (params: { topic: string; }) => Promise; /** * Retrieve all currently active WC sessions. * Used by the native app to display a list of connected dApps. */ getConnectedWCSessions: () => Promise<{ sessions: Record; }>; /** * Retrieve the pending session proposal, if one exists. * Used to restore UI state if the native confirmation screen needs * to be re-rendered (e.g. after a navigation event). */ getPendingPairing: () => Promise<{ proposal: WCSessionProposal | null; }>; /** * Respond to a session request from a connected dApp. * Used in the mobile flow where the native app shows its own confirmation UI * for signing/transaction requests instead of the webview handling it directly. * @param params.id - The request ID to respond to * @param params.topic - The session topic the request belongs to * @param params.approved - `true` to proceed with signing, `false` to reject */ respondSessionRequest: (params: { id: number; topic: string; approved: boolean; }) => Promise; /** * Event emitted by the webview when a dApp proposes a new session. * The native app should display a pairing confirmation UI and * call `confirmPairing` with the user's decision. */ onSessionProposal: (proposal: WCSessionProposal) => void; /** * Event emitted by the webview when a connected dApp sends a * signing or transaction request. The native app should display * a confirmation UI and call `respondSessionRequest` with the result. */ onSessionRequest: (request: WCSessionRequest) => void; /** * Event emitted by the webview when a session is deleted * (either by the dApp or due to expiry). The native app should * update its UI to reflect the disconnection. */ onSessionDelete: (params: { topic: string; }) => void; }; /** * List of event message names in {@link GlobalWalletModuleMessages}. * * Used to distinguish events (webview -> native notifications) from * request/response messages (native -> webview calls). This allows * the message transport layer to route events to event listeners * rather than treating them as request-response calls. */ export declare const globalWalletEventNames: ("onSessionProposal" | "onSessionRequest" | "onSessionDelete")[];