import type { Network, NetworkId, Namespace } from './networks'; import type { ConnectionMode } from './connection-mode'; import type { AvailableAddress } from './session'; import type { DetectedEIP6963WalletInfo, DetectedSolanaWalletInfo, DetectedTronWalletInfo, DetectedTonWalletInfo, ExtensionInjectedProvider, IntegratedBrowserInjectedProvider, WalletConnectProvider, TonConnectWalletProvider, WalletMetadata } from './UWC-state'; import type { EVMCapabilities, TransactionRequest, TransactionResult } from './transactions'; import type { SignatureType, EIP712TypedData } from './signature'; /** * A post-connect wallet lifecycle change observed from the live provider. * * PII-safe by construction: there is NO address field. For `accountChanged` we * signal only THAT the account/list changed (the new address is dropped at the * connector boundary). `chainChanged` carries the new CAIP-2 id (non-PII) when * resolvable. */ export type WalletLifecycleEvent = { type: 'accountChanged'; } | { type: 'chainChanged'; chainId?: NetworkId; } | { type: 'disconnect'; } | { type: 'sessionExpired'; }; /** * Names the session a lifecycle subscription is being attached FOR. The caller * (core) resolves it from the active session and passes it explicitly — a * connector must never infer it from its own ambient state, which can be * ambiguous (a secondary-namespace gather leaves more than one internal * service holding a live provider surface). */ export interface WalletLifecycleContext { /** Transport of the session being observed. */ connectionMode: ConnectionMode; /** ACTIVE namespace of the session — the surface the connector must observe. */ namespace?: Namespace; walletId?: string; } /** * Result interface for connect operations */ export interface ConnectorResult { networkId: NetworkId; address: string; availableAddresses: AvailableAddress[]; publicKey?: string; } /** * Result interface for network switch operations */ export interface SwitchNetworkResult { networkId: NetworkId; address: string; availableAddresses?: AvailableAddress[]; } /** * Common interface for all wallet connectors */ export interface Connector { /** * Connect to a wallet on the specified network * @param network The network to connect to * @param args Additional arguments specific to the connector type * @returns A promise that resolves to a ConnectorResult containing the network ID, wallet address, and available addresses */ connect(network: Network, provider?: ExtensionInjectedProvider | IntegratedBrowserInjectedProvider | WalletConnectProvider | TonConnectWalletProvider): Promise; /** * Get the connection URI for the wallet, if applicable * This is typically used for WalletConnect or similar protocols * to allow the user to scan a QR code or open a link * to initiate the connection. * @return A string representing the connection URI, or undefined if not applicable * @remarks This method is optional and may not be implemented by all connectors. */ getConnectionURI?(): string; /** * Pre-generate a connection pairing (URI) ahead of wallet selection, WITHOUT * waiting for approval. Warms the transport (e.g. opens the WalletConnect relay * socket on a cold client) and returns a URI the caller can deep-link inside a * user gesture; a subsequent `connect()` adopts the same pairing so the URI the * user approves matches the one opened. Optional — only connectors with a * pairing step (WalletConnect) implement it. * @param provider Only `supportedNetworkIds` is required (pass the UNION of the * session's WalletConnect wallets' networks so one pairing serves any wallet). * @returns The pairing URI. */ beginPairing?(provider: Pick): Promise; /** * Disconnect from the wallet * This method is optional and may not be implemented by all connectors. * @returns A promise that resolves when the disconnection is complete */ disconnect?(): Promise; /** * Switch to a different network * @param network The network to switch to * @param args Additional arguments specific to the connector type * @returns A promise that resolves to a SwitchNetworkResult containing the network ID and new wallet address */ switchNetwork(network: Network, provider?: ExtensionInjectedProvider | IntegratedBrowserInjectedProvider | WalletConnectProvider | TonConnectWalletProvider): Promise; /** * Get available wallets for a specific namespace * This method is optional and may not be implemented by all connectors. * @param namespace The namespace to check for available wallets (e.g., 'eip155', 'solana') * @param expectedWallets The expected wallets to check for * @returns A promise that resolves to an array of detected wallets, or undefined if not supported */ getAvailableWallets?(namespace: Namespace, expectedWallets?: WalletMetadata[]): Promise; /** * Sign a message with the connected wallet * @param message The message to sign * @param provider The wallet provider (required for injected connector) * @returns A promise that resolves to the signature */ signMessage?(message: string, provider?: ExtensionInjectedProvider | IntegratedBrowserInjectedProvider | WalletConnectProvider | TonConnectWalletProvider): Promise; /** * Sign EIP-712 typed structured data (eth_signTypedData_v4). * Required for ERC-3009 (Transfer With Authorization) and EIP-2612 (Permit) relay flows. * EVM-only (eip155); connectors that don't support it leave this undefined. * @returns A promise that resolves to the 65-byte hex signature (0x-prefixed) */ signTypedData?(typedData: EIP712TypedData, provider?: ExtensionInjectedProvider | IntegratedBrowserInjectedProvider | WalletConnectProvider): Promise; /** * Send a transaction with the connected wallet * @param request The transaction request parameters * @param provider The wallet provider (required for injected connector) * @returns A promise that resolves to the transaction result */ sendTransaction?(request: TransactionRequest, provider?: ExtensionInjectedProvider | IntegratedBrowserInjectedProvider | WalletConnectProvider | TonConnectWalletProvider): Promise; getWalletCapabilities?(from: string, networks: Network[]): Promise>; /** * Sign a Solana tx without broadcasting — raw bytes in/out (no @solana/web3.js * for callers). Fee-payer relay flows: the wallet adds only the user's * signature, the relay broadcasts. Optional; not all connectors support it. */ signSolanaTransactionBytes?(serializedTx: Uint8Array): Promise; /** * Subscribe to post-connect wallet lifecycle changes from the live provider * (account/chain switched in the wallet, disconnect, session expiry). For * OBSERVABILITY only — it never changes connection behaviour. * * Implementations MUST NOT include an address in the emitted event (the PII * boundary stays in core). The caller passes a `WalletLifecycleContext` * naming the session being observed (active namespace / transport / wallet); * implementations route by it rather than inferring from internal state. * Returns an unsubscribe function, or `undefined` when this connector/session * can't be observed (no live `.on`, unsupported namespace) — the core then * emits `lifecycleTelemetryUnavailable`. Optional: a connector that never * observes lifecycle leaves it undefined entirely. */ onLifecycleEvent?(listener: (event: WalletLifecycleEvent) => void, context: WalletLifecycleContext): (() => void) | undefined; } //# sourceMappingURL=connector.d.ts.map