@rango-dev/provider-walletconnect-2 0.57.0 → 0.57.1-next.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/adapter/adapter.d.ts +39 -0
  3. package/dist/adapter/adapter.d.ts.map +1 -0
  4. package/dist/adapter/index.d.ts +3 -0
  5. package/dist/adapter/index.d.ts.map +1 -0
  6. package/dist/adapter/modal-cache.d.ts +14 -0
  7. package/dist/adapter/modal-cache.d.ts.map +1 -0
  8. package/dist/adapter/modal.d.ts +25 -0
  9. package/dist/adapter/modal.d.ts.map +1 -0
  10. package/dist/adapter/networks.d.ts +60 -0
  11. package/dist/adapter/networks.d.ts.map +1 -0
  12. package/dist/adapter/provider-client.d.ts +3 -0
  13. package/dist/adapter/provider-client.d.ts.map +1 -0
  14. package/dist/adapter/registry.d.ts +4 -0
  15. package/dist/adapter/registry.d.ts.map +1 -0
  16. package/dist/adapter/session-cache.d.ts +17 -0
  17. package/dist/adapter/session-cache.d.ts.map +1 -0
  18. package/dist/adapter/task-queue.d.ts +11 -0
  19. package/dist/adapter/task-queue.d.ts.map +1 -0
  20. package/dist/chunk-GEAT645O.js +2 -0
  21. package/dist/chunk-GEAT645O.js.map +7 -0
  22. package/dist/constants.d.ts +4 -48
  23. package/dist/constants.d.ts.map +1 -0
  24. package/dist/evm-3KFL5N77.js +2 -0
  25. package/dist/evm-3KFL5N77.js.map +7 -0
  26. package/dist/mod.d.ts +4 -0
  27. package/dist/mod.d.ts.map +1 -0
  28. package/dist/mod.js +2 -0
  29. package/dist/mod.js.map +7 -0
  30. package/dist/namespaces/evm/hooks.d.ts +18 -0
  31. package/dist/namespaces/evm/hooks.d.ts.map +1 -0
  32. package/dist/namespaces/evm/namespace.d.ts +4 -0
  33. package/dist/namespaces/evm/namespace.d.ts.map +1 -0
  34. package/dist/namespaces/subscriber.d.ts +24 -0
  35. package/dist/namespaces/subscriber.d.ts.map +1 -0
  36. package/dist/provider.d.ts +3 -0
  37. package/dist/provider.d.ts.map +1 -0
  38. package/dist/session/accounts.d.ts +17 -0
  39. package/dist/session/accounts.d.ts.map +1 -0
  40. package/dist/session/bip122.d.ts +23 -0
  41. package/dist/session/bip122.d.ts.map +1 -0
  42. package/dist/session/chain-state.d.ts +6 -0
  43. package/dist/session/chain-state.d.ts.map +1 -0
  44. package/dist/session/evm-chain.d.ts +29 -0
  45. package/dist/session/evm-chain.d.ts.map +1 -0
  46. package/dist/session/evm.d.ts +25 -0
  47. package/dist/session/evm.d.ts.map +1 -0
  48. package/dist/session/lifecycle.d.ts +30 -0
  49. package/dist/session/lifecycle.d.ts.map +1 -0
  50. package/dist/session/lookup.d.ts +6 -0
  51. package/dist/session/lookup.d.ts.map +1 -0
  52. package/dist/session/proposals.d.ts +27 -0
  53. package/dist/session/proposals.d.ts.map +1 -0
  54. package/dist/session/restore-cache.d.ts +6 -0
  55. package/dist/session/restore-cache.d.ts.map +1 -0
  56. package/dist/session/teardown.d.ts +24 -0
  57. package/dist/session/teardown.d.ts.map +1 -0
  58. package/dist/signer.d.ts +2 -2
  59. package/dist/signer.d.ts.map +1 -0
  60. package/dist/signers/evm.d.ts +6 -4
  61. package/dist/signers/evm.d.ts.map +1 -0
  62. package/dist/types.d.ts +28 -11
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/utils.d.ts +17 -0
  65. package/dist/utils.d.ts.map +1 -0
  66. package/dist/wcConstants.d.ts +61 -0
  67. package/dist/wcConstants.d.ts.map +1 -0
  68. package/package.json +18 -13
  69. package/readme.md +14 -2
  70. package/src/adapter/adapter.ts +289 -0
  71. package/src/adapter/index.ts +2 -0
  72. package/src/adapter/modal-cache.ts +23 -0
  73. package/src/adapter/modal.ts +121 -0
  74. package/src/adapter/networks.ts +85 -0
  75. package/src/adapter/provider-client.ts +13 -0
  76. package/src/adapter/registry.ts +17 -0
  77. package/src/adapter/session-cache.ts +38 -0
  78. package/src/adapter/task-queue.ts +32 -0
  79. package/src/constants.ts +41 -76
  80. package/src/mod.ts +10 -0
  81. package/src/namespaces/evm/hooks.ts +148 -0
  82. package/src/namespaces/evm/namespace.ts +102 -0
  83. package/src/namespaces/subscriber.ts +106 -0
  84. package/src/provider.ts +35 -0
  85. package/src/session/accounts.ts +44 -0
  86. package/src/session/bip122.ts +225 -0
  87. package/src/session/chain-state.ts +38 -0
  88. package/src/session/evm-chain.ts +185 -0
  89. package/src/session/evm.ts +198 -0
  90. package/src/session/lifecycle.ts +241 -0
  91. package/src/session/lookup.ts +54 -0
  92. package/src/session/proposals.ts +96 -0
  93. package/src/session/restore-cache.ts +38 -0
  94. package/src/session/teardown.ts +181 -0
  95. package/src/signer.ts +9 -17
  96. package/src/signers/evm.ts +19 -17
  97. package/src/types.ts +31 -12
  98. package/src/utils.ts +68 -0
  99. package/src/wcConstants.ts +94 -0
  100. package/dist/chunk-6V3WUFOU.js +0 -2
  101. package/dist/chunk-6V3WUFOU.js.map +0 -7
  102. package/dist/chunk-BPSEZJUF.js +0 -2
  103. package/dist/chunk-BPSEZJUF.js.map +0 -7
  104. package/dist/chunk-DXVBX5XQ.js +0 -2
  105. package/dist/chunk-DXVBX5XQ.js.map +0 -7
  106. package/dist/dist-6GI3ECE5.js +0 -139
  107. package/dist/dist-6GI3ECE5.js.map +0 -7
  108. package/dist/evm-3ID4XY4Y.js +0 -2
  109. package/dist/evm-3ID4XY4Y.js.map +0 -7
  110. package/dist/helpers.d.ts +0 -31
  111. package/dist/index.d.ts +0 -21
  112. package/dist/index.js +0 -2
  113. package/dist/index.js.map +0 -7
  114. package/dist/session.d.ts +0 -63
  115. package/dist/signers/solana.d.ts +0 -14
  116. package/dist/solana-MFA7C5XI.js +0 -2
  117. package/dist/solana-MFA7C5XI.js.map +0 -7
  118. package/src/helpers.ts +0 -238
  119. package/src/index.ts +0 -234
  120. package/src/session.ts +0 -376
  121. package/src/signers/solana.ts +0 -160
  122. package/src/wc-types.d.ts +0 -31
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/mod.ts", "../src/provider.ts", "../src/adapter/adapter.ts", "../src/session/evm-chain.ts", "../src/session/accounts.ts", "../src/session/chain-state.ts", "../src/session/evm.ts", "../src/session/lifecycle.ts", "../src/adapter/modal.ts", "../src/adapter/networks.ts", "../src/session/bip122.ts", "../src/session/lookup.ts", "../src/session/proposals.ts", "../src/session/teardown.ts", "../src/session/restore-cache.ts", "../src/adapter/modal-cache.ts", "../src/adapter/provider-client.ts", "../src/adapter/session-cache.ts", "../src/adapter/task-queue.ts", "../src/adapter/registry.ts", "../src/constants.ts", "../src/signer.ts", "../src/namespaces/evm/namespace.ts", "../src/namespaces/evm/hooks.ts", "../src/namespaces/subscriber.ts"],
4
+ "sourcesContent": ["import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nexport type { Environments } from './types.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import type { Environments } from './types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { WalletConnectAdapter } from './adapter/adapter.js';\nimport { setAdapter } from './adapter/registry.js';\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm/namespace.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments: Environments) {\n const [, setState] = context.state();\n\n if (!environments.WC_PROJECT_ID) {\n return;\n }\n\n setAdapter(\n new WalletConnectAdapter({\n projectId: environments.WC_PROJECT_ID,\n meta: environments.meta || [],\n disableModalLink: environments.DISABLE_MODAL_AND_OPEN_LINK,\n themeMode: environments.themeMode,\n modalZIndex: environments.modalZIndex,\n })\n );\n setState('installed', true);\n console.debug('[wallet-connect-2] provider initialized.', context);\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import type { WalletConnectNamespace } from '../types.js';\nimport type { Chain } from '@hub3js/evm';\nimport type { SessionTypes } from '@walletconnect/types';\nimport type UniversalProvider from '@walletconnect/universal-provider';\nimport type { BlockchainMeta } from 'rango-types';\n\nimport { debug } from '@rango-dev/logging-core';\n\nimport {\n ensureConnectedToChain as ensureConnectedToChainHelper,\n getCurrentChainId as getCurrentChainIdHelper,\n resolveActiveChainReference as resolveActiveChainReferenceHelper,\n switchEvmNetwork as switchEvmNetworkHelper,\n} from '../session/evm-chain.js';\nimport {\n connectWalletConnectSession,\n prepareWalletConnectNamespace,\n} from '../session/lifecycle.js';\nimport { restoreAndCacheSession } from '../session/restore-cache.js';\nimport { removeSessionRecord } from '../session/teardown.js';\nimport { evmMetaToCaipChainIds } from '../utils.js';\n\nimport { ModalCache } from './modal-cache.js';\nimport { createUniversalProvider } from './provider-client.js';\nimport { createSessionCache } from './session-cache.js';\nimport { TaskQueue } from './task-queue.js';\n\n/**\n * Central coordinator for WalletConnect sessions used by hub EVM/UTXO namespaces.\n *\n * Owns provider state (client, session cache, modal) and delegates protocol/domain\n * logic to `session/*` helpers.\n */\nexport interface WalletConnectAdapterConfig {\n projectId: string;\n meta: BlockchainMeta[];\n disableModalLink?: string;\n themeMode?: 'light' | 'dark';\n modalZIndex?: number;\n}\n\nexport class WalletConnectAdapter {\n readonly #projectId: string;\n readonly #disableModalLink?: string;\n readonly #themeMode?: 'light' | 'dark';\n readonly #modalZIndex?: number;\n readonly #meta: BlockchainMeta[];\n #universalProvider: UniversalProvider | null = null;\n #universalProviderPromise: Promise<UniversalProvider> | null = null;\n\n readonly #cache = createSessionCache();\n readonly #modalCache = new ModalCache();\n\n /**\n * Serializes everything that mutates WalletConnect session state.\n *\n * Connecting and disconnecting must never overlap: tearing a session down also\n * deletes its pairing, and an overlapping connect has already minted a new one\n * by then - the teardown unsubscribes it, so `wc_proposeSession` publishes to a\n * topic we no longer listen on and the relay answers\n * `Topic repository: AlreadyExists`.\n *\n * The hub can't order this for us: `useHubAdapter.disconnect` drops the\n * promises `namespace.disconnect()` returns (it iterates with `forEach`), so it\n * resolves while teardown is still in flight and never joins the queue that\n * serializes `connect`.\n *\n * The cost is that a connect holds the queue for its whole lifetime, including\n * the wait for the user to approve in their wallet, so a disconnect raised\n * meanwhile waits its turn instead of interleaving. That is deliberate rather\n * than an oversight: the pairing has to survive from `client.connect()` through\n * settle, which is exactly the span being protected.\n */\n readonly #sessionQueue = new TaskQueue();\n\n constructor(config: WalletConnectAdapterConfig) {\n this.#projectId = config.projectId;\n this.#meta = config.meta;\n this.#disableModalLink = config.disableModalLink;\n this.#themeMode = config.themeMode;\n this.#modalZIndex = config.modalZIndex;\n }\n\n async getUniversalProvider(): Promise<UniversalProvider> {\n /*\n * Memoize the in-flight promise, not the resolved value. A namespace's\n * `before` subscribers are invoked with `forEach` (nothing awaits between\n * them), so several reach this method in the same tick - awaiting first and\n * assigning after would let each start its own `UniversalProvider`, leaving\n * several SignClients sharing one storage. The extra clients answer relay\n * traffic for a handshake they never made (\"Pending session not found for\n * topic X\", then \"No matching key. session topic doesn't exist: X\").\n */\n if (!this.#universalProviderPromise) {\n this.#universalProviderPromise = createUniversalProvider(this.#projectId)\n .then((provider) => {\n this.#universalProvider = provider;\n return provider;\n })\n .catch((error: unknown) => {\n // Don't cache a failed init - let the next caller retry.\n this.#universalProviderPromise = null;\n throw error;\n });\n }\n\n return this.#universalProviderPromise;\n }\n\n async getClient() {\n return (await this.getUniversalProvider()).client;\n }\n\n getSession(namespace: WalletConnectNamespace): SessionTypes.Struct | null {\n return this.#cache.get(namespace);\n }\n\n cacheSession(\n namespace: WalletConnectNamespace,\n session: SessionTypes.Struct\n ) {\n this.#cache.set(namespace, session);\n }\n\n clearSession(namespace: WalletConnectNamespace) {\n this.#cache.clear(namespace);\n }\n\n clearAllSessions() {\n this.#cache.clearAll();\n }\n\n async tryRestoreEagerSession(\n namespace: WalletConnectNamespace\n ): Promise<boolean> {\n return this.#sessionQueue.run(async () => {\n const client = await this.getClient();\n return !!(await restoreAndCacheSession(\n client,\n namespace,\n this.#cache,\n { validateAccounts: true },\n async (targetNamespace) =>\n this.#disconnectSessionQueued(targetNamespace)\n ));\n });\n }\n\n async ensureSession(options: {\n namespace: WalletConnectNamespace;\n chainReference?: string;\n }): Promise<SessionTypes.Struct> {\n return this.#sessionQueue.run(async () =>\n this.#ensureSessionQueued(options)\n );\n }\n\n async disconnectSession(namespace: WalletConnectNamespace) {\n return this.#sessionQueue.run(async () =>\n this.#disconnectSessionQueued(namespace)\n );\n }\n\n async resolveActiveChainReference(): Promise<string | undefined> {\n const session = this.getSession('evm');\n if (!session) {\n return undefined;\n }\n\n return resolveActiveChainReferenceHelper(await this.getClient(), session);\n }\n\n async getCurrentChainId(): Promise<`0x${string}`> {\n const session = this.getSession('evm');\n if (!session) {\n throw new Error(\n 'Unable to determine EVM chain id from WalletConnect session.'\n );\n }\n\n return getCurrentChainIdHelper(await this.getClient(), session);\n }\n\n async ensureConnectedToChain(\n chain?: string | Chain\n ): Promise<SessionTypes.Struct> {\n return ensureConnectedToChainHelper(this.#evmChainDeps(), chain);\n }\n\n async switchEvmNetwork(\n requestedChainId: string,\n currentChainId: string\n ): Promise<void> {\n const session = this.getSession('evm');\n if (!session) {\n throw new Error('WalletConnect session is not available.');\n }\n\n this.cacheSession(\n 'evm',\n await switchEvmNetworkHelper({\n client: await this.getClient(),\n session,\n meta: this.#meta,\n requestedChainId,\n currentChainId,\n })\n );\n }\n\n /*\n * The `Queued` suffix means \"already running inside `#sessionQueue`\". These\n * call each other directly and must never go back through the public methods\n * above: re-entering the queue from inside a task would wait for a turn that\n * cannot come until that same task finishes, which deadlocks.\n */\n\n async #ensureSessionQueued(options: {\n namespace: WalletConnectNamespace;\n chainReference?: string;\n }): Promise<SessionTypes.Struct> {\n const { namespace, chainReference } = options;\n const client = await this.getClient();\n const restored = await restoreAndCacheSession(\n client,\n namespace,\n this.#cache,\n undefined,\n async (targetNamespace) => this.#disconnectSessionQueued(targetNamespace)\n );\n if (restored) {\n return restored;\n }\n\n await prepareWalletConnectNamespace(client, namespace);\n\n const universalProvider = await this.getUniversalProvider();\n await universalProvider.cleanupPendingPairings().catch(() => undefined);\n\n const session = await connectWalletConnectSession(\n client,\n this.#modalCache.getModal({\n projectId: this.#projectId,\n universalProvider,\n themeMode: this.#themeMode,\n zIndex: this.#modalZIndex,\n }),\n {\n chains: evmMetaToCaipChainIds(this.#meta),\n envs: {\n WC_PROJECT_ID: this.#projectId,\n DISABLE_MODAL_AND_OPEN_LINK: this.#disableModalLink,\n },\n namespace,\n chainReference,\n }\n );\n\n this.#cache.set(namespace, session);\n return session;\n }\n\n async #disconnectSessionQueued(namespace: WalletConnectNamespace) {\n const session = this.getSession(namespace);\n if (this.#universalProvider?.client && session) {\n await removeSessionRecord(this.#universalProvider.client, session).catch(\n (error) => debug(error)\n );\n }\n this.clearSession(namespace);\n if (session) {\n this.#cache.clearTopic(session.topic);\n }\n }\n\n #evmChainDeps() {\n return {\n meta: this.#meta,\n getSession: (namespace: 'evm') => this.getSession(namespace),\n cacheSession: (namespace: 'evm', session: SessionTypes.Struct) =>\n this.cacheSession(namespace, session),\n getClient: async () => this.getClient(),\n ensureSession: async (options: {\n namespace: 'evm';\n chainReference?: string;\n }) => this.ensureSession(options),\n };\n }\n}\n", "import type { Chain } from '@hub3js/evm';\nimport type { ISignClient, SessionTypes } from '@walletconnect/types';\nimport type { BlockchainMeta } from 'rango-types';\n\nimport { error as logError } from '@rango-dev/logging-core';\nimport { ChainId } from 'caip';\n\nimport {\n chainReferenceToHex,\n parseChainReference,\n resolveNetworkName,\n} from '../utils.js';\nimport { EthereumRPCMethods, NAMESPACES } from '../wcConstants.js';\n\nimport { getAccountsFromSession } from './accounts.js';\nimport { getPersistedChainId, persistCurrentChainId } from './chain-state.js';\nimport {\n filterEvmAccounts,\n ignoreNamespaceMethods,\n switchOrAddEvmChain,\n updateSessionAccounts,\n} from './evm.js';\n\nexport type EvmChainDeps = {\n meta: BlockchainMeta[];\n getSession: (namespace: 'evm') => SessionTypes.Struct | null;\n cacheSession: (namespace: 'evm', session: SessionTypes.Struct) => void;\n getClient: () => Promise<ISignClient>;\n ensureSession: (options: {\n namespace: 'evm';\n chainReference?: string;\n }) => Promise<SessionTypes.Struct>;\n};\n\nexport async function resolveActiveChainReference(\n client: ISignClient,\n session: SessionTypes.Struct\n): Promise<string | undefined> {\n const persistedChainId = await getPersistedChainId(client);\n if (persistedChainId) {\n return persistedChainId;\n }\n\n const accounts = getAccountsFromSession(session);\n const evmAccounts = filterEvmAccounts(accounts);\n return evmAccounts[0]?.chainId;\n}\n\nexport async function getCurrentChainId(\n client: ISignClient,\n session: SessionTypes.Struct\n): Promise<`0x${string}`> {\n const reference = await resolveActiveChainReference(client, session);\n if (!reference) {\n throw new Error(\n 'Unable to determine EVM chain id from WalletConnect session.'\n );\n }\n\n return chainReferenceToHex(reference);\n}\n\n/**\n * Returns the session to keep using: `updateSessionAccounts` may rebuild it, and\n * the caller's copy is stale from that point on.\n */\nexport async function switchEvmNetwork(options: {\n client: ISignClient;\n session: SessionTypes.Struct;\n meta: BlockchainMeta[];\n requestedChainId: string;\n currentChainId: string;\n}): Promise<SessionTypes.Struct> {\n const { client, session, meta, requestedChainId, currentChainId } = options;\n\n const requestedReference = parseChainReference(requestedChainId);\n if (!requestedReference) {\n const error = new Error(`There is no match for ${requestedChainId}`);\n logError(error);\n throw error;\n }\n\n const chainIdStr = new ChainId({\n namespace: NAMESPACES.ETHEREUM,\n reference: requestedReference,\n }).toString();\n\n const requestedNetwork = resolveNetworkName(requestedChainId, meta);\n const currentNetwork = resolveNetworkName(currentChainId, meta);\n\n const evmNamespace = session.namespaces[NAMESPACES.ETHEREUM];\n const authorizedChains = evmNamespace?.chains || [];\n const authorizedMethods = evmNamespace?.methods || [];\n let activeSession = session;\n\n if (\n authorizedMethods.includes(EthereumRPCMethods.SWITCH_CHAIN) &&\n !ignoreNamespaceMethods(session)\n ) {\n if (!requestedNetwork || !currentNetwork) {\n const error = new Error(`Chain ${requestedReference} is not configured.`);\n logError(error);\n throw error;\n }\n\n activeSession = await updateSessionAccounts(\n client,\n session,\n requestedNetwork,\n currentNetwork,\n meta\n );\n await switchOrAddEvmChain(\n client,\n activeSession,\n meta,\n requestedNetwork,\n currentNetwork\n );\n } else if (!authorizedChains.includes(chainIdStr)) {\n const error = new Error(`Chain ${requestedReference} is not configured.`);\n logError(error);\n throw error;\n }\n\n await persistCurrentChainId(client, requestedReference);\n return activeSession;\n}\n\nexport async function switchToChainIfNeeded(\n deps: EvmChainDeps,\n requestedReference: string\n): Promise<void> {\n const session = deps.getSession('evm');\n if (!session) {\n throw new Error('WalletConnect session is not available.');\n }\n\n const client = await deps.getClient();\n const currentReference = await resolveActiveChainReference(client, session);\n if (currentReference === requestedReference) {\n await persistCurrentChainId(client, requestedReference);\n return;\n }\n\n const currentChainId = currentReference\n ? chainReferenceToHex(currentReference)\n : chainReferenceToHex(requestedReference);\n\n deps.cacheSession(\n 'evm',\n await switchEvmNetwork({\n client,\n session,\n meta: deps.meta,\n requestedChainId: requestedReference,\n currentChainId,\n })\n );\n}\n\nexport async function ensureConnectedToChain(\n deps: EvmChainDeps,\n chain?: string | Chain\n): Promise<SessionTypes.Struct> {\n const requestedReference = chain ? parseChainReference(chain) : undefined;\n\n if (!deps.getSession('evm')) {\n await deps.ensureSession({\n namespace: 'evm',\n chainReference: requestedReference,\n });\n }\n\n if (requestedReference) {\n await switchToChainIfNeeded(deps, requestedReference);\n }\n\n const session = deps.getSession('evm');\n if (!session) {\n throw new Error('WalletConnect session is not available.');\n }\n\n return session;\n}\n", "import type { SessionTypes, SignClientTypes } from '@walletconnect/types';\n\nimport { AccountId } from 'caip';\n\n/**\n * `accountsChanged` entries are CAIP-10 (`eip155:1:0x\u2026`) from wallets that follow\n * WC and a bare `0x\u2026` from the ones forwarding the EIP-1193 payload as-is.\n */\nexport function extractAddress(account: string): string {\n return account.includes(':') ? new AccountId(account).address : account;\n}\n\nexport function getAccountsFromSession(session: SessionTypes.Struct) {\n const accounts = Object.values(session.namespaces)\n .map((namespace) => namespace.accounts)\n .flat()\n .map((account) => {\n const { address, chainId } = new AccountId(account);\n return {\n address,\n chainId: chainId.reference,\n };\n });\n return accounts;\n}\n\nexport function getAccountsFromEvent(\n event: SignClientTypes.BaseEventArgs<{\n namespaces: SessionTypes.Namespaces;\n }>\n) {\n const accounts = Object.values(event.params.namespaces)\n .map((namespace) => namespace.accounts)\n .flat()\n .map((account) => {\n const { address, chainId } = new AccountId(account);\n return {\n accounts: [address],\n chainId: chainId.reference,\n };\n });\n\n return accounts;\n}\n", "import type { ISignClient } from '@walletconnect/types';\nimport type { BlockchainMeta } from 'rango-types';\n\nimport { CHAIN_ID_STORAGE } from '../wcConstants.js';\n\nexport async function persistCurrentChainId(\n client: ISignClient,\n chainId?: string\n) {\n return client.core.storage.setItem(CHAIN_ID_STORAGE, {\n defaultChainId: chainId ? parseInt(chainId) : '',\n });\n}\n\nexport async function getPersistedChainId(client: ISignClient) {\n try {\n const chainId = (await client.core.storage.getItem(CHAIN_ID_STORAGE))\n ?.defaultChainId;\n return !!chainId ? String(chainId) : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function getChainIdByNetworkName(\n network: string,\n meta: BlockchainMeta[]\n): string | undefined {\n const targetBlockchain = meta.find(\n (blockchain) => blockchain.name === network\n );\n const chainIdInHex = targetBlockchain?.chainId;\n if (!chainIdInHex) {\n return undefined;\n }\n\n return String(parseInt(chainIdInHex));\n}\n", "import type { ISignClient, SessionTypes } from '@walletconnect/types';\nimport type { BlockchainMeta } from 'rango-types';\n\nimport { debug } from '@rango-dev/logging-core';\nimport {\n convertEvmBlockchainMetaToEvmChainInfo,\n isEvmAddress,\n} from '@rango-dev/wallets-shared';\nimport { AccountId, ChainId } from 'caip';\nimport { isEvmBlockchain } from 'rango-types';\n\nimport { EthereumRPCMethods, NAMESPACES } from '../wcConstants.js';\n\nimport { getChainIdByNetworkName } from './chain-state.js';\n\nexport function getCurrentEvmAccountAddress(\n session: SessionTypes.Struct\n): string | undefined {\n return session.namespaces[NAMESPACES.ETHEREUM]?.accounts\n ?.map((account) => new AccountId(account).address)\n ?.filter((address) => isEvmAddress(address))?.[0];\n}\n\nexport function getEvmAccount(\n network: string,\n address: string,\n meta: BlockchainMeta[]\n): string | undefined {\n const currentChainId = getChainIdByNetworkName(network, meta);\n if (!currentChainId) {\n return undefined;\n }\n\n return AccountId.format({\n chainId: {\n namespace: NAMESPACES.ETHEREUM,\n reference: currentChainId,\n },\n address,\n });\n}\n\n// It's enough to return only connected network for the EVM networks and ignore others\nexport function filterEvmAccounts(\n accounts: {\n address: string;\n chainId: string;\n }[],\n currentChainId?: string\n) {\n let firstEvmAddress = false;\n return accounts\n .filter(({ address, chainId }) => {\n const isEvm = isEvmAddress(address);\n if (!isEvm) {\n return false;\n }\n if (currentChainId && chainId !== currentChainId) {\n return false;\n }\n if (!currentChainId) {\n if (firstEvmAddress) {\n return false;\n }\n firstEvmAddress = true;\n }\n return true;\n })\n .map(({ address, chainId }) => ({\n accounts: [address],\n chainId: chainId,\n }));\n}\n\nexport async function switchOrAddEvmChain(\n client: ISignClient,\n session: SessionTypes.Struct,\n meta: BlockchainMeta[],\n requestedNetwork: string,\n currentNetwork: string\n) {\n const evmBlockchains = meta.filter(isEvmBlockchain);\n const evmNetworksChainInfo =\n convertEvmBlockchainMetaToEvmChainInfo(evmBlockchains);\n const targetChain = evmNetworksChainInfo[requestedNetwork];\n const targetBlockchain = meta.find(\n (blockchain: BlockchainMeta) => blockchain.name === requestedNetwork\n );\n const chainIdInHex = targetBlockchain?.chainId;\n\n const currentChainId = getChainIdByNetworkName(currentNetwork, meta);\n const currentChainEip = ChainId.format({\n namespace: NAMESPACES.ETHEREUM,\n reference: String(currentChainId),\n });\n\n try {\n await client.request({\n topic: session.topic,\n request: {\n method: EthereumRPCMethods.SWITCH_CHAIN,\n params: [\n {\n chainId: chainIdInHex,\n },\n ],\n },\n // It's required to pass current chain, otherwise it won't work\n chainId: currentChainEip,\n });\n } catch (err) {\n // EIP-1193 \"Unrecognized chain ID\" - the wallet doesn't have this chain yet.\n const addChainError = 4902;\n const { code, message } = (err ?? {}) as {\n code?: number;\n message?: string;\n };\n if (code === addChainError || message?.includes(String(addChainError))) {\n await client.request({\n topic: session.topic,\n request: {\n method: EthereumRPCMethods.ADD_CHAIN,\n params: [targetChain],\n },\n // It's required to pass current chain, otherwise it won't work\n chainId: currentChainEip,\n });\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Adds the requested and current chains' accounts to the session so sign-client\n * accepts a request carrying their CAIP chain id, and returns the session to use\n * from here on.\n *\n * The record is rebuilt rather than pushed into: the struct is shared with the\n * store and the adapter cache, and the write below can fail (it is logged, not\n * thrown), which would otherwise leave both holding accounts the store never\n * accepted.\n */\nexport async function updateSessionAccounts(\n client: ISignClient,\n session: SessionTypes.Struct,\n requestedNetwork: string,\n currentNetwork: string,\n meta: BlockchainMeta[]\n): Promise<SessionTypes.Struct> {\n const evmNamespace = session.namespaces[NAMESPACES.ETHEREUM];\n const currentAccountAddress = getCurrentEvmAccountAddress(session);\n if (!evmNamespace || !currentAccountAddress) {\n return session;\n }\n\n const existing = evmNamespace.accounts ?? [];\n const wanted = [\n getEvmAccount(requestedNetwork, currentAccountAddress, meta),\n getEvmAccount(currentNetwork, currentAccountAddress, meta),\n ].filter(\n (account): account is string => !!account && !existing.includes(account)\n );\n\n if (!wanted.length) {\n return session;\n }\n\n const updated: SessionTypes.Struct = {\n ...session,\n namespaces: {\n ...session.namespaces,\n [NAMESPACES.ETHEREUM]: {\n ...evmNamespace,\n accounts: [...existing, ...new Set(wanted)],\n },\n },\n };\n\n try {\n await client.session.update(session.topic, {\n namespaces: updated.namespaces,\n });\n } catch (err) {\n debug(err instanceof Error ? err : new Error(String(err)));\n return session;\n }\n\n return updated;\n}\n\nexport function ignoreNamespaceMethods(session: SessionTypes.Struct): boolean {\n const WALLETS_WITH_WRONG_NAMESPACE_METHODS = ['trust', '1inch'];\n const peerName = session.peer?.metadata?.name;\n return WALLETS_WITH_WRONG_NAMESPACE_METHODS.some((name) =>\n peerName?.toLowerCase()?.includes(name)\n );\n}\n", "import type { AppKitModal } from '../adapter/modal.js';\nimport type {\n ConnectParams,\n CreateSessionParams,\n Environments,\n SignClientInstance,\n WalletConnectNamespace,\n} from '../types.js';\nimport type { ISignClient, SessionTypes } from '@walletconnect/types';\nimport type UniversalProvider from '@walletconnect/universal-provider';\n\nimport { debug } from '@rango-dev/logging-core';\nimport { timeout } from '@rango-dev/wallets-shared';\n\nimport { prepareModalForNamespace } from '../adapter/modal.js';\nimport { PING_TIMEOUT, WC_NAMESPACE_TO_CAIP } from '../wcConstants.js';\n\nimport { getAccountsFromSession } from './accounts.js';\nimport { filterBip122Accounts, resolveBip122Session } from './bip122.js';\nimport { getPersistedChainId } from './chain-state.js';\nimport { filterEvmAccounts } from './evm.js';\nimport { findSessionByNamespace } from './lookup.js';\nimport { generateOptionalNamespace } from './proposals.js';\nimport {\n cleanupStaleSessionsForNamespace,\n hasActivePairing,\n hasActiveSession,\n purgeOrphanedPairings,\n purgeOrphanedSessions,\n removeSessionRecord,\n} from './teardown.js';\n\nexport type RestoreWalletConnectSessionOptions = {\n validateAccounts?: boolean;\n};\n\nexport async function restoreWalletConnectSession(\n client: SignClientInstance,\n namespace: WalletConnectNamespace,\n options: RestoreWalletConnectSessionOptions = {}\n): Promise<SessionTypes.Struct | undefined> {\n const session = await restoreNamespaceSession(client, namespace);\n if (!session) {\n return undefined;\n }\n\n /*\n * Never wait for `bip122_addressesChanged` here. The wallet only emits it just\n * after approval, so a stored session that still has no account will never be\n * given one - waiting would stall for the full timeout and fail anyway. Report\n * it as unrestorable instead and let the caller negotiate a fresh session.\n */\n if (namespace === 'utxo' && filterBip122Accounts(session).length === 0) {\n return undefined;\n }\n\n if (options.validateAccounts) {\n const isValid = await hasNamespaceAccounts(client, namespace, session);\n if (!isValid) {\n return undefined;\n }\n }\n\n return session;\n}\n\nasync function hasNamespaceAccounts(\n client: SignClientInstance,\n namespace: WalletConnectNamespace,\n session: SessionTypes.Struct\n): Promise<boolean> {\n if (namespace === 'utxo') {\n return filterBip122Accounts(session).length > 0;\n }\n\n const accounts = getAccountsFromSession(session);\n const currentChainId = await getPersistedChainId(client);\n return filterEvmAccounts(accounts, currentChainId).length > 0;\n}\n\n/**\n * Ping the session topic and return it if still valid.\n * Returns undefined (instead of throwing) when storage contains stale records.\n */\nexport async function restoreNamespaceSession(\n client: SignClientInstance,\n namespace: WalletConnectNamespace\n): Promise<SessionTypes.Struct | undefined> {\n const session = findSessionByNamespace(client, namespace);\n if (!session?.topic) {\n return undefined;\n }\n\n if (!hasActiveSession(client, session.topic)) {\n await removeSessionRecord(client, session);\n return undefined;\n }\n\n if (session.pairingTopic && !hasActivePairing(client, session.pairingTopic)) {\n await removeSessionRecord(client, session);\n return undefined;\n }\n\n try {\n await timeout(\n client.ping({\n topic: session.topic,\n }),\n PING_TIMEOUT\n );\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n await removeSessionRecord(client, session);\n return undefined;\n }\n\n return findSessionByNamespace(client, namespace) ?? session;\n}\n\n/**\n * Clears unusable records ahead of a connect: orphaned sessions across every\n * namespace, plus `namespace`'s own stale ones.\n *\n * A *live* session belonging to another namespace is deliberately left alone -\n * EVM and UTXO each own an independent session, and only the namespace being\n * disconnected drops its own.\n */\nexport async function prepareWalletConnectNamespace(\n client: UniversalProvider['client'],\n namespace: WalletConnectNamespace\n): Promise<void> {\n await purgeOrphanedSessions(client);\n await cleanupStaleSessionsForNamespace(client, namespace);\n await purgeOrphanedPairings(client);\n}\n\n/**\n * Restores `namespace`'s session, or negotiates a new one.\n *\n * Callers are expected to have run {@link prepareWalletConnectNamespace} first -\n * this does not clean up on its own.\n */\nexport async function connectWalletConnectSession(\n client: UniversalProvider['client'],\n web3Modal: AppKitModal,\n params: ConnectParams\n): Promise<SessionTypes.Struct> {\n const { chains, namespace, chainReference } = params;\n\n const restored = await restoreWalletConnectSession(client, namespace);\n if (restored) {\n return restored;\n }\n\n const proposal = generateOptionalNamespace(\n chains,\n [namespace],\n chainReference\n );\n const session = await createSession(\n client,\n web3Modal,\n { optionalNamespaces: proposal ?? {} },\n {\n envs: params.envs,\n namespace,\n }\n );\n\n /*\n * Only a just-approved session can be waited on: bitcoin wallets routinely\n * approve bip122 with no account and send it moments later. A restored session\n * never reaches here, so the wait can't be spent on one that will never\n * receive the event.\n */\n if (namespace === 'utxo') {\n return resolveBip122Session(client, session);\n }\n\n return session;\n}\n\nasync function createSession(\n client: ISignClient,\n web3Modal: AppKitModal,\n options: CreateSessionParams,\n configs: {\n envs: Environments;\n namespace: WalletConnectNamespace;\n }\n): Promise<SessionTypes.Struct> {\n const { optionalNamespaces, pairingTopic } = options;\n\n try {\n const { uri, approval } = await client.connect({\n optionalNamespaces,\n pairingTopic,\n });\n\n let onCloseModal;\n if (uri) {\n const redirectLink = configs.envs.DISABLE_MODAL_AND_OPEN_LINK;\n if (redirectLink) {\n const url = `${redirectLink}/wc?uri=${encodeURIComponent(uri)}`;\n window.open(url, '_blank', 'noreferrer noopener');\n } else {\n await prepareModalForNamespace(web3Modal, configs.namespace);\n /*\n * `namespace` scopes the wallet list AppKit renders. It isn't in\n * AppKit's `OpenOptions` type but is honored at runtime, so it goes\n * through a pre-built object (an inline literal would trip the\n * excess-property check). `WC_NAMESPACE_TO_CAIP` is the single source\n * for the alias -> CAIP prefix instead of sniffing the payload keys.\n */\n const openOptions = {\n uri,\n namespace: WC_NAMESPACE_TO_CAIP[configs.namespace],\n };\n await web3Modal.open(openOptions);\n\n onCloseModal = new Promise((_, reject) => {\n web3Modal.subscribeState((state) => {\n if (!state.open) {\n reject(new Error('Modal has been closed.'));\n }\n });\n });\n }\n }\n\n const session = approval();\n\n if (onCloseModal) {\n const result = await Promise.race([session, onCloseModal]);\n return result as SessionTypes.Struct;\n }\n return await session;\n } finally {\n void web3Modal.close();\n }\n}\n", "import type { WalletConnectNamespace } from '../types.js';\nimport type { AppKitNetwork } from '@reown/appkit-common';\nimport type UniversalProvider from '@walletconnect/universal-provider';\n\nimport { createAppKit } from '@reown/appkit/core';\n\nimport { bitcoin, mainnet } from './networks.js';\n\nexport type AppKitModal = ReturnType<typeof createAppKitModal>;\n\nconst DEFAULT_MODAL_Z_INDEX = 999_999_999;\n\nexport type ModalParams = {\n projectId: string;\n universalProvider: UniversalProvider;\n themeMode?: 'light' | 'dark';\n zIndex?: number;\n};\n\n/*\n * Every WalletConnect namespace shares one AppKit instance with all networks\n * registered up front. A per-namespace instance had to be rebuilt on each\n * switch, and every rebuild re-ran AppKit init against its module-level\n * singleton controllers - leaving router history from the previous open mixed\n * into the next (a stray back button in the modal header). The active network\n * is chosen per connect with `switchNetwork` instead.\n *\n * The active network is now shared mutable state, so this is only safe while\n * connects are serialized (the adapter's `#sessionQueue`): the switch/open/close\n * for one namespace never interleaves with another's. A connect path that\n * bypassed that queue would race this switch.\n */\nconst NETWORKS: [AppKitNetwork, ...AppKitNetwork[]] = [mainnet, bitcoin];\n\n/**\n * The network to make active before opening the modal for a namespace. Keyed by\n * `WalletConnectNamespace` so a future namespace is a compile error until mapped.\n */\nconst NAMESPACE_NETWORK: Record<WalletConnectNamespace, AppKitNetwork> = {\n evm: mainnet,\n utxo: bitcoin,\n};\n\n/**\n * Make a namespace's network active before opening the shared modal.\n *\n * `open()` compares the requested namespace against AppKit's active chain: if\n * they differ it treats the open as a network switch and pushes an extra step\n * onto the router, which leaves a stray back button in the modal header. One\n * shared instance keeps whatever chain the previous connect left active, so we\n * switch it to the target here first - then `open()` sees a matching chain and\n * takes its clean, non-switching path.\n *\n * `ready()` first so AppKit init has registered the networks `switchNetwork`\n * looks up.\n */\nexport async function prepareModalForNamespace(\n web3Modal: AppKitModal,\n namespace: WalletConnectNamespace\n): Promise<void> {\n await web3Modal.ready();\n await web3Modal.switchNetwork(NAMESPACE_NETWORK[namespace]);\n}\n\nexport function createAppKitModal({\n projectId,\n universalProvider,\n themeMode = 'light',\n zIndex = DEFAULT_MODAL_Z_INDEX,\n}: ModalParams) {\n return createAppKit({\n projectId,\n networks: NETWORKS,\n universalProvider,\n /*\n * AppKit is intentionally kept out of the WalletConnect session lifecycle -\n * it renders the modal (QR + wallet list), nothing more. We drive the\n * handshake ourselves with `client.connect()` (see `session/lifecycle.ts`).\n *\n * Why: AppKit models one unified, multi-chain session with a single active\n * chain and its own reconnect/sync. The hub needs the opposite - EVM and\n * UTXO as independent sessions that connect, disconnect and eager-restore\n * separately (the adapter keeps one cache entry per namespace). Letting\n * AppKit drive via `provider.connect()` accumulates namespaces into a single\n * proposal, so connecting BTC after EVM asks the wallet for Ethereum - it was\n * tried and reverted. `manualWCControl: true` is AppKit's supported flag for\n * exactly this \"you render, I connect\" split.\n *\n * The visible cost: because we own the lifecycle, `provider.session` is never\n * set. With `enableReconnect: false`, AppKit init runs\n * `unSyncExistingConnection()`, whose `provider.disconnect()` hits a\n * `if (!this.session) throw` guard and AppKit logs the caught error as\n * `UniversalAdapter:disconnect - error: Please call connect() before\n * enable()`. It is expected and harmless - AppKit looking for a session to\n * clean up, finding none.\n *\n * Do NOT \"fix\" the log. Enabling reconnect makes AppKit actively restore/sync\n * connections it doesn't own, racing our own restore path and serialize\n * queue. Assigning `provider.session` removes the guard so that disconnect\n * (and every other AppKit-initiated disconnect) succeeds for real, tearing\n * down a live session on AppKit's schedule instead of ours. Both trade a\n * cosmetic log for real state conflicts.\n */\n enableReconnect: false,\n defaultNetwork: mainnet,\n defaultAccountTypes: { bip122: 'payment' },\n manualWCControl: true,\n /*\n * We register only one EVM network (`mainnet`) but the session approves every\n * EVM chain, so a network switch can land on a chain AppKit considers\n * \"unsupported\" and it auto-opens its UnsupportedChain modal\n * (ChainController.showUnsupportedChainUI). Allow it so AppKit doesn't police\n * the network we manage ourselves.\n */\n allowUnsupportedChain: true,\n themeMode,\n themeVariables: {\n '--apkt-z-index': zIndex,\n },\n });\n}\n", "import type { AppKitNetwork, CaipNetwork } from '@reown/appkit-common';\n\n/*\n * The two networks AppKit renders the modal for, defined here instead of\n * imported from `@reown/appkit/networks`.\n *\n * That entry point is `export * from 'viem/chains'` plus AppKit's own non-EVM\n * chains, so importing a single name off it pulls every viem chain definition\n * into the consumer's bundle. One of them (`tempo`) re-exports viem's tempo\n * chainConfig, which reaches `ox`'s salt-mining worker pool - and that module\n * routes `await import(id)` through a variable so bundlers skip\n * `node:worker_threads` in the browser. webpack can't resolve the expression\n * and warns \"Critical dependency: the request of a dependency is an\n * expression\"; react-scripts promotes warnings to errors on CI, which fails\n * the build for anyone consuming the widget through Create React App.\n *\n * viem publishes no per-chain subpath (`./chains` is the only export), so\n * there is no narrower import to reach for - the definitions are plain data,\n * so we carry the two we need.\n *\n * Keep these in sync with upstream if AppKit's `bitcoin` or viem's `mainnet`\n * changes: `@reown/appkit/dist/esm/src/networks/bitcoin.js` and\n * `viem/_esm/chains/definitions/mainnet.js`.\n */\n\n/**\n * Mirrors `defineChain` from both `viem/chains` and AppKit's networks module -\n * they are the same three-key spread. Declaring the viem-only formatter fields\n * keeps the objects structurally identical to the ones AppKit used to receive.\n */\nfunction defineChain<const chain extends AppKitNetwork>(chain: chain) {\n return {\n formatters: undefined,\n fees: undefined,\n serializers: undefined,\n ...chain,\n };\n}\n\n/** viem's `mainnet`, the only EVM network we register. */\nexport const mainnet = defineChain({\n id: 1,\n caipNetworkId: 'eip155:1',\n chainNamespace: 'eip155',\n name: 'Ethereum',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: {\n http: ['https://eth.merkle.io'],\n },\n },\n blockExplorers: {\n default: {\n name: 'Etherscan',\n url: 'https://etherscan.io',\n apiUrl: 'https://api.etherscan.io/api',\n },\n },\n contracts: {\n ensUniversalResolver: {\n address: '0xeeeeeeee14d718c2b47d9923deab1335e144eeee',\n blockCreated: 23_085_558,\n },\n multicall3: {\n address: '0xca11bde05977b3631167028862be2a173976ca11',\n blockCreated: 14_353_601,\n },\n },\n} satisfies CaipNetwork);\n\n/** AppKit's `bitcoin`, the only UTXO network we register. */\nexport const bitcoin = defineChain({\n id: '000000000019d6689c085ae165831e93',\n caipNetworkId: 'bip122:000000000019d6689c085ae165831e93',\n chainNamespace: 'bip122',\n name: 'Bitcoin',\n nativeCurrency: {\n name: 'Bitcoin',\n symbol: 'BTC',\n decimals: 8,\n },\n rpcUrls: {\n default: { http: ['https://rpc.walletconnect.org/v1'] },\n },\n} satisfies CaipNetwork);\n", "import type { SignClientInstance } from '../types.js';\nimport type { SessionTypes, SignClientTypes } from '@walletconnect/types';\n\nimport { debug } from '@rango-dev/logging-core';\nimport { CAIP_BITCOIN_CHAIN_ID } from '@rango-dev/wallets-core/namespaces/utxo';\nimport { AccountId } from 'caip';\n\nimport { BitcoinEvents, NAMESPACES } from '../wcConstants.js';\n\nexport function getBip122AccountsFromSession(\n session: SessionTypes.Struct\n): string[] {\n return session.namespaces[NAMESPACES.BITCOIN]?.accounts ?? [];\n}\n\nexport function filterBip122Accounts(session: SessionTypes.Struct) {\n return getBip122AccountsFromSession(session).map((account) => ({\n address: new AccountId(account).address,\n }));\n}\n\nexport type Bip122AddressEntry = {\n address: string;\n intention?: 'payment' | 'ordinal';\n};\n\n/**\n * Every address a `bip122_addressesChanged` payload carries, in wallet order.\n * Unlike {@link pickPaymentAddress} it makes no guess about which one is active.\n */\nexport function getAnnouncedAddresses(\n data: Bip122AddressEntry[] | string[] | undefined\n): string[] {\n if (!data?.length) {\n return [];\n }\n\n return data\n .map((entry) => (typeof entry === 'string' ? entry : entry?.address))\n .filter((address): address is string => !!address);\n}\n\nexport function pickPaymentAddress(\n data: Bip122AddressEntry[] | string[] | undefined\n): string | undefined {\n if (!data?.length) {\n return undefined;\n }\n\n const first = data[0];\n if (typeof first === 'string') {\n return first;\n }\n\n const entries = data as Bip122AddressEntry[];\n return (\n entries.find((entry) => entry.intention === 'payment')?.address ??\n entries[0]?.address\n );\n}\n\nexport function patchBip122SessionAccount(\n session: SessionTypes.Struct,\n address: string\n): SessionTypes.Struct {\n const btcNamespace = session.namespaces[NAMESPACES.BITCOIN];\n if (!btcNamespace) {\n return session;\n }\n\n const caipAccount = new AccountId({\n chainId: {\n namespace: NAMESPACES.BITCOIN,\n reference: CAIP_BITCOIN_CHAIN_ID,\n },\n address,\n }).toString();\n\n const accounts = btcNamespace.accounts ?? [];\n const hasAccount = accounts.some(\n (account) =>\n new AccountId(account).address.toLowerCase() === address.toLowerCase()\n );\n\n if (hasAccount) {\n return session;\n }\n\n return {\n ...session,\n namespaces: {\n ...session.namespaces,\n [NAMESPACES.BITCOIN]: {\n ...btcNamespace,\n accounts: [...accounts, caipAccount],\n },\n },\n };\n}\n\nconst BIP122_ACCOUNT_TIMEOUT = 15_000;\n\n/**\n * Bitcoin wallets often approve bip122 without accounts in the session object.\n * They emit bip122_addressesChanged or session_update shortly after approval.\n */\nexport async function resolveBip122Session(\n client: SignClientInstance,\n session: SessionTypes.Struct\n): Promise<SessionTypes.Struct> {\n const existing = filterBip122Accounts(session);\n if (existing.length) {\n return session;\n }\n\n const freshSession = client.session.get(session.topic) ?? session;\n const freshAccounts = filterBip122Accounts(freshSession);\n if (freshAccounts.length) {\n return freshSession;\n }\n\n const { address, session: resolvedSession } =\n await waitForBip122PaymentAddress(client, freshSession);\n\n const patched = patchBip122SessionAccount(resolvedSession, address);\n await persistSessionNamespaces(client, patched);\n return patched;\n}\n\n/**\n * The address the wallet reports via `bip122_addressesChanged` lands only on our\n * patched copy, so write it back to `client.session` - the record that restore,\n * teardown and staleness checks all read. Left unpersisted, the stored session\n * keeps `bip122.accounts === []`: `cleanupStaleSessionsForNamespace` reads a live\n * session as stale and disconnects it, and a reload waits again for an event the\n * wallet only emits right after approval.\n */\nasync function persistSessionNamespaces(\n client: SignClientInstance,\n session: SessionTypes.Struct\n): Promise<void> {\n try {\n await client.session.update(session.topic, {\n namespaces: session.namespaces,\n });\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n }\n}\n\nasync function waitForBip122PaymentAddress(\n client: SignClientInstance,\n session: SessionTypes.Struct,\n timeoutMs = BIP122_ACCOUNT_TIMEOUT\n): Promise<{ address: string; session: SessionTypes.Struct }> {\n return await new Promise((resolve, reject) => {\n const topic = session.topic;\n let settled = false;\n\n const finish = (address: string, updatedSession: SessionTypes.Struct) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n resolve({ address, session: updatedSession });\n };\n\n const fail = (error: Error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n reject(error);\n };\n\n const timer = setTimeout(() => {\n fail(\n new Error(\n 'Timed out waiting for Bitcoin account from wallet. Please try reconnecting.'\n )\n );\n }, timeoutMs);\n\n const cleanup = () => {\n clearTimeout(timer);\n client.off('session_event', onEvent);\n client.off('session_update', onUpdate);\n };\n\n const onEvent = (args: SignClientTypes.EventArguments['session_event']) => {\n if (args.topic !== topic) {\n return;\n }\n if (args.params.event.name !== BitcoinEvents.ADDRESSES_CHANGED) {\n return;\n }\n\n const address = pickPaymentAddress(\n args.params.event.data as Bip122AddressEntry[]\n );\n if (address) {\n finish(address, client.session.get(topic) ?? session);\n }\n };\n\n const onUpdate = (\n args: SignClientTypes.EventArguments['session_update']\n ) => {\n if (args.topic !== topic) {\n return;\n }\n\n const updatedSession = client.session.get(topic) ?? session;\n const accounts = filterBip122Accounts(updatedSession);\n if (accounts.length) {\n finish(accounts[0].address, updatedSession);\n }\n };\n\n client.on('session_event', onEvent);\n client.on('session_update', onUpdate);\n });\n}\n", "import type { WalletConnectNamespace } from '../types.js';\nimport type { ISignClient, SessionTypes } from '@walletconnect/types';\n\nimport { WC_NAMESPACE_TO_CAIP } from '../wcConstants.js';\n\nexport function getCaipNamespace(namespace: WalletConnectNamespace): string {\n return WC_NAMESPACE_TO_CAIP[namespace];\n}\n\nexport function findSessionByNamespace(\n client: ISignClient,\n namespace: WalletConnectNamespace\n): SessionTypes.Struct | undefined {\n const caipNamespace = getCaipNamespace(namespace);\n\n return client.session.getAll().find((session) => {\n const ns = session.namespaces[caipNamespace];\n if ((ns?.accounts?.length ?? 0) > 0) {\n return true;\n }\n\n return namespace === 'utxo' && (ns?.chains?.length ?? 0) > 0;\n });\n}\n\nexport function getSessionNamespace(\n session: SessionTypes.Struct\n): WalletConnectNamespace | undefined {\n const hasAccounts = (namespace: WalletConnectNamespace) =>\n (session.namespaces[WC_NAMESPACE_TO_CAIP[namespace]]?.accounts?.length ??\n 0) > 0;\n const hasChains = (namespace: WalletConnectNamespace) =>\n (session.namespaces[WC_NAMESPACE_TO_CAIP[namespace]]?.chains?.length ?? 0) >\n 0;\n\n /*\n * Prefer a namespace the wallet shared accounts for; fall back to one that\n * only negotiated chains (utxo can be chains-only before its account settles).\n */\n if (hasAccounts('evm')) {\n return 'evm';\n }\n if (hasAccounts('utxo')) {\n return 'utxo';\n }\n if (hasChains('utxo')) {\n return 'utxo';\n }\n if (hasChains('evm')) {\n return 'evm';\n }\n\n return undefined;\n}\n", "import type { WalletConnectNamespace } from '../types.js';\nimport type { ChainIdParams } from 'caip';\n\nimport { CAIP_BITCOIN_CHAIN_ID } from '@rango-dev/wallets-core/namespaces/utxo';\nimport { ChainId } from 'caip';\n\nimport {\n DEFAULT_BITCOIN_EVENTS,\n DEFAULT_BITCOIN_METHODS,\n DEFAULT_ETHEREUM_EVENTS,\n DEFAULT_ETHEREUM_METHODS,\n NAMESPACES,\n WC_NAMESPACE_TO_CAIP,\n} from '../wcConstants.js';\n\n/**\n * `chains` is required here so the same shape is assignable both to the\n * SignClient `ProposalTypes` (chains optional) and to the UniversalProvider\n * `NamespaceConfig` (chains required).\n */\nexport type FinalNamespaces = Record<\n string,\n { chains: string[]; methods: string[]; events: string[] }\n>;\n\ntype NamespaceProposal = {\n methods: string[];\n events: string[];\n resolveChains: (\n chains: ChainIdParams[],\n targetChainReference?: string\n ) => ChainIdParams[];\n};\n\n/**\n * Per-namespace proposal facts as data, keyed by `WalletConnectNamespace` so a\n * newly-added alias is a compile error until it's configured here. The CAIP\n * prefix comes from the shared `WC_NAMESPACE_TO_CAIP` map.\n */\nconst NAMESPACE_PROPOSALS: Record<WalletConnectNamespace, NamespaceProposal> = {\n evm: {\n methods: DEFAULT_ETHEREUM_METHODS,\n events: DEFAULT_ETHEREUM_EVENTS,\n resolveChains: (chains, targetChainReference) => {\n if (targetChainReference) {\n return [\n { namespace: NAMESPACES.ETHEREUM, reference: targetChainReference },\n ];\n }\n return chains.length > 0\n ? chains\n : [{ namespace: NAMESPACES.ETHEREUM, reference: '1' }];\n },\n },\n utxo: {\n methods: DEFAULT_BITCOIN_METHODS,\n events: DEFAULT_BITCOIN_EVENTS,\n resolveChains: () => [\n { namespace: NAMESPACES.BITCOIN, reference: CAIP_BITCOIN_CHAIN_ID },\n ],\n },\n};\n\n/**\n * Builds a WalletConnect namespace proposal (chains, methods, events).\n *\n * The result always goes to `optionalNamespaces`: sign-client merges\n * `requiredNamespaces` into `optionalNamespaces` and clears it before sending\n * the proposal, so passing anything as required only earns a deprecation\n * warning. Narrowing the proposal (see `targetChainReference`) is what actually\n * constrains what the wallet can approve.\n *\n * @param targetChainReference - When set for EVM, limits the proposal to this\n * single chain id (decimal string, e.g. `\"137\"`). Omit to include all EVM\n * chains from `chains`.\n */\nexport function generateOptionalNamespace(\n chains: ChainIdParams[],\n namespaces: WalletConnectNamespace[],\n targetChainReference?: string\n): FinalNamespaces | undefined {\n const proposal: FinalNamespaces = {};\n\n for (const namespace of namespaces) {\n const config = NAMESPACE_PROPOSALS[namespace];\n proposal[WC_NAMESPACE_TO_CAIP[namespace]] = {\n methods: config.methods,\n events: config.events,\n chains: config\n .resolveChains(chains, targetChainReference)\n .map((chain) => new ChainId(chain).toString()),\n };\n }\n\n return Object.keys(proposal).length > 0 ? proposal : undefined;\n}\n", "import type { SignClientInstance, WalletConnectNamespace } from '../types.js';\nimport type { ISignClient, SessionTypes } from '@walletconnect/types';\nimport type UniversalProvider from '@walletconnect/universal-provider';\n\nimport { debug } from '@rango-dev/logging-core';\nimport { getSdkError } from '@walletconnect/utils';\n\nimport { NAMESPACES } from '../wcConstants.js';\n\nimport { persistCurrentChainId } from './chain-state.js';\nimport { getSessionNamespace } from './lookup.js';\n\nfunction isNoMatchingKeyError(error: unknown): boolean {\n const message = error instanceof Error ? error.message : String(error);\n return message.includes('No matching key');\n}\n\nexport function hasActiveSession(client: ISignClient, topic: string): boolean {\n try {\n return !!client.session.get(topic);\n } catch {\n return false;\n }\n}\n\nexport function hasActivePairing(\n client: SignClientInstance,\n topic: string\n): boolean {\n return client.pairing.getAll().some((pairing) => pairing.topic === topic);\n}\n\nexport async function expireWalletConnectTopic(\n client: SignClientInstance,\n topic: string\n) {\n const sessions = client.session.getAll();\n const pairings = client.pairing.getAll();\n\n sessions.forEach((session: SessionTypes.Struct) => {\n if (session.topic === topic || session.pairingTopic === topic) {\n const requestForDeleteTopic =\n session.pairingTopic === topic ? session.pairingTopic : session.topic;\n client.core.expirer.set(requestForDeleteTopic, 0);\n }\n });\n\n pairings.forEach((pairing) => {\n if (pairing.topic === topic) {\n client.core.expirer.set(topic, 0);\n }\n });\n}\n\nexport async function removeSessionRecord(\n client: SignClientInstance,\n session: SessionTypes.Struct\n) {\n const namespace = getSessionNamespace(session);\n const pairingTopic = session.pairingTopic;\n\n if (hasActiveSession(client, session.topic)) {\n try {\n await client.disconnect({\n topic: session.topic,\n reason: getSdkError('USER_DISCONNECTED'),\n });\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n if (isNoMatchingKeyError(error)) {\n await expireWalletConnectTopic(client, session.topic);\n }\n }\n } else {\n await expireWalletConnectTopic(client, session.topic);\n }\n\n const remainingOnPairing = client.session\n .getAll()\n .filter((item) => item.pairingTopic === pairingTopic);\n\n if (!remainingOnPairing.length && pairingTopic) {\n if (hasActivePairing(client, pairingTopic)) {\n try {\n await client.disconnect({\n topic: pairingTopic,\n reason: getSdkError('USER_DISCONNECTED'),\n });\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n if (isNoMatchingKeyError(error)) {\n await expireWalletConnectTopic(client, pairingTopic);\n }\n }\n } else {\n await expireWalletConnectTopic(client, pairingTopic);\n }\n }\n\n if (namespace === 'evm') {\n void persistCurrentChainId(client, undefined);\n }\n}\n\nexport async function purgeOrphanedSessions(\n client: SignClientInstance\n): Promise<void> {\n const pairingTopics = new Set(\n client.pairing.getAll().map((pairing) => pairing.topic)\n );\n\n for (const session of [...client.session.getAll()]) {\n const pairingOrphaned =\n !!session.pairingTopic && !pairingTopics.has(session.pairingTopic);\n const sessionMissing = !hasActiveSession(client, session.topic);\n\n if (pairingOrphaned || sessionMissing) {\n await removeSessionRecord(client, session);\n }\n }\n}\n\n/**\n * Drops pairings that no session is using.\n *\n * The inverse of {@link purgeOrphanedSessions}, and the only thing that collects\n * them: a cancelled connect leaves behind the pairing `client.connect()` minted,\n * and `cleanupPendingPairings` only unsubscribes pairings - it never deletes the\n * record. Without this they accumulate in `client.pairing` and in storage for the\n * lifetime of the origin.\n *\n * Only safe to call while no connect is in flight (the adapter's `#sessionQueue`\n * guarantees that): a pairing awaiting its first approval has no session yet, so\n * dropping it would kill that handshake.\n */\nexport async function purgeOrphanedPairings(\n client: SignClientInstance\n): Promise<void> {\n const usedPairingTopics = new Set(\n client.session\n .getAll()\n .map((session) => session.pairingTopic)\n .filter((topic): topic is string => !!topic)\n );\n\n for (const pairing of [...client.pairing.getAll()]) {\n if (usedPairingTopics.has(pairing.topic)) {\n continue;\n }\n\n try {\n await client.disconnect({\n topic: pairing.topic,\n reason: getSdkError('USER_DISCONNECTED'),\n });\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n await expireWalletConnectTopic(client, pairing.topic);\n }\n }\n}\n\nexport async function cleanupStaleSessionsForNamespace(\n client: UniversalProvider['client'],\n namespace: WalletConnectNamespace\n): Promise<void> {\n for (const existing of client.session.getAll()) {\n if (getSessionNamespace(existing) !== namespace) {\n continue;\n }\n\n const btc = existing.namespaces[NAMESPACES.BITCOIN];\n if (\n btc &&\n (btc.chains?.length ?? 0) > 0 &&\n (btc.accounts?.length ?? 0) === 0\n ) {\n await removeSessionRecord(client, existing);\n }\n }\n}\n", "import type { SessionCache } from '../adapter/session-cache.js';\nimport type { SignClientInstance, WalletConnectNamespace } from '../types.js';\nimport type { SessionTypes } from '@walletconnect/types';\n\nimport { debug } from '@rango-dev/logging-core';\n\nimport {\n restoreWalletConnectSession,\n type RestoreWalletConnectSessionOptions,\n} from './lifecycle.js';\n\nexport async function restoreAndCacheSession(\n client: SignClientInstance,\n namespace: WalletConnectNamespace,\n cache: SessionCache,\n options?: RestoreWalletConnectSessionOptions,\n onDisconnect?: (namespace: WalletConnectNamespace) => Promise<void>\n): Promise<SessionTypes.Struct | null> {\n try {\n const session = await restoreWalletConnectSession(\n client,\n namespace,\n options\n );\n if (!session) {\n return null;\n }\n\n cache.set(namespace, session);\n return session;\n } catch (error) {\n debug(error instanceof Error ? error : new Error(String(error)));\n if (cache.get(namespace)) {\n await onDisconnect?.(namespace);\n }\n return null;\n }\n}\n", "import type { AppKitModal, ModalParams } from './modal.js';\n\nimport { createAppKitModal } from './modal.js';\n\n/**\n * Holds the single AppKit modal for the adapter's lifetime.\n *\n * One instance serves every namespace - all its networks are registered up front\n * and the active one is chosen per connect with `switchNetwork`. It is built once\n * and reused: rebuilding per namespace re-ran AppKit init against its shared\n * singleton controllers and left stale router/filter state behind.\n */\nexport class ModalCache {\n #web3Modal: AppKitModal | null = null;\n\n getModal(params: ModalParams): AppKitModal {\n if (!this.#web3Modal) {\n this.#web3Modal = createAppKitModal(params);\n }\n\n return this.#web3Modal;\n }\n}\n", "import UniversalProvider from '@walletconnect/universal-provider';\n\nimport { DEFAULT_APP_METADATA, RELAY_URL } from '../wcConstants.js';\n\nexport async function createUniversalProvider(\n projectId: string\n): Promise<UniversalProvider> {\n return UniversalProvider.init({\n relayUrl: RELAY_URL,\n projectId,\n metadata: DEFAULT_APP_METADATA,\n });\n}\n", "import type { WalletConnectNamespace } from '../types.js';\nimport type { SessionTypes } from '@walletconnect/types';\n\nexport type SessionCache = {\n get(namespace: WalletConnectNamespace): SessionTypes.Struct | null;\n set(namespace: WalletConnectNamespace, session: SessionTypes.Struct): void;\n clear(namespace: WalletConnectNamespace): void;\n /**\n * Drops every namespace holding `topic`. A wallet may approve more than was\n * proposed, so one settled session can back both namespaces - tearing its topic\n * down under one of them would otherwise leave the other pointing at a topic\n * the relay has already dropped.\n */\n clearTopic(topic: string): void;\n clearAll(): void;\n};\n\nexport function createSessionCache(): SessionCache {\n const sessions = new Map<WalletConnectNamespace, SessionTypes.Struct>();\n\n return {\n get: (namespace) => sessions.get(namespace) ?? null,\n\n set: (namespace, session) => void sessions.set(namespace, session),\n\n clear: (namespace) => void sessions.delete(namespace),\n\n clearTopic: (topic) => {\n for (const [namespace, session] of sessions) {\n if (session.topic === topic) {\n sessions.delete(namespace);\n }\n }\n },\n\n clearAll: () => sessions.clear(),\n };\n}\n", "/**\n * Runs tasks one at a time, in the order `run` was called.\n *\n * A task that rejects passes its rejection to its own caller and does not block\n * the tasks behind it.\n */\nexport class TaskQueue {\n /** Resolves once the task currently at the back of the queue has settled. */\n #tail: Promise<void> = Promise.resolve();\n\n async run<T>(task: () => Promise<T>): Promise<T> {\n const ourTurn = this.#tail;\n\n /*\n * Take our place at the back of the queue before awaiting anything, so\n * callers arriving in the same tick line up behind us rather than all\n * reading the same `#tail`. `releaseOurTurn` never rejects, which is what\n * lets the next task run even when this one throws.\n */\n let releaseOurTurn!: () => void;\n this.#tail = new Promise<void>((resolve) => {\n releaseOurTurn = resolve;\n });\n\n await ourTurn;\n try {\n return await task();\n } finally {\n releaseOurTurn();\n }\n }\n}\n", "import type { WalletConnectAdapter } from './adapter.js';\n\n/**\n * Holds the singleton adapter instance created in the provider's `init`.\n *\n * This lives in its own leaf module (importing nothing from `provider.ts` or the\n * namespaces) to break the `provider -> namespace -> provider` import cycle that\n * otherwise throws a TDZ error (\"Cannot access 'getAdapter' before initialization\")\n * when the namespace module evaluates its top-level subscriber factories.\n */\nlet adapter: WalletConnectAdapter;\n\nexport const getAdapter = () => adapter;\n\nexport const setAdapter = (instance: WalletConnectAdapter) => {\n adapter = instance;\n};\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { isEvmNamespace } from '@hub3js/evm';\n\nimport getSigners from './signer.js';\n\nexport const WALLET_ID = 'wallet-connect-2';\n\nexport const metadata: ProviderMetadata = {\n name: 'WalletConnect',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/walletconnect/icon.svg',\n extensions: {\n homepage: 'https://walletconnect.com/',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: isEvmNamespace,\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners() },\n },\n {\n name: 'details',\n value: {\n mobileWallet: true,\n showOnMobile: true,\n },\n },\n ],\n};\n", "import type { SignerFactory } from 'rango-types';\n\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { getAdapter } from './adapter/registry.js';\n\nexport default async function getSigners(): Promise<SignerFactory> {\n const adapter = getAdapter();\n if (!adapter) {\n throw new Error('WalletConnect provider has not been initialized.');\n }\n\n const client = await adapter.getClient();\n\n const signers = new DefaultSignerFactory();\n const EVMSigner = (\n await dynamicImportWithRefinedError(\n async () => await import('./signers/evm.js')\n )\n ).default;\n signers.registerSigner(\n TxType.EVM,\n new EVMSigner(client, () => adapter.getSession('evm'))\n );\n\n return signers;\n}\n", "import type { Context } from '@hub3js/core';\nimport type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { getAdapter } from '../../adapter/registry.js';\nimport { WALLET_ID } from '../../constants.js';\nimport { getAccountsFromSession } from '../../session/accounts.js';\nimport { filterEvmAccounts } from '../../session/evm.js';\nimport { chainReferenceToHex, parseChainReference } from '../../utils.js';\n\nimport {\n sessionDeleteSubscriber,\n sessionEventSubscriber,\n sessionUpdateSubscriber,\n} from './hooks.js';\n\nconst [sessionUpdate, sessionUpdateCleanup] = sessionUpdateSubscriber();\nconst [sessionEvent, sessionEventCleanup] = sessionEventSubscriber();\nconst [sessionDelete, sessionDeleteCleanup] = sessionDeleteSubscriber();\n\nconst connect = builders\n .connect()\n .action(async function (_context: Context<EvmActions>, chain?: string) {\n const adapter = getAdapter();\n // `chain` is set when connecting to a specific network (swap auto-switch or hub connect with network).\n const requestedReference = chain ? parseChainReference(chain) : undefined;\n const session = await adapter.ensureConnectedToChain(chain);\n const activeReference =\n requestedReference ?? (await adapter.resolveActiveChainReference());\n\n if (!activeReference) {\n throw new Error(\n 'Unable to determine EVM chain id from WalletConnect session.'\n );\n }\n\n const accounts = getAccountsFromSession(session);\n const evmAccounts = filterEvmAccounts(accounts, activeReference);\n\n if (!evmAccounts.length) {\n throw new Error('No EVM accounts found in WalletConnect session.');\n }\n\n return {\n accounts: utils.formatAccountsToCAIP(\n evmAccounts.map((account) => account.accounts[0]),\n activeReference\n ),\n network: chainReferenceToHex(activeReference),\n };\n })\n .before(sessionUpdate)\n .before(sessionEvent)\n .before(sessionDelete)\n .or(sessionUpdateCleanup)\n .or(sessionEventCleanup)\n .or(sessionDeleteCleanup)\n .or((_, err) => {\n void getAdapter().disconnectSession('evm');\n return err;\n })\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(async () => getAdapter().tryRestoreEagerSession('evm'))\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .before(async () => {\n await getAdapter().disconnectSession('evm');\n })\n .after(sessionUpdateCleanup)\n .after(sessionEventCleanup)\n .after(sessionDeleteCleanup)\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(async () => getAdapter().getCurrentChainId())\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(disconnect)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { utils } from '@hub3js/evm';\nimport { ChainId } from 'caip';\n\nimport {\n extractAddress,\n getAccountsFromEvent,\n} from '../../session/accounts.js';\nimport {\n getPersistedChainId,\n persistCurrentChainId,\n} from '../../session/chain-state.js';\nimport { filterEvmAccounts } from '../../session/evm.js';\nimport { expireWalletConnectTopic } from '../../session/teardown.js';\nimport { chainReferenceToHex, parseChainReference } from '../../utils.js';\nimport { EthereumEvents, NAMESPACES } from '../../wcConstants.js';\nimport { createSessionSubscriber } from '../subscriber.js';\n\n/**\n * WC signals an account switch via `session_update` (re-shared namespaces with the\n * newly-selected account first), so the active account is published from this event.\n */\nexport function sessionUpdateSubscriber() {\n return createSessionSubscriber<'session_update', EvmActions>(\n 'evm',\n 'session_update',\n async ({ args, session, adapter, context }) => {\n /*\n * Keep the cached struct in step with what the wallet just re-shared.\n * `switchEvmNetwork` reads the authorized chains and methods back out\n * of it, so a stale copy rejects a chain the wallet has since added\n * (`wallet_addEthereumChain` lands here as a `session_update`) with\n * \"Chain X is not configured\".\n */\n if (args.params.namespaces[NAMESPACES.ETHEREUM]) {\n adapter.cacheSession('evm', {\n ...session,\n namespaces: args.params.namespaces,\n });\n }\n\n const allAccounts = getAccountsFromEvent(args);\n if (!allAccounts.length) {\n return;\n }\n\n const entries = allAccounts.map((accountsWithChain) => ({\n address: accountsWithChain.accounts[0],\n chainId: accountsWithChain.chainId,\n }));\n\n const [getState, setState] = context.state();\n const hubNetwork = getState().network;\n const persistedChain = await getPersistedChainId(\n await adapter.getClient()\n );\n const activeReference =\n parseChainReference(hubNetwork ?? undefined) ?? persistedChain;\n\n let evmAccounts = filterEvmAccounts(entries, activeReference);\n if (!evmAccounts.length) {\n evmAccounts = filterEvmAccounts(entries);\n }\n if (!evmAccounts.length) {\n return;\n }\n\n const chainIdHex = chainReferenceToHex(evmAccounts[0].chainId);\n setState(\n 'accounts',\n utils.formatAccountsToCAIP([evmAccounts[0].accounts[0]], chainIdHex)\n );\n setState('network', chainIdHex);\n }\n );\n}\n\n/**\n * Addresses out of an `accountsChanged` payload. Spec says `string[]`, but wallets\n * forwarding the EIP-1193 event as-is send a bare value, so the shape is coerced\n * before anything reads it.\n */\nfunction eventAccounts(data: unknown): string[] {\n return (Array.isArray(data) ? data : [data])\n .filter((entry): entry is string => typeof entry === 'string' && !!entry)\n .map(extractAddress);\n}\n\n/**\n * Handles WC `session_event` payloads: EIP-1193 `accountsChanged` (publish the new\n * accounts, or disconnect when the wallet revokes them all) and `chainChanged`\n * (update and persist the active chain). Any other event is ignored.\n */\nexport function sessionEventSubscriber() {\n return createSessionSubscriber<'session_event', EvmActions>(\n 'evm',\n 'session_event',\n ({ args, adapter, context }) => {\n const [, setState] = context.state();\n\n if (args.params.event.name === EthereumEvents.ACCOUNTS_CHANGED) {\n const accounts = eventAccounts(args.params.event.data);\n /*\n * An empty payload is the wallet revoking access (locked, or the account\n * unlinked from this dApp), not a switch - there is nothing to publish.\n */\n if (!accounts.length) {\n void context.action('disconnect');\n return;\n }\n\n const chainIdHex = chainReferenceToHex(\n ChainId.parse(args.params.chainId).reference\n );\n setState('network', chainIdHex);\n setState('accounts', utils.formatAccountsToCAIP(accounts, chainIdHex));\n return;\n }\n\n if (args.params.event.name === EthereumEvents.CHAIN_CHANGED) {\n const chainIdHex = chainReferenceToHex(args.params.event.data);\n setState('network', chainIdHex);\n void adapter\n .getClient()\n .then(async (client) => persistCurrentChainId(client, chainIdHex));\n }\n }\n );\n}\n\n/**\n * Reflects a wallet-initiated `session_delete` into the hub: clears the cached\n * session, expires the WC topic, and runs the hub `disconnect` action.\n */\nexport function sessionDeleteSubscriber() {\n return createSessionSubscriber<'session_delete', EvmActions>(\n 'evm',\n 'session_delete',\n ({ args, adapter, context }) => {\n adapter.clearSession('evm');\n void adapter\n .getClient()\n .then(async (client) => expireWalletConnectTopic(client, args.topic));\n context.action('disconnect');\n }\n );\n}\n", "import type { WalletConnectAdapter } from '../adapter/adapter.js';\nimport type { WalletConnectNamespace } from '../types.js';\nimport type {\n Actions,\n Context,\n Subscriber,\n SubscriberCleanUp,\n} from '@hub3js/core';\nimport type { SessionTypes, SignClientTypes } from '@walletconnect/types';\n\nimport { debug } from '@rango-dev/logging-core';\n\nimport { getAdapter } from '../adapter/registry.js';\n\n/** The WC client events a namespace subscribes to. */\nexport type SessionEventName =\n | 'session_update'\n | 'session_event'\n | 'session_delete';\n\nexport type SessionEventHandler<\n Name extends SessionEventName,\n ActionsType extends Actions<ActionsType>\n> = (event: {\n args: SignClientTypes.EventArguments[Name];\n /** The cached session this event was matched against. */\n session: SessionTypes.Struct;\n adapter: WalletConnectAdapter;\n context: Context<ActionsType>;\n}) => void | Promise<void>;\n\nfunction logHandlerError(error: unknown) {\n debug(error instanceof Error ? error : new Error(String(error)));\n}\n\n/**\n * Builds a hub subscriber for one WC client event, scoped to one namespace.\n *\n * Every namespace hook needs the same four things - resolve the client, only act\n * on events for the session this namespace has cached, register, and unregister\n * the exact same handler reference. Getting the topic guard wrong is what makes a\n * hook act on the other namespace's session, so it lives here rather than being\n * repeated per hook.\n */\nexport function createSessionSubscriber<\n Name extends SessionEventName,\n ActionsType extends Actions<ActionsType>\n>(\n namespace: WalletConnectNamespace,\n event: Name,\n handle: SessionEventHandler<Name, ActionsType>\n): [Subscriber<ActionsType>, SubscriberCleanUp<ActionsType>] {\n let handler: ((args: SignClientTypes.EventArguments[Name]) => void) | null =\n null;\n\n return [\n async (context) => {\n const adapter = getAdapter();\n const client = await adapter.getClient();\n\n /*\n * A namespace re-runs its `before` subscribers on every connect, so drop the\n * previous registration first - otherwise each reconnect leaves another live\n * handler behind and only the last one is ever removed.\n */\n if (handler) {\n client.off(event, handler);\n }\n\n handler = (args) => {\n const session = adapter.getSession(namespace);\n if (!session || args.topic !== session.topic) {\n return;\n }\n\n /*\n * WC dispatches these from its own async request pipeline with nothing\n * catching downstream, so a throw here (a payload shaped unlike anything\n * the handler expects) would surface as an unhandled rejection and take\n * the rest of that pipeline's processing with it. Async handlers are\n * covered too - their rejection lands nowhere otherwise.\n */\n try {\n const handled = handle({ args, session, adapter, context });\n if (handled instanceof Promise) {\n void handled.catch(logHandlerError);\n }\n } catch (error) {\n logHandlerError(error);\n }\n };\n\n client.on(event, handler);\n },\n (_, err) => {\n const currentHandler = handler;\n if (currentHandler) {\n handler = null;\n void getAdapter()\n .getClient()\n .then((client) => client.off(event, currentHandler));\n }\n return err;\n },\n ];\n}\n"],
5
+ "mappings": "mIAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,OAAuB,eCIhC,OAAS,SAAAC,OAAa,0BCFtB,OAAS,SAASC,MAAgB,0BAClC,OAAS,WAAAC,OAAe,OCHxB,OAAS,aAAAC,MAAiB,OAMnB,SAASC,GAAeC,EAAyB,CACtD,OAAOA,EAAQ,SAAS,GAAG,EAAI,IAAIC,EAAUD,CAAO,EAAE,QAAUA,CAClE,CAFgBE,EAAAH,GAAA,kBAIT,SAASI,EAAuBC,EAA8B,CAWnE,OAViB,OAAO,OAAOA,EAAQ,UAAU,EAC9C,IAAKC,GAAcA,EAAU,QAAQ,EACrC,KAAK,EACL,IAAKL,GAAY,CAChB,GAAM,CAAE,QAAAM,EAAS,QAAAC,CAAQ,EAAI,IAAIN,EAAUD,CAAO,EAClD,MAAO,CACL,QAAAM,EACA,QAASC,EAAQ,SACnB,CACF,CAAC,CAEL,CAZgBL,EAAAC,EAAA,0BAcT,SAASK,GACdC,EAGA,CAYA,OAXiB,OAAO,OAAOA,EAAM,OAAO,UAAU,EACnD,IAAKJ,GAAcA,EAAU,QAAQ,EACrC,KAAK,EACL,IAAKL,GAAY,CAChB,GAAM,CAAE,QAAAM,EAAS,QAAAC,CAAQ,EAAI,IAAIN,EAAUD,CAAO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W,EAAE,kBAAkB,KAAK,CAC5C,CAAC,EACA,MAAMb,EAAoB,EAC1B,MAAMG,EAAmB,EACzB,MAAMG,EAAoB,EAC1B,MAAM,EAEH0B,GAAavB,EAChB,WAAW,EACX,OAAO,SAAYI,EAAW,EAAE,kBAAkB,CAAC,EACnD,MAAM,EAEHoB,GAAM,IAAIC,GAA6B,MAAOC,CAAS,EAC1D,OAAO3B,EAAO,EACd,OAAOoB,EAAe,EACtB,OAAOC,EAAgB,EACvB,OAAOE,EAAU,EACjB,OAAOC,EAAU,EACjB,MAAM,ErB1FT,IAAMI,GAAgBC,EAAA,IACpB,IAAIC,GAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAASC,EAA4B,CACnD,GAAM,CAAC,CAAEC,CAAQ,EAAIF,EAAQ,MAAM,EAE9BC,EAAa,gBAIlBE,GACE,IAAIC,EAAqB,CACvB,UAAWH,EAAa,cACxB,KAAMA,EAAa,MAAQ,CAAC,EAC5B,iBAAkBA,EAAa,4BAC/B,UAAWA,EAAa,UACxB,YAAaA,EAAa,WAC5B,CAAC,CACH,EACAC,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,2CAA4CF,CAAO,EACnE,CAAC,EACA,OAAO,WAAYK,EAAQ,EAC3B,IAAI,MAAOC,EAAG,EACd,MAAM,EAvBW,iBDHtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,GAAc,CAAC,EAAE,MAAM,EAD1C",
6
+ "names": ["defineVersions", "ProviderBuilder", "debug", "logError", "ChainId", "AccountId", "extractAddress", "account", "AccountId", "__name", "getAccountsFromSession", "session", "namespace", "address", "chainId", "getAccountsFromEvent", "event", "persistCurrentChainId", "client", "chainId", "CHAIN_ID_STORAGE", "__name", "getPersistedChainId", "getChainIdByNetworkName", "network", "meta", "chainIdInHex", "blockchain", "debug", "convertEvmBlockchainMetaToEvmChainInfo", "isEvmAddress", "AccountId", "ChainId", "isEvmBlockchain", "getCurrentEvmAccountAddress", "session", "account", "AccountId", "address", "isEvmAddress", "__name", "getEvmAccount", "network", "meta", "currentChainId", "getChainIdByNetworkName", "filterEvmAccounts", "accounts", "firstEvmAddress", "chainId", "switchOrAddEvmChain", "client", "requestedNetwork", "currentNetwork", "evmBlockchains", "isEvmBlockchain", "targetChain", "convertEvmBlockchainMetaToEvmChainInfo", "chainIdInHex", "blockchain", "currentChainEip", "ChainId", "err", "code", "message", "updateSessionAccounts", "evmNamespace", "currentAccountAddress", "existing", "wanted", "updated", "debug", "ignoreNamespaceMethods", "WALLETS_WITH_WRONG_NAMESPACE_METHODS", "peerName", "name", "resolveActiveChainReference", "client", "session", "persistedChainId", "getPersistedChainId", "accounts", "getAccountsFromSession", "filterEvmAccounts", "__name", "getCurrentChainId", "reference", "chainReferenceToHex", "switchEvmNetwork", "options", "meta", "requestedChainId", "currentChainId", "requestedReference", "parseChainReference", "error", "logError", "chainIdStr", "ChainId", "requestedNetwork", "resolveNetworkName", "currentNetwork", "evmNamespace", "authorizedChains", "authorizedMethods", "activeSession", "ignoreNamespaceMethods", "updateSessionAccounts", "switchOrAddEvmChain", "persistCurrentChainId", "switchToChainIfNeeded", "deps", "currentReference", "ensureConnectedToChain", "chain", "debug", "timeout", "createAppKit", "defineChain", "chain", "__name", "mainnet", "bitcoin", "DEFAULT_MODAL_Z_INDEX", "NETWORKS", "mainnet", "bitcoin", "NAMESPACE_NETWORK", "prepareModalForNamespace", "web3Modal", "namespace", "__name", "createAppKitModal", "projectId", "universalProvider", "themeMode", "zIndex", "createAppKit", "debug", "CAIP_BITCOIN_CHAIN_ID", "AccountId", "getBip122AccountsFromSession", "session", "__name", "filterBip122Accounts", "account", "AccountId", "pickPaymentAddress", "data", "first", "entries", "entry", "__name", "patchBip122SessionAccount", "session", "address", "btcNamespace", "caipAccount", "AccountId", "CAIP_BITCOIN_CHAIN_ID", "accounts", "account", "BIP122_ACCOUNT_TIMEOUT", "resolveBip122Session", "client", "filterBip122Accounts", "freshSession", "resolvedSession", "waitForBip122PaymentAddress", "patched", "persistSessionNamespaces", "error", "debug", "timeoutMs", "resolve", "reject", "topic", "settled", "finish", "updatedSession", "cleanup", "fail", "timer", "onEvent", "onUpdate", "args", "getCaipNamespace", "namespace", "WC_NAMESPACE_TO_CAIP", "__name", "findSessionByNamespace", "client", "caipNamespace", "session", "ns", "getSessionNamespace", "hasAccounts", "hasChains", "CAIP_BITCOIN_CHAIN_ID", "ChainId", "NAMESPACE_PROPOSALS", "DEFAULT_ETHEREUM_METHODS", "DEFAULT_ETHEREUM_EVENTS", "chains", "targetChainReference", "DEFAULT_BITCOIN_METHODS", "DEFAULT_BITCOIN_EVENTS", "CAIP_BITCOIN_CHAIN_ID", "generateOptionalNamespace", "namespaces", "proposal", "namespace", "config", "WC_NAMESPACE_TO_CAIP", "chain", "ChainId", "__name", "debug", "getSdkError", "isNoMatchingKeyError", "error", "__name", "hasActiveSession", "client", "topic", "hasActivePairing", "pairing", "expireWalletConnectTopic", "sessions", "pairings", "session", "requestForDeleteTopic", "removeSessionRecord", "namespace", "getSessionNamespace", "pairingTopic", "getSdkError", "debug", "item", "persistCurrentChainId", "purgeOrphanedSessions", "pairingTopics", "pairingOrphaned", "sessionMissing", "purgeOrphanedPairings", "usedPairingTopics", "cleanupStaleSessionsForNamespace", "existing", "btc", "restoreWalletConnectSession", "client", "namespace", "options", "session", "restoreNamespaceSession", "filterBip122Accounts", "hasNamespaceAccounts", "__name", "accounts", "getAccountsFromSession", "currentChainId", "getPersistedChainId", "filterEvmAccounts", "findSessionByNamespace", "hasActiveSession", "removeSessionRecord", "hasActivePairing", "timeout", "error", "debug", "prepareWalletConnectNamespace", "purgeOrphanedSessions", "cleanupStaleSessionsForNamespace", "purgeOrphanedPairings", "connectWalletConnectSession", "web3Modal", "params", "chains", "chainReference", "restored", "proposal", "generateOptionalNamespace", "createSession", "resolveBip122Session", "configs", "optionalNamespaces", "pairingTopic", "uri", "approval", "onCloseModal", "redirectLink", "url", "prepareModalForNamespace", "openOptions", "WC_NAMESPACE_TO_CAIP", "_", "reject", "state", "debug", "restoreAndCacheSession", "client", "namespace", "cache", "options", "onDisconnect", "session", "restoreWalletConnectSession", "error", "debug", "__name", "ModalCache", "__name", "#web3Modal", "params", "createAppKitModal", "UniversalProvider", "createUniversalProvider", "projectId", "UniversalProvider", "RELAY_URL", "DEFAULT_APP_METADATA", "__name", "createSessionCache", "sessions", "namespace", "session", "topic", "__name", "TaskQueue", "__name", "#tail", "task", "ourTurn", "releaseOurTurn", "resolve", "WalletConnectAdapter", "__name", "#projectId", "#disableModalLink", "#themeMode", "#modalZIndex", "#meta", "#universalProvider", "#universalProviderPromise", "#cache", "createSessionCache", "#modalCache", "ModalCache", "#sessionQueue", "TaskQueue", "config", "createUniversalProvider", "provider", "error", "namespace", "session", "client", "restoreAndCacheSession", "targetNamespace", "#disconnectSessionQueued", "options", "#ensureSessionQueued", "resolveActiveChainReference", "getCurrentChainId", "chain", "ensureConnectedToChain", "#evmChainDeps", "requestedChainId", "currentChainId", "switchEvmNetwork", "chainReference", "restored", "prepareWalletConnectNamespace", "universalProvider", "connectWalletConnectSession", "evmMetaToCaipChainIds", "removeSessionRecord", "debug", "adapter", "getAdapter", "__name", "setAdapter", "instance", "isEvmNamespace", "dynamicImportWithRefinedError", "DefaultSignerFactory", "TxType", "getSigners", "adapter", "getAdapter", "client", "signers", "DefaultSignerFactory", "EVMSigner", "dynamicImportWithRefinedError", "TxType", "__name", "WALLET_ID", "metadata", "isEvmNamespace", "getSigners", "NamespaceBuilder", "actions", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "utils", "ChainId", "debug", "logHandlerError", "error", "debug", "__name", "createSessionSubscriber", "namespace", "event", "handle", "handler", "context", "adapter", "getAdapter", "client", "args", "session", "handled", "_", "err", "currentHandler", "sessionUpdateSubscriber", "createSessionSubscriber", "args", "session", "adapter", "context", "allAccounts", "getAccountsFromEvent", "entries", "accountsWithChain", "getState", "setState", "hubNetwork", "persistedChain", "getPersistedChainId", "activeReference", "parseChainReference", "evmAccounts", "filterEvmAccounts", "chainIdHex", "chainReferenceToHex", "utils", "__name", "eventAccounts", "data", "entry", "extractAddress", "sessionEventSubscriber", "accounts", "ChainId", "client", "persistCurrentChainId", "sessionDeleteSubscriber", "expireWalletConnectTopic", "sessionUpdate", "sessionUpdateCleanup", "sessionUpdateSubscriber", "sessionEvent", "sessionEventCleanup", "sessionEventSubscriber", "sessionDelete", "sessionDeleteCleanup", "sessionDeleteSubscriber", "connect", "builders", "_context", "chain", "adapter", "getAdapter", "requestedReference", "parseChainReference", "session", "activeReference", "accounts", "getAccountsFromSession", "evmAccounts", "filterEvmAccounts", "utils", "account", "chainReferenceToHex", "_", "err", "standardizeAndThrowError", "canEagerConnect", "canSwitchNetwork", "actions", "disconnect", "getChainId", "evm", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "environments", "setState", "setAdapter", "WalletConnectAdapter", "metadata", "evm", "versions", "__name", "defineVersions", "buildProvider"]
7
+ }
@@ -0,0 +1,18 @@
1
+ import type { EvmActions } from '@hub3js/evm';
2
+ /**
3
+ * WC signals an account switch via `session_update` (re-shared namespaces with the
4
+ * newly-selected account first), so the active account is published from this event.
5
+ */
6
+ export declare function sessionUpdateSubscriber(): [import("@hub3js/core").Subscriber<EvmActions>, import("@hub3js/core").SubscriberCleanUp<EvmActions>];
7
+ /**
8
+ * Handles WC `session_event` payloads: EIP-1193 `accountsChanged` (publish the new
9
+ * accounts, or disconnect when the wallet revokes them all) and `chainChanged`
10
+ * (update and persist the active chain). Any other event is ignored.
11
+ */
12
+ export declare function sessionEventSubscriber(): [import("@hub3js/core").Subscriber<EvmActions>, import("@hub3js/core").SubscriberCleanUp<EvmActions>];
13
+ /**
14
+ * Reflects a wallet-initiated `session_delete` into the hub: clears the cached
15
+ * session, expires the WC topic, and runs the hub `disconnect` action.
16
+ */
17
+ export declare function sessionDeleteSubscriber(): [import("@hub3js/core").Subscriber<EvmActions>, import("@hub3js/core").SubscriberCleanUp<EvmActions>];
18
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmB9C;;;GAGG;AACH,wBAAgB,uBAAuB,0GAqDtC;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,0GAmCrC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,0GAYtC"}
@@ -0,0 +1,4 @@
1
+ import type { EvmActions } from '@hub3js/evm';
2
+ declare const evm: import("@hub3js/core").ProxiedNamespace<EvmActions>;
3
+ export { evm };
4
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/namespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4F9C,QAAA,MAAM,GAAG,qDAMC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { WalletConnectAdapter } from '../adapter/adapter.js';
2
+ import type { WalletConnectNamespace } from '../types.js';
3
+ import type { Actions, Context, Subscriber, SubscriberCleanUp } from '@hub3js/core';
4
+ import type { SessionTypes, SignClientTypes } from '@walletconnect/types';
5
+ /** The WC client events a namespace subscribes to. */
6
+ export type SessionEventName = 'session_update' | 'session_event' | 'session_delete';
7
+ export type SessionEventHandler<Name extends SessionEventName, ActionsType extends Actions<ActionsType>> = (event: {
8
+ args: SignClientTypes.EventArguments[Name];
9
+ /** The cached session this event was matched against. */
10
+ session: SessionTypes.Struct;
11
+ adapter: WalletConnectAdapter;
12
+ context: Context<ActionsType>;
13
+ }) => void | Promise<void>;
14
+ /**
15
+ * Builds a hub subscriber for one WC client event, scoped to one namespace.
16
+ *
17
+ * Every namespace hook needs the same four things - resolve the client, only act
18
+ * on events for the session this namespace has cached, register, and unregister
19
+ * the exact same handler reference. Getting the topic guard wrong is what makes a
20
+ * hook act on the other namespace's session, so it lives here rather than being
21
+ * repeated per hook.
22
+ */
23
+ export declare function createSessionSubscriber<Name extends SessionEventName, ActionsType extends Actions<ActionsType>>(namespace: WalletConnectNamespace, event: Name, handle: SessionEventHandler<Name, ActionsType>): [Subscriber<ActionsType>, SubscriberCleanUp<ActionsType>];
24
+ //# sourceMappingURL=subscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../src/namespaces/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,UAAU,EACV,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAM1E,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,eAAe,GACf,gBAAgB,CAAC;AAErB,MAAM,MAAM,mBAAmB,CAC7B,IAAI,SAAS,gBAAgB,EAC7B,WAAW,SAAS,OAAO,CAAC,WAAW,CAAC,IACtC,CAAC,KAAK,EAAE;IACV,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC3C,yDAAyD;IACzD,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAM3B;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,SAAS,gBAAgB,EAC7B,WAAW,SAAS,OAAO,CAAC,WAAW,CAAC,EAExC,SAAS,EAAE,sBAAsB,EACjC,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,GAC7C,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAsD3D"}
@@ -0,0 +1,3 @@
1
+ declare const buildProvider: () => import("@hub3js/core").Provider<Record<"evm", import("@hub3js/evm").EvmActions>>;
2
+ export { buildProvider };
3
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,aAAa,wFAuBP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { SessionTypes, SignClientTypes } from '@walletconnect/types';
2
+ /**
3
+ * `accountsChanged` entries are CAIP-10 (`eip155:1:0x…`) from wallets that follow
4
+ * WC and a bare `0x…` from the ones forwarding the EIP-1193 payload as-is.
5
+ */
6
+ export declare function extractAddress(account: string): string;
7
+ export declare function getAccountsFromSession(session: SessionTypes.Struct): {
8
+ address: string;
9
+ chainId: string;
10
+ }[];
11
+ export declare function getAccountsFromEvent(event: SignClientTypes.BaseEventArgs<{
12
+ namespaces: SessionTypes.Namespaces;
13
+ }>): {
14
+ accounts: string[];
15
+ chainId: string;
16
+ }[];
17
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/session/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI1E;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM;;;IAYlE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC;IACnC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;CACrC,CAAC;;;IAcH"}
@@ -0,0 +1,23 @@
1
+ import type { SignClientInstance } from '../types.js';
2
+ import type { SessionTypes } from '@walletconnect/types';
3
+ export declare function getBip122AccountsFromSession(session: SessionTypes.Struct): string[];
4
+ export declare function filterBip122Accounts(session: SessionTypes.Struct): {
5
+ address: string;
6
+ }[];
7
+ export type Bip122AddressEntry = {
8
+ address: string;
9
+ intention?: 'payment' | 'ordinal';
10
+ };
11
+ /**
12
+ * Every address a `bip122_addressesChanged` payload carries, in wallet order.
13
+ * Unlike {@link pickPaymentAddress} it makes no guess about which one is active.
14
+ */
15
+ export declare function getAnnouncedAddresses(data: Bip122AddressEntry[] | string[] | undefined): string[];
16
+ export declare function pickPaymentAddress(data: Bip122AddressEntry[] | string[] | undefined): string | undefined;
17
+ export declare function patchBip122SessionAccount(session: SessionTypes.Struct, address: string): SessionTypes.Struct;
18
+ /**
19
+ * Bitcoin wallets often approve bip122 without accounts in the session object.
20
+ * They emit bip122_addressesChanged or session_update shortly after approval.
21
+ */
22
+ export declare function resolveBip122Session(client: SignClientInstance, session: SessionTypes.Struct): Promise<SessionTypes.Struct>;
23
+ //# sourceMappingURL=bip122.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip122.d.ts","sourceRoot":"","sources":["../../src/session/bip122.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAQ1E,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,CAAC,MAAM,GAC3B,MAAM,EAAE,CAEV;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM;;IAIhE;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,GAChD,MAAM,EAAE,CAQV;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,GAChD,MAAM,GAAG,SAAS,CAepB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,YAAY,CAAC,MAAM,EAC5B,OAAO,EAAE,MAAM,GACd,YAAY,CAAC,MAAM,CAkCrB;AAID;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,YAAY,CAAC,MAAM,GAC3B,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAkB9B"}
@@ -0,0 +1,6 @@
1
+ import type { ISignClient } from '@walletconnect/types';
2
+ import type { BlockchainMeta } from 'rango-types';
3
+ export declare function persistCurrentChainId(client: ISignClient, chainId?: string): Promise<void>;
4
+ export declare function getPersistedChainId(client: ISignClient): Promise<string | undefined>;
5
+ export declare function getChainIdByNetworkName(network: string, meta: BlockchainMeta[]): string | undefined;
6
+ //# sourceMappingURL=chain-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-state.d.ts","sourceRoot":"","sources":["../../src/session/chain-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,MAAM,iBAKjB;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,WAAW,+BAQ5D;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,EAAE,GACrB,MAAM,GAAG,SAAS,CAUpB"}
@@ -0,0 +1,29 @@
1
+ import type { Chain } from '@hub3js/evm';
2
+ import type { ISignClient, SessionTypes } from '@walletconnect/types';
3
+ import type { BlockchainMeta } from 'rango-types';
4
+ export type EvmChainDeps = {
5
+ meta: BlockchainMeta[];
6
+ getSession: (namespace: 'evm') => SessionTypes.Struct | null;
7
+ cacheSession: (namespace: 'evm', session: SessionTypes.Struct) => void;
8
+ getClient: () => Promise<ISignClient>;
9
+ ensureSession: (options: {
10
+ namespace: 'evm';
11
+ chainReference?: string;
12
+ }) => Promise<SessionTypes.Struct>;
13
+ };
14
+ export declare function resolveActiveChainReference(client: ISignClient, session: SessionTypes.Struct): Promise<string | undefined>;
15
+ export declare function getCurrentChainId(client: ISignClient, session: SessionTypes.Struct): Promise<`0x${string}`>;
16
+ /**
17
+ * Returns the session to keep using: `updateSessionAccounts` may rebuild it, and
18
+ * the caller's copy is stale from that point on.
19
+ */
20
+ export declare function switchEvmNetwork(options: {
21
+ client: ISignClient;
22
+ session: SessionTypes.Struct;
23
+ meta: BlockchainMeta[];
24
+ requestedChainId: string;
25
+ currentChainId: string;
26
+ }): Promise<SessionTypes.Struct>;
27
+ export declare function switchToChainIfNeeded(deps: EvmChainDeps, requestedReference: string): Promise<void>;
28
+ export declare function ensureConnectedToChain(deps: EvmChainDeps, chain?: string | Chain): Promise<SessionTypes.Struct>;
29
+ //# sourceMappingURL=evm-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm-chain.d.ts","sourceRoot":"","sources":["../../src/session/evm-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;A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CAAC,YAAY,CAAC,MAAM,CAAC,CAoB9B"}
@@ -0,0 +1,25 @@
1
+ import type { ISignClient, SessionTypes } from '@walletconnect/types';
2
+ import type { BlockchainMeta } from 'rango-types';
3
+ export declare function getCurrentEvmAccountAddress(session: SessionTypes.Struct): string | undefined;
4
+ export declare function getEvmAccount(network: string, address: string, meta: BlockchainMeta[]): string | undefined;
5
+ export declare function filterEvmAccounts(accounts: {
6
+ address: string;
7
+ chainId: string;
8
+ }[], currentChainId?: string): {
9
+ accounts: string[];
10
+ chainId: string;
11
+ }[];
12
+ export declare function switchOrAddEvmChain(client: ISignClient, session: SessionTypes.Struct, meta: BlockchainMeta[], requestedNetwork: string, currentNetwork: string): Promise<void>;
13
+ /**
14
+ * Adds the requested and current chains' accounts to the session so sign-client
15
+ * accepts a request carrying their CAIP chain id, and returns the session to use
16
+ * from here on.
17
+ *
18
+ * The record is rebuilt rather than pushed into: the struct is shared with the
19
+ * store and the adapter cache, and the write below can fail (it is logged, not
20
+ * thrown), which would otherwise leave both holding accounts the store never
21
+ * accepted.
22
+ */
23
+ export declare function updateSessionAccounts(client: ISignClient, session: SessionTypes.Struct, requestedNetwork: string, currentNetwork: string, meta: BlockchainMeta[]): Promise<SessionTypes.Struct>;
24
+ export declare function ignoreNamespaceMethods(session: SessionTypes.Struct): boolean;
25
+ //# sourceMappingURL=evm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/session/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAclD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,YAAY,CAAC,MAAM,GAC3B,MAAM,GAAG,SAAS,CAIpB;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,EAAE,GACrB,MAAM,GAAG,SAAS,CAapB;AAGD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,EAAE,EACH,cAAc,CAAC,EAAE,MAAM;;;IAwBxB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,CAAC,MAAM,EAC5B,IAAI,EAAE,cAAc,EAAE,EACtB,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,iBAoDvB;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,CAAC,MAAM,EAC5B,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,cAAc,EAAE,GACrB,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAwC9B;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,GAAG,OAAO,CAM5E"}
@@ -0,0 +1,30 @@
1
+ import type { AppKitModal } from '../adapter/modal.js';
2
+ import type { ConnectParams, SignClientInstance, WalletConnectNamespace } from '../types.js';
3
+ import type { SessionTypes } from '@walletconnect/types';
4
+ import type UniversalProvider from '@walletconnect/universal-provider';
5
+ export type RestoreWalletConnectSessionOptions = {
6
+ validateAccounts?: boolean;
7
+ };
8
+ export declare function restoreWalletConnectSession(client: SignClientInstance, namespace: WalletConnectNamespace, options?: RestoreWalletConnectSessionOptions): Promise<SessionTypes.Struct | undefined>;
9
+ /**
10
+ * Ping the session topic and return it if still valid.
11
+ * Returns undefined (instead of throwing) when storage contains stale records.
12
+ */
13
+ export declare function restoreNamespaceSession(client: SignClientInstance, namespace: WalletConnectNamespace): Promise<SessionTypes.Struct | undefined>;
14
+ /**
15
+ * Clears unusable records ahead of a connect: orphaned sessions across every
16
+ * namespace, plus `namespace`'s own stale ones.
17
+ *
18
+ * A *live* session belonging to another namespace is deliberately left alone -
19
+ * EVM and UTXO each own an independent session, and only the namespace being
20
+ * disconnected drops its own.
21
+ */
22
+ export declare function prepareWalletConnectNamespace(client: UniversalProvider['client'], namespace: WalletConnectNamespace): Promise<void>;
23
+ /**
24
+ * Restores `namespace`'s session, or negotiates a new one.
25
+ *
26
+ * Callers are expected to have run {@link prepareWalletConnectNamespace} first -
27
+ * this does not clean up on its own.
28
+ */
29
+ export declare function connectWalletConnectSession(client: UniversalProvider['client'], web3Modal: AppKitModal, params: ConnectParams): Promise<SessionTypes.Struct>;
30
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/session/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,aAAa,EAGb,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,iBAAiB,MAAM,mCAAmC,CAAC;AAuBvE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,sBAAsB,EACjC,OAAO,GAAE,kCAAuC,GAC/C,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,CAwB1C;AAgBD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,sBAAsB,GAChC,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,CA8B1C;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EACnC,SAAS,EAAE,sBAAsB,GAChC,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EACnC,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAkC9B"}
@@ -0,0 +1,6 @@
1
+ import type { WalletConnectNamespace } from '../types.js';
2
+ import type { ISignClient, SessionTypes } from '@walletconnect/types';
3
+ export declare function getCaipNamespace(namespace: WalletConnectNamespace): string;
4
+ export declare function findSessionByNamespace(client: ISignClient, namespace: WalletConnectNamespace): SessionTypes.Struct | undefined;
5
+ export declare function getSessionNamespace(session: SessionTypes.Struct): WalletConnectNamespace | undefined;
6
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/session/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAItE,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,sBAAsB,GAAG,MAAM,CAE1E;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,sBAAsB,GAChC,YAAY,CAAC,MAAM,GAAG,SAAS,CAWjC;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,CAAC,MAAM,GAC3B,sBAAsB,GAAG,SAAS,CA0BpC"}
@@ -0,0 +1,27 @@
1
+ import type { WalletConnectNamespace } from '../types.js';
2
+ import type { ChainIdParams } from 'caip';
3
+ /**
4
+ * `chains` is required here so the same shape is assignable both to the
5
+ * SignClient `ProposalTypes` (chains optional) and to the UniversalProvider
6
+ * `NamespaceConfig` (chains required).
7
+ */
8
+ export type FinalNamespaces = Record<string, {
9
+ chains: string[];
10
+ methods: string[];
11
+ events: string[];
12
+ }>;
13
+ /**
14
+ * Builds a WalletConnect namespace proposal (chains, methods, events).
15
+ *
16
+ * The result always goes to `optionalNamespaces`: sign-client merges
17
+ * `requiredNamespaces` into `optionalNamespaces` and clears it before sending
18
+ * the proposal, so passing anything as required only earns a deprecation
19
+ * warning. Narrowing the proposal (see `targetChainReference`) is what actually
20
+ * constrains what the wallet can approve.
21
+ *
22
+ * @param targetChainReference - When set for EVM, limits the proposal to this
23
+ * single chain id (decimal string, e.g. `"137"`). Omit to include all EVM
24
+ * chains from `chains`.
25
+ */
26
+ export declare function generateOptionalNamespace(chains: ChainIdParams[], namespaces: WalletConnectNamespace[], targetChainReference?: string): FinalNamespaces | undefined;
27
+ //# sourceMappingURL=proposals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposals.d.ts","sourceRoot":"","sources":["../../src/session/proposals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAc1C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAC1D,CAAC;AAwCF;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,aAAa,EAAE,EACvB,UAAU,EAAE,sBAAsB,EAAE,EACpC,oBAAoB,CAAC,EAAE,MAAM,GAC5B,eAAe,GAAG,SAAS,CAe7B"}
@@ -0,0 +1,6 @@
1
+ import type { SessionCache } from '../adapter/session-cache.js';
2
+ import type { SignClientInstance, WalletConnectNamespace } from '../types.js';
3
+ import type { SessionTypes } from '@walletconnect/types';
4
+ import { type RestoreWalletConnectSessionOptions } from './lifecycle.js';
5
+ export declare function restoreAndCacheSession(client: SignClientInstance, namespace: WalletConnectNamespace, cache: SessionCache, options?: RestoreWalletConnectSessionOptions, onDisconnect?: (namespace: WalletConnectNamespace) => Promise<void>): Promise<SessionTypes.Struct | null>;
6
+ //# sourceMappingURL=restore-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore-cache.d.ts","sourceRoot":"","sources":["../../src/session/restore-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,EAEL,KAAK,kCAAkC,EACxC,MAAM,gBAAgB,CAAC;AAExB,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,sBAAsB,EACjC,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,kCAAkC,EAC5C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,GAClE,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBrC"}