@metamask/connect-evm 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/README.md +448 -41
- package/dist/browser/es/connect-evm.mjs +222 -151
- package/dist/browser/es/connect-evm.mjs.map +1 -1
- package/dist/src/connect.d.ts +55 -31
- package/dist/src/connect.d.ts.map +1 -1
- package/dist/src/connect.js +203 -153
- package/dist/src/connect.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger.d.ts +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +3 -5
- package/dist/src/logger.js.map +1 -1
- package/dist/src/provider.d.ts +3 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +6 -9
- package/dist/src/provider.js.map +1 -1
- package/dist/src/types.d.ts +7 -6
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/infura.d.ts +3 -0
- package/dist/src/utils/infura.d.ts.map +1 -0
- package/dist/src/utils/infura.js +16 -0
- package/dist/src/utils/infura.js.map +1 -0
- package/dist/types/index.d.ts +68 -41
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/index.ts","../../../src/connect.ts","../../../src/constants.ts","../../../src/logger.ts","../../../src/provider.ts","../../../src/utils/caip.ts","../../../src/utils/type-guards.ts"],"sourcesContent":["export { getInfuraRpcUrls } from '@metamask/connect-multichain';\nexport { createEVMClient, type MetamaskConnectEVM } from './connect';\nexport type { EIP1193Provider } from './provider';\n\nexport type * from './types';\n","import { analytics } from '@metamask/analytics';\nimport type { Caip25CaveatValue } from '@metamask/chain-agnostic-permission';\nimport type {\n ConnectionStatus,\n MultichainCore,\n MultichainOptions,\n Scope,\n SessionData,\n} from '@metamask/connect-multichain';\nimport {\n createMultichainClient,\n getWalletActionAnalyticsProperties,\n isRejectionError,\n TransportType,\n} from '@metamask/connect-multichain';\nimport {\n numberToHex,\n hexToNumber,\n isHexString as isHex,\n} from '@metamask/utils';\n\nimport { IGNORED_METHODS } from './constants';\nimport { enableDebug, logger } from './logger';\nimport { EIP1193Provider } from './provider';\nimport type {\n AddEthereumChainParameter,\n Address,\n CaipAccountId,\n EventHandlers,\n Hex,\n MetamaskConnectEVMOptions,\n ProviderRequest,\n ProviderRequestInterceptor,\n} from './types';\nimport { getPermittedEthChainIds } from './utils/caip';\nimport {\n isAccountsRequest,\n isAddChainRequest,\n isChainIdRequest,\n isConnectRequest,\n isSwitchChainRequest,\n validSupportedChainsUrls,\n} from './utils/type-guards';\n\nconst DEFAULT_CHAIN_ID = 1;\nconst CHAIN_STORE_KEY = 'cache_eth_chainId';\n\n/** The options for the connect method */\ntype ConnectOptions = {\n /** The account to connect to */\n account?: string | undefined;\n /** Whether to force a request regardless of an existing session */\n forceRequest?: boolean;\n /** All available chain IDs in the dapp */\n chainIds: number[];\n};\n\n/**\n * The MetamaskConnectEVM class provides an EIP-1193 compatible interface for connecting\n * to MetaMask and interacting with Ethereum Virtual Machine (EVM) networks.\n *\n * This class serves as a modern replacement for MetaMask SDK V1, offering enhanced\n * functionality and cross-platform compatibility. It wraps the Multichain SDK to provide\n * a simplified, EIP-1193 compliant API for dapp developers.\n *\n * Key features:\n * - EIP-1193 provider interface for seamless integration with existing dapp code\n * - Automatic session recovery when reloading or opening in new tabs\n * - Chain switching with automatic chain addition if not configured\n * - Event-driven architecture with support for connect, disconnect, accountsChanged, and chainChanged events\n * - Cross-platform support for browser extensions and mobile applications\n * - Built-in handling of common Ethereum methods (eth_accounts, wallet_switchEthereumChain, etc.)\n *\n * @example\n * ```typescript\n * const sdk = await createEVMClient({\n * dapp: { name: 'My DApp', url: 'https://mydapp.com' }\n * });\n *\n * await sdk.connect({ chainId: 1 });\n * const provider = await sdk.getProvider();\n * const accounts = await provider.request({ method: 'eth_accounts' });\n * ```\n */\nexport class MetamaskConnectEVM {\n /** The core instance of the Multichain SDK */\n readonly #core: MultichainCore;\n\n /** An instance of the EIP-1193 provider interface */\n readonly #provider: EIP1193Provider;\n\n /** The session scopes currently permitted */\n #sessionScopes: SessionData['sessionScopes'] = {};\n\n /** Optional event handlers for the EIP-1193 provider events. */\n readonly #eventHandlers?: Partial<EventHandlers> | undefined;\n\n /** The handler for the wallet_sessionChanged event */\n readonly #sessionChangedHandler: (session?: SessionData) => void;\n\n /** The handler for the display_uri event */\n readonly #displayUriHandler: (uri: string) => void;\n\n /** The clean-up function for the notification handler */\n #removeNotificationHandler?: () => void;\n\n /**\n * Creates a new MetamaskConnectEVM instance.\n *\n * @param options - The options for the MetamaskConnectEVM instance\n * @param options.core - The core instance of the Multichain SDK\n * @param options.eventHandlers - Optional event handlers for EIP-1193 provider events\n */\n constructor({ core, eventHandlers }: MetamaskConnectEVMOptions) {\n this.#core = core;\n\n this.#provider = new EIP1193Provider(\n core,\n this.#requestInterceptor.bind(this),\n );\n\n this.#eventHandlers = eventHandlers;\n\n /**\n * Handles the wallet_sessionChanged event.\n * Updates the internal connection state with the new session data.\n *\n * @param session - The session data\n */\n this.#sessionChangedHandler = (session): void => {\n logger('event: wallet_sessionChanged', session);\n this.#sessionScopes = session?.sessionScopes ?? {};\n };\n this.#core.on(\n 'wallet_sessionChanged',\n this.#sessionChangedHandler.bind(this),\n );\n\n /**\n * Handles the display_uri event.\n * Forwards the QR code URI to the provider for custom UI implementations.\n */\n this.#displayUriHandler = this.#onDisplayUri.bind(this);\n this.#core.on('display_uri', this.#displayUriHandler);\n\n // Attempt to set the permitted accounts if there's a valid previous session.\n // TODO (wenfix): does it make sense to catch here?\n this.#attemptSessionRecovery().catch((error) => {\n console.error('Error attempting session recovery', error);\n });\n\n logger('Connect/EVM constructor completed');\n }\n\n /**\n * Gets the core options for analytics checks.\n *\n * @returns The multichain options from the core instance\n */\n #getCoreOptions(): MultichainOptions {\n return (this.#core as any).options as MultichainOptions;\n }\n\n /**\n * Creates invoke options for analytics tracking.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n * @returns Invoke options object for analytics\n */\n #createInvokeOptions(\n method: string,\n scope: Scope,\n params: unknown[],\n ): {\n scope: Scope;\n request: { method: string; params: unknown[] };\n } {\n return {\n scope,\n request: { method, params },\n };\n }\n\n /**\n * Tracks a wallet action requested event.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n */\n async #trackWalletActionRequested(\n method: string,\n scope: Scope,\n params: unknown[],\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n analytics.track('mmconnect_wallet_action_requested', props);\n } catch (error) {\n logger('Error tracking mmconnect_wallet_action_requested event', error);\n }\n }\n\n /**\n * Tracks a wallet action succeeded event.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n */\n async #trackWalletActionSucceeded(\n method: string,\n scope: Scope,\n params: unknown[],\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n analytics.track('mmconnect_wallet_action_succeeded', props);\n } catch (error) {\n logger('Error tracking mmconnect_wallet_action_succeeded event', error);\n }\n }\n\n /**\n * Tracks a wallet action failed or rejected event based on the error.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n * @param error - The error that occurred\n */\n async #trackWalletActionFailed(\n method: string,\n scope: Scope,\n params: unknown[],\n error: unknown,\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n const isRejection = isRejectionError(error);\n if (isRejection) {\n analytics.track('mmconnect_wallet_action_rejected', props);\n } else {\n analytics.track('mmconnect_wallet_action_failed', props);\n }\n } catch {\n logger('Error tracking wallet action rejected or failed event', error);\n }\n }\n\n /**\n * Gets the currently selected chainId from cache, or falls back to the first permitted chain.\n *\n * @param permittedChainIds - Array of permitted chain IDs in hex format\n * @returns The selected chainId (hex string)\n */\n async #getSelectedChainId(permittedChainIds: Hex[]): Promise<Hex> {\n try {\n const cachedChainId =\n await this.#core.storage.adapter.get(CHAIN_STORE_KEY);\n if (cachedChainId) {\n const chainId: Hex = JSON.parse(cachedChainId);\n\n // Validate that the cached chainId is in the permitted chains list\n if (permittedChainIds.includes(chainId)) {\n return chainId;\n }\n }\n } catch (error) {\n logger('Error retrieving cached chainId', error);\n }\n\n // Fallback to the first permitted chain if cache retrieval failed or returned an invalid chain\n return permittedChainIds[0];\n }\n\n /**\n * Connects to the wallet with the specified chain ID and optional account.\n *\n * @param options - The connection options\n * @param options.account - Optional specific account to connect to\n * @param options.forceRequest - Wwhether to force a request regardless of an existing session\n * @param options.chainIds - Array of chain IDs to connect to\n * @returns A promise that resolves with the connected accounts and chain ID\n */\n async connect(\n { account, forceRequest, chainIds }: ConnectOptions = {\n chainIds: [DEFAULT_CHAIN_ID],\n },\n ): Promise<{ accounts: Address[]; chainId: number }> {\n logger('request: connect', { account });\n\n if (!chainIds || chainIds.length === 0) {\n throw new Error('chainIds must be an array of at least one chain ID');\n }\n\n const caipChainIds = Array.from(\n new Set(chainIds.concat(DEFAULT_CHAIN_ID) ?? [DEFAULT_CHAIN_ID]),\n ).map((id) => `eip155:${id}`);\n\n const caipAccountIds = account\n ? caipChainIds.map((caipChainId) => `${caipChainId}:${account}`)\n : [];\n\n await this.#core.connect(\n caipChainIds as Scope[],\n caipAccountIds as CaipAccountId[],\n undefined,\n forceRequest,\n );\n\n const hexPermittedChainIds = getPermittedEthChainIds(this.#sessionScopes);\n\n const initialAccounts = await this.#core.transport.sendEip1193Message<\n { method: 'eth_accounts'; params: [] },\n { result: string[]; id: number; jsonrpc: '2.0' }\n >({ method: 'eth_accounts', params: [] });\n\n const chainId = await this.#getSelectedChainId(hexPermittedChainIds);\n\n this.#onConnect({\n chainId,\n accounts: initialAccounts.result as Address[],\n });\n\n // Remove previous notification handler if it exists\n this.#removeNotificationHandler?.();\n\n this.#removeNotificationHandler = this.#core.transport.onNotification(\n (notification) => {\n // @ts-expect-error TODO: address this\n if (notification?.method === 'metamask_accountsChanged') {\n // @ts-expect-error TODO: address this\n const accounts = notification?.params;\n logger('transport-event: accountsChanged', accounts);\n this.#onAccountsChanged(accounts);\n }\n\n // @ts-expect-error TODO: address this\n if (notification?.method === 'metamask_chainChanged') {\n // @ts-expect-error TODO: address this\n const notificationChainId = Number(notification?.params?.chainId);\n logger('transport-event: chainChanged', notificationChainId);\n // Cache the chainId for persistence across page refreshes\n this.#cacheChainId(notificationChainId).catch((error) => {\n logger('Error caching chainId in notification handler', error);\n });\n this.#onChainChanged(notificationChainId);\n }\n },\n );\n\n logger('fulfilled-request: connect', {\n chainId: chainIds[0],\n accounts: this.#provider.accounts,\n });\n\n // TODO: update required here since accounts and chainId are now promises\n return {\n accounts: this.#provider.accounts,\n chainId: hexToNumber(chainId),\n };\n }\n\n /**\n * Connects to the wallet and signs a message using personal_sign.\n *\n * @param options - The connection options\n * @param options.message - The message to sign after connecting\n * @param options.chainIds - Optional chain IDs to connect to (defaults to ethereum mainnet if not provided)\n * @returns A promise that resolves with the signature\n * @throws Error if the selected account is not available after timeout\n */\n async connectAndSign({\n message,\n chainIds,\n }: {\n message: string;\n chainIds?: number[];\n }): Promise<string> {\n const { accounts, chainId } = await this.connect({\n chainIds: chainIds ?? [DEFAULT_CHAIN_ID],\n });\n\n const result = (await this.#provider.request({\n method: 'personal_sign',\n params: [accounts[0], message],\n })) as string;\n\n this.#eventHandlers?.connectAndSign?.({\n accounts,\n chainId,\n signResponse: result,\n });\n\n return result;\n }\n\n /**\n * Connects to the wallet and invokes a method with specified parameters.\n *\n * @param options - The options for connecting and invoking the method\n * @param options.method - The method name to invoke\n * @param options.params - The parameters to pass to the method, or a function that receives the account and returns params\n * @param options.chainIds - Optional chain IDs to connect to (defaults to ethereum mainnet if not provided)\n * @param options.account - Optional specific account to connect to\n * @param options.forceRequest - Whether to force a request regardless of an existing session\n * @returns A promise that resolves with the result of the method invocation\n * @throws Error if the selected account is not available after timeout (for methods that require an account)\n */\n async connectWith({\n method,\n params,\n chainIds,\n account,\n forceRequest,\n }: {\n method: string;\n params: unknown[] | ((account: Address) => unknown[]);\n chainIds?: number[];\n account?: string | undefined;\n forceRequest?: boolean;\n }): Promise<unknown> {\n const { accounts: connectedAccounts, chainId: connectedChainId } =\n await this.connect({\n chainIds: chainIds ?? [DEFAULT_CHAIN_ID],\n account,\n forceRequest,\n });\n\n const resolvedParams =\n typeof params === 'function' ? params(connectedAccounts[0]) : params;\n\n const result = await this.#provider.request({\n method,\n params: resolvedParams,\n });\n\n this.#eventHandlers?.connectWith?.({\n accounts: connectedAccounts,\n chainId: connectedChainId,\n connectWithResponse: result,\n });\n\n return result;\n }\n\n /**\n * Disconnects from the wallet by revoking the session and cleaning up event listeners.\n *\n * @returns A promise that resolves when disconnection is complete\n */\n async disconnect(): Promise<void> {\n logger('request: disconnect');\n\n await this.#core.disconnect();\n this.#onDisconnect();\n this.#clearConnectionState();\n\n this.#core.off('wallet_sessionChanged', this.#sessionChangedHandler);\n this.#core.off('display_uri', this.#displayUriHandler);\n\n if (this.#removeNotificationHandler) {\n this.#removeNotificationHandler();\n this.#removeNotificationHandler = undefined;\n }\n\n logger('fulfilled-request: disconnect');\n }\n\n /**\n * Switches the Ethereum chain. Will track state internally whenever possible.\n *\n * @param options - The options for the switch chain request\n * @param options.chainId - The chain ID to switch to\n * @param options.chainConfiguration - The chain configuration to use in case the chain is not present by the wallet\n * @returns The result of the switch chain request\n */\n async switchChain({\n chainId,\n chainConfiguration,\n }: {\n chainId: number | Hex;\n chainConfiguration?: AddEthereumChainParameter;\n }): Promise<unknown> {\n const method = 'wallet_switchEthereumChain';\n const hexChainId = isHex(chainId) ? chainId : numberToHex(chainId);\n const scope: Scope = `eip155:${isHex(chainId) ? hexToNumber(chainId) : chainId}`;\n const params = [{ chainId: hexChainId }];\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n // TODO (wenfix): better way to return here other than resolving.\n if (this.selectedChainId === hexChainId) {\n return Promise.resolve();\n }\n\n const permittedChainIds = getPermittedEthChainIds(this.#sessionScopes);\n\n if (\n permittedChainIds.includes(hexChainId) &&\n this.#core.transportType === TransportType.MWP\n ) {\n await this.#cacheChainId(hexChainId);\n this.#onChainChanged(hexChainId);\n await this.#trackWalletActionSucceeded(method, scope, params);\n return Promise.resolve();\n }\n\n try {\n const result = await this.#request({\n method: 'wallet_switchEthereumChain',\n params,\n });\n\n // When using the MWP transport, the error is returned instead of thrown,\n // so we force it into the catch block here.\n const resultWithError = result as { error?: { message: string } };\n if (resultWithError?.error) {\n throw new Error(resultWithError.error.message);\n }\n\n await this.#trackWalletActionSucceeded(method, scope, params);\n if ((result as { result: unknown }).result === null) {\n // result is successful we eagerly call onChainChanged to update the provider's selected chain ID.\n await this.#cacheChainId(hexChainId);\n this.#onChainChanged(hexChainId);\n }\n return result;\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n // Fallback to add the chain if its not configured in the wallet.\n if ((error as Error).message.includes('Unrecognized chain ID')) {\n return this.#addEthereumChain(chainConfiguration);\n }\n throw error;\n }\n }\n\n /**\n * Handles several EIP-1193 requests that require special handling\n * due the nature of the Multichain SDK.\n *\n * @param request - The request object containing the method and params\n * @returns The result of the request or undefined if the request is ignored\n */\n async #requestInterceptor(\n request: ProviderRequest,\n ): ReturnType<ProviderRequestInterceptor> {\n logger(`Intercepting request for method: ${request.method}`);\n\n if (IGNORED_METHODS.includes(request.method)) {\n // TODO: replace with correct method unsupported provider error\n return Promise.reject(\n new Error(\n `Method: ${request.method} is not supported by Metamask Connect/EVM`,\n ),\n );\n }\n\n if (request.method === 'wallet_revokePermissions') {\n return this.disconnect();\n }\n\n if (isConnectRequest(request)) {\n // When calling wallet_requestPermissions, we need to force a new session request to prompt\n // the user for accounts, because internally the Multichain SDK will check if\n // the user is already connected and skip the request if so, unless we\n // explicitly request a specific account. This is needed to workaround\n // wallet_requestPermissions not requesting specific accounts.\n const shouldForceConnectionRequest =\n request.method === 'wallet_requestPermissions';\n\n const { method, params } = request;\n const initiallySelectedChainId = DEFAULT_CHAIN_ID;\n const scope: Scope = `eip155:${initiallySelectedChainId}`;\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n try {\n const result = await this.connect({\n chainIds: [initiallySelectedChainId],\n forceRequest: shouldForceConnectionRequest,\n });\n await this.#trackWalletActionSucceeded(method, scope, params);\n return result;\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n throw error;\n }\n }\n\n if (isSwitchChainRequest(request)) {\n return this.switchChain({\n chainId: parseInt(request.params[0].chainId, 16),\n });\n }\n\n if (isAddChainRequest(request)) {\n return this.#addEthereumChain(request.params[0]);\n }\n\n if (isAccountsRequest(request)) {\n const { method } = request;\n const chainId = this.#provider.selectedChainId\n ? hexToNumber(this.#provider.selectedChainId)\n : 1;\n const scope: Scope = `eip155:${chainId}`;\n const params: unknown[] = [];\n\n await this.#trackWalletActionRequested(method, scope, params);\n await this.#trackWalletActionSucceeded(method, scope, params);\n\n return this.#provider.accounts;\n }\n\n if (isChainIdRequest(request)) {\n return this.#provider.selectedChainId;\n }\n\n logger('Request not intercepted, forwarding to default handler', request);\n return Promise.resolve();\n }\n\n /**\n * Clears the internal connection state: accounts and chainId\n */\n #clearConnectionState(): void {\n this.#provider.accounts = [];\n this.#provider.selectedChainId = undefined as unknown as number;\n }\n\n /**\n * Adds an Ethereum chain using the latest chain configuration received from\n * a switchEthereumChain request\n *\n * @param chainConfiguration - The chain configuration to use in case the chain is not present by the wallet\n * @returns Nothing\n */\n async #addEthereumChain(\n chainConfiguration?: AddEthereumChainParameter,\n ): Promise<void> {\n logger('addEthereumChain called', { chainConfiguration });\n const method = 'wallet_addEthereumChain';\n\n if (!chainConfiguration) {\n throw new Error('No chain configuration found.');\n }\n\n // Get chain ID from config or use current chain\n const chainId = chainConfiguration.chainId\n ? parseInt(chainConfiguration.chainId, 16)\n : hexToNumber(this.#provider.selectedChainId ?? '0x1');\n const scope: Scope = `eip155:${chainId}`;\n const params = [chainConfiguration];\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n try {\n const result = await this.#request({\n method: 'wallet_addEthereumChain',\n params,\n });\n\n if ((result as { result: unknown }).result === null) {\n // if result is successful we eagerly call onChainChanged to update the provider's selected chain ID.\n await this.#cacheChainId(chainId);\n this.#onChainChanged(chainId);\n }\n await this.#trackWalletActionSucceeded(method, scope, params);\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n throw error;\n }\n }\n\n /**\n * Submits a request to the EIP-1193 provider\n *\n * @param request - The request object containing the method and params\n * @param request.method - The method to request\n * @param request.params - The parameters to pass to the method\n * @returns The result of the request\n */\n async #request(request: {\n method: string;\n params: unknown[];\n }): Promise<unknown> {\n logger('direct request to metamask-provider called', request);\n const result = this.#core.transport.sendEip1193Message(request);\n if (\n request.method === 'wallet_addEthereumChain' ||\n request.method === 'wallet_switchEthereumChain'\n ) {\n this.#core.openDeeplinkIfNeeded();\n }\n return result;\n }\n\n /**\n * Caches the chainId to storage for persistence across page refreshes.\n *\n * @param chainId - The chain ID (can be hex string or number)\n */\n async #cacheChainId(chainId: Hex | number): Promise<void> {\n try {\n const hexChainId = isHex(chainId) ? chainId : numberToHex(chainId);\n await this.#core.storage.adapter.set(\n CHAIN_STORE_KEY,\n JSON.stringify(hexChainId),\n );\n } catch (error) {\n logger('Error caching chainId', error);\n }\n }\n\n /**\n * Handles chain change events and updates the provider's selected chain ID.\n *\n * @param chainId - The new chain ID (can be hex string or number)\n */\n #onChainChanged(chainId: Hex | number): void {\n const hexChainId = isHex(chainId) ? chainId : numberToHex(chainId);\n if (hexChainId === this.#provider.selectedChainId) {\n return;\n }\n logger('handler: chainChanged', { chainId });\n this.#provider.selectedChainId = chainId;\n this.#eventHandlers?.chainChanged?.(hexChainId);\n this.#provider.emit('chainChanged', hexChainId);\n }\n\n /**\n * Handles accounts change events and updates the provider's accounts list.\n *\n * @param accounts - The new list of permitted accounts\n */\n #onAccountsChanged(accounts: Address[]): void {\n logger('handler: accountsChanged', accounts);\n this.#provider.accounts = accounts;\n this.#provider.emit('accountsChanged', accounts);\n this.#eventHandlers?.accountsChanged?.(accounts);\n }\n\n /**\n * Handles connection events and emits the connect event to listeners.\n *\n * @param options - The connection options\n * @param options.chainId - The chain ID of the connection (can be hex string or number)\n * @param options.accounts - The accounts of the connection\n */\n #onConnect({\n chainId,\n accounts,\n }: {\n chainId: Hex | number;\n accounts: Address[];\n }): void {\n logger('handler: connect', { chainId, accounts });\n const data = {\n chainId: isHex(chainId) ? chainId : numberToHex(chainId),\n accounts,\n };\n\n this.#provider.emit('connect', data);\n this.#eventHandlers?.connect?.(data);\n\n this.#onChainChanged(chainId);\n this.#onAccountsChanged(accounts);\n }\n\n /**\n * Handles disconnection events and emits the disconnect event to listeners.\n * Also clears accounts by triggering an accountsChanged event with an empty array.\n */\n #onDisconnect(): void {\n logger('handler: disconnect');\n this.#provider.emit('disconnect');\n this.#eventHandlers?.disconnect?.();\n\n this.#onAccountsChanged([]);\n }\n\n /**\n * Handles display_uri events and emits them to the provider.\n * This allows consumers to display their own custom QR code UI.\n *\n * @param uri - The deeplink URI to be displayed as a QR code\n */\n #onDisplayUri(uri: string): void {\n logger('handler: display_uri', uri);\n this.#provider.emit('display_uri', uri);\n this.#eventHandlers?.displayUri?.(uri);\n }\n\n /**\n * Will trigger an accountsChanged event if there's a valid previous session.\n * This is needed because the accountsChanged event is not triggered when\n * revising, reloading or opening the app in a new tab.\n *\n * This works by checking by checking events received during MultichainCore initialization,\n * and if there's a wallet_sessionChanged event, it will add a 1-time listener for eth_accounts results\n * and trigger an accountsChanged event if the results are valid accounts.\n */\n async #attemptSessionRecovery(): Promise<void> {\n // Skip session recovery if transport is not initialized yet.\n // Transport is only initialized when there's a stored session or after connect() is called.\n // Only attempt recovery if we're in a state where transport should be available.\n if (this.#core.status !== 'connected' && this.#core.status !== 'connecting') {\n return;\n }\n try {\n const response = await this.#core.transport.request<\n { method: 'wallet_getSession' },\n {\n result: { sessionScopes: Caip25CaveatValue };\n id: number;\n jsonrpc: '2.0';\n }\n >({\n method: 'wallet_getSession',\n });\n\n const { sessionScopes } = response.result;\n\n this.#sessionScopes = sessionScopes;\n const permittedChainIds = getPermittedEthChainIds(sessionScopes);\n\n // Instead of using the accounts we get back from calling `wallet_getSession`\n // we get permitted accounts from `eth_accounts` to make sure we have them ordered by last selected account\n // and correctly set the currently selected account for the dapp\n const permittedAccounts = await this.#core.transport.sendEip1193Message<\n { method: 'eth_accounts'; params: [] },\n { result: Address[]; id: number; jsonrpc: '2.0' }\n >({ method: 'eth_accounts', params: [] });\n\n const chainId = await this.#getSelectedChainId(permittedChainIds);\n\n if (permittedChainIds.length && permittedAccounts.result) {\n this.#onConnect({\n chainId,\n accounts: permittedAccounts.result,\n });\n }\n } catch (error) {\n console.error('Error attempting session recovery', error);\n }\n }\n\n /**\n * Gets the EIP-1193 provider instance\n *\n * @returns The EIP-1193 provider instance\n */\n getProvider(): EIP1193Provider {\n return this.#provider;\n }\n\n /**\n * Gets the currently selected chain ID on the wallet\n *\n * @returns The currently selected chain ID or undefined if no chain is selected\n */\n getChainId(): Hex | undefined {\n return this.selectedChainId;\n }\n\n /**\n * Gets the currently selected account on the wallet\n *\n * @returns The currently selected account or undefined if no account is selected\n */\n getAccount(): Address | undefined {\n return this.#provider.selectedAccount;\n }\n\n // Convenience getters for the EIP-1193 provider\n /**\n * Gets the currently permitted accounts\n *\n * @returns The currently permitted accounts\n */\n get accounts(): Address[] {\n return this.#provider.accounts;\n }\n\n /**\n * Gets the currently selected account on the wallet\n *\n * @returns The currently selected account or undefined if no account is selected\n */\n get selectedAccount(): Address | undefined {\n return this.#provider.selectedAccount;\n }\n\n /**\n * Gets the currently selected chain ID on the wallet\n *\n * @returns The currently selected chain ID or undefined if no chain is selected\n */\n get selectedChainId(): Hex | undefined {\n return this.#provider.selectedChainId;\n }\n\n /**\n * Gets the current connection status\n *\n * @returns The current connection status\n */\n get status(): ConnectionStatus {\n return this.#core.status;\n }\n}\n\n/**\n * Creates a new Metamask Connect/EVM instance\n *\n * @param options - The options for the Metamask Connect/EVM layer\n * @param options.dapp - Dapp identification and branding settings\n * @param options.api - API configuration including read-only RPC map\n * @param options.api.supportedNetworks - A map of CAIP chain IDs to RPC URLs for read-only requests\n * @param options.ui - UI configuration options\n * @param options.ui.headless - Whether to run without UI\n * @param options.ui.preferExtension - Whether to prefer browser extension\n * @param options.ui.showInstallModal - Whether to render installation modal for desktop extension\n * @param options.eventEmitter - The event emitter to use for the Metamask Connect/EVM layer\n * @param options.eventHandlers - The event handlers to use for the Metamask Connect/EVM layer\n * @returns The Metamask Connect/EVM layer instance\n */\nexport async function createEVMClient(\n options: Pick<MultichainOptions, 'dapp' | 'api'> &\n { ui?: Omit<MultichainOptions['ui'], 'factory'>; } & {\n eventHandlers?: Partial<EventHandlers>;\n debug?: boolean;\n },\n): Promise<MetamaskConnectEVM> {\n enableDebug(options.debug);\n\n logger('Creating Metamask Connect/EVM with options:', options);\n\n // Validate that supportedNetworks is provided and not empty\n if (\n !options.api?.supportedNetworks ||\n Object.keys(options.api.supportedNetworks).length === 0\n ) {\n throw new Error(\n 'supportedNetworks is required and must contain at least one chain configuration',\n );\n }\n\n validSupportedChainsUrls(options.api.supportedNetworks, 'supportedNetworks');\n\n try {\n const core = await createMultichainClient({\n ...options,\n api: {\n supportedNetworks: options.api.supportedNetworks,\n },\n });\n\n return new MetamaskConnectEVM({\n core,\n eventHandlers: options.eventHandlers,\n supportedNetworks: options.api.supportedNetworks,\n });\n } catch (error) {\n console.error('Error creating Metamask Connect/EVM', error);\n throw error;\n }\n}\n","export const IGNORED_METHODS = [\n 'metamask_getProviderState',\n 'metamask_sendDomainMetadata',\n 'metamask_logWeb3ShimUsage',\n 'wallet_registerOnboarding',\n 'net_version',\n 'wallet_getPermissions',\n];\n\nexport const CONNECT_METHODS = [\n 'wallet_requestPermissions',\n 'eth_requestAccounts',\n];\n\nexport const ACCOUNTS_METHODS = ['eth_accounts', 'eth_coinbase'];\n\nexport const CHAIN_METHODS = ['eth_chainId'];\n\nexport const INTERCEPTABLE_METHODS = [\n ...ACCOUNTS_METHODS,\n ...IGNORED_METHODS,\n ...CONNECT_METHODS,\n ...CHAIN_METHODS,\n // These have bespoke handlers\n 'wallet_revokePermissions',\n 'wallet_switchEthereumChain',\n 'wallet_addEthereumChain',\n];\n","import {\n createLogger,\n enableDebug as debug,\n} from '@metamask/connect-multichain';\n\nconst namespace = 'metamask-connect:evm';\n\n// @ts-expect-error logger needs to be typed properly\nexport const logger = createLogger(namespace, '63');\n\nexport const enableDebug = (debugEnabled: boolean = false): void => {\n if (debugEnabled) {\n // @ts-expect-error logger needs to be typed properly\n debug(namespace);\n }\n};\n","import type { MultichainCore, Scope } from '@metamask/connect-multichain';\nimport { EventEmitter } from '@metamask/connect-multichain';\nimport { hexToNumber, numberToHex } from '@metamask/utils';\n\nimport { INTERCEPTABLE_METHODS } from './constants';\nimport { logger } from './logger';\nimport type {\n Address,\n EIP1193ProviderEvents,\n Hex,\n JsonRpcCallback,\n JsonRpcRequest,\n JsonRpcResponse,\n ProviderRequest,\n ProviderRequestInterceptor,\n} from './types';\n\n/**\n * EIP-1193 Provider wrapper around the Multichain SDK.\n */\nexport class EIP1193Provider extends EventEmitter<EIP1193ProviderEvents> {\n /** The core instance of the Multichain SDK */\n readonly #core: MultichainCore;\n\n /** Interceptor function to handle specific methods */\n readonly #requestInterceptor: ProviderRequestInterceptor;\n\n /** The currently permitted accounts */\n #accounts: Address[] = [];\n\n /** The currently selected chain ID on the wallet */\n #selectedChainId?: Hex | undefined;\n\n constructor(core: MultichainCore, interceptor: ProviderRequestInterceptor) {\n super();\n this.#core = core;\n this.#requestInterceptor = interceptor;\n\n // Bind all public methods to ensure `this` context is preserved\n // when methods are extracted or passed as callbacks.\n // This eliminates the need for Proxy wrappers in consumers.\n this.request = this.request.bind(this);\n this.sendAsync = this.sendAsync.bind(this);\n this.send = this.send.bind(this);\n\n // Bind inherited EventEmitter methods\n this.on = this.on.bind(this);\n this.off = this.off.bind(this);\n this.emit = this.emit.bind(this);\n this.once = this.once.bind(this);\n this.removeListener = this.removeListener.bind(this);\n this.listenerCount = this.listenerCount.bind(this);\n }\n\n /**\n * Performs a EIP-1193 request.\n *\n * @param request - The request object containing the method and params\n * @returns The result of the request\n */\n async request(request: ProviderRequest): Promise<unknown> {\n logger(\n `request: ${request.method} - chainId: ${this.selectedChainId}`,\n request.params,\n );\n /* Some methods require special handling, so we intercept them here\n * and handle them in MetamaskConnectEVM.requestInterceptor method. */\n if (INTERCEPTABLE_METHODS.includes(request.method)) {\n return this.#requestInterceptor?.(request);\n }\n\n if (!this.#selectedChainId) {\n // TODO: replace with a better error\n throw new Error('No chain ID selected');\n }\n\n const chainId = hexToNumber(this.#selectedChainId);\n const scope: Scope = `eip155:${chainId}`;\n\n // Validate that the chain is configured in supportedNetworks\n // This check is performed here to provide better error messages\n // The RpcClient will also validate, but this gives us a chance to provide\n // a clearer error message before the request is routed\n const coreOptions = (this.#core as any).options; // TODO: options is `protected readonly` property, this needs to be refactored so `any` type assertion is not necessary\n const supportedNetworks = coreOptions?.api?.supportedNetworks ?? {};\n if (!supportedNetworks[scope]) {\n throw new Error(\n `Chain ${scope} is not configured in supportedNetworks. Requests cannot be made to chains not explicitly configured in supportedNetworks.`,\n );\n }\n\n return this.#core.invokeMethod({\n scope,\n request: {\n method: request.method,\n params: request.params,\n },\n });\n }\n\n // Getters and setters\n public get selectedAccount(): Address | undefined {\n return this.accounts[0];\n }\n\n public set accounts(accounts: Address[]) {\n this.#accounts = accounts;\n }\n\n public get accounts(): Address[] {\n return this.#accounts;\n }\n\n public get selectedChainId(): Hex | undefined {\n return this.#selectedChainId;\n }\n\n public set selectedChainId(chainId: Hex | number | undefined) {\n const hexChainId =\n chainId && typeof chainId === 'number' ? numberToHex(chainId) : chainId;\n\n // Don't overwrite the selected chain ID with an undefined value\n if (!hexChainId) {\n return;\n }\n\n this.#selectedChainId = hexChainId as Hex;\n }\n\n // ==========================================\n // Legacy compatibility methods\n // ==========================================\n\n /**\n * Alias for selectedChainId for legacy compatibility.\n * Many dApps expect a `chainId` property on the provider.\n */\n public get chainId(): Hex | undefined {\n return this.selectedChainId;\n }\n\n /**\n * Legacy method for sending JSON-RPC requests.\n * @deprecated Use `request` instead. This method is provided for backwards compatibility.\n * @param request - The JSON-RPC request object\n * @param callback - Optional callback function. If provided, the method returns void.\n * @returns A promise resolving to the JSON-RPC response, or void if a callback is provided.\n */\n async sendAsync<TParams = unknown, TResult = unknown>(\n request: JsonRpcRequest<TParams>,\n callback?: JsonRpcCallback<TResult>,\n ): Promise<JsonRpcResponse<TResult> | void> {\n const id = request.id ?? 1;\n\n const promise = this.request({\n method: request.method,\n params: request.params as unknown,\n })\n .then(\n (result): JsonRpcResponse<TResult> => ({\n id,\n jsonrpc: '2.0',\n result: result as TResult,\n }),\n )\n .catch(\n (error): JsonRpcResponse<TResult> => ({\n id,\n jsonrpc: '2.0',\n error: {\n code: error.code ?? -32603,\n message: error.message ?? 'Internal error',\n data: error.data,\n },\n }),\n );\n\n if (callback) {\n promise\n .then((response) => {\n if (response.error) {\n callback(new Error(response.error.message), response);\n } else {\n callback(null, response);\n }\n })\n .catch((error) => {\n callback(error, null);\n });\n return;\n }\n\n return promise;\n }\n\n /**\n * Legacy method for sending JSON-RPC requests synchronously (callback-based).\n * @deprecated Use `request` instead. This method is provided for backwards compatibility.\n * @param request - The JSON-RPC request object\n * @param callback - The callback function to receive the response\n */\n send<TParams = unknown, TResult = unknown>(\n request: JsonRpcRequest<TParams>,\n callback: JsonRpcCallback<TResult>,\n ): void {\n this.sendAsync(request, callback);\n }\n}\n","import type { InternalScopesObject } from '@metamask/chain-agnostic-permission';\nimport {\n getPermittedEthChainIds as _getPermittedEthChainIds,\n getEthAccounts as _getEthAccounts,\n} from '@metamask/chain-agnostic-permission';\nimport type { SessionData } from '@metamask/connect-multichain';\n\nimport type { Address, Hex } from '../types';\n\n/**\n * Get the Ethereum accounts from the session data\n *\n * @param sessionScopes - The session scopes\n * @returns The Ethereum accounts\n */\nexport const getEthAccounts = (\n sessionScopes: SessionData['sessionScopes'] | undefined,\n): Address[] => {\n if (!sessionScopes) {\n return [];\n }\n\n return _getEthAccounts({\n requiredScopes: sessionScopes as InternalScopesObject,\n optionalScopes: sessionScopes as InternalScopesObject,\n });\n};\n\n/**\n * Get the permitted Ethereum chain IDs from the session scopes.\n * Wrapper around getPermittedEthChainIds from @metamask/chain-agnostic-permission\n *\n * @param sessionScopes - The session scopes\n * @returns The permitted Ethereum chain IDs\n */\nexport const getPermittedEthChainIds = (\n sessionScopes: SessionData['sessionScopes'] | undefined,\n): Hex[] => {\n if (!sessionScopes) {\n return [];\n }\n\n return _getPermittedEthChainIds({\n requiredScopes: sessionScopes as InternalScopesObject,\n optionalScopes: sessionScopes as InternalScopesObject,\n });\n};\n","import type { ProviderRequest } from '../types';\n\n/**\n * Type guard for connect-like requests:\n * - wallet_requestPermissions\n * - eth_requestAccounts\n *\n * @param req - The request object to check\n * @returns True if the request is a connect-like request, false otherwise\n */\nexport function isConnectRequest(req: ProviderRequest): req is Extract<\n ProviderRequest,\n {\n method: 'wallet_requestPermissions' | 'eth_requestAccounts';\n }\n> {\n return (\n req.method === 'wallet_requestPermissions' ||\n req.method === 'eth_requestAccounts'\n );\n}\n\n/**\n * Type guard for wallet_switchEthereumChain request.\n *\n * @param req - The request object to check\n * @returns True if the request is a wallet_switchEthereumChain request, false otherwise\n */\nexport function isSwitchChainRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'wallet_switchEthereumChain' }> {\n return req.method === 'wallet_switchEthereumChain';\n}\n\n/**\n * Type guard for wallet_addEthereumChain request.\n *\n * @param req - The request object to check\n * @returns True if the request is a wallet_addEthereumChain request, false otherwise\n */\nexport function isAddChainRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'wallet_addEthereumChain' }> {\n return req.method === 'wallet_addEthereumChain';\n}\n\n/**\n * Type guard for generic accounts request:\n * - eth_accounts\n * - eth_coinbase\n *\n * @param req - The request object to check\n * @returns True if the request is a generic accounts request, false otherwise\n */\nexport function isAccountsRequest(\n req: ProviderRequest,\n): req is Extract<\n ProviderRequest,\n { method: 'eth_accounts' | 'eth_coinbase' }\n> {\n return req.method === 'eth_accounts' || req.method === 'eth_coinbase';\n}\n\n/**\n * Type guard for generic eth_chainId request.\n *\n * @param req - The request object to check\n * @returns True if the request is a eth_chainId request, false otherwise\n */\nexport function isChainIdRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'eth_chainId' }> {\n return req.method === 'eth_chainId';\n}\n\n/**\n * Validates that all values in a Record are valid URLs.\n *\n * @param record - The record to validate (e.g., supportedNetworks)\n * @param recordName - The name of the record for error messages\n * @throws Error if any values are invalid URLs\n */\nexport function validSupportedChainsUrls(\n record: Record<string, string>,\n recordName: string,\n): void {\n const invalidUrls: string[] = [];\n for (const [key, url] of Object.entries(record)) {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n } catch {\n invalidUrls.push(`${key}: ${url}`);\n }\n }\n\n if (invalidUrls.length > 0) {\n throw new Error(\n `${recordName} contains invalid URLs:\\n${invalidUrls.join('\\n')}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,wBAAwB;;;ACAjC,SAAS,iBAAiB;AAS1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE,eAAA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Q,IAAI,iBAAiB,EAAE,WAAW,GACtD;AACA,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,6BAAyB,QAAQ,IAAI,mBAAmB,mBAAmB;AAE3E,QAAI;AACF,YAAM,OAAO,MAAM,uBAAuB,iCACrC,UADqC;AAAA,QAExC,KAAK;AAAA,UACH,mBAAmB,QAAQ,IAAI;AAAA,QACjC;AAAA,MACF,EAAC;AAED,aAAO,IAAI,mBAAmB;AAAA,QAC5B;AAAA,QACA,eAAe,QAAQ;AAAA,QACvB,mBAAmB,QAAQ,IAAI;AAAA,MACjC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC,KAAK;AAC1D,YAAM;AAAA,IACR;AAAA,EACF;AAAA;","names":["numberToHex","hexToNumber","_a","_core","_a","hexToNumber","numberToHex"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/infura.ts","../../../src/connect.ts","../../../src/constants.ts","../../../src/logger.ts","../../../src/provider.ts","../../../src/utils/caip.ts","../../../src/utils/type-guards.ts"],"sourcesContent":["import type { RpcUrlsMap } from '@metamask/connect-multichain';\nimport { getInfuraRpcUrls as getInfuraRpcUrlsMultichain } from '@metamask/connect-multichain';\nimport type { CaipChainId, Hex } from '@metamask/utils';\nimport {\n KnownCaipNamespace,\n numberToHex,\n parseCaipChainId,\n} from '@metamask/utils';\n\nexport const getInfuraRpcUrls = (infuraAPIKey: string): RpcUrlsMap => {\n const caipMap = getInfuraRpcUrlsMultichain(infuraAPIKey);\n const hexMap = Object.entries(caipMap).reduce<Record<Hex, string>>(\n (acc, [key, url]) => {\n const { namespace, reference } = parseCaipChainId(key as CaipChainId);\n if (namespace !== KnownCaipNamespace.Eip155) {\n return acc;\n }\n const chainId = numberToHex(parseInt(reference, 10));\n acc[chainId] = url as string;\n return acc;\n },\n {},\n );\n return hexMap;\n};\n","/* eslint-disable no-restricted-syntax -- Private class properties use established patterns */\nimport { analytics } from '@metamask/analytics';\nimport { parseScopeString } from '@metamask/chain-agnostic-permission';\nimport type {\n ConnectionStatus,\n MultichainCore,\n MultichainOptions,\n Scope,\n SessionData,\n} from '@metamask/connect-multichain';\nimport {\n createMultichainClient,\n getWalletActionAnalyticsProperties,\n isRejectionError,\n TransportType,\n} from '@metamask/connect-multichain';\nimport { hexToNumber } from '@metamask/utils';\n\nimport { IGNORED_METHODS } from './constants';\nimport { enableDebug, logger } from './logger';\nimport { EIP1193Provider } from './provider';\nimport type {\n AddEthereumChainParameter,\n Address,\n CaipAccountId,\n EventHandlers,\n Hex,\n MetamaskConnectEVMOptions,\n ProviderRequest,\n ProviderRequestInterceptor,\n} from './types';\nimport { getEthAccounts, getPermittedEthChainIds } from './utils/caip';\nimport {\n isAccountsRequest,\n isAddChainRequest,\n isChainIdRequest,\n isConnectRequest,\n isSwitchChainRequest,\n validSupportedChainsUrls,\n} from './utils/type-guards';\n\nconst DEFAULT_CHAIN_ID = '0x1';\nconst CHAIN_STORE_KEY = 'cache_eth_chainId';\n\n/** The options for the connect method */\ntype ConnectOptions = {\n /** The account to connect to */\n account?: string | undefined;\n /** Whether to force a request regardless of an existing session */\n forceRequest?: boolean;\n /** All available chain IDs in the dapp in hex format */\n chainIds?: Hex[];\n};\n\nexport type ConnectEvmStatus = 'disconnected' | 'connected' | 'connecting';\n\n/**\n * The MetamaskConnectEVM class provides an EIP-1193 compatible interface for connecting\n * to MetaMask and interacting with Ethereum Virtual Machine (EVM) networks.\n *\n * This class serves as a modern replacement for MetaMask SDK V1, offering enhanced\n * functionality and cross-platform compatibility. It wraps the Multichain SDK to provide\n * a simplified, EIP-1193 compliant API for dapp developers.\n *\n * Key features:\n * - EIP-1193 provider interface for seamless integration with existing dapp code\n * - Automatic session recovery when reloading or opening in new tabs\n * - Chain switching with automatic chain addition if not configured\n * - Event-driven architecture with support for connect, disconnect, accountsChanged, and chainChanged events\n * - Cross-platform support for browser extensions and mobile applications\n * - Built-in handling of common Ethereum methods (eth_accounts, wallet_switchEthereumChain, etc.)\n *\n * @example\n * ```typescript\n * const client = await createEVMClient({\n * dapp: { name: 'My DApp', url: 'https://mydapp.com' }\n * });\n *\n * const { accounts, chainId } = await client.connect({ chainIds: [1, 137] }); // Connect to Ethereum Mainnet, and Polygon\n *\n * const provider = client.getProvider();\n * const signedMessage = await provider.request({ method: 'personal_sign', params: ['0x0', accounts[0]] });\n * ```\n */\nexport class MetamaskConnectEVM {\n /** The core instance of the Multichain SDK */\n readonly #core: MultichainCore;\n\n /** An instance of the EIP-1193 provider interface */\n readonly #provider: EIP1193Provider;\n\n /** The session scopes currently permitted */\n #sessionScopes: SessionData['sessionScopes'] = {};\n\n /** Optional event handlers for the EIP-1193 provider events. */\n readonly #eventHandlers?: Partial<EventHandlers> | undefined;\n\n /** The handler for the wallet_sessionChanged event */\n readonly #sessionChangedHandler: (session?: SessionData) => void;\n\n /** The handler for the display_uri event */\n readonly #displayUriHandler: (uri: string) => void;\n\n /** The clean-up function for the notification handler */\n #removeNotificationHandler?: () => void;\n\n /** The current connection status */\n #status: ConnectEvmStatus = 'disconnected';\n\n /**\n * Creates a new MetamaskConnectEVM instance.\n * Use the static `create()` method instead to ensure proper async initialization.\n *\n * @param options - The options for the MetamaskConnectEVM instance\n * @param options.core - The core instance of the Multichain SDK\n * @param options.eventHandlers - Optional event handlers for EIP-1193 provider events\n */\n private constructor({ core, eventHandlers }: MetamaskConnectEVMOptions) {\n this.#core = core;\n\n this.#provider = new EIP1193Provider(\n core,\n this.#requestInterceptor.bind(this),\n );\n\n this.#eventHandlers = eventHandlers;\n\n /**\n * Handles the wallet_sessionChanged event.\n * Updates the internal connection state with the new session data.\n *\n * @param session - The session data\n */\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#sessionChangedHandler = this.#onSessionChanged.bind(this);\n this.#core.on('wallet_sessionChanged', this.#sessionChangedHandler);\n\n /**\n * Handles the display_uri event.\n * Forwards the QR code URI to the provider for custom UI implementations.\n */\n this.#displayUriHandler = this.#onDisplayUri.bind(this);\n this.#core.on('display_uri', this.#displayUriHandler);\n\n logger('Connect/EVM constructor completed');\n }\n\n /**\n * Creates a fully initialized MetamaskConnectEVM instance.\n * This is the recommended way to instantiate the class, as it ensures\n * all async initialization (like session recovery) completes before\n * the instance is returned.\n *\n * @param options - The options for the MetamaskConnectEVM instance\n * @param options.core - The core instance of the Multichain SDK\n * @param options.eventHandlers - Optional event handlers for EIP-1193 provider events\n * @returns A promise that resolves with a fully initialized MetamaskConnectEVM instance\n */\n static async create(\n options: MetamaskConnectEVMOptions,\n ): Promise<MetamaskConnectEVM> {\n const instance = new MetamaskConnectEVM(options);\n await instance.#core.emitSessionChanged();\n return instance;\n }\n\n /**\n * Gets the core options for analytics checks.\n *\n * @returns The multichain options from the core instance\n */\n #getCoreOptions(): MultichainOptions {\n return (this.#core as any).options as MultichainOptions;\n }\n\n /**\n * Creates invoke options for analytics tracking.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n * @returns Invoke options object for analytics\n */\n #createInvokeOptions(\n method: string,\n scope: Scope,\n params: unknown[],\n ): {\n scope: Scope;\n request: { method: string; params: unknown[] };\n } {\n return {\n scope,\n request: { method, params },\n };\n }\n\n /**\n * Tracks a wallet action requested event.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n */\n async #trackWalletActionRequested(\n method: string,\n scope: Scope,\n params: unknown[],\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n analytics.track('mmconnect_wallet_action_requested', props);\n } catch (error) {\n logger('Error tracking mmconnect_wallet_action_requested event', error);\n }\n }\n\n /**\n * Tracks a wallet action succeeded event.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n */\n async #trackWalletActionSucceeded(\n method: string,\n scope: Scope,\n params: unknown[],\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n analytics.track('mmconnect_wallet_action_succeeded', props);\n } catch (error) {\n logger('Error tracking mmconnect_wallet_action_succeeded event', error);\n }\n }\n\n /**\n * Tracks a wallet action failed or rejected event based on the error.\n *\n * @param method - The RPC method name\n * @param scope - The CAIP chain ID scope\n * @param params - The method parameters\n * @param error - The error that occurred\n */\n async #trackWalletActionFailed(\n method: string,\n scope: Scope,\n params: unknown[],\n error: unknown,\n ): Promise<void> {\n const coreOptions = this.#getCoreOptions();\n try {\n const invokeOptions = this.#createInvokeOptions(method, scope, params);\n const props = await getWalletActionAnalyticsProperties(\n coreOptions,\n this.#core.storage,\n invokeOptions,\n );\n const isRejection = isRejectionError(error);\n if (isRejection) {\n analytics.track('mmconnect_wallet_action_rejected', props);\n } else {\n analytics.track('mmconnect_wallet_action_failed', props);\n }\n } catch {\n logger('Error tracking wallet action rejected or failed event', error);\n }\n }\n\n /**\n * Gets the currently selected chainId from cache, or falls back to the first permitted chain.\n *\n * @param permittedChainIds - Array of permitted chain IDs in hex format\n * @returns The selected chainId (hex string)\n */\n async #getSelectedChainId(permittedChainIds: Hex[]): Promise<Hex> {\n try {\n const cachedChainId =\n await this.#core.storage.adapter.get(CHAIN_STORE_KEY);\n if (cachedChainId) {\n const chainId: Hex = JSON.parse(cachedChainId);\n\n // Validate that the cached chainId is in the permitted chains list\n if (permittedChainIds.includes(chainId)) {\n return chainId;\n }\n }\n } catch (error) {\n logger('Error retrieving cached chainId', error);\n }\n\n // Fallback to the first permitted chain if cache retrieval failed or returned an invalid chain\n return permittedChainIds[0];\n }\n\n /**\n * Connects to the wallet with the specified chain ID and optional account.\n *\n * @param options - The connection options\n * @param [options.account] - Optional param to specify an account to connect to\n * @param [options.forceRequest] - Optional param to force a connection request regardless of whether there is a pre-existing session\n * @param [options.chainIds] - Array of chain IDs to connect to (defaults to ethereum mainnet if not provided)\n * @returns A promise that resolves with the connected accounts and chain ID\n */\n async connect({\n account,\n forceRequest,\n chainIds = [DEFAULT_CHAIN_ID],\n }: ConnectOptions = {}): Promise<{ accounts: Address[]; chainId: Hex }> {\n logger('request: connect', { account });\n\n if (!chainIds || chainIds.length === 0) {\n throw new Error('chainIds must be an array of at least one chain ID');\n }\n\n const caipChainIds = Array.from(\n new Set(chainIds.concat(DEFAULT_CHAIN_ID) ?? [DEFAULT_CHAIN_ID]),\n ).map((id) => `eip155:${hexToNumber(id)}`);\n\n const caipAccountIds = account\n ? caipChainIds.map((caipChainId) => `${caipChainId}:${account}`)\n : [];\n\n this.#status = 'connecting';\n\n try {\n // Wait for the wallet_sessionChanged event to fire and set the provider properties\n const result = new Promise((resolve) => {\n this.#provider.once('connect', ({ chainId, accounts }) => {\n logger('fulfilled-request: connect', {\n chainId,\n accounts,\n });\n resolve({\n accounts,\n chainId: chainId as Hex,\n });\n });\n });\n\n await this.#core.connect(\n caipChainIds as Scope[],\n caipAccountIds as CaipAccountId[],\n undefined,\n forceRequest,\n );\n\n return result as Promise<{ accounts: Address[]; chainId: Hex }>;\n } catch (error) {\n this.#status = 'disconnected';\n logger('Error connecting to wallet', error);\n throw error;\n }\n }\n\n /**\n * Connects to the wallet and signs a message using personal_sign.\n *\n * @param options - The connection options\n * @param options.message - The message to sign after connecting\n * @param [options.chainIds] - Optional hex chain IDs to connect to (defaults to ethereum mainnet if not provided)\n * @returns A promise that resolves with the signature\n * @throws Error if the selected account is not available after timeout\n */\n async connectAndSign({\n message,\n chainIds,\n }: {\n message: string;\n chainIds?: Hex[];\n }): Promise<string> {\n const { accounts, chainId } = await this.connect({\n chainIds: chainIds ?? [DEFAULT_CHAIN_ID],\n });\n\n const result = (await this.#provider.request({\n method: 'personal_sign',\n params: [accounts[0], message],\n })) as string;\n\n this.#eventHandlers?.connectAndSign?.({\n accounts,\n chainId,\n signResponse: result,\n });\n\n return result;\n }\n\n /**\n * Connects to the wallet and invokes a method with specified parameters.\n *\n * @param options - The options for connecting and invoking the method\n * @param options.method - The method name to invoke\n * @param options.params - The parameters to pass to the method, or a function that receives the account and returns params\n * @param [options.chainIds] - Optional hex chain IDs to connect to (defaults to ethereum mainnet if not provided)\n * @param [options.account] - Optional specific account to connect to\n * @param [options.forceRequest] - Whether to force a request regardless of an existing session\n * @returns A promise that resolves with the result of the method invocation\n * @throws Error if the selected account is not available after timeout (for methods that require an account)\n */\n async connectWith({\n method,\n params,\n chainIds,\n account,\n forceRequest,\n }: {\n method: string;\n params: unknown[] | ((account: Address) => unknown[]);\n chainIds?: Hex[];\n account?: string | undefined;\n forceRequest?: boolean;\n }): Promise<unknown> {\n const { accounts: connectedAccounts, chainId: connectedChainId } =\n await this.connect({\n chainIds: chainIds ?? [DEFAULT_CHAIN_ID],\n account,\n forceRequest,\n });\n\n const resolvedParams =\n typeof params === 'function' ? params(connectedAccounts[0]) : params;\n\n const result = await this.#provider.request({\n method,\n params: resolvedParams,\n });\n\n this.#eventHandlers?.connectWith?.({\n accounts: connectedAccounts,\n chainId: connectedChainId,\n connectWithResponse: result,\n });\n\n return result;\n }\n\n /**\n * Disconnects from the wallet by revoking the session and cleaning up event listeners.\n *\n * @returns A promise that resolves when disconnection is complete\n */\n async disconnect(): Promise<void> {\n logger('request: disconnect');\n\n const sessionScopes = this.#sessionScopes;\n const eip155Scopes = Object.keys(sessionScopes).filter((scope) => {\n const { namespace } = parseScopeString(scope as Scope);\n return namespace === 'eip155';\n });\n\n await this.#core.disconnect(eip155Scopes as Scope[]);\n this.#onDisconnect();\n this.#clearConnectionState();\n\n // Note: We intentionally do NOT remove the display_uri and wallet_sessionChanged\n // listeners here. These are instance-scoped listeners that should remain active\n // for the lifetime of the SDK instance, allowing reconnection to work properly.\n // Session-scoped listeners (like the notification handler below) are removed.\n\n this.#removeNotificationHandler?.();\n this.#removeNotificationHandler = undefined;\n\n logger('fulfilled-request: disconnect');\n }\n\n /**\n * Switches the Ethereum chain. Will track state internally whenever possible.\n *\n * @param options - The options for the switch chain request\n * @param options.chainId - The chain ID to switch to\n * @param [options.chainConfiguration] - The chain configuration to use in case the chain is not present by the wallet\n * @returns A promise that resolves when the chain has been switched\n */\n async switchChain({\n chainId,\n chainConfiguration,\n }: {\n chainId: Hex;\n chainConfiguration?: AddEthereumChainParameter;\n }): Promise<void> {\n const method = 'wallet_switchEthereumChain';\n const scope: Scope = `eip155:${hexToNumber(chainId)}`;\n const params = [{ chainId }];\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n // TODO (wenfix): better way to return here other than resolving.\n if (this.selectedChainId === chainId) {\n return Promise.resolve();\n }\n\n const permittedChainIds = getPermittedEthChainIds(this.#sessionScopes);\n\n if (\n permittedChainIds.includes(chainId) &&\n this.#core.transportType === TransportType.MWP\n ) {\n await this.#cacheChainId(chainId);\n this.#onChainChanged(chainId);\n await this.#trackWalletActionSucceeded(method, scope, params);\n return Promise.resolve();\n }\n\n try {\n const result = await this.#request({\n method: 'wallet_switchEthereumChain',\n params,\n });\n\n // When using the MWP transport, the error is returned instead of thrown,\n // so we force it into the catch block here.\n const resultWithError = result as { error?: { message: string } };\n if (resultWithError?.error) {\n throw new Error(resultWithError.error.message);\n }\n\n await this.#trackWalletActionSucceeded(method, scope, params);\n if ((result as { result: unknown }).result === null) {\n // result is successful we eagerly call onChainChanged to update the provider's selected chain ID.\n await this.#cacheChainId(chainId);\n this.#onChainChanged(chainId);\n }\n return Promise.resolve();\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n // Fallback to add the chain if its not configured in the wallet.\n if ((error as Error).message.includes('Unrecognized chain ID')) {\n return this.#addEthereumChain(chainConfiguration);\n }\n throw error;\n }\n }\n\n /**\n * Handles several EIP-1193 requests that require special handling\n * due the nature of the Multichain SDK.\n *\n * @param request - The request object containing the method and params\n * @returns The result of the request or undefined if the request is ignored\n */\n async #requestInterceptor(\n request: ProviderRequest,\n ): ReturnType<ProviderRequestInterceptor> {\n logger(`Intercepting request for method: ${request.method}`);\n\n if (IGNORED_METHODS.includes(request.method)) {\n // TODO: replace with correct method unsupported provider error\n return Promise.reject(\n new Error(\n `Method: ${request.method} is not supported by Metamask Connect/EVM`,\n ),\n );\n }\n\n if (request.method === 'wallet_revokePermissions') {\n return this.disconnect();\n }\n\n if (isConnectRequest(request)) {\n // When calling wallet_requestPermissions, we need to force a new session request to prompt\n // the user for accounts, because internally the Multichain SDK will check if\n // the user is already connected and skip the request if so, unless we\n // explicitly request a specific account. This is needed to workaround\n // wallet_requestPermissions not requesting specific accounts.\n const shouldForceConnectionRequest =\n request.method === 'wallet_requestPermissions';\n\n const { method, params } = request;\n const initiallySelectedChainId = DEFAULT_CHAIN_ID;\n const scope: Scope = `eip155:${initiallySelectedChainId}`;\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n try {\n const result = await this.connect({\n chainIds: [initiallySelectedChainId],\n forceRequest: shouldForceConnectionRequest,\n });\n await this.#trackWalletActionSucceeded(method, scope, params);\n return result;\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n throw error;\n }\n }\n\n if (isSwitchChainRequest(request)) {\n return this.switchChain({\n chainId: request.params[0].chainId as Hex,\n });\n }\n\n if (isAddChainRequest(request)) {\n return this.#addEthereumChain(request.params[0]);\n }\n\n if (isAccountsRequest(request)) {\n const { method } = request;\n const decimalChainId = hexToNumber(\n this.#provider.selectedChainId ?? '0x1',\n );\n const scope: Scope = `eip155:${decimalChainId}`;\n const params: unknown[] = [];\n\n await this.#trackWalletActionRequested(method, scope, params);\n await this.#trackWalletActionSucceeded(method, scope, params);\n\n return this.#provider.accounts;\n }\n\n if (isChainIdRequest(request)) {\n return this.#provider.selectedChainId;\n }\n\n logger('Request not intercepted, forwarding to default handler', request);\n return Promise.resolve();\n }\n\n /**\n * Clears the internal connection state: accounts and chainId\n */\n #clearConnectionState(): void {\n this.#provider.accounts = [];\n this.#provider.selectedChainId = undefined;\n }\n\n /**\n * Adds an Ethereum chain using the latest chain configuration received from\n * a switchEthereumChain request\n *\n * @param chainConfiguration - The chain configuration to use in case the chain is not present by the wallet\n * @returns Nothing\n */\n async #addEthereumChain(\n chainConfiguration?: AddEthereumChainParameter,\n ): Promise<void> {\n logger('addEthereumChain called', { chainConfiguration });\n const method = 'wallet_addEthereumChain';\n\n if (!chainConfiguration) {\n throw new Error('No chain configuration found.');\n }\n\n // Get chain ID from config or use current chain\n const chainId =\n (chainConfiguration.chainId as Hex) ||\n this.#provider.selectedChainId ||\n '0x1';\n const decimalChainId = hexToNumber(chainId);\n const scope: Scope = `eip155:${decimalChainId}`;\n const params = [chainConfiguration];\n\n await this.#trackWalletActionRequested(method, scope, params);\n\n try {\n const result = await this.#request({\n method: 'wallet_addEthereumChain',\n params,\n });\n\n if ((result as { result: unknown }).result === null) {\n // if result is successful we eagerly call onChainChanged to update the provider's selected chain ID.\n await this.#cacheChainId(chainId);\n this.#onChainChanged(chainId);\n }\n await this.#trackWalletActionSucceeded(method, scope, params);\n } catch (error) {\n await this.#trackWalletActionFailed(method, scope, params, error);\n throw error;\n }\n }\n\n /**\n * Submits a request to the EIP-1193 provider\n *\n * @param request - The request object containing the method and params\n * @param request.method - The method to request\n * @param request.params - The parameters to pass to the method\n * @returns The result of the request\n */\n async #request(request: {\n method: string;\n params: unknown[];\n }): Promise<unknown> {\n logger('direct request to metamask-provider called', request);\n const result = this.#core.transport.sendEip1193Message(request);\n if (\n request.method === 'wallet_addEthereumChain' ||\n request.method === 'wallet_switchEthereumChain'\n ) {\n this.#core.openSimpleDeeplinkIfNeeded();\n }\n return result;\n }\n\n /**\n * Caches the chainId to storage for persistence across page refreshes.\n *\n * @param chainId - The hex chain ID\n */\n async #cacheChainId(chainId: Hex): Promise<void> {\n try {\n await this.#core.storage.adapter.set(\n CHAIN_STORE_KEY,\n JSON.stringify(chainId),\n );\n } catch (error) {\n logger('Error caching chainId', error);\n }\n }\n\n async #onSessionChanged(session?: SessionData): Promise<void> {\n logger('event: wallet_sessionChanged', session);\n this.#sessionScopes = session?.sessionScopes ?? {};\n const hexPermittedChainIds = getPermittedEthChainIds(this.#sessionScopes);\n if (hexPermittedChainIds.length === 0) {\n this.#onDisconnect();\n } else {\n let initialAccounts: Address[] = [];\n if (this.#core.status === 'connected') {\n const ethAccountsResponse =\n await this.#core.transport.sendEip1193Message({\n method: 'eth_accounts',\n params: [],\n });\n initialAccounts = ethAccountsResponse.result as Address[];\n } else {\n initialAccounts = getEthAccounts(this.#sessionScopes);\n }\n\n const chainId = await this.#getSelectedChainId(hexPermittedChainIds);\n\n this.#onConnect({\n chainId,\n accounts: initialAccounts,\n });\n }\n }\n\n /**\n * Handles chain change events and updates the provider's selected chain ID.\n *\n * @param chainId - The new hex chain ID\n */\n #onChainChanged(chainId: Hex): void {\n if (chainId === this.#provider.selectedChainId) {\n return;\n }\n logger('handler: chainChanged', { chainId });\n this.#provider.selectedChainId = chainId;\n this.#eventHandlers?.chainChanged?.(chainId);\n this.#provider.emit('chainChanged', chainId);\n }\n\n /**\n * Handles accounts change events and updates the provider's accounts list.\n *\n * @param accounts - The new list of permitted accounts\n */\n #onAccountsChanged(accounts: Address[]): void {\n const accountsUnchanged =\n accounts.length === this.#provider.accounts.length &&\n accounts.every((acct, idx) => acct === this.#provider.accounts[idx]);\n if (accountsUnchanged) {\n return;\n }\n logger('handler: accountsChanged', accounts);\n this.#provider.accounts = accounts;\n this.#provider.emit('accountsChanged', accounts);\n this.#eventHandlers?.accountsChanged?.(accounts);\n }\n\n /**\n * Handles connection events and emits the connect event to listeners.\n *\n * @param options - The connection options\n * @param options.chainId - The hex chain ID of the connection\n * @param options.accounts - The accounts of the connection\n */\n #onConnect({\n chainId,\n accounts,\n }: {\n chainId: Hex;\n accounts: Address[];\n }): void {\n logger('handler: connect', { chainId, accounts });\n const data = {\n chainId,\n accounts,\n };\n\n if (this.#status !== 'connected') {\n this.#status = 'connected';\n this.#provider.emit('connect', data);\n this.#eventHandlers?.connect?.(data);\n\n this.#removeNotificationHandler?.();\n\n // TODO: Verify if #core.on('metamask_accountsChanged') and #core.on('metamask_chainChanged')\n // would work here instead\n this.#removeNotificationHandler = this.#core.transport.onNotification(\n (notification) => {\n // @ts-expect-error TODO: address this\n if (notification?.method === 'metamask_accountsChanged') {\n // @ts-expect-error TODO: address this\n const notificationAccounts = notification?.params;\n logger('transport-event: accountsChanged', notificationAccounts);\n // why are we not caching the accounts here?\n this.#onAccountsChanged(notificationAccounts);\n }\n\n // @ts-expect-error TODO: address this\n if (notification?.method === 'metamask_chainChanged') {\n // @ts-expect-error TODO: address this\n const notificationChainId = notification?.params?.chainId;\n logger('transport-event: chainChanged', notificationChainId);\n // Cache the chainId for persistence across page refreshes\n this.#cacheChainId(notificationChainId).catch((error) => {\n logger('Error caching chainId in notification handler', error);\n });\n this.#onChainChanged(notificationChainId);\n }\n },\n );\n }\n\n this.#onChainChanged(chainId);\n this.#onAccountsChanged(accounts);\n }\n\n /**\n * Handles disconnection events and emits the disconnect event to listeners.\n * Also clears accounts by triggering an accountsChanged event with an empty array.\n */\n #onDisconnect(): void {\n if (this.#status === 'disconnected') {\n return;\n }\n this.#status = 'disconnected';\n\n logger('handler: disconnect');\n this.#provider.emit('disconnect');\n this.#eventHandlers?.disconnect?.();\n\n this.#onAccountsChanged([]);\n }\n\n /**\n * Handles display_uri events and emits them to the provider.\n * This allows consumers to display their own custom QR code UI.\n *\n * @param uri - The deeplink URI to be displayed as a QR code\n */\n #onDisplayUri(uri: string): void {\n if (this.#status !== 'connecting') {\n return;\n }\n\n logger('handler: display_uri', uri);\n this.#provider.emit('display_uri', uri);\n this.#eventHandlers?.displayUri?.(uri);\n }\n\n /**\n * Gets the EIP-1193 provider instance\n *\n * @returns The EIP-1193 provider instance\n */\n getProvider(): EIP1193Provider {\n return this.#provider;\n }\n\n /**\n * Gets the currently selected chain ID on the wallet\n *\n * @returns The currently selected chain ID or undefined if no chain is selected\n */\n getChainId(): Hex | undefined {\n return this.selectedChainId;\n }\n\n /**\n * Gets the currently selected account on the wallet\n *\n * @returns The currently selected account or undefined if no account is selected\n */\n getAccount(): Address | undefined {\n return this.#provider.selectedAccount;\n }\n\n // Convenience getters for the EIP-1193 provider\n /**\n * Gets the currently permitted accounts\n *\n * @returns The currently permitted accounts\n */\n get accounts(): Address[] {\n return this.#provider.accounts;\n }\n\n /**\n * Gets the currently selected account on the wallet\n *\n * @returns The currently selected account or undefined if no account is selected\n */\n get selectedAccount(): Address | undefined {\n return this.#provider.selectedAccount;\n }\n\n /**\n * Gets the currently selected chain ID on the wallet\n *\n * @returns The currently selected chain ID or undefined if no chain is selected\n */\n get selectedChainId(): Hex | undefined {\n return this.#provider.selectedChainId;\n }\n\n /**\n * Gets the current connection status\n *\n * @returns The current connection status\n */\n get status(): ConnectionStatus {\n return this.#core.status;\n }\n}\n\n/**\n * Creates a new Metamask Connect/EVM instance\n *\n * @param options - The options for the Metamask Connect/EVM layer\n * @param options.dapp - Dapp identification and branding settings\n * @param options.api - API configuration including read-only RPC map\n * @param options.api.supportedNetworks - A map of hex chain IDs to RPC URLs for read-only requests\n * @param [options.ui] - UI configuration options\n * @param [options.ui.headless] - Whether to run without UI\n * @param [options.ui.preferExtension] - Whether to prefer browser extension\n * @param [options.ui.showInstallModal] - Whether to render installation modal for desktop extension\n * @param [options.mobile] - Mobile configuration options\n * @param [options.mobile.preferredOpenLink] - Custom handler for opening deeplinks (useful for React Native, etc.)\n * @param [options.mobile.useDeeplink] - Whether to use native deeplinks instead of universal links\n * @param [options.transport] - Transport configuration (e.g., extensionId, notification handler)\n * @param [options.transport.extensionId] - Extension ID for browser extension transport\n * @param [options.transport.onNotification] - Callback for receiving transport notifications\n * @param [options.eventHandlers] - Event handlers for the Metamask Connect/EVM layer\n * @param [options.debug] - Enable debug logging\n * @returns The Metamask-Connect EVM client instance\n */\nexport async function createEVMClient(\n options: Pick<MultichainOptions, 'dapp' | 'mobile' | 'transport'> & {\n ui?: Omit<MultichainOptions['ui'], 'factory'>;\n } & {\n eventHandlers?: Partial<EventHandlers>;\n debug?: boolean;\n api: {\n supportedNetworks: Record<Hex, string>;\n };\n },\n): Promise<MetamaskConnectEVM> {\n if (options.debug) {\n enableDebug();\n }\n\n logger('Creating Metamask Connect/EVM with options:', options);\n\n // Validate that supportedNetworks is provided and not empty\n if (\n !options.api?.supportedNetworks ||\n Object.keys(options.api.supportedNetworks).length === 0\n ) {\n throw new Error(\n 'supportedNetworks is required and must contain at least one chain configuration',\n );\n }\n\n validSupportedChainsUrls(options.api.supportedNetworks, 'supportedNetworks');\n\n const supportedNetworksCaipChainId = Object.entries(\n options.api.supportedNetworks,\n ).reduce<Record<string, string>>((acc, [hexChainId, url]) => {\n const decimalChainId = parseInt(hexChainId, 16);\n const caip2ChainId = `eip155:${decimalChainId}`;\n acc[caip2ChainId] = url;\n return acc;\n }, {});\n\n try {\n const core = await createMultichainClient({\n ...options,\n api: {\n supportedNetworks: supportedNetworksCaipChainId,\n },\n });\n\n return MetamaskConnectEVM.create({\n core,\n eventHandlers: options.eventHandlers,\n supportedNetworks: options.api.supportedNetworks,\n });\n } catch (error) {\n console.error('Error creating Metamask Connect/EVM', error);\n throw error;\n }\n}\n","export const IGNORED_METHODS = [\n 'metamask_getProviderState',\n 'metamask_sendDomainMetadata',\n 'metamask_logWeb3ShimUsage',\n 'wallet_registerOnboarding',\n 'net_version',\n 'wallet_getPermissions',\n];\n\nexport const CONNECT_METHODS = [\n 'wallet_requestPermissions',\n 'eth_requestAccounts',\n];\n\nexport const ACCOUNTS_METHODS = ['eth_accounts', 'eth_coinbase'];\n\nexport const CHAIN_METHODS = ['eth_chainId'];\n\nexport const INTERCEPTABLE_METHODS = [\n ...ACCOUNTS_METHODS,\n ...IGNORED_METHODS,\n ...CONNECT_METHODS,\n ...CHAIN_METHODS,\n // These have bespoke handlers\n 'wallet_revokePermissions',\n 'wallet_switchEthereumChain',\n 'wallet_addEthereumChain',\n];\n","import {\n createLogger,\n enableDebug as debug,\n} from '@metamask/connect-multichain';\n\nconst namespace = 'metamask-connect:evm';\n\n// @ts-expect-error logger needs to be typed properly\nexport const logger = createLogger(namespace, '63');\n\nexport const enableDebug = (): void => {\n // @ts-expect-error logger needs to be typed properly\n debug(namespace);\n};\n","/* eslint-disable promise/always-return -- Legacy callback patterns */\n/* eslint-disable promise/no-callback-in-promise -- Legacy sendAsync/send API */\n/* eslint-disable consistent-return -- Legacy method returns void or Promise */\n/* eslint-disable @typescript-eslint/no-floating-promises -- Legacy fire-and-forget pattern */\n/* eslint-disable jsdoc/require-returns -- Inherited from abstract class */\nimport type { MultichainCore, Scope } from '@metamask/connect-multichain';\nimport { EventEmitter } from '@metamask/connect-multichain';\nimport { hexToNumber } from '@metamask/utils';\n\nimport { INTERCEPTABLE_METHODS } from './constants';\nimport { logger } from './logger';\nimport type {\n Address,\n EIP1193ProviderEvents,\n Hex,\n JsonRpcCallback,\n JsonRpcRequest,\n JsonRpcResponse,\n ProviderRequest,\n ProviderRequestInterceptor,\n} from './types';\n\n/**\n * EIP-1193 Provider wrapper around the Multichain SDK.\n */\nexport class EIP1193Provider extends EventEmitter<EIP1193ProviderEvents> {\n /** The core instance of the Multichain SDK */\n readonly #core: MultichainCore;\n\n /** Interceptor function to handle specific methods */\n readonly #requestInterceptor: ProviderRequestInterceptor;\n\n /** The currently permitted accounts */\n #accounts: Address[] = [];\n\n /** The currently selected chain ID on the wallet */\n #selectedChainId?: Hex | undefined;\n\n constructor(core: MultichainCore, interceptor: ProviderRequestInterceptor) {\n super();\n this.#core = core;\n this.#requestInterceptor = interceptor;\n\n // Bind all public methods to ensure `this` context is preserved\n // when methods are extracted or passed as callbacks.\n // This eliminates the need for Proxy wrappers in consumers.\n this.request = this.request.bind(this);\n this.sendAsync = this.sendAsync.bind(this);\n this.send = this.send.bind(this);\n\n // Bind inherited EventEmitter methods\n this.on = this.on.bind(this);\n this.off = this.off.bind(this);\n this.emit = this.emit.bind(this);\n this.once = this.once.bind(this);\n this.removeListener = this.removeListener.bind(this);\n this.listenerCount = this.listenerCount.bind(this);\n }\n\n /**\n * Performs a EIP-1193 request.\n *\n * @param request - The request object containing the method and params\n * @returns The result of the request\n */\n async request(request: ProviderRequest): Promise<unknown> {\n logger(\n `request: ${request.method} - chainId: ${this.selectedChainId}`,\n request.params,\n );\n /* Some methods require special handling, so we intercept them here\n * and handle them in MetamaskConnectEVM.requestInterceptor method. */\n if (INTERCEPTABLE_METHODS.includes(request.method)) {\n return this.#requestInterceptor?.(request);\n }\n\n if (!this.#selectedChainId) {\n // TODO: replace with a better error\n throw new Error('No chain ID selected');\n }\n\n const decimalChainId = hexToNumber(this.#selectedChainId);\n const scope: Scope = `eip155:${decimalChainId}`;\n\n // Validate that the chain is configured in supportedNetworks\n // This check is performed here to provide better error messages\n // The RpcClient will also validate, but this gives us a chance to provide\n // a clearer error message before the request is routed\n const coreOptions = (this.#core as any).options; // TODO: options is `protected readonly` property, this needs to be refactored so `any` type assertion is not necessary\n const supportedNetworks = coreOptions?.api?.supportedNetworks ?? {};\n if (!supportedNetworks[scope]) {\n throw new Error(\n `Chain ${scope} is not configured in supportedNetworks. Requests cannot be made to chains not explicitly configured in supportedNetworks.`,\n );\n }\n\n return this.#core.invokeMethod({\n scope,\n request: {\n method: request.method,\n params: request.params,\n },\n });\n }\n\n // Getters and setters\n public get selectedAccount(): Address | undefined {\n return this.accounts[0];\n }\n\n public set accounts(accounts: Address[]) {\n this.#accounts = accounts;\n }\n\n public get accounts(): Address[] {\n return this.#accounts;\n }\n\n public get selectedChainId(): Hex | undefined {\n return this.#selectedChainId;\n }\n\n public set selectedChainId(chainId: Hex | undefined) {\n this.#selectedChainId = chainId;\n }\n\n // ==========================================\n // Legacy compatibility methods\n // ==========================================\n\n /**\n * Alias for selectedChainId for legacy compatibility.\n * Many dApps expect a `chainId` property on the provider.\n */\n public get chainId(): Hex | undefined {\n return this.selectedChainId;\n }\n\n /**\n * Legacy method for sending JSON-RPC requests.\n *\n * @deprecated Use `request` instead. This method is provided for backwards compatibility.\n * @param request - The JSON-RPC request object\n * @param callback - Optional callback function. If provided, the method returns void.\n * @returns A promise resolving to the JSON-RPC response, or void if a callback is provided.\n */\n async sendAsync<TParams = unknown, TResult = unknown>(\n request: JsonRpcRequest<TParams>,\n callback?: JsonRpcCallback<TResult>,\n ): Promise<JsonRpcResponse<TResult> | void> {\n const id = request.id ?? 1;\n\n const promise = this.request({\n method: request.method,\n params: request.params as unknown,\n })\n .then(\n (result): JsonRpcResponse<TResult> => ({\n id,\n jsonrpc: '2.0',\n result: result as TResult,\n }),\n )\n .catch(\n (error): JsonRpcResponse<TResult> => ({\n id,\n jsonrpc: '2.0',\n error: {\n code: error.code ?? -32603,\n message: error.message ?? 'Internal error',\n data: error.data,\n },\n }),\n );\n\n if (callback) {\n promise\n .then((response) => {\n if (response.error) {\n callback(new Error(response.error.message), response);\n } else {\n callback(null, response);\n }\n })\n .catch((error) => {\n callback(error, null);\n });\n return;\n }\n\n return promise;\n }\n\n /**\n * Legacy method for sending JSON-RPC requests synchronously (callback-based).\n *\n * @deprecated Use `request` instead. This method is provided for backwards compatibility.\n * @param request - The JSON-RPC request object\n * @param callback - The callback function to receive the response\n */\n send<TParams = unknown, TResult = unknown>(\n request: JsonRpcRequest<TParams>,\n callback: JsonRpcCallback<TResult>,\n ): void {\n this.sendAsync(request, callback);\n }\n}\n","import type { InternalScopesObject } from '@metamask/chain-agnostic-permission';\nimport {\n getPermittedEthChainIds as _getPermittedEthChainIds,\n getEthAccounts as _getEthAccounts,\n} from '@metamask/chain-agnostic-permission';\nimport type { SessionData } from '@metamask/connect-multichain';\n\nimport type { Address, Hex } from '../types';\n\n/**\n * Get the Ethereum accounts from the session data\n *\n * @param sessionScopes - The session scopes\n * @returns The Ethereum accounts\n */\nexport const getEthAccounts = (\n sessionScopes: SessionData['sessionScopes'] | undefined,\n): Address[] => {\n if (!sessionScopes) {\n return [];\n }\n\n return _getEthAccounts({\n requiredScopes: sessionScopes as InternalScopesObject,\n optionalScopes: sessionScopes as InternalScopesObject,\n });\n};\n\n/**\n * Get the permitted Ethereum chain IDs from the session scopes.\n * Wrapper around getPermittedEthChainIds from @metamask/chain-agnostic-permission\n *\n * @param sessionScopes - The session scopes\n * @returns The permitted Ethereum chain IDs\n */\nexport const getPermittedEthChainIds = (\n sessionScopes: SessionData['sessionScopes'] | undefined,\n): Hex[] => {\n if (!sessionScopes) {\n return [];\n }\n\n return _getPermittedEthChainIds({\n requiredScopes: sessionScopes as InternalScopesObject,\n optionalScopes: sessionScopes as InternalScopesObject,\n });\n};\n","import type { ProviderRequest } from '../types';\n\n/**\n * Type guard for connect-like requests:\n * - wallet_requestPermissions\n * - eth_requestAccounts\n *\n * @param req - The request object to check\n * @returns True if the request is a connect-like request, false otherwise\n */\nexport function isConnectRequest(req: ProviderRequest): req is Extract<\n ProviderRequest,\n {\n method: 'wallet_requestPermissions' | 'eth_requestAccounts';\n }\n> {\n return (\n req.method === 'wallet_requestPermissions' ||\n req.method === 'eth_requestAccounts'\n );\n}\n\n/**\n * Type guard for wallet_switchEthereumChain request.\n *\n * @param req - The request object to check\n * @returns True if the request is a wallet_switchEthereumChain request, false otherwise\n */\nexport function isSwitchChainRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'wallet_switchEthereumChain' }> {\n return req.method === 'wallet_switchEthereumChain';\n}\n\n/**\n * Type guard for wallet_addEthereumChain request.\n *\n * @param req - The request object to check\n * @returns True if the request is a wallet_addEthereumChain request, false otherwise\n */\nexport function isAddChainRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'wallet_addEthereumChain' }> {\n return req.method === 'wallet_addEthereumChain';\n}\n\n/**\n * Type guard for generic accounts request:\n * - eth_accounts\n * - eth_coinbase\n *\n * @param req - The request object to check\n * @returns True if the request is a generic accounts request, false otherwise\n */\nexport function isAccountsRequest(\n req: ProviderRequest,\n): req is Extract<\n ProviderRequest,\n { method: 'eth_accounts' | 'eth_coinbase' }\n> {\n return req.method === 'eth_accounts' || req.method === 'eth_coinbase';\n}\n\n/**\n * Type guard for generic eth_chainId request.\n *\n * @param req - The request object to check\n * @returns True if the request is a eth_chainId request, false otherwise\n */\nexport function isChainIdRequest(\n req: ProviderRequest,\n): req is Extract<ProviderRequest, { method: 'eth_chainId' }> {\n return req.method === 'eth_chainId';\n}\n\n/**\n * Validates that all values in a Record are valid URLs.\n *\n * @param record - The record to validate (e.g., supportedNetworks)\n * @param recordName - The name of the record for error messages\n * @throws Error if any values are invalid URLs\n */\nexport function validSupportedChainsUrls(\n record: Record<string, string>,\n recordName: string,\n): void {\n const invalidUrls: string[] = [];\n for (const [key, url] of Object.entries(record)) {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n } catch {\n invalidUrls.push(`${key}: ${url}`);\n }\n }\n\n if (invalidUrls.length > 0) {\n throw new Error(\n `${recordName} contains invalid URLs:\\n${invalidUrls.join('\\n')}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,oBAAoB,kCAAkC;AAE/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,mBAAmB,CAAC,iBAAqC;AACpE,QAAM,UAAU,2BAA2B,YAAY;AACvD,QAAM,SAAS,OAAO,QAAQ,OAAO,EAAE;AAAA,IACrC,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM;AACnB,YAAM,EAAE,WAAAA,YAAW,UAAU,IAAI,iBAAiB,GAAkB;AACpE,UAAIA,eAAc,mBAAmB,QAAQ;AAC3C,eAAO;AAAA,MACT;AACA,YAAM,UAAU,YAAY,SAAS,WAAW,EAAE,CAAC;AACnD,UAAI,OAAO,IAAI;AACf,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACA,SAAO;AACT;;;ACvBA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AAQjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAAC,oBAAmB;;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AACjB,kBAAY;AAAA,IACd;AAEA,WAAO,+CAA+C,OAAO;AAG7D,QACE,GAAC,aAAQ,QAAR,mBAAa,sBACd,OAAO,KAAK,QAAQ,IAAI,iBAAiB,EAAE,WAAW,GACtD;AACA,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,6BAAyB,QAAQ,IAAI,mBAAmB,mBAAmB;AAE3E,UAAM,+BAA+B,OAAO;AAAA,MAC1C,QAAQ,IAAI;AAAA,IACd,EAAE,OAA+B,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM;AAC3D,YAAM,iBAAiB,SAAS,YAAY,EAAE;AAC9C,YAAM,eAAe,UAAU,cAAc;AAC7C,UAAI,YAAY,IAAI;AACpB,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAEL,QAAI;AACF,YAAM,OAAO,MAAM,uBAAuB,iCACrC,UADqC;AAAA,QAExC,KAAK;AAAA,UACH,mBAAmB;AAAA,QACrB;AAAA,MACF,EAAC;AAED,aAAO,mBAAmB,OAAO;AAAA,QAC/B;AAAA,QACA,eAAe,QAAQ;AAAA,QACvB,mBAAmB,QAAQ,IAAI;AAAA,MACjC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC,KAAK;AAC1D,YAAM;AAAA,IACR;AAAA,EACF;AAAA;","names":["namespace","hexToNumber","_a","_core","hexToNumber","namespace","_a"]}
|
package/dist/src/connect.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ type ConnectOptions = {
|
|
|
7
7
|
account?: string | undefined;
|
|
8
8
|
/** Whether to force a request regardless of an existing session */
|
|
9
9
|
forceRequest?: boolean;
|
|
10
|
-
/** All available chain IDs in the dapp */
|
|
11
|
-
chainIds
|
|
10
|
+
/** All available chain IDs in the dapp in hex format */
|
|
11
|
+
chainIds?: Hex[];
|
|
12
12
|
};
|
|
13
|
+
export type ConnectEvmStatus = 'disconnected' | 'connected' | 'connecting';
|
|
13
14
|
/**
|
|
14
15
|
* The MetamaskConnectEVM class provides an EIP-1193 compatible interface for connecting
|
|
15
16
|
* to MetaMask and interacting with Ethereum Virtual Machine (EVM) networks.
|
|
@@ -28,50 +29,64 @@ type ConnectOptions = {
|
|
|
28
29
|
*
|
|
29
30
|
* @example
|
|
30
31
|
* ```typescript
|
|
31
|
-
* const
|
|
32
|
+
* const client = await createEVMClient({
|
|
32
33
|
* dapp: { name: 'My DApp', url: 'https://mydapp.com' }
|
|
33
34
|
* });
|
|
34
35
|
*
|
|
35
|
-
* await
|
|
36
|
-
*
|
|
37
|
-
* const
|
|
36
|
+
* const { accounts, chainId } = await client.connect({ chainIds: [1, 137] }); // Connect to Ethereum Mainnet, and Polygon
|
|
37
|
+
*
|
|
38
|
+
* const provider = client.getProvider();
|
|
39
|
+
* const signedMessage = await provider.request({ method: 'personal_sign', params: ['0x0', accounts[0]] });
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
export declare class MetamaskConnectEVM {
|
|
41
43
|
#private;
|
|
42
44
|
/**
|
|
43
45
|
* Creates a new MetamaskConnectEVM instance.
|
|
46
|
+
* Use the static `create()` method instead to ensure proper async initialization.
|
|
47
|
+
*
|
|
48
|
+
* @param options - The options for the MetamaskConnectEVM instance
|
|
49
|
+
* @param options.core - The core instance of the Multichain SDK
|
|
50
|
+
* @param options.eventHandlers - Optional event handlers for EIP-1193 provider events
|
|
51
|
+
*/
|
|
52
|
+
private constructor();
|
|
53
|
+
/**
|
|
54
|
+
* Creates a fully initialized MetamaskConnectEVM instance.
|
|
55
|
+
* This is the recommended way to instantiate the class, as it ensures
|
|
56
|
+
* all async initialization (like session recovery) completes before
|
|
57
|
+
* the instance is returned.
|
|
44
58
|
*
|
|
45
59
|
* @param options - The options for the MetamaskConnectEVM instance
|
|
46
60
|
* @param options.core - The core instance of the Multichain SDK
|
|
47
61
|
* @param options.eventHandlers - Optional event handlers for EIP-1193 provider events
|
|
62
|
+
* @returns A promise that resolves with a fully initialized MetamaskConnectEVM instance
|
|
48
63
|
*/
|
|
49
|
-
|
|
64
|
+
static create(options: MetamaskConnectEVMOptions): Promise<MetamaskConnectEVM>;
|
|
50
65
|
/**
|
|
51
66
|
* Connects to the wallet with the specified chain ID and optional account.
|
|
52
67
|
*
|
|
53
68
|
* @param options - The connection options
|
|
54
|
-
* @param options.account - Optional
|
|
55
|
-
* @param options.forceRequest -
|
|
56
|
-
* @param options.chainIds - Array of chain IDs to connect to
|
|
69
|
+
* @param [options.account] - Optional param to specify an account to connect to
|
|
70
|
+
* @param [options.forceRequest] - Optional param to force a connection request regardless of whether there is a pre-existing session
|
|
71
|
+
* @param [options.chainIds] - Array of chain IDs to connect to (defaults to ethereum mainnet if not provided)
|
|
57
72
|
* @returns A promise that resolves with the connected accounts and chain ID
|
|
58
73
|
*/
|
|
59
|
-
connect({ account, forceRequest, chainIds }?: ConnectOptions): Promise<{
|
|
74
|
+
connect({ account, forceRequest, chainIds, }?: ConnectOptions): Promise<{
|
|
60
75
|
accounts: Address[];
|
|
61
|
-
chainId:
|
|
76
|
+
chainId: Hex;
|
|
62
77
|
}>;
|
|
63
78
|
/**
|
|
64
79
|
* Connects to the wallet and signs a message using personal_sign.
|
|
65
80
|
*
|
|
66
81
|
* @param options - The connection options
|
|
67
82
|
* @param options.message - The message to sign after connecting
|
|
68
|
-
* @param options.chainIds - Optional chain IDs to connect to (defaults to ethereum mainnet if not provided)
|
|
83
|
+
* @param [options.chainIds] - Optional hex chain IDs to connect to (defaults to ethereum mainnet if not provided)
|
|
69
84
|
* @returns A promise that resolves with the signature
|
|
70
85
|
* @throws Error if the selected account is not available after timeout
|
|
71
86
|
*/
|
|
72
87
|
connectAndSign({ message, chainIds, }: {
|
|
73
88
|
message: string;
|
|
74
|
-
chainIds?:
|
|
89
|
+
chainIds?: Hex[];
|
|
75
90
|
}): Promise<string>;
|
|
76
91
|
/**
|
|
77
92
|
* Connects to the wallet and invokes a method with specified parameters.
|
|
@@ -79,16 +94,16 @@ export declare class MetamaskConnectEVM {
|
|
|
79
94
|
* @param options - The options for connecting and invoking the method
|
|
80
95
|
* @param options.method - The method name to invoke
|
|
81
96
|
* @param options.params - The parameters to pass to the method, or a function that receives the account and returns params
|
|
82
|
-
* @param options.chainIds - Optional chain IDs to connect to (defaults to ethereum mainnet if not provided)
|
|
83
|
-
* @param options.account - Optional specific account to connect to
|
|
84
|
-
* @param options.forceRequest - Whether to force a request regardless of an existing session
|
|
97
|
+
* @param [options.chainIds] - Optional hex chain IDs to connect to (defaults to ethereum mainnet if not provided)
|
|
98
|
+
* @param [options.account] - Optional specific account to connect to
|
|
99
|
+
* @param [options.forceRequest] - Whether to force a request regardless of an existing session
|
|
85
100
|
* @returns A promise that resolves with the result of the method invocation
|
|
86
101
|
* @throws Error if the selected account is not available after timeout (for methods that require an account)
|
|
87
102
|
*/
|
|
88
103
|
connectWith({ method, params, chainIds, account, forceRequest, }: {
|
|
89
104
|
method: string;
|
|
90
105
|
params: unknown[] | ((account: Address) => unknown[]);
|
|
91
|
-
chainIds?:
|
|
106
|
+
chainIds?: Hex[];
|
|
92
107
|
account?: string | undefined;
|
|
93
108
|
forceRequest?: boolean;
|
|
94
109
|
}): Promise<unknown>;
|
|
@@ -103,13 +118,13 @@ export declare class MetamaskConnectEVM {
|
|
|
103
118
|
*
|
|
104
119
|
* @param options - The options for the switch chain request
|
|
105
120
|
* @param options.chainId - The chain ID to switch to
|
|
106
|
-
* @param options.chainConfiguration - The chain configuration to use in case the chain is not present by the wallet
|
|
107
|
-
* @returns
|
|
121
|
+
* @param [options.chainConfiguration] - The chain configuration to use in case the chain is not present by the wallet
|
|
122
|
+
* @returns A promise that resolves when the chain has been switched
|
|
108
123
|
*/
|
|
109
124
|
switchChain({ chainId, chainConfiguration, }: {
|
|
110
|
-
chainId:
|
|
125
|
+
chainId: Hex;
|
|
111
126
|
chainConfiguration?: AddEthereumChainParameter;
|
|
112
|
-
}): Promise<
|
|
127
|
+
}): Promise<void>;
|
|
113
128
|
/**
|
|
114
129
|
* Gets the EIP-1193 provider instance
|
|
115
130
|
*
|
|
@@ -159,20 +174,29 @@ export declare class MetamaskConnectEVM {
|
|
|
159
174
|
* @param options - The options for the Metamask Connect/EVM layer
|
|
160
175
|
* @param options.dapp - Dapp identification and branding settings
|
|
161
176
|
* @param options.api - API configuration including read-only RPC map
|
|
162
|
-
* @param options.api.supportedNetworks - A map of
|
|
163
|
-
* @param options.ui - UI configuration options
|
|
164
|
-
* @param options.ui.headless - Whether to run without UI
|
|
165
|
-
* @param options.ui.preferExtension - Whether to prefer browser extension
|
|
166
|
-
* @param options.ui.showInstallModal - Whether to render installation modal for desktop extension
|
|
167
|
-
* @param options.
|
|
168
|
-
* @param options.
|
|
169
|
-
* @
|
|
177
|
+
* @param options.api.supportedNetworks - A map of hex chain IDs to RPC URLs for read-only requests
|
|
178
|
+
* @param [options.ui] - UI configuration options
|
|
179
|
+
* @param [options.ui.headless] - Whether to run without UI
|
|
180
|
+
* @param [options.ui.preferExtension] - Whether to prefer browser extension
|
|
181
|
+
* @param [options.ui.showInstallModal] - Whether to render installation modal for desktop extension
|
|
182
|
+
* @param [options.mobile] - Mobile configuration options
|
|
183
|
+
* @param [options.mobile.preferredOpenLink] - Custom handler for opening deeplinks (useful for React Native, etc.)
|
|
184
|
+
* @param [options.mobile.useDeeplink] - Whether to use native deeplinks instead of universal links
|
|
185
|
+
* @param [options.transport] - Transport configuration (e.g., extensionId, notification handler)
|
|
186
|
+
* @param [options.transport.extensionId] - Extension ID for browser extension transport
|
|
187
|
+
* @param [options.transport.onNotification] - Callback for receiving transport notifications
|
|
188
|
+
* @param [options.eventHandlers] - Event handlers for the Metamask Connect/EVM layer
|
|
189
|
+
* @param [options.debug] - Enable debug logging
|
|
190
|
+
* @returns The Metamask-Connect EVM client instance
|
|
170
191
|
*/
|
|
171
|
-
export declare function createEVMClient(options: Pick<MultichainOptions, 'dapp' | '
|
|
192
|
+
export declare function createEVMClient(options: Pick<MultichainOptions, 'dapp' | 'mobile' | 'transport'> & {
|
|
172
193
|
ui?: Omit<MultichainOptions['ui'], 'factory'>;
|
|
173
194
|
} & {
|
|
174
195
|
eventHandlers?: Partial<EventHandlers>;
|
|
175
196
|
debug?: boolean;
|
|
197
|
+
api: {
|
|
198
|
+
supportedNetworks: Record<Hex, string>;
|
|
199
|
+
};
|
|
176
200
|
}): Promise<MetamaskConnectEVM>;
|
|
177
201
|
export {};
|
|
178
202
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EAGlB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,yBAAyB,EACzB,OAAO,EAEP,aAAa,EACb,GAAG,EACH,yBAAyB,EAG1B,MAAM,SAAS,CAAC;AAcjB,yCAAyC;AACzC,KAAK,cAAc,GAAG;IACpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,mEAAmE;IACnE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,WAAW,GAAG,YAAY,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,kBAAkB;;IAyB7B;;;;;;;OAOG;IACH,OAAO;IA8BP;;;;;;;;;;OAUG;WACU,MAAM,CACjB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC;IAoJ9B;;;;;;;;OAQG;IACG,OAAO,CAAC,EACZ,OAAO,EACP,YAAY,EACZ,QAA6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