@kheopskit/core 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/WalletAccountId-6ZXQM_ed.mjs +116 -0
- package/dist/WalletAccountId-6ZXQM_ed.mjs.map +1 -0
- package/dist/WalletAccountId-D8Xc13VY.js +151 -0
- package/dist/WalletAccountId-D8Xc13VY.js.map +1 -0
- package/dist/{config-Csp5p0-Z.d.ts → config-CubhhFON.d.ts} +2 -2
- package/dist/{config-qMsgD8tJ.d.mts → config-rvX2pkqc.d.mts} +2 -2
- package/dist/ethereum.d.mts +1 -1
- package/dist/ethereum.d.ts +1 -1
- package/dist/ethereum.js +11 -11
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/dist/index.mjs +3 -3
- package/dist/{instance--1tqj7s5.mjs → instance-0-PWH43j.mjs} +3 -3
- package/dist/{instance--1tqj7s5.mjs.map → instance-0-PWH43j.mjs.map} +1 -1
- package/dist/{instance-CrdktIu7.d.ts → instance-BokWUMmA.d.ts} +2 -2
- package/dist/{instance-4DgSj55G.js → instance-CegD47uC.js} +25 -25
- package/dist/{instance-4DgSj55G.js.map → instance-CegD47uC.js.map} +1 -1
- package/dist/{instance-Gv9IDCIY.d.mts → instance-DoOr7mrc.d.mts} +2 -2
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +4 -4
- package/dist/internal.mjs +2 -2
- package/dist/{platformAccounts-BcLoaZZb.js → platformAccounts-D8XmOSvD.js} +130 -113
- package/dist/platformAccounts-D8XmOSvD.js.map +1 -0
- package/dist/{platformAccounts-3jM3W1fB.mjs → platformAccounts-sy621l8C.mjs} +84 -97
- package/dist/platformAccounts-sy621l8C.mjs.map +1 -0
- package/dist/polkadot.d.mts +1 -1
- package/dist/polkadot.d.ts +1 -1
- package/dist/polkadot.js +10 -10
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +2 -2
- package/dist/solana.d.mts +1 -1
- package/dist/solana.d.ts +1 -1
- package/dist/solana.js +10 -10
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/{types-C9aw2FEm.d.mts → types-BfIzw1fd.d.mts} +7 -1
- package/dist/{types-C9aw2FEm.d.ts → types-BfIzw1fd.d.ts} +7 -1
- package/dist/walletconnect.d.mts +1 -1
- package/dist/walletconnect.d.ts +1 -1
- package/dist/walletconnect.js +20 -17
- package/dist/walletconnect.js.map +1 -1
- package/dist/walletconnect.mjs +17 -14
- package/dist/walletconnect.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/platformAccounts-3jM3W1fB.mjs.map +0 -1
- package/dist/platformAccounts-BcLoaZZb.js.map +0 -1
- package/dist/types-DaRMgleZ.js +0 -169
- package/dist/types-DaRMgleZ.js.map +0 -1
- package/dist/types-DcpmEGhO.mjs +0 -104
- package/dist/types-DcpmEGhO.mjs.map +0 -1
package/dist/solana.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.js","names":["KheopskitError","KheopskitError","address","getTransactionEncoder","getTransactionDecoder","getBase58Decoder","getBase58Encoder","getBase64Decoder","getBase64Encoder","of","getCachedObservable$","Observable","getWalletAccountId","shareReplay","getWalletConnectSessionAccounts$","getSessionCaip10s","getCaip10Addresses","createPlatformAccounts$","Observable","getWallets","shareReplay","createInjectedWallets$","getWalletId","KheopskitError","isEip1193UserRejection","isRefusalMessage","clearCachedObservablesByPrefix"],"sources":["../src/api/solana/chains.ts","../src/api/solana/signer.ts","../src/api/solana/accounts.ts","../src/api/solana/wallets.ts","../src/api/solana/plugin.ts"],"sourcesContent":["import { KheopskitError } from \"../errors\";\n\n/**\n * Wallet Standard chain identifiers for Solana clusters.\n *\n * These are the values wallets advertise in their `chains` arrays and the\n * values kheopskit accepts in `solana({ chain })`.\n *\n * @see https://github.com/anza-xyz/wallet-standard\n */\nexport type SolanaChainId =\n\t| \"solana:mainnet\"\n\t| \"solana:devnet\"\n\t| \"solana:testnet\"\n\t| \"solana:localnet\";\n\nexport const DEFAULT_SOLANA_CHAIN: SolanaChainId = \"solana:mainnet\";\n\nconst SOLANA_CHAIN_IDS = [\n\t\"solana:mainnet\",\n\t\"solana:devnet\",\n\t\"solana:testnet\",\n\t\"solana:localnet\",\n] as const satisfies SolanaChainId[];\n\nexport const isSolanaChainId = (value: unknown): value is SolanaChainId =>\n\ttypeof value === \"string\" &&\n\t(SOLANA_CHAIN_IDS as readonly string[]).includes(value);\n\n/**\n * Maps Wallet Standard chain ids to the CAIP-2 chain ids used by WalletConnect.\n *\n * CAIP-2 ids use the first 32 characters of the cluster's genesis hash as the\n * reference. The values below match `@reown/appkit/networks` (solana,\n * solanaDevnet, solanaTestnet), which is what AppKit puts in session namespaces.\n *\n * `localnet` has no canonical CAIP-2 id and cannot be used over WalletConnect.\n */\nconst SOLANA_CHAIN_TO_CAIP2 = {\n\t\"solana:mainnet\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n\t\"solana:devnet\": \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\",\n\t\"solana:testnet\": \"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z\",\n} as const satisfies Partial<Record<SolanaChainId, string>>;\n\n/**\n * Returns the CAIP-2 chain id for a Solana chain, for use in WalletConnect\n * requests and when reading WalletConnect session namespaces.\n *\n * @throws if the chain has no canonical CAIP-2 id (e.g. localnet)\n */\nexport const getSolanaCaip2 = (chain: SolanaChainId): string => {\n\tconst caip2 = (SOLANA_CHAIN_TO_CAIP2 as Record<string, string | undefined>)[\n\t\tchain\n\t];\n\tif (!caip2)\n\t\tthrow new KheopskitError(\n\t\t\t\"UNSUPPORTED_CHAIN\",\n\t\t\t`Solana chain \"${chain}\" cannot be used over WalletConnect (no CAIP-2 id).`,\n\t\t);\n\treturn caip2;\n};\n\n/**\n * AppKit's *deprecated* CAIP-2 cluster ids (its `deprecatedCaipNetworkId`\n * values). Some wallets still place accounts in the WC session under these, so\n * map them back to a {@link SolanaChainId} instead of silently falling back to\n * the configured chain. Requests always use the current ids from\n * {@link SOLANA_CHAIN_TO_CAIP2}; testnet has no deprecated id.\n */\nconst DEPRECATED_CAIP2_TO_SOLANA_CHAIN: Record<string, SolanaChainId> = {\n\t\"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ\": \"solana:mainnet\",\n\t\"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K\": \"solana:devnet\",\n};\n\nconst CAIP2_TO_SOLANA_CHAIN: Record<string, SolanaChainId> = {\n\t...Object.fromEntries(\n\t\tObject.entries(SOLANA_CHAIN_TO_CAIP2).map(([chain, caip2]) => [\n\t\t\tcaip2,\n\t\t\tchain as SolanaChainId,\n\t\t]),\n\t),\n\t...DEPRECATED_CAIP2_TO_SOLANA_CHAIN,\n};\n\n/**\n * Maps a CAIP-2 chain id (as found in WalletConnect session namespaces) back to\n * its {@link SolanaChainId}, or `undefined` if it isn't a recognised cluster.\n */\nexport const getSolanaChainIdFromCaip2 = (\n\tcaip2: string,\n): SolanaChainId | undefined => CAIP2_TO_SOLANA_CHAIN[caip2];\n","import {\n\taddress,\n\tgetBase58Decoder,\n\tgetBase58Encoder,\n\tgetBase64Decoder,\n\tgetBase64Encoder,\n\tgetTransactionDecoder,\n\tgetTransactionEncoder,\n\ttype SignableMessage,\n\ttype SignatureBytes,\n\ttype TransactionModifyingSigner,\n} from \"@solana/kit\";\nimport type {\n\tSolanaSignAndSendTransactionFeature,\n\tSolanaSignMessageFeature,\n\tSolanaSignTransactionFeature,\n} from \"@solana/wallet-standard-features\";\nimport type {\n\tWalletAccount,\n\tWallet as WalletStandardWallet,\n} from \"@wallet-standard/base\";\nimport { KheopskitError } from \"../errors\";\nimport type { WalletConnectProvider } from \"../types\";\nimport { getSolanaCaip2, type SolanaChainId } from \"./chains\";\nimport type { SolanaSigner } from \"./types\";\n\nconst SOLANA_SIGN_MESSAGE = \"solana:signMessage\";\nconst SOLANA_SIGN_TRANSACTION = \"solana:signTransaction\";\nconst SOLANA_SIGN_AND_SEND_TRANSACTION = \"solana:signAndSendTransaction\";\n\ntype SignMessageApi = SolanaSignMessageFeature[typeof SOLANA_SIGN_MESSAGE];\ntype SignTransactionApi =\n\tSolanaSignTransactionFeature[typeof SOLANA_SIGN_TRANSACTION];\ntype SignAndSendApi =\n\tSolanaSignAndSendTransactionFeature[typeof SOLANA_SIGN_AND_SEND_TRANSACTION];\n\n/** The branded array type expected back from a transaction-modifying signer. */\ntype SignedTransactions = Awaited<\n\tReturnType<TransactionModifyingSigner[\"modifyAndSignTransactions\"]>\n>;\n\nconst requireFeature = <T>(wallet: WalletStandardWallet, name: string): T => {\n\tconst feature = (wallet.features as Record<string, unknown>)[name];\n\tif (!feature)\n\t\tthrow new KheopskitError(\n\t\t\t\"FEATURE_NOT_SUPPORTED\",\n\t\t\t`wallet \"${wallet.name}\" does not support ${name}`,\n\t\t);\n\treturn feature as T;\n};\n\n/**\n * Builds a {@link SolanaSigner} backed by a Wallet Standard wallet's\n * `solana:*` features (injected wallets).\n *\n * Transactions are exchanged as wire bytes; messages and signatures as raw\n * bytes. Calling a method whose feature the wallet does not advertise throws.\n */\nexport const createInjectedSolanaSigner = (\n\twallet: WalletStandardWallet,\n\taccount: WalletAccount,\n\tchain: SolanaChainId,\n): SolanaSigner => {\n\tconst signerAddress = address(account.address);\n\n\treturn {\n\t\taddress: signerAddress,\n\t\tmodifyAndSignMessages: async (messages) => {\n\t\t\tconst feature = requireFeature<SignMessageApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_MESSAGE,\n\t\t\t);\n\t\t\tconst outputs = await feature.signMessage(\n\t\t\t\t...messages.map((m) => ({ account, message: m.content })),\n\t\t\t);\n\t\t\treturn messages.map((m, i) => {\n\t\t\t\tconst output = outputs[i];\n\t\t\t\tif (!output) throw new Error(\"[kheopskit] missing signMessage output\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: output.signedMessage,\n\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t...m.signatures,\n\t\t\t\t\t\t[signerAddress]: output.signature as SignatureBytes,\n\t\t\t\t\t},\n\t\t\t\t} satisfies SignableMessage;\n\t\t\t});\n\t\t},\n\t\tmodifyAndSignTransactions: async (transactions) => {\n\t\t\tconst feature = requireFeature<SignTransactionApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_TRANSACTION,\n\t\t\t);\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst decoder = getTransactionDecoder();\n\t\t\tconst outputs = await feature.signTransaction(\n\t\t\t\t...transactions.map((tx) => ({\n\t\t\t\t\taccount,\n\t\t\t\t\ttransaction: new Uint8Array(encoder.encode(tx)),\n\t\t\t\t\tchain,\n\t\t\t\t})),\n\t\t\t);\n\t\t\treturn transactions.map((_tx, i) => {\n\t\t\t\tconst output = outputs[i];\n\t\t\t\tif (!output)\n\t\t\t\t\tthrow new Error(\"[kheopskit] missing signTransaction output\");\n\t\t\t\treturn decoder.decode(output.signedTransaction);\n\t\t\t}) as unknown as SignedTransactions;\n\t\t},\n\t\tsignAndSendTransactions: async (transactions) => {\n\t\t\tconst feature = requireFeature<SignAndSendApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_AND_SEND_TRANSACTION,\n\t\t\t);\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst outputs = await feature.signAndSendTransaction(\n\t\t\t\t...transactions.map((tx) => ({\n\t\t\t\t\taccount,\n\t\t\t\t\ttransaction: new Uint8Array(encoder.encode(tx)),\n\t\t\t\t\tchain,\n\t\t\t\t})),\n\t\t\t);\n\t\t\treturn outputs.map((output) => output.signature as SignatureBytes);\n\t\t},\n\t};\n};\n\n/**\n * Builds a {@link SolanaSigner} backed by a WalletConnect session, adapting the\n * `solana_*` RPC methods to the same interface as the injected signer.\n *\n * The CAIP-2 chain id is derived from {@link SolanaChainId}; transactions are\n * base64-encoded and messages/signatures base58-encoded, per the WalletConnect\n * Solana spec.\n */\nexport const createWalletConnectSolanaSigner = (\n\tprovider: WalletConnectProvider,\n\taccountAddress: string,\n\tchain: SolanaChainId,\n): SolanaSigner => {\n\tconst signerAddress = address(accountAddress);\n\n\tconst request = <T>(method: string, params: unknown): Promise<T> => {\n\t\tif (!provider.session)\n\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\t\t// Resolved lazily (not at signer construction) so building a signer for a\n\t\t// cluster without a CAIP-2 id (e.g. localnet) doesn't throw until a request\n\t\t// is actually attempted.\n\t\treturn provider.client.request<T>({\n\t\t\ttopic: provider.session.topic,\n\t\t\tchainId: getSolanaCaip2(chain),\n\t\t\trequest: { method, params },\n\t\t});\n\t};\n\n\treturn {\n\t\taddress: signerAddress,\n\t\tmodifyAndSignMessages: async (messages) => {\n\t\t\t// @solana/kit naming is the inverse of the value direction here: a\n\t\t\t// Decoder turns bytes -> string (so `toBase58` produces a base58 string),\n\t\t\t// an Encoder turns string -> bytes (so `fromBase58` parses one).\n\t\t\tconst toBase58 = getBase58Decoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\treturn Promise.all(\n\t\t\t\tmessages.map(async (m) => {\n\t\t\t\t\tconst { signature } = await request<{ signature: string }>(\n\t\t\t\t\t\t\"solana_signMessage\",\n\t\t\t\t\t\t{ pubkey: accountAddress, message: toBase58.decode(m.content) },\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: m.content,\n\t\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t\t...m.signatures,\n\t\t\t\t\t\t\t[signerAddress]: fromBase58.encode(signature) as SignatureBytes,\n\t\t\t\t\t\t},\n\t\t\t\t\t} satisfies SignableMessage;\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t\tmodifyAndSignTransactions: async (transactions) => {\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst decoder = getTransactionDecoder();\n\t\t\tconst toBase64 = getBase64Decoder();\n\t\t\tconst fromBase64 = getBase64Encoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\tconst signed = await Promise.all(\n\t\t\t\ttransactions.map(async (tx) => {\n\t\t\t\t\tconst result = await request<{\n\t\t\t\t\t\ttransaction?: string;\n\t\t\t\t\t\tsignature?: string;\n\t\t\t\t\t}>(\"solana_signTransaction\", {\n\t\t\t\t\t\ttransaction: toBase64.decode(encoder.encode(tx)),\n\t\t\t\t\t});\n\t\t\t\t\t// Wallets may return either the full signed transaction (base64)\n\t\t\t\t\t// or just the signature (base58) to merge into the original.\n\t\t\t\t\tif (result.transaction)\n\t\t\t\t\t\treturn decoder.decode(fromBase64.encode(result.transaction));\n\t\t\t\t\tif (result.signature)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...tx,\n\t\t\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t\t\t...tx.signatures,\n\t\t\t\t\t\t\t\t[signerAddress]: fromBase58.encode(\n\t\t\t\t\t\t\t\t\tresult.signature,\n\t\t\t\t\t\t\t\t) as SignatureBytes,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"[kheopskit] solana_signTransaction returned no transaction or signature\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn signed as unknown as SignedTransactions;\n\t\t},\n\t\tsignAndSendTransactions: async (transactions) => {\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst toBase64 = getBase64Decoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\treturn Promise.all(\n\t\t\t\ttransactions.map(async (tx) => {\n\t\t\t\t\tconst { signature } = await request<{ signature: string }>(\n\t\t\t\t\t\t\"solana_signAndSendTransaction\",\n\t\t\t\t\t\t{ transaction: toBase64.decode(encoder.encode(tx)) },\n\t\t\t\t\t);\n\t\t\t\t\treturn fromBase58.encode(signature) as SignatureBytes;\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t};\n};\n","import type { StandardEventsFeature } from \"@wallet-standard/features\";\nimport { Observable, of, shareReplay } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type { WalletConnectWallet } from \"../types\";\nimport { getSolanaChainIdFromCaip2, type SolanaChainId } from \"./chains\";\nimport {\n\tcreateInjectedSolanaSigner,\n\tcreateWalletConnectSolanaSigner,\n} from \"./signer\";\nimport type {\n\tSolanaAccount,\n\tSolanaInjectedWallet,\n\tSolanaWallet,\n} from \"./types\";\n\ntype StandardEventsApi = StandardEventsFeature[\"standard:events\"];\n\nconst getInjectedWalletAccounts$ = (\n\twallet: SolanaInjectedWallet,\n\tchain: SolanaChainId,\n): Observable<SolanaAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:${chain}`, () =>\n\t\tnew Observable<SolanaAccount[]>((subscriber) => {\n\t\t\tconst standardWallet = wallet.wallet;\n\n\t\t\tconst buildAccounts = (): SolanaAccount[] =>\n\t\t\t\tstandardWallet.accounts.map(\n\t\t\t\t\t(account): SolanaAccount => ({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, account.address),\n\t\t\t\t\t\tplatform: \"solana\",\n\t\t\t\t\t\taddress: account.address,\n\t\t\t\t\t\tchains: wallet.chains,\n\t\t\t\t\t\tsigner: createInjectedSolanaSigner(standardWallet, account, chain),\n\t\t\t\t\t\tgetSigner: (c) =>\n\t\t\t\t\t\t\tcreateInjectedSolanaSigner(standardWallet, account, c),\n\t\t\t\t\t\tname: account.label,\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tsubscriber.next(buildAccounts());\n\n\t\t\t// Re-emit when the wallet's authorized accounts change.\n\t\t\tconst eventsFeature = (\n\t\t\t\tstandardWallet.features as Record<string, unknown>\n\t\t\t)[\"standard:events\"] as StandardEventsApi | undefined;\n\t\t\tconst off = eventsFeature?.on(\"change\", () =>\n\t\t\t\tsubscriber.next(buildAccounts()),\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\toff?.();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n\tchain: SolanaChainId,\n): Observable<SolanaAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"solana\",\n\t\tnamespace: \"solana\",\n\t\tcacheKey: `accounts:${wallet.id}:solana:${chain}`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst solanaCaip10s = getSessionCaip10s(session, \"solana\");\n\t\t\tconst addresses = getCaip10Addresses(solanaCaip10s);\n\n\t\t\t// Clusters the session actually advertises (\"solana:<chainRef>\" from\n\t\t\t// each CAIP-10 entry), mapped back to SolanaChainId. Falls back to the\n\t\t\t// configured chain when none are recognised.\n\t\t\tconst advertisedChains = [\n\t\t\t\t...new Set(\n\t\t\t\t\tsolanaCaip10s\n\t\t\t\t\t\t.map((account) => account.split(\":\").slice(0, 2).join(\":\"))\n\t\t\t\t\t\t.map(getSolanaChainIdFromCaip2)\n\t\t\t\t\t\t.filter((c): c is SolanaChainId => !!c),\n\t\t\t\t),\n\t\t\t];\n\t\t\tconst chains = advertisedChains.length ? advertisedChains : [chain];\n\n\t\t\treturn addresses.map(\n\t\t\t\t(accountAddress): SolanaAccount => ({\n\t\t\t\t\tid: getWalletAccountId(wallet.id, accountAddress),\n\t\t\t\t\tplatform: \"solana\",\n\t\t\t\t\taddress: accountAddress,\n\t\t\t\t\tchains,\n\t\t\t\t\tsigner: createWalletConnectSolanaSigner(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\taccountAddress,\n\t\t\t\t\t\tchain,\n\t\t\t\t\t),\n\t\t\t\t\tgetSigner: (c) =>\n\t\t\t\t\t\tcreateWalletConnectSolanaSigner(provider, accountAddress, c),\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t});\n\nexport const getSolanaAccounts$ = (\n\tsolanaWallets$: Observable<(SolanaWallet | WalletConnectWallet)[]>,\n\tsolanaChain: SolanaChainId,\n) =>\n\tcreatePlatformAccounts$({\n\t\twallets$: solanaWallets$,\n\t\tgetInjectedAccounts$: (wallet) =>\n\t\t\tgetInjectedWalletAccounts$(wallet, solanaChain),\n\t\tgetWalletConnectAccounts$: (wallet) =>\n\t\t\tgetWalletConnectAccounts$(wallet, solanaChain),\n\t\t// Re-emit when the advertised clusters change, not just on id changes.\n\t\taccountChangeKey: (account) => `${account.id}|${account.chains.join(\",\")}`,\n\t});\n","import { getWallets } from \"@wallet-standard/app\";\nimport type { Wallet as WalletStandardWallet } from \"@wallet-standard/base\";\nimport type {\n\tStandardConnectFeature,\n\tStandardDisconnectFeature,\n} from \"@wallet-standard/features\";\nimport { Observable, shareReplay } from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { getWalletId } from \"../../utils/WalletId\";\nimport {\n\tisEip1193UserRejection,\n\tisRefusalMessage,\n\tKheopskitError,\n} from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport { isSolanaChainId, type SolanaChainId } from \"./chains\";\nimport type { SolanaInjectedWallet } from \"./types\";\n\ntype ConnectApi = StandardConnectFeature[\"standard:connect\"];\ntype DisconnectApi = StandardDisconnectFeature[\"standard:disconnect\"];\n\nconst SOLANA_NAMESPACE_PREFIX = \"solana:\";\n\n/** A Wallet Standard wallet is Solana-capable if it advertises a solana chain or feature. */\nconst isSolanaWallet = (wallet: WalletStandardWallet): boolean =>\n\twallet.chains.some((chain) => chain.startsWith(SOLANA_NAMESPACE_PREFIX)) ||\n\tObject.keys(wallet.features).some((feature) =>\n\t\tfeature.startsWith(SOLANA_NAMESPACE_PREFIX),\n\t);\n\nconst getSolanaChains = (wallet: WalletStandardWallet): SolanaChainId[] =>\n\twallet.chains.filter((chain): chain is SolanaChainId =>\n\t\tisSolanaChainId(chain),\n\t);\n\n/**\n * Observable of Solana-capable Wallet Standard wallets, updated as wallets\n * register/unregister. Returns an empty array during SSR.\n */\nconst walletStandardWallets$ = new Observable<readonly WalletStandardWallet[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - the Wallet Standard registry requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst { get, on } = getWallets();\n\t\tconst emit = () => subscriber.next(get().filter(isSolanaWallet));\n\n\t\temit();\n\n\t\tconst offRegister = on(\"register\", emit);\n\t\tconst offUnregister = on(\"unregister\", emit);\n\n\t\treturn () => {\n\t\t\toffRegister();\n\t\t\toffUnregister();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getSolanaWallets$ = (store: KheopskitStore) =>\n\tcreateInjectedWallets$<WalletStandardWallet, SolanaInjectedWallet>(store, {\n\t\tsources$: walletStandardWallets$,\n\t\tgetWalletId: (wallet) => getWalletId(\"solana\", wallet.name),\n\t\tconnect: async (wallet, walletId) => {\n\t\t\tconst feature = (wallet.features as Record<string, unknown>)[\n\t\t\t\t\"standard:connect\"\n\t\t\t] as ConnectApi | undefined;\n\t\t\tif (!feature)\n\t\t\t\tthrow new KheopskitError(\n\t\t\t\t\t\"FEATURE_NOT_SUPPORTED\",\n\t\t\t\t\t`wallet ${walletId} does not support standard:connect`,\n\t\t\t\t\t{ walletId },\n\t\t\t\t);\n\n\t\t\tawait feature.connect();\n\t\t},\n\t\tisUserRejection: (error) =>\n\t\t\tisEip1193UserRejection(error) || isRefusalMessage(error),\n\t\t// standard:disconnect is an optional feature. Await it when present so a\n\t\t// failed disconnect rejects the returned promise; if absent we still\n\t\t// clear local state.\n\t\tdisconnect: async (wallet) => {\n\t\t\tconst feature = (wallet.features as Record<string, unknown>)[\n\t\t\t\t\"standard:disconnect\"\n\t\t\t] as DisconnectApi | undefined;\n\t\t\tawait feature?.disconnect();\n\t\t},\n\t\t// Drop cached account observables for this wallet so a later reconnect\n\t\t// rebuilds them against the current wallet handle, not a stale closure.\n\t\tonDisconnected: (walletId) =>\n\t\t\tclearCachedObservablesByPrefix(`accounts:${walletId}:`),\n\t\tbuildWallet: ({\n\t\t\tsource: wallet,\n\t\t\twalletId,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}) => ({\n\t\t\tplatform: \"solana\",\n\t\t\ttype: \"injected\",\n\t\t\tid: walletId,\n\t\t\tsourceId: wallet.name,\n\t\t\twallet,\n\t\t\tchains: getSolanaChains(wallet),\n\t\t\tname: wallet.name,\n\t\t\ticon: wallet.icon,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}),\n\t});\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getSolanaAccounts$ } from \"./accounts\";\nimport {\n\tDEFAULT_SOLANA_CHAIN,\n\tisSolanaChainId,\n\ttype SolanaChainId,\n} from \"./chains\";\nimport type { SolanaAccount, SolanaWallet } from \"./types\";\nimport { getSolanaWallets$ } from \"./wallets\";\n\nexport type SolanaPluginOptions = {\n\t/**\n\t * Solana cluster that account signers target. Each account also exposes a\n\t * `getSigner(chain)` factory for targeting another cluster.\n\t *\n\t * @default \"solana:mainnet\"\n\t */\n\tchain?: SolanaChainId;\n};\n\n/**\n * Solana platform plugin. Pass to `createKheopskit({ platforms: [solana()] })`.\n *\n * @example\n * ```ts\n * import { solana } from \"@kheopskit/core/solana\";\n * solana({ chain: \"solana:mainnet\" });\n * ```\n */\nexport const solana = (\n\toptions: SolanaPluginOptions = {},\n): KheopskitPlatform<\"solana\", SolanaWallet, SolanaAccount> => {\n\tconst chain = options.chain ?? DEFAULT_SOLANA_CHAIN;\n\n\tif (!isSolanaChainId(chain)) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown solana chain: ${JSON.stringify(chain)}. Valid values: \"solana:mainnet\", \"solana:devnet\", \"solana:testnet\", \"solana:localnet\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"solana\",\n\t\tgetWallets$: (ctx: PlatformContext) => getSolanaWallets$(ctx.store),\n\t\tgetAccounts$: (wallets$) => getSolanaAccounts$(wallets$, chain),\n\t};\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,uBAAsC;AAEnD,MAAM,mBAAmB;CACxB;CACA;CACA;CACA;AACD;AAEA,MAAa,mBAAmB,UAC/B,OAAO,UAAU,YAChB,iBAAuC,SAAS,KAAK;;;;;;;;;;AAWvD,MAAM,wBAAwB;CAC7B,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;AACnB;;;;;;;AAQA,MAAa,kBAAkB,UAAiC;CAC/D,MAAM,QAAS,sBACd;CAED,IAAI,CAAC,OACJ,MAAM,IAAIA,eAAAA,eACT,qBACA,iBAAiB,MAAM,oDACxB;CACD,OAAO;AACR;;;;;;;;AASA,MAAM,mCAAkE;CACvE,2CAA2C;CAC3C,2CAA2C;AAC5C;AAEA,MAAM,wBAAuD;CAC5D,GAAG,OAAO,YACT,OAAO,QAAQ,qBAAqB,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC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CAAC,SACJ,MAAM,IAAIC,eAAAA,eACT,yBACA,UAAU,SAAS,qCACnB,EAAE,SAAS,CACZ;EAED,MAAM,QAAQ,QAAQ;CACvB;CACA,kBAAkB,UACjBC,eAAAA,uBAAuB,KAAK,KAAKC,eAAAA,iBAAiB,KAAK;CAIxD,YAAY,OAAO,WAAW;EAI7B,MAHiB,OAAO,SACvB,sBAEY,EAAE,WAAW;CAC3B;CAGA,iBAAiB,aAChBC,cAAAA,+BAA+B,YAAY,SAAS,EAAE;CACvD,cAAc,EACb,QAAQ,QACR,UACA,QACA,OACA,aACA,SACA,kBACM;EACN,UAAU;EACV,MAAM;EACN,IAAI;EACJ,UAAU,OAAO;EACjB;EACA,QAAQ,gBAAgB,MAAM;EAC9B,MAAM,OAAO;EACb,MAAM,OAAO;EACb;EACA;EACA;EACA;EACA;CACD;AACD,CAAC;;;;;;;;;;;;AC3FF,MAAa,UACZ,UAA+B,CAAC,MAC8B;CAC9D,MAAM,QAAQ,QAAQ,SAAA;CAEtB,IAAI,CAAC,gBAAgB,KAAK,GACzB,QAAQ,KACP,qCAAqC,KAAK,UAAU,KAAK,EAAE,wFAC5D;CAGD,OAAO;EACN,UAAU;EACV,cAAc,QAAyB,kBAAkB,IAAI,KAAK;EAClE,eAAe,aAAa,mBAAmB,UAAU,KAAK;CAC/D;AACD"}
|
|
1
|
+
{"version":3,"file":"solana.js","names":["KheopskitError","KheopskitError","address","getTransactionEncoder","getTransactionDecoder","getBase58Decoder","getBase58Encoder","getBase64Decoder","getBase64Encoder","of","getCachedObservable$","Observable","getWalletAccountId","shareReplay","getWalletConnectSessionAccounts$","getSessionCaip10s","getCaip10Addresses","createPlatformAccounts$","Observable","getWallets","shareReplay","createInjectedWallets$","getWalletId","KheopskitError","isEip1193UserRejection","isRefusalMessage","clearCachedObservablesByPrefix"],"sources":["../src/api/solana/chains.ts","../src/api/solana/signer.ts","../src/api/solana/accounts.ts","../src/api/solana/wallets.ts","../src/api/solana/plugin.ts"],"sourcesContent":["import { KheopskitError } from \"../errors\";\n\n/**\n * Wallet Standard chain identifiers for Solana clusters.\n *\n * These are the values wallets advertise in their `chains` arrays and the\n * values kheopskit accepts in `solana({ chain })`.\n *\n * @see https://github.com/anza-xyz/wallet-standard\n */\nexport type SolanaChainId =\n\t| \"solana:mainnet\"\n\t| \"solana:devnet\"\n\t| \"solana:testnet\"\n\t| \"solana:localnet\";\n\nexport const DEFAULT_SOLANA_CHAIN: SolanaChainId = \"solana:mainnet\";\n\nconst SOLANA_CHAIN_IDS = [\n\t\"solana:mainnet\",\n\t\"solana:devnet\",\n\t\"solana:testnet\",\n\t\"solana:localnet\",\n] as const satisfies SolanaChainId[];\n\nexport const isSolanaChainId = (value: unknown): value is SolanaChainId =>\n\ttypeof value === \"string\" &&\n\t(SOLANA_CHAIN_IDS as readonly string[]).includes(value);\n\n/**\n * Maps Wallet Standard chain ids to the CAIP-2 chain ids used by WalletConnect.\n *\n * CAIP-2 ids use the first 32 characters of the cluster's genesis hash as the\n * reference. The values below match `@reown/appkit/networks` (solana,\n * solanaDevnet, solanaTestnet), which is what AppKit puts in session namespaces.\n *\n * `localnet` has no canonical CAIP-2 id and cannot be used over WalletConnect.\n */\nconst SOLANA_CHAIN_TO_CAIP2 = {\n\t\"solana:mainnet\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n\t\"solana:devnet\": \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\",\n\t\"solana:testnet\": \"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z\",\n} as const satisfies Partial<Record<SolanaChainId, string>>;\n\n/**\n * Returns the CAIP-2 chain id for a Solana chain, for use in WalletConnect\n * requests and when reading WalletConnect session namespaces.\n *\n * @throws if the chain has no canonical CAIP-2 id (e.g. localnet)\n */\nexport const getSolanaCaip2 = (chain: SolanaChainId): string => {\n\tconst caip2 = (SOLANA_CHAIN_TO_CAIP2 as Record<string, string | undefined>)[\n\t\tchain\n\t];\n\tif (!caip2)\n\t\tthrow new KheopskitError(\n\t\t\t\"UNSUPPORTED_CHAIN\",\n\t\t\t`Solana chain \"${chain}\" cannot be used over WalletConnect (no CAIP-2 id).`,\n\t\t);\n\treturn caip2;\n};\n\n/**\n * AppKit's *deprecated* CAIP-2 cluster ids (its `deprecatedCaipNetworkId`\n * values). Some wallets still place accounts in the WC session under these, so\n * map them back to a {@link SolanaChainId} instead of silently falling back to\n * the configured chain. Requests always use the current ids from\n * {@link SOLANA_CHAIN_TO_CAIP2}; testnet has no deprecated id.\n */\nconst DEPRECATED_CAIP2_TO_SOLANA_CHAIN: Record<string, SolanaChainId> = {\n\t\"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ\": \"solana:mainnet\",\n\t\"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K\": \"solana:devnet\",\n};\n\nconst CAIP2_TO_SOLANA_CHAIN: Record<string, SolanaChainId> = {\n\t...Object.fromEntries(\n\t\tObject.entries(SOLANA_CHAIN_TO_CAIP2).map(([chain, caip2]) => [\n\t\t\tcaip2,\n\t\t\tchain as SolanaChainId,\n\t\t]),\n\t),\n\t...DEPRECATED_CAIP2_TO_SOLANA_CHAIN,\n};\n\n/**\n * Maps a CAIP-2 chain id (as found in WalletConnect session namespaces) back to\n * its {@link SolanaChainId}, or `undefined` if it isn't a recognised cluster.\n */\nexport const getSolanaChainIdFromCaip2 = (\n\tcaip2: string,\n): SolanaChainId | undefined => CAIP2_TO_SOLANA_CHAIN[caip2];\n","import {\n\taddress,\n\tgetBase58Decoder,\n\tgetBase58Encoder,\n\tgetBase64Decoder,\n\tgetBase64Encoder,\n\tgetTransactionDecoder,\n\tgetTransactionEncoder,\n\ttype SignableMessage,\n\ttype SignatureBytes,\n\ttype TransactionModifyingSigner,\n} from \"@solana/kit\";\nimport type {\n\tSolanaSignAndSendTransactionFeature,\n\tSolanaSignMessageFeature,\n\tSolanaSignTransactionFeature,\n} from \"@solana/wallet-standard-features\";\nimport type {\n\tWalletAccount,\n\tWallet as WalletStandardWallet,\n} from \"@wallet-standard/base\";\nimport { KheopskitError } from \"../errors\";\nimport type { WalletConnectProvider } from \"../types\";\nimport { getSolanaCaip2, type SolanaChainId } from \"./chains\";\nimport type { SolanaSigner } from \"./types\";\n\nconst SOLANA_SIGN_MESSAGE = \"solana:signMessage\";\nconst SOLANA_SIGN_TRANSACTION = \"solana:signTransaction\";\nconst SOLANA_SIGN_AND_SEND_TRANSACTION = \"solana:signAndSendTransaction\";\n\ntype SignMessageApi = SolanaSignMessageFeature[typeof SOLANA_SIGN_MESSAGE];\ntype SignTransactionApi =\n\tSolanaSignTransactionFeature[typeof SOLANA_SIGN_TRANSACTION];\ntype SignAndSendApi =\n\tSolanaSignAndSendTransactionFeature[typeof SOLANA_SIGN_AND_SEND_TRANSACTION];\n\n/** The branded array type expected back from a transaction-modifying signer. */\ntype SignedTransactions = Awaited<\n\tReturnType<TransactionModifyingSigner[\"modifyAndSignTransactions\"]>\n>;\n\nconst requireFeature = <T>(wallet: WalletStandardWallet, name: string): T => {\n\tconst feature = (wallet.features as Record<string, unknown>)[name];\n\tif (!feature)\n\t\tthrow new KheopskitError(\n\t\t\t\"FEATURE_NOT_SUPPORTED\",\n\t\t\t`wallet \"${wallet.name}\" does not support ${name}`,\n\t\t);\n\treturn feature as T;\n};\n\n/**\n * Builds a {@link SolanaSigner} backed by a Wallet Standard wallet's\n * `solana:*` features (injected wallets).\n *\n * Transactions are exchanged as wire bytes; messages and signatures as raw\n * bytes. Calling a method whose feature the wallet does not advertise throws.\n */\nexport const createInjectedSolanaSigner = (\n\twallet: WalletStandardWallet,\n\taccount: WalletAccount,\n\tchain: SolanaChainId,\n): SolanaSigner => {\n\tconst signerAddress = address(account.address);\n\n\treturn {\n\t\taddress: signerAddress,\n\t\tmodifyAndSignMessages: async (messages) => {\n\t\t\tconst feature = requireFeature<SignMessageApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_MESSAGE,\n\t\t\t);\n\t\t\tconst outputs = await feature.signMessage(\n\t\t\t\t...messages.map((m) => ({ account, message: m.content })),\n\t\t\t);\n\t\t\treturn messages.map((m, i) => {\n\t\t\t\tconst output = outputs[i];\n\t\t\t\tif (!output) throw new Error(\"[kheopskit] missing signMessage output\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: output.signedMessage,\n\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t...m.signatures,\n\t\t\t\t\t\t[signerAddress]: output.signature as SignatureBytes,\n\t\t\t\t\t},\n\t\t\t\t} satisfies SignableMessage;\n\t\t\t});\n\t\t},\n\t\tmodifyAndSignTransactions: async (transactions) => {\n\t\t\tconst feature = requireFeature<SignTransactionApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_TRANSACTION,\n\t\t\t);\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst decoder = getTransactionDecoder();\n\t\t\tconst outputs = await feature.signTransaction(\n\t\t\t\t...transactions.map((tx) => ({\n\t\t\t\t\taccount,\n\t\t\t\t\ttransaction: new Uint8Array(encoder.encode(tx)),\n\t\t\t\t\tchain,\n\t\t\t\t})),\n\t\t\t);\n\t\t\treturn transactions.map((_tx, i) => {\n\t\t\t\tconst output = outputs[i];\n\t\t\t\tif (!output)\n\t\t\t\t\tthrow new Error(\"[kheopskit] missing signTransaction output\");\n\t\t\t\treturn decoder.decode(output.signedTransaction);\n\t\t\t}) as unknown as SignedTransactions;\n\t\t},\n\t\tsignAndSendTransactions: async (transactions) => {\n\t\t\tconst feature = requireFeature<SignAndSendApi>(\n\t\t\t\twallet,\n\t\t\t\tSOLANA_SIGN_AND_SEND_TRANSACTION,\n\t\t\t);\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst outputs = await feature.signAndSendTransaction(\n\t\t\t\t...transactions.map((tx) => ({\n\t\t\t\t\taccount,\n\t\t\t\t\ttransaction: new Uint8Array(encoder.encode(tx)),\n\t\t\t\t\tchain,\n\t\t\t\t})),\n\t\t\t);\n\t\t\treturn outputs.map((output) => output.signature as SignatureBytes);\n\t\t},\n\t};\n};\n\n/**\n * Builds a {@link SolanaSigner} backed by a WalletConnect session, adapting the\n * `solana_*` RPC methods to the same interface as the injected signer.\n *\n * The CAIP-2 chain id is derived from {@link SolanaChainId}; transactions are\n * base64-encoded and messages/signatures base58-encoded, per the WalletConnect\n * Solana spec.\n */\nexport const createWalletConnectSolanaSigner = (\n\tprovider: WalletConnectProvider,\n\taccountAddress: string,\n\tchain: SolanaChainId,\n): SolanaSigner => {\n\tconst signerAddress = address(accountAddress);\n\n\tconst request = <T>(method: string, params: unknown): Promise<T> => {\n\t\tif (!provider.session)\n\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\t\t// Resolved lazily (not at signer construction) so building a signer for a\n\t\t// cluster without a CAIP-2 id (e.g. localnet) doesn't throw until a request\n\t\t// is actually attempted.\n\t\treturn provider.client.request<T>({\n\t\t\ttopic: provider.session.topic,\n\t\t\tchainId: getSolanaCaip2(chain),\n\t\t\trequest: { method, params },\n\t\t});\n\t};\n\n\treturn {\n\t\taddress: signerAddress,\n\t\tmodifyAndSignMessages: async (messages) => {\n\t\t\t// @solana/kit naming is the inverse of the value direction here: a\n\t\t\t// Decoder turns bytes -> string (so `toBase58` produces a base58 string),\n\t\t\t// an Encoder turns string -> bytes (so `fromBase58` parses one).\n\t\t\tconst toBase58 = getBase58Decoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\treturn Promise.all(\n\t\t\t\tmessages.map(async (m) => {\n\t\t\t\t\tconst { signature } = await request<{ signature: string }>(\n\t\t\t\t\t\t\"solana_signMessage\",\n\t\t\t\t\t\t{ pubkey: accountAddress, message: toBase58.decode(m.content) },\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: m.content,\n\t\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t\t...m.signatures,\n\t\t\t\t\t\t\t[signerAddress]: fromBase58.encode(signature) as SignatureBytes,\n\t\t\t\t\t\t},\n\t\t\t\t\t} satisfies SignableMessage;\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t\tmodifyAndSignTransactions: async (transactions) => {\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst decoder = getTransactionDecoder();\n\t\t\tconst toBase64 = getBase64Decoder();\n\t\t\tconst fromBase64 = getBase64Encoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\tconst signed = await Promise.all(\n\t\t\t\ttransactions.map(async (tx) => {\n\t\t\t\t\tconst result = await request<{\n\t\t\t\t\t\ttransaction?: string;\n\t\t\t\t\t\tsignature?: string;\n\t\t\t\t\t}>(\"solana_signTransaction\", {\n\t\t\t\t\t\ttransaction: toBase64.decode(encoder.encode(tx)),\n\t\t\t\t\t});\n\t\t\t\t\t// Wallets may return either the full signed transaction (base64)\n\t\t\t\t\t// or just the signature (base58) to merge into the original.\n\t\t\t\t\tif (result.transaction)\n\t\t\t\t\t\treturn decoder.decode(fromBase64.encode(result.transaction));\n\t\t\t\t\tif (result.signature)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...tx,\n\t\t\t\t\t\t\tsignatures: {\n\t\t\t\t\t\t\t\t...tx.signatures,\n\t\t\t\t\t\t\t\t[signerAddress]: fromBase58.encode(\n\t\t\t\t\t\t\t\t\tresult.signature,\n\t\t\t\t\t\t\t\t) as SignatureBytes,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"[kheopskit] solana_signTransaction returned no transaction or signature\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn signed as unknown as SignedTransactions;\n\t\t},\n\t\tsignAndSendTransactions: async (transactions) => {\n\t\t\tconst encoder = getTransactionEncoder();\n\t\t\tconst toBase64 = getBase64Decoder();\n\t\t\tconst fromBase58 = getBase58Encoder();\n\t\t\treturn Promise.all(\n\t\t\t\ttransactions.map(async (tx) => {\n\t\t\t\t\tconst { signature } = await request<{ signature: string }>(\n\t\t\t\t\t\t\"solana_signAndSendTransaction\",\n\t\t\t\t\t\t{ transaction: toBase64.decode(encoder.encode(tx)) },\n\t\t\t\t\t);\n\t\t\t\t\treturn fromBase58.encode(signature) as SignatureBytes;\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t};\n};\n","import type { StandardEventsFeature } from \"@wallet-standard/features\";\nimport { Observable, of, shareReplay } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type { WalletConnectWallet } from \"../types\";\nimport { getSolanaChainIdFromCaip2, type SolanaChainId } from \"./chains\";\nimport {\n\tcreateInjectedSolanaSigner,\n\tcreateWalletConnectSolanaSigner,\n} from \"./signer\";\nimport type {\n\tSolanaAccount,\n\tSolanaInjectedWallet,\n\tSolanaWallet,\n} from \"./types\";\n\ntype StandardEventsApi = StandardEventsFeature[\"standard:events\"];\n\nconst getInjectedWalletAccounts$ = (\n\twallet: SolanaInjectedWallet,\n\tchain: SolanaChainId,\n): Observable<SolanaAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:${chain}`, () =>\n\t\tnew Observable<SolanaAccount[]>((subscriber) => {\n\t\t\tconst standardWallet = wallet.wallet;\n\n\t\t\tconst buildAccounts = (): SolanaAccount[] =>\n\t\t\t\tstandardWallet.accounts.map(\n\t\t\t\t\t(account): SolanaAccount => ({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, account.address),\n\t\t\t\t\t\tplatform: \"solana\",\n\t\t\t\t\t\taddress: account.address,\n\t\t\t\t\t\tchains: wallet.chains,\n\t\t\t\t\t\tsigner: createInjectedSolanaSigner(standardWallet, account, chain),\n\t\t\t\t\t\tgetSigner: (c) =>\n\t\t\t\t\t\t\tcreateInjectedSolanaSigner(standardWallet, account, c),\n\t\t\t\t\t\tname: account.label,\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tsubscriber.next(buildAccounts());\n\n\t\t\t// Re-emit when the wallet's authorized accounts change.\n\t\t\tconst eventsFeature = (\n\t\t\t\tstandardWallet.features as Record<string, unknown>\n\t\t\t)[\"standard:events\"] as StandardEventsApi | undefined;\n\t\t\tconst off = eventsFeature?.on(\"change\", () =>\n\t\t\t\tsubscriber.next(buildAccounts()),\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\toff?.();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n\tchain: SolanaChainId,\n): Observable<SolanaAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"solana\",\n\t\tnamespace: \"solana\",\n\t\tcacheKey: `accounts:${wallet.id}:solana:${chain}`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst solanaCaip10s = getSessionCaip10s(session, \"solana\");\n\t\t\tconst addresses = getCaip10Addresses(solanaCaip10s);\n\n\t\t\t// Clusters the session actually advertises (\"solana:<chainRef>\" from\n\t\t\t// each CAIP-10 entry), mapped back to SolanaChainId. Falls back to the\n\t\t\t// configured chain when none are recognised.\n\t\t\tconst advertisedChains = [\n\t\t\t\t...new Set(\n\t\t\t\t\tsolanaCaip10s\n\t\t\t\t\t\t.map((account) => account.split(\":\").slice(0, 2).join(\":\"))\n\t\t\t\t\t\t.map(getSolanaChainIdFromCaip2)\n\t\t\t\t\t\t.filter((c): c is SolanaChainId => !!c),\n\t\t\t\t),\n\t\t\t];\n\t\t\tconst chains = advertisedChains.length ? advertisedChains : [chain];\n\n\t\t\treturn addresses.map(\n\t\t\t\t(accountAddress): SolanaAccount => ({\n\t\t\t\t\tid: getWalletAccountId(wallet.id, accountAddress),\n\t\t\t\t\tplatform: \"solana\",\n\t\t\t\t\taddress: accountAddress,\n\t\t\t\t\tchains,\n\t\t\t\t\tsigner: createWalletConnectSolanaSigner(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\taccountAddress,\n\t\t\t\t\t\tchain,\n\t\t\t\t\t),\n\t\t\t\t\tgetSigner: (c) =>\n\t\t\t\t\t\tcreateWalletConnectSolanaSigner(provider, accountAddress, c),\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t});\n\nexport const getSolanaAccounts$ = (\n\tsolanaWallets$: Observable<(SolanaWallet | WalletConnectWallet)[]>,\n\tsolanaChain: SolanaChainId,\n) =>\n\tcreatePlatformAccounts$({\n\t\twallets$: solanaWallets$,\n\t\tgetInjectedAccounts$: (wallet) =>\n\t\t\tgetInjectedWalletAccounts$(wallet, solanaChain),\n\t\tgetWalletConnectAccounts$: (wallet) =>\n\t\t\tgetWalletConnectAccounts$(wallet, solanaChain),\n\t\t// Re-emit when the advertised clusters change, not just on id changes.\n\t\taccountChangeKey: (account) => `${account.id}|${account.chains.join(\",\")}`,\n\t});\n","import { getWallets } from \"@wallet-standard/app\";\nimport type { Wallet as WalletStandardWallet } from \"@wallet-standard/base\";\nimport type {\n\tStandardConnectFeature,\n\tStandardDisconnectFeature,\n} from \"@wallet-standard/features\";\nimport { Observable, shareReplay } from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { getWalletId } from \"../../utils/WalletId\";\nimport {\n\tisEip1193UserRejection,\n\tisRefusalMessage,\n\tKheopskitError,\n} from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport { isSolanaChainId, type SolanaChainId } from \"./chains\";\nimport type { SolanaInjectedWallet } from \"./types\";\n\ntype ConnectApi = StandardConnectFeature[\"standard:connect\"];\ntype DisconnectApi = StandardDisconnectFeature[\"standard:disconnect\"];\n\nconst SOLANA_NAMESPACE_PREFIX = \"solana:\";\n\n/** A Wallet Standard wallet is Solana-capable if it advertises a solana chain or feature. */\nconst isSolanaWallet = (wallet: WalletStandardWallet): boolean =>\n\twallet.chains.some((chain) => chain.startsWith(SOLANA_NAMESPACE_PREFIX)) ||\n\tObject.keys(wallet.features).some((feature) =>\n\t\tfeature.startsWith(SOLANA_NAMESPACE_PREFIX),\n\t);\n\nconst getSolanaChains = (wallet: WalletStandardWallet): SolanaChainId[] =>\n\twallet.chains.filter((chain): chain is SolanaChainId =>\n\t\tisSolanaChainId(chain),\n\t);\n\n/**\n * Observable of Solana-capable Wallet Standard wallets, updated as wallets\n * register/unregister. Returns an empty array during SSR.\n */\nconst walletStandardWallets$ = new Observable<readonly WalletStandardWallet[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - the Wallet Standard registry requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst { get, on } = getWallets();\n\t\tconst emit = () => subscriber.next(get().filter(isSolanaWallet));\n\n\t\temit();\n\n\t\tconst offRegister = on(\"register\", emit);\n\t\tconst offUnregister = on(\"unregister\", emit);\n\n\t\treturn () => {\n\t\t\toffRegister();\n\t\t\toffUnregister();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getSolanaWallets$ = (store: KheopskitStore) =>\n\tcreateInjectedWallets$<WalletStandardWallet, SolanaInjectedWallet>(store, {\n\t\tsources$: walletStandardWallets$,\n\t\tgetWalletId: (wallet) => getWalletId(\"solana\", wallet.name),\n\t\tconnect: async (wallet, walletId) => {\n\t\t\tconst feature = (wallet.features as Record<string, unknown>)[\n\t\t\t\t\"standard:connect\"\n\t\t\t] as ConnectApi | undefined;\n\t\t\tif (!feature)\n\t\t\t\tthrow new KheopskitError(\n\t\t\t\t\t\"FEATURE_NOT_SUPPORTED\",\n\t\t\t\t\t`wallet ${walletId} does not support standard:connect`,\n\t\t\t\t\t{ walletId },\n\t\t\t\t);\n\n\t\t\tawait feature.connect();\n\t\t},\n\t\tisUserRejection: (error) =>\n\t\t\tisEip1193UserRejection(error) || isRefusalMessage(error),\n\t\t// standard:disconnect is an optional feature. Await it when present so a\n\t\t// failed disconnect rejects the returned promise; if absent we still\n\t\t// clear local state.\n\t\tdisconnect: async (wallet) => {\n\t\t\tconst feature = (wallet.features as Record<string, unknown>)[\n\t\t\t\t\"standard:disconnect\"\n\t\t\t] as DisconnectApi | undefined;\n\t\t\tawait feature?.disconnect();\n\t\t},\n\t\t// Drop cached account observables for this wallet so a later reconnect\n\t\t// rebuilds them against the current wallet handle, not a stale closure.\n\t\tonDisconnected: (walletId) =>\n\t\t\tclearCachedObservablesByPrefix(`accounts:${walletId}:`),\n\t\tbuildWallet: ({\n\t\t\tsource: wallet,\n\t\t\twalletId,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}) => ({\n\t\t\tplatform: \"solana\",\n\t\t\ttype: \"injected\",\n\t\t\tid: walletId,\n\t\t\tsourceId: wallet.name,\n\t\t\twallet,\n\t\t\tchains: getSolanaChains(wallet),\n\t\t\tname: wallet.name,\n\t\t\ticon: wallet.icon,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}),\n\t});\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getSolanaAccounts$ } from \"./accounts\";\nimport {\n\tDEFAULT_SOLANA_CHAIN,\n\tisSolanaChainId,\n\ttype SolanaChainId,\n} from \"./chains\";\nimport type { SolanaAccount, SolanaWallet } from \"./types\";\nimport { getSolanaWallets$ } from \"./wallets\";\n\nexport type SolanaPluginOptions = {\n\t/**\n\t * Solana cluster that account signers target. Each account also exposes a\n\t * `getSigner(chain)` factory for targeting another cluster.\n\t *\n\t * @default \"solana:mainnet\"\n\t */\n\tchain?: SolanaChainId;\n};\n\n/**\n * Solana platform plugin. Pass to `createKheopskit({ platforms: [solana()] })`.\n *\n * @example\n * ```ts\n * import { solana } from \"@kheopskit/core/solana\";\n * solana({ chain: \"solana:mainnet\" });\n * ```\n */\nexport const solana = (\n\toptions: SolanaPluginOptions = {},\n): KheopskitPlatform<\"solana\", SolanaWallet, SolanaAccount> => {\n\tconst chain = options.chain ?? DEFAULT_SOLANA_CHAIN;\n\n\tif (!isSolanaChainId(chain)) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown solana chain: ${JSON.stringify(chain)}. Valid values: \"solana:mainnet\", \"solana:devnet\", \"solana:testnet\", \"solana:localnet\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"solana\",\n\t\tgetWallets$: (ctx: PlatformContext) => getSolanaWallets$(ctx.store),\n\t\tgetAccounts$: (wallets$) => getSolanaAccounts$(wallets$, chain),\n\t};\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,uBAAsC;AAEnD,MAAM,mBAAmB;CACxB;CACA;CACA;CACA;AACD;AAEA,MAAa,mBAAmB,UAC/B,OAAO,UAAU,YAChB,iBAAuC,SAAS,KAAK;;;;;;;;;;AAWvD,MAAM,wBAAwB;CAC7B,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;AACnB;;;;;;;AAQA,MAAa,kBAAkB,UAAiC;CAC/D,MAAM,QAAS,sBACd;CAED,IAAI,CAAC,OACJ,MAAM,IAAIA,eAAAA,eACT,qBACA,iBAAiB,MAAM,oDACxB;CACD,OAAO;AACR;;;;;;;;AASA,MAAM,mCAAkE;CACvE,2CAA2C;CAC3C,2CAA2C;AAC5C;AAEA,MAAM,wBAAuD;CAC5D,GAAG,OAA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C1D,SAAS,OAAO,QAAQ,aAAa;EACpC,MAAM,UAAW,OAAO,SACvB;EAED,IAAI,CAAC,SACJ,MAAM,IAAIC,eAAAA,eACT,yBACA,UAAU,SAAS,qCACnB,EAAE,SAAS,CACZ;EAED,MAAM,QAAQ,QAAQ;CACvB;CACA,kBAAkB,UACjBC,eAAAA,uBAAuB,KAAK,KAAKC,eAAAA,iBAAiB,KAAK;CAIxD,YAAY,OAAO,WAAW;EAI7B,MAHiB,OAAO,SACvB,sBAEY,EAAE,WAAW;CAC3B;CAGA,iBAAiB,aAChBC,yBAAAA,+BAA+B,YAAY,SAAS,EAAE;CACvD,cAAc,EACb,QAAQ,QACR,UACA,QACA,OACA,aACA,SACA,kBACM;EACN,UAAU;EACV,MAAM;EACN,IAAI;EACJ,UAAU,OAAO;EACjB;EACA,QAAQ,gBAAgB,MAAM;EAC9B,MAAM,OAAO;EACb,MAAM,OAAO;EACb;EACA;EACA;EACA;EACA;CACD;AACD,CAAC;;;;;;;;;;;;AC3FF,MAAa,UACZ,UAA+B,CAAC,MAC8B;CAC9D,MAAM,QAAQ,QAAQ,SAAA;CAEtB,IAAI,CAAC,gBAAgB,KAAK,GACzB,QAAQ,KACP,qCAAqC,KAAK,UAAU,KAAK,EAAE,wFAC5D;CAGD,OAAO;EACN,UAAU;EACV,cAAc,QAAyB,kBAAkB,IAAI,KAAK;EAClE,eAAe,aAAa,mBAAmB,UAAU,KAAK;CAC/D;AACD"}
|
package/dist/solana.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { a as getWalletConnectSessionAccounts$, g as getCachedObservable$, h as clearCachedObservablesByPrefix, i as getSessionCaip10s, l as getWalletId, o as isInjectedWallet, r as getCaip10Addresses, s as isWalletConnectWallet, t as createPlatformAccounts$ } from "./platformAccounts-sy621l8C.mjs";
|
|
2
|
+
import { a as isSolanaAddress, t as getWalletAccountId } from "./WalletAccountId-6ZXQM_ed.mjs";
|
|
3
3
|
import { a as isRefusalMessage, i as isEip1193UserRejection, t as KheopskitError } from "./errors-DszTFbnO.mjs";
|
|
4
4
|
import { t as createInjectedWallets$ } from "./injectedWallets-CUo7rVqB.mjs";
|
|
5
5
|
import { Observable, of, shareReplay } from "rxjs";
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as SyncableStorage } from "./storage-D3AwNgqc.mjs";
|
|
2
|
-
import { S as WalletPlatform, a as CachedAccount, g as PolkadotAccountType, o as CachedWallet } from "./types-
|
|
3
|
-
import { n as DEFAULT_HYDRATION_TIMEOUT_MS, t as DEFAULT_HYDRATION_GRACE_PERIOD_MS } from "./config-
|
|
2
|
+
import { S as WalletPlatform, a as CachedAccount, g as PolkadotAccountType, o as CachedWallet } from "./types-BfIzw1fd.mjs";
|
|
3
|
+
import { n as DEFAULT_HYDRATION_TIMEOUT_MS, t as DEFAULT_HYDRATION_GRACE_PERIOD_MS } from "./config-rvX2pkqc.mjs";
|
|
4
4
|
import { Observable } from "rxjs";
|
|
5
5
|
//#region src/testing/cachedState.d.ts
|
|
6
6
|
type InjectedWalletId = `${WalletPlatform}:${string}`;
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as SyncableStorage } from "./storage-D3AwNgqc.js";
|
|
2
|
-
import { S as WalletPlatform, a as CachedAccount, g as PolkadotAccountType, o as CachedWallet } from "./types-
|
|
3
|
-
import { n as DEFAULT_HYDRATION_TIMEOUT_MS, t as DEFAULT_HYDRATION_GRACE_PERIOD_MS } from "./config-
|
|
2
|
+
import { S as WalletPlatform, a as CachedAccount, g as PolkadotAccountType, o as CachedWallet } from "./types-BfIzw1fd.js";
|
|
3
|
+
import { n as DEFAULT_HYDRATION_TIMEOUT_MS, t as DEFAULT_HYDRATION_GRACE_PERIOD_MS } from "./config-CubhhFON.js";
|
|
4
4
|
import { Observable } from "rxjs";
|
|
5
5
|
//#region src/testing/cachedState.d.ts
|
|
6
6
|
type InjectedWalletId = `${WalletPlatform}:${string}`;
|
|
@@ -106,6 +106,12 @@ type WalletConnectProvider = {
|
|
|
106
106
|
accounts?: string[];
|
|
107
107
|
methods?: string[];
|
|
108
108
|
}>;
|
|
109
|
+
peer?: {
|
|
110
|
+
metadata: {
|
|
111
|
+
name?: string;
|
|
112
|
+
icons?: string[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
109
115
|
};
|
|
110
116
|
client: {
|
|
111
117
|
request<T = unknown>(args: {
|
|
@@ -708,4 +714,4 @@ type CachedAccount = {
|
|
|
708
714
|
};
|
|
709
715
|
//#endregion
|
|
710
716
|
export { getWalletId as A, WalletStatus as C, KheopskitError as D, isWalletConnectWallet as E, parseWalletAccountId as F, parseWalletId as M, WalletAccountId as N, KheopskitErrorCode as O, getWalletAccountId as P, WalletPlatform as S, isInjectedWallet as T, WalletConnectMetadata as _, CachedAccount as a, WalletConnectWallet as b, KheopskitConfig as c, KheopskitStore as d, KheopskitStoreData as f, PolkadotAccountType as g, PlatformContext as h, BaseWalletAccount as i, isValidWalletId as j, WalletId as k, KheopskitPlatform as l, PlaceholderWallet as m, AppKitInstance as n, CachedWallet as o, Placeholder as p, BaseWallet as r, ConnectOptions as s, AccountOf as t, KheopskitState as u, WalletConnectPlugin as v, WalletType as w, WalletOf as x, WalletConnectProvider as y };
|
|
711
|
-
//# sourceMappingURL=types-
|
|
717
|
+
//# sourceMappingURL=types-BfIzw1fd.d.mts.map
|
|
@@ -106,6 +106,12 @@ type WalletConnectProvider = {
|
|
|
106
106
|
accounts?: string[];
|
|
107
107
|
methods?: string[];
|
|
108
108
|
}>;
|
|
109
|
+
peer?: {
|
|
110
|
+
metadata: {
|
|
111
|
+
name?: string;
|
|
112
|
+
icons?: string[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
109
115
|
};
|
|
110
116
|
client: {
|
|
111
117
|
request<T = unknown>(args: {
|
|
@@ -708,4 +714,4 @@ type CachedAccount = {
|
|
|
708
714
|
};
|
|
709
715
|
//#endregion
|
|
710
716
|
export { getWalletId as A, WalletStatus as C, KheopskitError as D, isWalletConnectWallet as E, parseWalletAccountId as F, parseWalletId as M, WalletAccountId as N, KheopskitErrorCode as O, getWalletAccountId as P, WalletPlatform as S, isInjectedWallet as T, WalletConnectMetadata as _, CachedAccount as a, WalletConnectWallet as b, KheopskitConfig as c, KheopskitStore as d, KheopskitStoreData as f, PolkadotAccountType as g, PlatformContext as h, BaseWalletAccount as i, isValidWalletId as j, WalletId as k, KheopskitPlatform as l, PlaceholderWallet as m, AppKitInstance as n, CachedWallet as o, Placeholder as p, BaseWallet as r, ConnectOptions as s, AccountOf as t, KheopskitState as u, WalletConnectPlugin as v, WalletType as w, WalletOf as x, WalletConnectProvider as y };
|
|
711
|
-
//# sourceMappingURL=types-
|
|
717
|
+
//# sourceMappingURL=types-BfIzw1fd.d.ts.map
|
package/dist/walletconnect.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, _ as WalletConnectMetadata, b as WalletConnectWallet, v as WalletConnectPlugin } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, _ as WalletConnectMetadata, b as WalletConnectWallet, v as WalletConnectPlugin } from "./types-BfIzw1fd.mjs";
|
|
2
2
|
//#region src/api/walletconnect/plugin.d.ts
|
|
3
3
|
type WalletConnectOptions = {
|
|
4
4
|
projectId: string;
|
package/dist/walletconnect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, _ as WalletConnectMetadata, b as WalletConnectWallet, v as WalletConnectPlugin } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, _ as WalletConnectMetadata, b as WalletConnectWallet, v as WalletConnectPlugin } from "./types-BfIzw1fd.js";
|
|
2
2
|
//#region src/api/walletconnect/plugin.d.ts
|
|
3
3
|
type WalletConnectOptions = {
|
|
4
4
|
projectId: string;
|
package/dist/walletconnect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_platformAccounts = require("./platformAccounts-D8XmOSvD.js");
|
|
3
3
|
const require_errors = require("./errors-B6Z21vkI.js");
|
|
4
4
|
let rxjs = require("rxjs");
|
|
5
5
|
//#region src/api/walletconnect/plugin.ts
|
|
@@ -39,7 +39,7 @@ const resetAppKitCache = () => {
|
|
|
39
39
|
* this wallet and avoids matching a sibling whose id is a string prefix.
|
|
40
40
|
*/
|
|
41
41
|
const dropAccountsCache = (platform) => {
|
|
42
|
-
|
|
42
|
+
require_platformAccounts.clearCachedObservablesByPrefix(`accounts:${require_platformAccounts.WALLET_CONNECT_WALLET_ID}:${platform}:`);
|
|
43
43
|
};
|
|
44
44
|
const namespaceOf = {
|
|
45
45
|
polkadot: "polkadot",
|
|
@@ -72,12 +72,17 @@ const createConnector$ = (appKit) => {
|
|
|
72
72
|
opening: false,
|
|
73
73
|
error: void 0
|
|
74
74
|
});
|
|
75
|
-
const
|
|
75
|
+
const liveSession = (platform) => {
|
|
76
|
+
const namespace = namespaceOf[platform];
|
|
77
|
+
const session = appKit.getProvider(namespace)?.session;
|
|
78
|
+
return session && require_platformAccounts.getSessionCaip10s(session, namespace).length > 0 ? session : void 0;
|
|
79
|
+
};
|
|
80
|
+
const syncProviders = () => {
|
|
76
81
|
status$.next({
|
|
77
82
|
...status$.value,
|
|
78
|
-
isPolkadotConnected: !!
|
|
79
|
-
isEthereumConnected: !!
|
|
80
|
-
isSolanaConnected: !!
|
|
83
|
+
isPolkadotConnected: !!liveSession("polkadot"),
|
|
84
|
+
isEthereumConnected: !!liveSession("ethereum"),
|
|
85
|
+
isSolanaConnected: !!liveSession("solana")
|
|
81
86
|
});
|
|
82
87
|
};
|
|
83
88
|
const openModal = async () => {
|
|
@@ -89,7 +94,7 @@ const createConnector$ = (appKit) => {
|
|
|
89
94
|
try {
|
|
90
95
|
await appKit.open();
|
|
91
96
|
} catch (cause) {
|
|
92
|
-
const error = require_errors.toConnectError(cause,
|
|
97
|
+
const error = require_errors.toConnectError(cause, require_platformAccounts.WALLET_CONNECT_WALLET_ID, () => false);
|
|
93
98
|
status$.next({
|
|
94
99
|
...status$.value,
|
|
95
100
|
opening: false,
|
|
@@ -120,14 +125,14 @@ const createConnector$ = (appKit) => {
|
|
|
120
125
|
}), (0, rxjs.map)(({ opening, error, ...connected }) => {
|
|
121
126
|
const platforms = enabledPlatforms.filter((p) => connected[p]);
|
|
122
127
|
const isConnected = platforms.length > 0;
|
|
123
|
-
const
|
|
128
|
+
const peer = platforms[0] && liveSession(platforms[0])?.peer?.metadata;
|
|
124
129
|
return {
|
|
125
|
-
id:
|
|
130
|
+
id: require_platformAccounts.WALLET_CONNECT_WALLET_ID,
|
|
126
131
|
type: "walletconnect",
|
|
127
132
|
platforms,
|
|
128
133
|
appKit: appKitInstance,
|
|
129
|
-
name:
|
|
130
|
-
icon:
|
|
134
|
+
name: peer?.name || "WalletConnect",
|
|
135
|
+
icon: peer?.icons?.[0] || WALLET_CONNECT_ICON,
|
|
131
136
|
connect: async () => {
|
|
132
137
|
if (!isConnected) await openModal();
|
|
133
138
|
},
|
|
@@ -141,15 +146,13 @@ const createConnector$ = (appKit) => {
|
|
|
141
146
|
}));
|
|
142
147
|
return new rxjs.Observable((subscriber) => {
|
|
143
148
|
for (const platform of allPlatforms) dropAccountsCache(platform);
|
|
144
|
-
syncProviders(
|
|
145
|
-
polkadot: appKit.getProvider("polkadot"),
|
|
146
|
-
eip155: appKit.getProvider("eip155"),
|
|
147
|
-
solana: appKit.getProvider("solana")
|
|
148
|
-
});
|
|
149
|
+
syncProviders();
|
|
149
150
|
const unsubProviders = appKit.subscribeProviders(syncProviders);
|
|
151
|
+
const sessionSub = (0, rxjs.from)(appKit.getUniversalProvider()).pipe((0, rxjs.catchError)(() => rxjs.EMPTY), (0, rxjs.switchMap)((provider) => provider ? (0, rxjs.merge)((0, rxjs.fromEvent)(provider, "session_delete"), (0, rxjs.fromEvent)(provider, "connect"), (0, rxjs.of)(void 0)) : rxjs.EMPTY)).subscribe(syncProviders);
|
|
150
152
|
const sub = wallet$.subscribe(subscriber);
|
|
151
153
|
return () => {
|
|
152
154
|
sub.unsubscribe();
|
|
155
|
+
sessionSub.unsubscribe();
|
|
153
156
|
unsubProviders();
|
|
154
157
|
};
|
|
155
158
|
});
|
|
@@ -219,7 +222,7 @@ const walletConnect = (options) => ({
|
|
|
219
222
|
getWallet$: ({ config }) => getWalletConnectWallet$(options, config.debug)
|
|
220
223
|
});
|
|
221
224
|
//#endregion
|
|
222
|
-
exports.isWalletConnectWallet =
|
|
225
|
+
exports.isWalletConnectWallet = require_platformAccounts.isWalletConnectWallet;
|
|
223
226
|
exports.resetAppKitCache = resetAppKitCache;
|
|
224
227
|
exports.walletConnect = walletConnect;
|
|
225
228
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletconnect.js","names":["WALLET_CONNECT_WALLET_ID","BehaviorSubject","toConnectError","map","distinctUntilChanged","tap","Observable","of","from","shareReplay","switchMap"],"sources":["../src/api/walletconnect/plugin.ts"],"sourcesContent":["import type { AppKit } from \"@reown/appkit/core\";\nimport {\n\tBehaviorSubject,\n\tdistinctUntilChanged,\n\tfrom,\n\tmap,\n\tObservable,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttap,\n} from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { WALLET_CONNECT_WALLET_ID } from \"../../utils/WalletId\";\nimport { type KheopskitError, toConnectError } from \"../errors\";\nimport type {\n\tAppKitInstance,\n\tWalletConnectMetadata,\n\tWalletConnectPlugin,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"../types\";\n\nexport type WalletConnectOptions = {\n\tprojectId: string;\n\tmetadata: WalletConnectMetadata;\n\t/**\n\t * Networks AppKit should enable. Pass `AppKitNetwork[]` from\n\t * `@reown/appkit/networks` (see\n\t * https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup).\n\t * Loosely typed (`unknown`) so the declarations don't depend on\n\t * `@reown/appkit`'s types; the value is forwarded to AppKit as-is.\n\t */\n\tnetworks: [unknown, ...unknown[]];\n\tthemeMode?: \"light\" | \"dark\";\n\tthemeVariables?: Record<string, string | number>;\n\t/**\n\t * Extra Reown AppKit `createAppKit` options (e.g. `featuredWalletIds`,\n\t * `features`, `allWallets`), forwarded as-is; see\n\t * https://docs.reown.com/appkit/javascript/core/options.\n\t * kheopskit sets `projectId`, `metadata`, `networks`, `themeMode`,\n\t * `themeVariables` and `universalProviderConfigOverride` itself, so those\n\t * keys are rejected here.\n\t */\n\tappKitOptions?: AppKitOptions;\n};\n\ntype KheopskitOwnedAppKitKey =\n\t| \"projectId\"\n\t| \"metadata\"\n\t| \"networks\"\n\t| \"themeMode\"\n\t| \"themeVariables\"\n\t| \"universalProviderConfigOverride\";\n\ntype AppKitOptions = Record<string, unknown> &\n\tPartial<Record<KheopskitOwnedAppKitKey, never>>;\n\n/**\n * Dynamically import @reown/appkit/core to avoid loading browser-only code\n * during SSR or in edge runtimes like Cloudflare Workers.\n * The AppKit library uses Lit for web components which requires document.\n */\nconst loadAppKit = async () => {\n\ttry {\n\t\tconst { createAppKit } = await import(\"@reown/appkit/core\");\n\t\treturn createAppKit;\n\t} catch (cause) {\n\t\tconsole.error(\n\t\t\t\"[kheopskit] WalletConnect is configured but @reown/appkit could not be loaded. \" +\n\t\t\t\t\"Install it with `pnpm add @reown/appkit` (or remove config.walletConnect). \" +\n\t\t\t\t\"WalletConnect wallets are disabled; injected wallets still work.\",\n\t\t\tcause,\n\t\t);\n\t\treturn null;\n\t}\n};\n\nconst WALLET_CONNECT_ICON =\n\t\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjQwMCIgdmlld0JveD0iMCAwIDQwMCA0MDAiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi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NS42MDg1LTIuMDg2IDcuNzQ4MSAwbDUwLjE3ODkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3Ny00OC45MzJjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMGw1MC4xNzkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3OS00OC45MzFjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+\";\n\n// Once it exists, the appKit object should never be recreated. Anchored on\n// globalThis so it stays a single instance even if this module is duplicated\n// across bundle chunks (e.g. CJS subpath entries).\nconst APPKIT_SYMBOL = Symbol.for(\"kheopskit.cachedAppKit\");\n// The projectId AppKit was first initialised with. AppKit is a process-wide\n// singleton, so a later call with a different WalletConnect config is silently\n// ignored — we keep this to warn loudly instead of letting it pass unnoticed.\nconst APPKIT_PROJECT_ID_SYMBOL = Symbol.for(\"kheopskit.cachedAppKitProjectId\");\ntype AppKitGlobal = Record<\n\tsymbol,\n\tObservable<WalletConnectWallet | null> | string | undefined\n>;\nconst getCachedAppKit = ():\n\t| Observable<WalletConnectWallet | null>\n\t| undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] as\n\t\t| Observable<WalletConnectWallet | null>\n\t\t| undefined;\nconst getCachedAppKitProjectId = (): string | undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] as\n\t\t| string\n\t\t| undefined;\nconst setCachedAppKit = (\n\tvalue: Observable<WalletConnectWallet | null> | undefined,\n\tprojectId?: string,\n): void => {\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] = value;\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] = projectId;\n};\n\n/**\n * Clears the cached AppKit observable.\n * Use when configuration changes or for testing purposes.\n * Note: This does NOT destroy the appKit instance created by Reown.\n */\nexport const resetAppKitCache = (): void => {\n\tsetCachedAppKit(undefined);\n};\n\n/**\n * Keys are `accounts:<walletId>:...`; the trailing colon scopes the prefix to\n * this wallet and avoids matching a sibling whose id is a string prefix.\n */\nconst dropAccountsCache = (platform: WalletPlatform): void => {\n\tclearCachedObservablesByPrefix(\n\t\t`accounts:${WALLET_CONNECT_WALLET_ID}:${platform}:`,\n\t);\n};\n\nconst namespaceOf: Record<WalletPlatform, string> = {\n\tpolkadot: \"polkadot\",\n\tethereum: \"eip155\",\n\tsolana: \"solana\",\n};\nconst allPlatforms: WalletPlatform[] = [\"polkadot\", \"ethereum\", \"solana\"];\n\nconst methodsByNamespace: Record<string, string[]> = {\n\tpolkadot: [\"polkadot_signTransaction\", \"polkadot_signMessage\"],\n\tsolana: [\n\t\t\"solana_signTransaction\",\n\t\t\"solana_signMessage\",\n\t\t\"solana_signAndSendTransaction\",\n\t],\n};\n\n// AppKit turns every overridden namespace into a pairing request, and rejects\n// the pairing when one of them has no chains.\nconst methodsFor = (networks: unknown[]): Record<string, string[]> => {\n\tconst namespaces = new Set(\n\t\tnetworks.map(\n\t\t\t(network) => (network as { chainNamespace?: string }).chainNamespace,\n\t\t),\n\t);\n\treturn Object.fromEntries(\n\t\tObject.entries(methodsByNamespace).filter(([namespace]) =>\n\t\t\tnamespaces.has(namespace),\n\t\t),\n\t);\n};\n\nconst createConnector$ = (appKit: AppKit): Observable<WalletConnectWallet> => {\n\t// Exposed on the wallet as the (decoupled) AppKitInstance escape hatch.\n\tconst appKitInstance = appKit as unknown as AppKitInstance;\n\n\tconst status$ = new BehaviorSubject<{\n\t\tisPolkadotConnected: boolean;\n\t\tisEthereumConnected: boolean;\n\t\tisSolanaConnected: boolean;\n\t\topening: boolean;\n\t\terror: KheopskitError | undefined;\n\t}>({\n\t\tisPolkadotConnected: false,\n\t\tisEthereumConnected: false,\n\t\tisSolanaConnected: false,\n\t\topening: false,\n\t\terror: undefined,\n\t});\n\n\tconst syncProviders = (providers: Partial<Record<string, unknown>>) => {\n\t\tstatus$.next({\n\t\t\t...status$.value,\n\t\t\tisPolkadotConnected: !!providers.polkadot,\n\t\t\tisEthereumConnected: !!providers.eip155,\n\t\t\tisSolanaConnected: !!providers.solana,\n\t\t});\n\t};\n\n\tconst openModal = async () => {\n\t\tstatus$.next({ ...status$.value, opening: true, error: undefined });\n\t\ttry {\n\t\t\tawait appKit.open();\n\t\t} catch (cause) {\n\t\t\tconst error = toConnectError(\n\t\t\t\tcause,\n\t\t\t\tWALLET_CONNECT_WALLET_ID,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tstatus$.next({ ...status$.value, opening: false, error });\n\t\t\tthrow error;\n\t\t}\n\t\tstatus$.next({ ...status$.value, opening: false });\n\t};\n\n\tconst enabledPlatforms = allPlatforms.filter((p) =>\n\t\t(appKit.chainNamespaces as string[]).includes(namespaceOf[p]),\n\t);\n\n\tlet prevConnected = {\n\t\tpolkadot: false,\n\t\tethereum: false,\n\t\tsolana: false,\n\t};\n\n\tconst wallet$ = status$.pipe(\n\t\tmap((s) => ({\n\t\t\tpolkadot: s.isPolkadotConnected,\n\t\t\tethereum: s.isEthereumConnected,\n\t\t\tsolana: s.isSolanaConnected,\n\t\t\topening: s.opening,\n\t\t\terror: s.error,\n\t\t})),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\ta.polkadot === b.polkadot &&\n\t\t\t\ta.ethereum === b.ethereum &&\n\t\t\t\ta.solana === b.solana &&\n\t\t\t\ta.opening === b.opening &&\n\t\t\t\ta.error === b.error,\n\t\t),\n\t\ttap((connected) => {\n\t\t\t// Drop caches for namespaces that just went disconnected.\n\t\t\tfor (const platform of allPlatforms)\n\t\t\t\tif (prevConnected[platform] && !connected[platform])\n\t\t\t\t\tdropAccountsCache(platform);\n\t\t\tprevConnected = connected;\n\t\t}),\n\t\tmap(({ opening, error, ...connected }): WalletConnectWallet => {\n\t\t\tconst platforms = enabledPlatforms.filter((p) => connected[p]);\n\t\t\tconst isConnected = platforms.length > 0;\n\t\t\tconst walletInfo = appKit.getWalletInfo();\n\t\t\treturn {\n\t\t\t\tid: WALLET_CONNECT_WALLET_ID,\n\t\t\t\ttype: \"walletconnect\",\n\t\t\t\tplatforms,\n\t\t\t\tappKit: appKitInstance,\n\t\t\t\tname: walletInfo?.name || \"WalletConnect\",\n\t\t\t\ticon: walletInfo?.icon || WALLET_CONNECT_ICON,\n\t\t\t\t// One shared session: connecting opens the modal; the wallet\n\t\t\t\t// approves namespaces in that single pairing. Disconnect is\n\t\t\t\t// session-wide; re-pair to change the approved set.\n\t\t\t\tconnect: async () => {\n\t\t\t\t\tif (!isConnected) await openModal();\n\t\t\t\t},\n\t\t\t\tdisconnect: async () => {\n\t\t\t\t\tif (isConnected) await appKit.disconnect();\n\t\t\t\t},\n\t\t\t\tstatus: isConnected\n\t\t\t\t\t? \"connected\"\n\t\t\t\t\t: opening\n\t\t\t\t\t\t? \"connecting\"\n\t\t\t\t\t\t: \"disconnected\",\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn new Observable<WalletConnectWallet>((subscriber) => {\n\t\tfor (const platform of allPlatforms) dropAccountsCache(platform);\n\t\t// AppKit's subscribeProviders only reports later changes, so read the\n\t\t// state that may have changed while nobody observed.\n\t\tsyncProviders({\n\t\t\tpolkadot: appKit.getProvider(\"polkadot\"),\n\t\t\teip155: appKit.getProvider(\"eip155\"),\n\t\t\tsolana: appKit.getProvider(\"solana\"),\n\t\t});\n\t\tconst unsubProviders = appKit.subscribeProviders(syncProviders);\n\t\tconst sub = wallet$.subscribe(subscriber);\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tunsubProviders();\n\t\t};\n\t});\n};\n\n/**\n * @remarks\n * The AppKit instance is a process-wide singleton: a second instance would\n * share AppKit's module-level controller state with the first, so it is\n * created once. The **first** call with a `walletConnect` config wins;\n * later calls with a *different* `walletConnect` config reuse that first\n * instance. Call {@link resetAppKitCache} before re-initialising if the\n * WalletConnect config must change.\n *\n * One WalletConnect session is shared across every namespace, and a namespace\n * can only be established during the initial pairing — it can't be added to a\n * live session afterwards. So this exposes ONE connector (not one per platform):\n * `connect()` opens the modal; the wallet approves whichever namespaces it\n * supports in that single pairing, and `platforms` reflects what the live\n * session carries. Per-namespace accounts are derived by each platform plugin.\n */\nconst getWalletConnectWallet$ = (\n\twalletConnect: WalletConnectOptions,\n\tdebug: boolean,\n): Observable<WalletConnectWallet | null> => {\n\t// SSR guard - don't try to load AppKit on the server\n\tif (typeof window === \"undefined\") return of(null);\n\n\tconst cachedProjectId = getCachedAppKitProjectId();\n\tif (\n\t\tcachedProjectId !== undefined &&\n\t\tcachedProjectId !== walletConnect.projectId\n\t) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] WalletConnect is already initialised with projectId %s; \" +\n\t\t\t\t\"AppKit is a process-wide singleton, so the first configuration wins and \" +\n\t\t\t\t\"projectId %s is ignored. Call resetAppKitCache() before re-initialising \" +\n\t\t\t\t\"if the WalletConnect config must change.\",\n\t\t\tcachedProjectId,\n\t\t\twalletConnect.projectId,\n\t\t);\n\t}\n\n\tlet cachedAppKit = getCachedAppKit();\n\tif (!cachedAppKit) {\n\t\t// Dynamic import avoids loading @reown/appkit at module-eval time (SSR /\n\t\t// edge runtimes like Cloudflare Workers).\n\t\tconst connectorOnce$ = from(loadAppKit()).pipe(\n\t\t\tmap((createAppKit) =>\n\t\t\t\t// @reown/appkit missing (optional peer dep) — degrade gracefully.\n\t\t\t\tcreateAppKit\n\t\t\t\t\t? createConnector$(\n\t\t\t\t\t\t\tcreateAppKit({\n\t\t\t\t\t\t\t\tallWallets: \"HIDE\",\n\t\t\t\t\t\t\t\tdebug,\n\t\t\t\t\t\t\t\tallowUnsupportedChain: true,\n\t\t\t\t\t\t\t\t...walletConnect.appKitOptions,\n\t\t\t\t\t\t\t\tprojectId: walletConnect.projectId,\n\t\t\t\t\t\t\t\tmetadata: walletConnect.metadata,\n\t\t\t\t\t\t\t\tnetworks: walletConnect.networks as never,\n\t\t\t\t\t\t\t\tthemeMode: walletConnect.themeMode,\n\t\t\t\t\t\t\t\tthemeVariables: walletConnect.themeVariables as never,\n\t\t\t\t\t\t\t\tuniversalProviderConfigOverride: {\n\t\t\t\t\t\t\t\t\tmethods: methodsFor(walletConnect.networks),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: null,\n\t\t\t),\n\t\t\tshareReplay({ refCount: false, bufferSize: 1 }),\n\t\t);\n\t\tcachedAppKit = connectorOnce$.pipe(\n\t\t\tswitchMap((wallet$) => wallet$ ?? of(null)),\n\t\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t\t);\n\t\tsetCachedAppKit(cachedAppKit, walletConnect.projectId);\n\t}\n\n\treturn cachedAppKit;\n};\n\n/**\n * The WalletConnect plugin for `config.walletConnect`. Importing this entry is\n * what brings Reown AppKit into a dapp's bundle; a dapp that never imports it\n * ships none of it.\n *\n * @example\n * ```ts\n * import { walletConnect } from \"@kheopskit/core/walletconnect\";\n *\n * createKheopskit({\n * platforms: [polkadot()],\n * walletConnect: walletConnect({ projectId, metadata, networks }),\n * });\n * ```\n */\nexport const walletConnect = (\n\toptions: WalletConnectOptions,\n): WalletConnectPlugin => ({\n\ttype: \"walletconnect\",\n\tmetadata: options.metadata,\n\tgetWallet$: ({ config }) => getWalletConnectWallet$(options, config.debug),\n});\n"],"mappings":";;;;;;;;;;AA+DA,MAAM,aAAa,YAAY;CAC9B,IAAI;EACH,MAAM,EAAE,iBAAiB,MAAM,OAAO;EACtC,OAAO;CACR,SAAS,OAAO;EACf,QAAQ,MACP,8NAGA,KACD;EACA,OAAO;CACR;AACD;AAEA,MAAM,sBACL;AAKD,MAAM,gBAAgB,OAAO,IAAI,wBAAwB;AAIzD,MAAM,2BAA2B,OAAO,IAAI,iCAAiC;AAK7E,MAAM,wBAGJ,WAAuC;AAGzC,MAAM,iCACJ,WAAuC;AAG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Ac,SAAS;CACtD;CAEA,OAAO;AACR;;;;;;;;;;;;;;;;AAiBA,MAAa,iBACZ,aAC0B;CAC1B,MAAM;CACN,UAAU,QAAQ;CAClB,aAAa,EAAE,aAAa,wBAAwB,SAAS,OAAO,KAAK;AAC1E"}
|
|
1
|
+
{"version":3,"file":"walletconnect.js","names":["WALLET_CONNECT_WALLET_ID","BehaviorSubject","getSessionCaip10s","toConnectError","map","distinctUntilChanged","tap","Observable","from","catchError","EMPTY","switchMap","merge","fromEvent","of","shareReplay"],"sources":["../src/api/walletconnect/plugin.ts"],"sourcesContent":["import type { AppKit } from \"@reown/appkit/core\";\nimport {\n\tBehaviorSubject,\n\tcatchError,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttap,\n} from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { WALLET_CONNECT_WALLET_ID } from \"../../utils/WalletId\";\nimport { type KheopskitError, toConnectError } from \"../errors\";\nimport { getSessionCaip10s } from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tWalletConnectMetadata,\n\tWalletConnectPlugin,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"../types\";\n\nexport type WalletConnectOptions = {\n\tprojectId: string;\n\tmetadata: WalletConnectMetadata;\n\t/**\n\t * Networks AppKit should enable. Pass `AppKitNetwork[]` from\n\t * `@reown/appkit/networks` (see\n\t * https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup).\n\t * Loosely typed (`unknown`) so the declarations don't depend on\n\t * `@reown/appkit`'s types; the value is forwarded to AppKit as-is.\n\t */\n\tnetworks: [unknown, ...unknown[]];\n\tthemeMode?: \"light\" | \"dark\";\n\tthemeVariables?: Record<string, string | number>;\n\t/**\n\t * Extra Reown AppKit `createAppKit` options (e.g. `featuredWalletIds`,\n\t * `features`, `allWallets`), forwarded as-is; see\n\t * https://docs.reown.com/appkit/javascript/core/options.\n\t * kheopskit sets `projectId`, `metadata`, `networks`, `themeMode`,\n\t * `themeVariables` and `universalProviderConfigOverride` itself, so those\n\t * keys are rejected here.\n\t */\n\tappKitOptions?: AppKitOptions;\n};\n\ntype KheopskitOwnedAppKitKey =\n\t| \"projectId\"\n\t| \"metadata\"\n\t| \"networks\"\n\t| \"themeMode\"\n\t| \"themeVariables\"\n\t| \"universalProviderConfigOverride\";\n\ntype AppKitOptions = Record<string, unknown> &\n\tPartial<Record<KheopskitOwnedAppKitKey, never>>;\n\n/**\n * Dynamically import @reown/appkit/core to avoid loading browser-only code\n * during SSR or in edge runtimes like Cloudflare Workers.\n * The AppKit library uses Lit for web components which requires document.\n */\nconst loadAppKit = async () => {\n\ttry {\n\t\tconst { createAppKit } = await import(\"@reown/appkit/core\");\n\t\treturn createAppKit;\n\t} catch (cause) {\n\t\tconsole.error(\n\t\t\t\"[kheopskit] WalletConnect is configured but @reown/appkit could not be loaded. \" +\n\t\t\t\t\"Install it with `pnpm add @reown/appkit` (or remove config.walletConnect). \" +\n\t\t\t\t\"WalletConnect wallets are disabled; injected wallets still work.\",\n\t\t\tcause,\n\t\t);\n\t\treturn null;\n\t}\n};\n\nconst WALLET_CONNECT_ICON =\n\t\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjQwMCIgdmlld0JveD0iMCAwIDQwMCA0MDAiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxjbGlwUGF0aCBpZD0iYSI+PHBhdGggZD0ibTAgMGg0MDB2NDAwaC00MDB6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjYSkiPjxjaXJjbGUgY3g9IjIwMCIgY3k9IjIw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cgNS42MDgtMi4wODcgNy43NDggMHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+\";\n\n// Once it exists, the appKit object should never be recreated. Anchored on\n// globalThis so it stays a single instance even if this module is duplicated\n// across bundle chunks (e.g. CJS subpath entries).\nconst APPKIT_SYMBOL = Symbol.for(\"kheopskit.cachedAppKit\");\n// The projectId AppKit was first initialised with. AppKit is a process-wide\n// singleton, so a later call with a different WalletConnect config is silently\n// ignored — we keep this to warn loudly instead of letting it pass unnoticed.\nconst APPKIT_PROJECT_ID_SYMBOL = Symbol.for(\"kheopskit.cachedAppKitProjectId\");\ntype AppKitGlobal = Record<\n\tsymbol,\n\tObservable<WalletConnectWallet | null> | string | undefined\n>;\nconst getCachedAppKit = ():\n\t| Observable<WalletConnectWallet | null>\n\t| undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] as\n\t\t| Observable<WalletConnectWallet | null>\n\t\t| undefined;\nconst getCachedAppKitProjectId = (): string | undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] as\n\t\t| string\n\t\t| undefined;\nconst setCachedAppKit = (\n\tvalue: Observable<WalletConnectWallet | null> | undefined,\n\tprojectId?: string,\n): void => {\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] = value;\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] = projectId;\n};\n\n/**\n * Clears the cached AppKit observable.\n * Use when configuration changes or for testing purposes.\n * Note: This does NOT destroy the appKit instance created by Reown.\n */\nexport const resetAppKitCache = (): void => {\n\tsetCachedAppKit(undefined);\n};\n\n/**\n * Keys are `accounts:<walletId>:...`; the trailing colon scopes the prefix to\n * this wallet and avoids matching a sibling whose id is a string prefix.\n */\nconst dropAccountsCache = (platform: WalletPlatform): void => {\n\tclearCachedObservablesByPrefix(\n\t\t`accounts:${WALLET_CONNECT_WALLET_ID}:${platform}:`,\n\t);\n};\n\nconst namespaceOf = {\n\tpolkadot: \"polkadot\",\n\tethereum: \"eip155\",\n\tsolana: \"solana\",\n} as const satisfies Record<WalletPlatform, string>;\nconst allPlatforms: WalletPlatform[] = [\"polkadot\", \"ethereum\", \"solana\"];\n\nconst methodsByNamespace: Record<string, string[]> = {\n\tpolkadot: [\"polkadot_signTransaction\", \"polkadot_signMessage\"],\n\tsolana: [\n\t\t\"solana_signTransaction\",\n\t\t\"solana_signMessage\",\n\t\t\"solana_signAndSendTransaction\",\n\t],\n};\n\n// AppKit turns every overridden namespace into a pairing request, and rejects\n// the pairing when one of them has no chains.\nconst methodsFor = (networks: unknown[]): Record<string, string[]> => {\n\tconst namespaces = new Set(\n\t\tnetworks.map(\n\t\t\t(network) => (network as { chainNamespace?: string }).chainNamespace,\n\t\t),\n\t);\n\treturn Object.fromEntries(\n\t\tObject.entries(methodsByNamespace).filter(([namespace]) =>\n\t\t\tnamespaces.has(namespace),\n\t\t),\n\t);\n};\n\nconst createConnector$ = (appKit: AppKit): Observable<WalletConnectWallet> => {\n\t// Exposed on the wallet as the (decoupled) AppKitInstance escape hatch.\n\tconst appKitInstance = appKit as unknown as AppKitInstance;\n\n\tconst status$ = new BehaviorSubject<{\n\t\tisPolkadotConnected: boolean;\n\t\tisEthereumConnected: boolean;\n\t\tisSolanaConnected: boolean;\n\t\topening: boolean;\n\t\terror: KheopskitError | undefined;\n\t}>({\n\t\tisPolkadotConnected: false,\n\t\tisEthereumConnected: false,\n\t\tisSolanaConnected: false,\n\t\topening: false,\n\t\terror: undefined,\n\t});\n\n\tconst liveSession = (platform: WalletPlatform) => {\n\t\tconst namespace = namespaceOf[platform];\n\t\tconst session =\n\t\t\tappKit.getProvider<WalletConnectProvider>(namespace)?.session;\n\t\treturn session && getSessionCaip10s(session, namespace).length > 0\n\t\t\t? session\n\t\t\t: undefined;\n\t};\n\n\tconst syncProviders = () => {\n\t\tstatus$.next({\n\t\t\t...status$.value,\n\t\t\tisPolkadotConnected: !!liveSession(\"polkadot\"),\n\t\t\tisEthereumConnected: !!liveSession(\"ethereum\"),\n\t\t\tisSolanaConnected: !!liveSession(\"solana\"),\n\t\t});\n\t};\n\n\tconst openModal = async () => {\n\t\tstatus$.next({ ...status$.value, opening: true, error: undefined });\n\t\ttry {\n\t\t\tawait appKit.open();\n\t\t} catch (cause) {\n\t\t\tconst error = toConnectError(\n\t\t\t\tcause,\n\t\t\t\tWALLET_CONNECT_WALLET_ID,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tstatus$.next({ ...status$.value, opening: false, error });\n\t\t\tthrow error;\n\t\t}\n\t\tstatus$.next({ ...status$.value, opening: false });\n\t};\n\n\tconst enabledPlatforms = allPlatforms.filter((p) =>\n\t\t(appKit.chainNamespaces as string[]).includes(namespaceOf[p]),\n\t);\n\n\tlet prevConnected = {\n\t\tpolkadot: false,\n\t\tethereum: false,\n\t\tsolana: false,\n\t};\n\n\tconst wallet$ = status$.pipe(\n\t\tmap((s) => ({\n\t\t\tpolkadot: s.isPolkadotConnected,\n\t\t\tethereum: s.isEthereumConnected,\n\t\t\tsolana: s.isSolanaConnected,\n\t\t\topening: s.opening,\n\t\t\terror: s.error,\n\t\t})),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\ta.polkadot === b.polkadot &&\n\t\t\t\ta.ethereum === b.ethereum &&\n\t\t\t\ta.solana === b.solana &&\n\t\t\t\ta.opening === b.opening &&\n\t\t\t\ta.error === b.error,\n\t\t),\n\t\ttap((connected) => {\n\t\t\t// Drop caches for namespaces that just went disconnected.\n\t\t\tfor (const platform of allPlatforms)\n\t\t\t\tif (prevConnected[platform] && !connected[platform])\n\t\t\t\t\tdropAccountsCache(platform);\n\t\t\tprevConnected = connected;\n\t\t}),\n\t\tmap(({ opening, error, ...connected }): WalletConnectWallet => {\n\t\t\tconst platforms = enabledPlatforms.filter((p) => connected[p]);\n\t\t\tconst isConnected = platforms.length > 0;\n\t\t\tconst peer = platforms[0] && liveSession(platforms[0])?.peer?.metadata;\n\t\t\treturn {\n\t\t\t\tid: WALLET_CONNECT_WALLET_ID,\n\t\t\t\ttype: \"walletconnect\",\n\t\t\t\tplatforms,\n\t\t\t\tappKit: appKitInstance,\n\t\t\t\tname: peer?.name || \"WalletConnect\",\n\t\t\t\ticon: peer?.icons?.[0] || WALLET_CONNECT_ICON,\n\t\t\t\t// One shared session: connecting opens the modal; the wallet\n\t\t\t\t// approves namespaces in that single pairing. Disconnect is\n\t\t\t\t// session-wide; re-pair to change the approved set.\n\t\t\t\tconnect: async () => {\n\t\t\t\t\tif (!isConnected) await openModal();\n\t\t\t\t},\n\t\t\t\tdisconnect: async () => {\n\t\t\t\t\tif (isConnected) await appKit.disconnect();\n\t\t\t\t},\n\t\t\t\tstatus: isConnected\n\t\t\t\t\t? \"connected\"\n\t\t\t\t\t: opening\n\t\t\t\t\t\t? \"connecting\"\n\t\t\t\t\t\t: \"disconnected\",\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn new Observable<WalletConnectWallet>((subscriber) => {\n\t\tfor (const platform of allPlatforms) dropAccountsCache(platform);\n\t\t// AppKit's subscribeProviders only reports later changes, so read the\n\t\t// state that may have changed while nobody observed.\n\t\tsyncProviders();\n\t\tconst unsubProviders = appKit.subscribeProviders(syncProviders);\n\t\t// AppKit keeps a namespace's provider registered when the wallet ends the\n\t\t// session, and registers that same object again on the next pairing, so\n\t\t// subscribeProviders reports neither.\n\t\tconst sessionSub = from(appKit.getUniversalProvider())\n\t\t\t.pipe(\n\t\t\t\tcatchError(() => EMPTY),\n\t\t\t\tswitchMap((provider) =>\n\t\t\t\t\tprovider\n\t\t\t\t\t\t? merge(\n\t\t\t\t\t\t\t\tfromEvent(provider, \"session_delete\"),\n\t\t\t\t\t\t\t\tfromEvent(provider, \"connect\"),\n\t\t\t\t\t\t\t\tof(undefined),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: EMPTY,\n\t\t\t\t),\n\t\t\t)\n\t\t\t.subscribe(syncProviders);\n\t\tconst sub = wallet$.subscribe(subscriber);\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tsessionSub.unsubscribe();\n\t\t\tunsubProviders();\n\t\t};\n\t});\n};\n\n/**\n * @remarks\n * The AppKit instance is a process-wide singleton: a second instance would\n * share AppKit's module-level controller state with the first, so it is\n * created once. The **first** call with a `walletConnect` config wins;\n * later calls with a *different* `walletConnect` config reuse that first\n * instance. Call {@link resetAppKitCache} before re-initialising if the\n * WalletConnect config must change.\n *\n * One WalletConnect session is shared across every namespace, and a namespace\n * can only be established during the initial pairing — it can't be added to a\n * live session afterwards. So this exposes ONE connector (not one per platform):\n * `connect()` opens the modal; the wallet approves whichever namespaces it\n * supports in that single pairing, and `platforms` reflects what the live\n * session carries. Per-namespace accounts are derived by each platform plugin.\n */\nconst getWalletConnectWallet$ = (\n\twalletConnect: WalletConnectOptions,\n\tdebug: boolean,\n): Observable<WalletConnectWallet | null> => {\n\t// SSR guard - don't try to load AppKit on the server\n\tif (typeof window === \"undefined\") return of(null);\n\n\tconst cachedProjectId = getCachedAppKitProjectId();\n\tif (\n\t\tcachedProjectId !== undefined &&\n\t\tcachedProjectId !== walletConnect.projectId\n\t) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] WalletConnect is already initialised with projectId %s; \" +\n\t\t\t\t\"AppKit is a process-wide singleton, so the first configuration wins and \" +\n\t\t\t\t\"projectId %s is ignored. Call resetAppKitCache() before re-initialising \" +\n\t\t\t\t\"if the WalletConnect config must change.\",\n\t\t\tcachedProjectId,\n\t\t\twalletConnect.projectId,\n\t\t);\n\t}\n\n\tlet cachedAppKit = getCachedAppKit();\n\tif (!cachedAppKit) {\n\t\t// Dynamic import avoids loading @reown/appkit at module-eval time (SSR /\n\t\t// edge runtimes like Cloudflare Workers).\n\t\tconst connectorOnce$ = from(loadAppKit()).pipe(\n\t\t\tmap((createAppKit) =>\n\t\t\t\t// @reown/appkit missing (optional peer dep) — degrade gracefully.\n\t\t\t\tcreateAppKit\n\t\t\t\t\t? createConnector$(\n\t\t\t\t\t\t\tcreateAppKit({\n\t\t\t\t\t\t\t\tallWallets: \"HIDE\",\n\t\t\t\t\t\t\t\tdebug,\n\t\t\t\t\t\t\t\tallowUnsupportedChain: true,\n\t\t\t\t\t\t\t\t...walletConnect.appKitOptions,\n\t\t\t\t\t\t\t\tprojectId: walletConnect.projectId,\n\t\t\t\t\t\t\t\tmetadata: walletConnect.metadata,\n\t\t\t\t\t\t\t\tnetworks: walletConnect.networks as never,\n\t\t\t\t\t\t\t\tthemeMode: walletConnect.themeMode,\n\t\t\t\t\t\t\t\tthemeVariables: walletConnect.themeVariables as never,\n\t\t\t\t\t\t\t\tuniversalProviderConfigOverride: {\n\t\t\t\t\t\t\t\t\tmethods: methodsFor(walletConnect.networks),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: null,\n\t\t\t),\n\t\t\tshareReplay({ refCount: false, bufferSize: 1 }),\n\t\t);\n\t\tcachedAppKit = connectorOnce$.pipe(\n\t\t\tswitchMap((wallet$) => wallet$ ?? of(null)),\n\t\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t\t);\n\t\tsetCachedAppKit(cachedAppKit, walletConnect.projectId);\n\t}\n\n\treturn cachedAppKit;\n};\n\n/**\n * The WalletConnect plugin for `config.walletConnect`. Importing this entry is\n * what brings Reown AppKit into a dapp's bundle; a dapp that never imports it\n * ships none of it.\n *\n * @example\n * ```ts\n * import { walletConnect } from \"@kheopskit/core/walletconnect\";\n *\n * createKheopskit({\n * platforms: [polkadot()],\n * walletConnect: walletConnect({ projectId, metadata, networks }),\n * });\n * ```\n */\nexport const walletConnect = (\n\toptions: WalletConnectOptions,\n): WalletConnectPlugin => ({\n\ttype: \"walletconnect\",\n\tmetadata: options.metadata,\n\tgetWallet$: ({ config }) => getWalletConnectWallet$(options, config.debug),\n});\n"],"mappings":";;;;;;;;;;AAqEA,MAAM,aAAa,YA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AW,aAAa,QAAA,GAAOI,KAAAA,GAAAA,CAAG,IAAI;CAEjD,MAAM,kBAAkB,yBAAyB;CACjD,IACC,oBAAoB,KAAA,KACpB,oBAAoB,cAAc,WAElC,QAAQ,KACP,gQAIA,iBACA,cAAc,SACf;CAGD,IAAI,eAAe,gBAAgB;CACnC,IAAI,CAAC,cAAc;EA2BlB,gBAAA,GAxBuBN,KAAAA,KAAAA,CAAK,WAAW,CAAC,CAAC,CAAC,MAAA,GACzCJ,KAAAA,IAAAA,EAAK,iBAEJ,eACG,iBACA,aAAa;GACZ,YAAY;GACZ;GACA,uBAAuB;GACvB,GAAG,cAAc;GACjB,WAAW,cAAc;GACzB,UAAU,cAAc;GACxB,UAAU,cAAc;GACxB,WAAW,cAAc;GACzB,gBAAgB,cAAc;GAC9B,iCAAiC,EAChC,SAAS,WAAW,cAAc,QAAQ,EAC3C;EACD,CAAC,CACF,IACC,IACJ,IAAA,GACAW,KAAAA,YAAAA,CAAY;GAAE,UAAU;GAAO,YAAY;EAAE,CAAC,CAEnB,CAAC,CAAC,MAAA,GAC7BJ,KAAAA,UAAAA,EAAW,YAAY,YAAA,GAAWG,KAAAA,GAAAA,CAAG,IAAI,CAAC,IAAA,GAC1CC,KAAAA,YAAAA,CAAY;GAAE,UAAU;GAAM,YAAY;EAAE,CAAC,CAC9C;EACA,gBAAgB,cAAc,cAAc,SAAS;CACtD;CAEA,OAAO;AACR;;;;;;;;;;;;;;;;AAiBA,MAAa,iBACZ,aAC0B;CAC1B,MAAM;CACN,UAAU,QAAQ;CAClB,aAAa,EAAE,aAAa,wBAAwB,SAAS,OAAO,KAAK;AAC1E"}
|
package/dist/walletconnect.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as WALLET_CONNECT_WALLET_ID, h as clearCachedObservablesByPrefix, i as getSessionCaip10s, s as isWalletConnectWallet } from "./platformAccounts-sy621l8C.mjs";
|
|
2
2
|
import { o as toConnectError } from "./errors-DszTFbnO.mjs";
|
|
3
|
-
import { BehaviorSubject, Observable, distinctUntilChanged, from, map, of, shareReplay, switchMap, tap } from "rxjs";
|
|
3
|
+
import { BehaviorSubject, EMPTY, Observable, catchError, distinctUntilChanged, from, fromEvent, map, merge, of, shareReplay, switchMap, tap } from "rxjs";
|
|
4
4
|
//#region src/api/walletconnect/plugin.ts
|
|
5
5
|
/**
|
|
6
6
|
* Dynamically import @reown/appkit/core to avoid loading browser-only code
|
|
@@ -71,12 +71,17 @@ const createConnector$ = (appKit) => {
|
|
|
71
71
|
opening: false,
|
|
72
72
|
error: void 0
|
|
73
73
|
});
|
|
74
|
-
const
|
|
74
|
+
const liveSession = (platform) => {
|
|
75
|
+
const namespace = namespaceOf[platform];
|
|
76
|
+
const session = appKit.getProvider(namespace)?.session;
|
|
77
|
+
return session && getSessionCaip10s(session, namespace).length > 0 ? session : void 0;
|
|
78
|
+
};
|
|
79
|
+
const syncProviders = () => {
|
|
75
80
|
status$.next({
|
|
76
81
|
...status$.value,
|
|
77
|
-
isPolkadotConnected: !!
|
|
78
|
-
isEthereumConnected: !!
|
|
79
|
-
isSolanaConnected: !!
|
|
82
|
+
isPolkadotConnected: !!liveSession("polkadot"),
|
|
83
|
+
isEthereumConnected: !!liveSession("ethereum"),
|
|
84
|
+
isSolanaConnected: !!liveSession("solana")
|
|
80
85
|
});
|
|
81
86
|
};
|
|
82
87
|
const openModal = async () => {
|
|
@@ -119,14 +124,14 @@ const createConnector$ = (appKit) => {
|
|
|
119
124
|
}), map(({ opening, error, ...connected }) => {
|
|
120
125
|
const platforms = enabledPlatforms.filter((p) => connected[p]);
|
|
121
126
|
const isConnected = platforms.length > 0;
|
|
122
|
-
const
|
|
127
|
+
const peer = platforms[0] && liveSession(platforms[0])?.peer?.metadata;
|
|
123
128
|
return {
|
|
124
129
|
id: WALLET_CONNECT_WALLET_ID,
|
|
125
130
|
type: "walletconnect",
|
|
126
131
|
platforms,
|
|
127
132
|
appKit: appKitInstance,
|
|
128
|
-
name:
|
|
129
|
-
icon:
|
|
133
|
+
name: peer?.name || "WalletConnect",
|
|
134
|
+
icon: peer?.icons?.[0] || WALLET_CONNECT_ICON,
|
|
130
135
|
connect: async () => {
|
|
131
136
|
if (!isConnected) await openModal();
|
|
132
137
|
},
|
|
@@ -140,15 +145,13 @@ const createConnector$ = (appKit) => {
|
|
|
140
145
|
}));
|
|
141
146
|
return new Observable((subscriber) => {
|
|
142
147
|
for (const platform of allPlatforms) dropAccountsCache(platform);
|
|
143
|
-
syncProviders(
|
|
144
|
-
polkadot: appKit.getProvider("polkadot"),
|
|
145
|
-
eip155: appKit.getProvider("eip155"),
|
|
146
|
-
solana: appKit.getProvider("solana")
|
|
147
|
-
});
|
|
148
|
+
syncProviders();
|
|
148
149
|
const unsubProviders = appKit.subscribeProviders(syncProviders);
|
|
150
|
+
const sessionSub = from(appKit.getUniversalProvider()).pipe(catchError(() => EMPTY), switchMap((provider) => provider ? merge(fromEvent(provider, "session_delete"), fromEvent(provider, "connect"), of(void 0)) : EMPTY)).subscribe(syncProviders);
|
|
149
151
|
const sub = wallet$.subscribe(subscriber);
|
|
150
152
|
return () => {
|
|
151
153
|
sub.unsubscribe();
|
|
154
|
+
sessionSub.unsubscribe();
|
|
152
155
|
unsubProviders();
|
|
153
156
|
};
|
|
154
157
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletconnect.mjs","names":[],"sources":["../src/api/walletconnect/plugin.ts"],"sourcesContent":["import type { AppKit } from \"@reown/appkit/core\";\nimport {\n\tBehaviorSubject,\n\tdistinctUntilChanged,\n\tfrom,\n\tmap,\n\tObservable,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttap,\n} from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { WALLET_CONNECT_WALLET_ID } from \"../../utils/WalletId\";\nimport { type KheopskitError, toConnectError } from \"../errors\";\nimport type {\n\tAppKitInstance,\n\tWalletConnectMetadata,\n\tWalletConnectPlugin,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"../types\";\n\nexport type WalletConnectOptions = {\n\tprojectId: string;\n\tmetadata: WalletConnectMetadata;\n\t/**\n\t * Networks AppKit should enable. Pass `AppKitNetwork[]` from\n\t * `@reown/appkit/networks` (see\n\t * https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup).\n\t * Loosely typed (`unknown`) so the declarations don't depend on\n\t * `@reown/appkit`'s types; the value is forwarded to AppKit as-is.\n\t */\n\tnetworks: [unknown, ...unknown[]];\n\tthemeMode?: \"light\" | \"dark\";\n\tthemeVariables?: Record<string, string | number>;\n\t/**\n\t * Extra Reown AppKit `createAppKit` options (e.g. `featuredWalletIds`,\n\t * `features`, `allWallets`), forwarded as-is; see\n\t * https://docs.reown.com/appkit/javascript/core/options.\n\t * kheopskit sets `projectId`, `metadata`, `networks`, `themeMode`,\n\t * `themeVariables` and `universalProviderConfigOverride` itself, so those\n\t * keys are rejected here.\n\t */\n\tappKitOptions?: AppKitOptions;\n};\n\ntype KheopskitOwnedAppKitKey =\n\t| \"projectId\"\n\t| \"metadata\"\n\t| \"networks\"\n\t| \"themeMode\"\n\t| \"themeVariables\"\n\t| \"universalProviderConfigOverride\";\n\ntype AppKitOptions = Record<string, unknown> &\n\tPartial<Record<KheopskitOwnedAppKitKey, never>>;\n\n/**\n * Dynamically import @reown/appkit/core to avoid loading browser-only code\n * during SSR or in edge runtimes like Cloudflare Workers.\n * The AppKit library uses Lit for web components which requires document.\n */\nconst loadAppKit = async () => {\n\ttry {\n\t\tconst { createAppKit } = await import(\"@reown/appkit/core\");\n\t\treturn createAppKit;\n\t} catch (cause) {\n\t\tconsole.error(\n\t\t\t\"[kheopskit] WalletConnect is configured but @reown/appkit could not be loaded. \" +\n\t\t\t\t\"Install it with `pnpm add @reown/appkit` (or remove config.walletConnect). \" +\n\t\t\t\t\"WalletConnect wallets are disabled; injected wallets still work.\",\n\t\t\tcause,\n\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jE3OCA0OC45MzFjLTIuMTM5IDIuMDg3LTUuNjA4IDIuMDg3LTcuNzQ4IDBsLTcwLjcwMTUtNjguOTQ1Yy0yLjEzOTYtMi4wODYtMi4xMzk2LTUuNDY5IDAtNy41NTVsMTUuNjc5NS0xNS4yOWMyLjEzOTYtMi4wODYgNS42MDg1LTIuMDg2IDcuNzQ4MSAwbDUwLjE3ODkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3Ny00OC45MzJjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMGw1MC4xNzkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3OS00OC45MzFjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+\";\n\n// Once it exists, the appKit object should never be recreated. Anchored on\n// globalThis so it stays a single instance even if this module is duplicated\n// across bundle chunks (e.g. CJS subpath entries).\nconst APPKIT_SYMBOL = Symbol.for(\"kheopskit.cachedAppKit\");\n// The projectId AppKit was first initialised with. AppKit is a process-wide\n// singleton, so a later call with a different WalletConnect config is silently\n// ignored — we keep this to warn loudly instead of letting it pass unnoticed.\nconst APPKIT_PROJECT_ID_SYMBOL = Symbol.for(\"kheopskit.cachedAppKitProjectId\");\ntype AppKitGlobal = Record<\n\tsymbol,\n\tObservable<WalletConnectWallet | null> | string | undefined\n>;\nconst getCachedAppKit = ():\n\t| Observable<WalletConnectWallet | null>\n\t| undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] as\n\t\t| Observable<WalletConnectWallet | null>\n\t\t| undefined;\nconst getCachedAppKitProjectId = (): string | undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] as\n\t\t| string\n\t\t| undefined;\nconst setCachedAppKit = (\n\tvalue: Observable<WalletConnectWallet | null> | undefined,\n\tprojectId?: string,\n): void => {\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] = value;\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] = projectId;\n};\n\n/**\n * Clears the cached AppKit observable.\n * Use when configuration changes or for testing purposes.\n * Note: This does NOT destroy the appKit instance created by Reown.\n */\nexport const resetAppKitCache = (): void => {\n\tsetCachedAppKit(undefined);\n};\n\n/**\n * Keys are `accounts:<walletId>:...`; the trailing colon scopes the prefix to\n * this wallet and avoids matching a sibling whose id is a string prefix.\n */\nconst dropAccountsCache = (platform: WalletPlatform): void => {\n\tclearCachedObservablesByPrefix(\n\t\t`accounts:${WALLET_CONNECT_WALLET_ID}:${platform}:`,\n\t);\n};\n\nconst namespaceOf: Record<WalletPlatform, string> = {\n\tpolkadot: \"polkadot\",\n\tethereum: \"eip155\",\n\tsolana: \"solana\",\n};\nconst allPlatforms: WalletPlatform[] = [\"polkadot\", \"ethereum\", \"solana\"];\n\nconst methodsByNamespace: Record<string, string[]> = {\n\tpolkadot: [\"polkadot_signTransaction\", \"polkadot_signMessage\"],\n\tsolana: [\n\t\t\"solana_signTransaction\",\n\t\t\"solana_signMessage\",\n\t\t\"solana_signAndSendTransaction\",\n\t],\n};\n\n// AppKit turns every overridden namespace into a pairing request, and rejects\n// the pairing when one of them has no chains.\nconst methodsFor = (networks: unknown[]): Record<string, string[]> => {\n\tconst namespaces = new Set(\n\t\tnetworks.map(\n\t\t\t(network) => (network as { chainNamespace?: string }).chainNamespace,\n\t\t),\n\t);\n\treturn Object.fromEntries(\n\t\tObject.entries(methodsByNamespace).filter(([namespace]) =>\n\t\t\tnamespaces.has(namespace),\n\t\t),\n\t);\n};\n\nconst createConnector$ = (appKit: AppKit): Observable<WalletConnectWallet> => {\n\t// Exposed on the wallet as the (decoupled) AppKitInstance escape hatch.\n\tconst appKitInstance = appKit as unknown as AppKitInstance;\n\n\tconst status$ = new BehaviorSubject<{\n\t\tisPolkadotConnected: boolean;\n\t\tisEthereumConnected: boolean;\n\t\tisSolanaConnected: boolean;\n\t\topening: boolean;\n\t\terror: KheopskitError | undefined;\n\t}>({\n\t\tisPolkadotConnected: false,\n\t\tisEthereumConnected: false,\n\t\tisSolanaConnected: false,\n\t\topening: false,\n\t\terror: undefined,\n\t});\n\n\tconst syncProviders = (providers: Partial<Record<string, unknown>>) => {\n\t\tstatus$.next({\n\t\t\t...status$.value,\n\t\t\tisPolkadotConnected: !!providers.polkadot,\n\t\t\tisEthereumConnected: !!providers.eip155,\n\t\t\tisSolanaConnected: !!providers.solana,\n\t\t});\n\t};\n\n\tconst openModal = async () => {\n\t\tstatus$.next({ ...status$.value, opening: true, error: undefined });\n\t\ttry {\n\t\t\tawait appKit.open();\n\t\t} catch (cause) {\n\t\t\tconst error = toConnectError(\n\t\t\t\tcause,\n\t\t\t\tWALLET_CONNECT_WALLET_ID,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tstatus$.next({ ...status$.value, opening: false, error });\n\t\t\tthrow error;\n\t\t}\n\t\tstatus$.next({ ...status$.value, opening: false });\n\t};\n\n\tconst enabledPlatforms = allPlatforms.filter((p) =>\n\t\t(appKit.chainNamespaces as string[]).includes(namespaceOf[p]),\n\t);\n\n\tlet prevConnected = {\n\t\tpolkadot: false,\n\t\tethereum: false,\n\t\tsolana: false,\n\t};\n\n\tconst wallet$ = status$.pipe(\n\t\tmap((s) => ({\n\t\t\tpolkadot: s.isPolkadotConnected,\n\t\t\tethereum: s.isEthereumConnected,\n\t\t\tsolana: s.isSolanaConnected,\n\t\t\topening: s.opening,\n\t\t\terror: s.error,\n\t\t})),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\ta.polkadot === b.polkadot &&\n\t\t\t\ta.ethereum === b.ethereum &&\n\t\t\t\ta.solana === b.solana &&\n\t\t\t\ta.opening === b.opening &&\n\t\t\t\ta.error === b.error,\n\t\t),\n\t\ttap((connected) => {\n\t\t\t// Drop caches for namespaces that just went disconnected.\n\t\t\tfor (const platform of allPlatforms)\n\t\t\t\tif (prevConnected[platform] && !connected[platform])\n\t\t\t\t\tdropAccountsCache(platform);\n\t\t\tprevConnected = connected;\n\t\t}),\n\t\tmap(({ opening, error, ...connected }): WalletConnectWallet => {\n\t\t\tconst platforms = enabledPlatforms.filter((p) => connected[p]);\n\t\t\tconst isConnected = platforms.length > 0;\n\t\t\tconst walletInfo = appKit.getWalletInfo();\n\t\t\treturn {\n\t\t\t\tid: WALLET_CONNECT_WALLET_ID,\n\t\t\t\ttype: \"walletconnect\",\n\t\t\t\tplatforms,\n\t\t\t\tappKit: appKitInstance,\n\t\t\t\tname: walletInfo?.name || \"WalletConnect\",\n\t\t\t\ticon: walletInfo?.icon || WALLET_CONNECT_ICON,\n\t\t\t\t// One shared session: connecting opens the modal; the wallet\n\t\t\t\t// approves namespaces in that single pairing. Disconnect is\n\t\t\t\t// session-wide; re-pair to change the approved set.\n\t\t\t\tconnect: async () => {\n\t\t\t\t\tif (!isConnected) await openModal();\n\t\t\t\t},\n\t\t\t\tdisconnect: async () => {\n\t\t\t\t\tif (isConnected) await appKit.disconnect();\n\t\t\t\t},\n\t\t\t\tstatus: isConnected\n\t\t\t\t\t? \"connected\"\n\t\t\t\t\t: opening\n\t\t\t\t\t\t? \"connecting\"\n\t\t\t\t\t\t: \"disconnected\",\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn new Observable<WalletConnectWallet>((subscriber) => {\n\t\tfor (const platform of allPlatforms) dropAccountsCache(platform);\n\t\t// AppKit's subscribeProviders only reports later changes, so read the\n\t\t// state that may have changed while nobody observed.\n\t\tsyncProviders({\n\t\t\tpolkadot: appKit.getProvider(\"polkadot\"),\n\t\t\teip155: appKit.getProvider(\"eip155\"),\n\t\t\tsolana: appKit.getProvider(\"solana\"),\n\t\t});\n\t\tconst unsubProviders = appKit.subscribeProviders(syncProviders);\n\t\tconst sub = wallet$.subscribe(subscriber);\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tunsubProviders();\n\t\t};\n\t});\n};\n\n/**\n * @remarks\n * The AppKit instance is a process-wide singleton: a second instance would\n * share AppKit's module-level controller state with the first, so it is\n * created once. The **first** call with a `walletConnect` config wins;\n * later calls with a *different* `walletConnect` config reuse that first\n * instance. Call {@link resetAppKitCache} before re-initialising if the\n * WalletConnect config must change.\n *\n * One WalletConnect session is shared across every namespace, and a namespace\n * can only be established during the initial pairing — it can't be added to a\n * live session afterwards. So this exposes ONE connector (not one per platform):\n * `connect()` opens the modal; the wallet approves whichever namespaces it\n * supports in that single pairing, and `platforms` reflects what the live\n * session carries. Per-namespace accounts are derived by each platform plugin.\n */\nconst getWalletConnectWallet$ = (\n\twalletConnect: WalletConnectOptions,\n\tdebug: boolean,\n): Observable<WalletConnectWallet | null> => {\n\t// SSR guard - don't try to load AppKit on the server\n\tif (typeof window === \"undefined\") return of(null);\n\n\tconst cachedProjectId = getCachedAppKitProjectId();\n\tif (\n\t\tcachedProjectId !== undefined &&\n\t\tcachedProjectId !== walletConnect.projectId\n\t) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] WalletConnect is already initialised with projectId %s; \" +\n\t\t\t\t\"AppKit is a process-wide singleton, so the first configuration wins and \" +\n\t\t\t\t\"projectId %s is ignored. Call resetAppKitCache() before re-initialising \" +\n\t\t\t\t\"if the WalletConnect config must change.\",\n\t\t\tcachedProjectId,\n\t\t\twalletConnect.projectId,\n\t\t);\n\t}\n\n\tlet cachedAppKit = getCachedAppKit();\n\tif (!cachedAppKit) {\n\t\t// Dynamic import avoids loading @reown/appkit at module-eval time (SSR /\n\t\t// edge runtimes like Cloudflare Workers).\n\t\tconst connectorOnce$ = from(loadAppKit()).pipe(\n\t\t\tmap((createAppKit) =>\n\t\t\t\t// @reown/appkit missing (optional peer dep) — degrade gracefully.\n\t\t\t\tcreateAppKit\n\t\t\t\t\t? createConnector$(\n\t\t\t\t\t\t\tcreateAppKit({\n\t\t\t\t\t\t\t\tallWallets: \"HIDE\",\n\t\t\t\t\t\t\t\tdebug,\n\t\t\t\t\t\t\t\tallowUnsupportedChain: true,\n\t\t\t\t\t\t\t\t...walletConnect.appKitOptions,\n\t\t\t\t\t\t\t\tprojectId: walletConnect.projectId,\n\t\t\t\t\t\t\t\tmetadata: walletConnect.metadata,\n\t\t\t\t\t\t\t\tnetworks: walletConnect.networks as never,\n\t\t\t\t\t\t\t\tthemeMode: walletConnect.themeMode,\n\t\t\t\t\t\t\t\tthemeVariables: walletConnect.themeVariables as never,\n\t\t\t\t\t\t\t\tuniversalProviderConfigOverride: {\n\t\t\t\t\t\t\t\t\tmethods: methodsFor(walletConnect.networks),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: null,\n\t\t\t),\n\t\t\tshareReplay({ refCount: false, bufferSize: 1 }),\n\t\t);\n\t\tcachedAppKit = connectorOnce$.pipe(\n\t\t\tswitchMap((wallet$) => wallet$ ?? of(null)),\n\t\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t\t);\n\t\tsetCachedAppKit(cachedAppKit, walletConnect.projectId);\n\t}\n\n\treturn cachedAppKit;\n};\n\n/**\n * The WalletConnect plugin for `config.walletConnect`. Importing this entry is\n * what brings Reown AppKit into a dapp's bundle; a dapp that never imports it\n * ships none of it.\n *\n * @example\n * ```ts\n * import { walletConnect } from \"@kheopskit/core/walletconnect\";\n *\n * createKheopskit({\n * platforms: [polkadot()],\n * walletConnect: walletConnect({ projectId, metadata, networks }),\n * });\n * ```\n */\nexport const walletConnect = (\n\toptions: WalletConnectOptions,\n): WalletConnectPlugin => ({\n\ttype: \"walletconnect\",\n\tmetadata: options.metadata,\n\tgetWallet$: ({ config }) => getWalletConnectWallet$(options, config.debug),\n});\n"],"mappings":";;;;;;;;;AA+DA,MAAM,aAAa,YAAY;CAC9B,IAAI;EACH,MAAM,EAAE,iBAAiB,MAAM,OAAO;EACtC,OAAO;CACR,SAAS,OAAO;EACf,QAAQ,MACP,8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QAAQ;CAClB,aAAa,EAAE,aAAa,wBAAwB,SAAS,OAAO,KAAK;AAC1E"}
|
|
1
|
+
{"version":3,"file":"walletconnect.mjs","names":[],"sources":["../src/api/walletconnect/plugin.ts"],"sourcesContent":["import type { AppKit } from \"@reown/appkit/core\";\nimport {\n\tBehaviorSubject,\n\tcatchError,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttap,\n} from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../../utils/getCachedObservable\";\nimport { WALLET_CONNECT_WALLET_ID } from \"../../utils/WalletId\";\nimport { type KheopskitError, toConnectError } from \"../errors\";\nimport { getSessionCaip10s } from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tWalletConnectMetadata,\n\tWalletConnectPlugin,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"../types\";\n\nexport type WalletConnectOptions = {\n\tprojectId: string;\n\tmetadata: WalletConnectMetadata;\n\t/**\n\t * Networks AppKit should enable. Pass `AppKitNetwork[]` from\n\t * `@reown/appkit/networks` (see\n\t * https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup).\n\t * Loosely typed (`unknown`) so the declarations don't depend on\n\t * `@reown/appkit`'s types; the value is forwarded to AppKit as-is.\n\t */\n\tnetworks: [unknown, ...unknown[]];\n\tthemeMode?: \"light\" | \"dark\";\n\tthemeVariables?: Record<string, string | number>;\n\t/**\n\t * Extra Reown AppKit `createAppKit` options (e.g. `featuredWalletIds`,\n\t * `features`, `allWallets`), forwarded as-is; see\n\t * https://docs.reown.com/appkit/javascript/core/options.\n\t * kheopskit sets `projectId`, `metadata`, `networks`, `themeMode`,\n\t * `themeVariables` and `universalProviderConfigOverride` itself, so those\n\t * keys are rejected here.\n\t */\n\tappKitOptions?: AppKitOptions;\n};\n\ntype KheopskitOwnedAppKitKey =\n\t| \"projectId\"\n\t| \"metadata\"\n\t| \"networks\"\n\t| \"themeMode\"\n\t| \"themeVariables\"\n\t| \"universalProviderConfigOverride\";\n\ntype AppKitOptions = Record<string, unknown> &\n\tPartial<Record<KheopskitOwnedAppKitKey, never>>;\n\n/**\n * Dynamically import @reown/appkit/core to avoid loading browser-only code\n * during SSR or in edge runtimes like Cloudflare Workers.\n * The AppKit library uses Lit for web components which requires document.\n */\nconst loadAppKit = async () => {\n\ttry {\n\t\tconst { createAppKit } = await import(\"@reown/appkit/core\");\n\t\treturn createAppKit;\n\t} catch (cause) {\n\t\tconsole.error(\n\t\t\t\"[kheopskit] WalletConnect is configured but @reown/appkit could not be loaded. \" +\n\t\t\t\t\"Install it with `pnpm add @reown/appkit` (or remove config.walletConnect). \" +\n\t\t\t\t\"WalletConnect wallets are disabled; injected wallets still work.\",\n\t\t\tcause,\n\t\t);\n\t\treturn null;\n\t}\n};\n\nconst WALLET_CONNECT_ICON =\n\t\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjQwMCIgdmlld0JveD0iMCAwIDQwMCA0MDAiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxjbGlwUGF0aCBpZD0iYSI+PHBhdGggZD0ibTAgMGg0MDB2NDAwaC00MDB6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjYSkiPjxjaXJjbGUgY3g9IjIwMCIgY3k9IjIwMCIgZmlsbD0iIzMzOTZmZiIgcj0iMTk5LjUiIHN0cm9rZT0iIzY2YjFmZiIvPjxwYXRoIGQ9Im0xMjIuNTE5IDE0OC45NjVjNDIuNzkxLTQxLjcyOSAxMTIuMTcxLTQxLjcyOSAxNTQuOTYyIDBsNS4xNSA1LjAyMmMyLjE0IDIuMDg2IDIuMTQgNS40NjkgMCA3LjU1NWwtMTcuNjE3IDE3LjE4Yy0xLjA3IDEuMDQzLTIuODA0IDEuMDQzLTMuODc0IDBsLTcuMDg3LTYuOTExYy0yOS44NTMtMjkuMTExLTc4LjI1My0yOS4xMTEtMTA4LjEwNiAwbC03LjU5IDcuNDAxYy0xLjA3IDEuMDQzLTIuODA0IDEuMDQzLTMuODc0IDBsLTE3LjYxNy0xNy4xOGMtMi4xNC0yLjA4Ni0yLjE0LTUuNDY5IDAtNy41NTV6bTE5MS4zOTcgMzUuNTI5IDE1LjY3OSAxNS4yOWMyLjE0IDIuMDg2IDIuMTQgNS40NjkgMCA3LjU1NWwtNzAuNyA2OC45NDRjLTIuMTM5IDIuMDg3LTUuNjA4IDIuMDg3LTcuNzQ4IDBsLTUwLjE3OC00OC45MzFjLS41MzUtLjUyMi0xLjQwMi0uNTIyLTEuOTM3IDBsLTUwLjE3OCA0OC45MzFjLTIuMTM5IDIuMDg3LTUuNjA4IDIuMDg3LTcuNzQ4IDBsLTcwLjcwMTUtNjguOTQ1Yy0yLjEzOTYtMi4wODYtMi4xMzk2LTUuNDY5IDAtNy41NTVsMTUuNjc5NS0xNS4yOWMyLjEzOTYtMi4wODYgNS42MDg1LTIuMDg2IDcuNzQ4MSAwbDUwLjE3ODkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3Ny00OC45MzJjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMGw1MC4xNzkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3OS00OC45MzFjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+\";\n\n// Once it exists, the appKit object should never be recreated. Anchored on\n// globalThis so it stays a single instance even if this module is duplicated\n// across bundle chunks (e.g. CJS subpath entries).\nconst APPKIT_SYMBOL = Symbol.for(\"kheopskit.cachedAppKit\");\n// The projectId AppKit was first initialised with. AppKit is a process-wide\n// singleton, so a later call with a different WalletConnect config is silently\n// ignored — we keep this to warn loudly instead of letting it pass unnoticed.\nconst APPKIT_PROJECT_ID_SYMBOL = Symbol.for(\"kheopskit.cachedAppKitProjectId\");\ntype AppKitGlobal = Record<\n\tsymbol,\n\tObservable<WalletConnectWallet | null> | string | undefined\n>;\nconst getCachedAppKit = ():\n\t| Observable<WalletConnectWallet | null>\n\t| undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] as\n\t\t| Observable<WalletConnectWallet | null>\n\t\t| undefined;\nconst getCachedAppKitProjectId = (): string | undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] as\n\t\t| string\n\t\t| undefined;\nconst setCachedAppKit = (\n\tvalue: Observable<WalletConnectWallet | null> | undefined,\n\tprojectId?: string,\n): void => {\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] = value;\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_PROJECT_ID_SYMBOL] = projectId;\n};\n\n/**\n * Clears the cached AppKit observable.\n * Use when configuration changes or for testing purposes.\n * Note: This does NOT destroy the appKit instance created by Reown.\n */\nexport const resetAppKitCache = (): void => {\n\tsetCachedAppKit(undefined);\n};\n\n/**\n * Keys are `accounts:<walletId>:...`; the trailing colon scopes the prefix to\n * this wallet and avoids matching a sibling whose id is a string prefix.\n */\nconst dropAccountsCache = (platform: WalletPlatform): void => {\n\tclearCachedObservablesByPrefix(\n\t\t`accounts:${WALLET_CONNECT_WALLET_ID}:${platform}:`,\n\t);\n};\n\nconst namespaceOf = {\n\tpolkadot: \"polkadot\",\n\tethereum: \"eip155\",\n\tsolana: \"solana\",\n} as const satisfies Record<WalletPlatform, string>;\nconst allPlatforms: WalletPlatform[] = [\"polkadot\", \"ethereum\", \"solana\"];\n\nconst methodsByNamespace: Record<string, string[]> = {\n\tpolkadot: [\"polkadot_signTransaction\", \"polkadot_signMessage\"],\n\tsolana: [\n\t\t\"solana_signTransaction\",\n\t\t\"solana_signMessage\",\n\t\t\"solana_signAndSendTransaction\",\n\t],\n};\n\n// AppKit turns every overridden namespace into a pairing request, and rejects\n// the pairing when one of them has no chains.\nconst methodsFor = (networks: unknown[]): Record<string, string[]> => {\n\tconst namespaces = new Set(\n\t\tnetworks.map(\n\t\t\t(network) => (network as { chainNamespace?: string }).chainNamespace,\n\t\t),\n\t);\n\treturn Object.fromEntries(\n\t\tObject.entries(methodsByNamespace).filter(([namespace]) =>\n\t\t\tnamespaces.has(namespace),\n\t\t),\n\t);\n};\n\nconst createConnector$ = (appKit: AppKit): Observable<WalletConnectWallet> => {\n\t// Exposed on the wallet as the (decoupled) AppKitInstance escape hatch.\n\tconst appKitInstance = appKit as unknown as AppKitInstance;\n\n\tconst status$ = new BehaviorSubject<{\n\t\tisPolkadotConnected: boolean;\n\t\tisEthereumConnected: boolean;\n\t\tisSolanaConnected: boolean;\n\t\topening: boolean;\n\t\terror: KheopskitError | undefined;\n\t}>({\n\t\tisPolkadotConnected: false,\n\t\tisEthereumConnected: false,\n\t\tisSolanaConnected: false,\n\t\topening: false,\n\t\terror: undefined,\n\t});\n\n\tconst liveSession = (platform: WalletPlatform) => {\n\t\tconst namespace = namespaceOf[platform];\n\t\tconst session =\n\t\t\tappKit.getProvider<WalletConnectProvider>(namespace)?.session;\n\t\treturn session && getSessionCaip10s(session, namespace).length > 0\n\t\t\t? session\n\t\t\t: undefined;\n\t};\n\n\tconst syncProviders = () => {\n\t\tstatus$.next({\n\t\t\t...status$.value,\n\t\t\tisPolkadotConnected: !!liveSession(\"polkadot\"),\n\t\t\tisEthereumConnected: !!liveSession(\"ethereum\"),\n\t\t\tisSolanaConnected: !!liveSession(\"solana\"),\n\t\t});\n\t};\n\n\tconst openModal = async () => {\n\t\tstatus$.next({ ...status$.value, opening: true, error: undefined });\n\t\ttry {\n\t\t\tawait appKit.open();\n\t\t} catch (cause) {\n\t\t\tconst error = toConnectError(\n\t\t\t\tcause,\n\t\t\t\tWALLET_CONNECT_WALLET_ID,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tstatus$.next({ ...status$.value, opening: false, error });\n\t\t\tthrow error;\n\t\t}\n\t\tstatus$.next({ ...status$.value, opening: false });\n\t};\n\n\tconst enabledPlatforms = allPlatforms.filter((p) =>\n\t\t(appKit.chainNamespaces as string[]).includes(namespaceOf[p]),\n\t);\n\n\tlet prevConnected = {\n\t\tpolkadot: false,\n\t\tethereum: false,\n\t\tsolana: false,\n\t};\n\n\tconst wallet$ = status$.pipe(\n\t\tmap((s) => ({\n\t\t\tpolkadot: s.isPolkadotConnected,\n\t\t\tethereum: s.isEthereumConnected,\n\t\t\tsolana: s.isSolanaConnected,\n\t\t\topening: s.opening,\n\t\t\terror: s.error,\n\t\t})),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\ta.polkadot === b.polkadot &&\n\t\t\t\ta.ethereum === b.ethereum &&\n\t\t\t\ta.solana === b.solana &&\n\t\t\t\ta.opening === b.opening &&\n\t\t\t\ta.error === b.error,\n\t\t),\n\t\ttap((connected) => {\n\t\t\t// Drop caches for namespaces that just went disconnected.\n\t\t\tfor (const platform of allPlatforms)\n\t\t\t\tif (prevConnected[platform] && !connected[platform])\n\t\t\t\t\tdropAccountsCache(platform);\n\t\t\tprevConnected = connected;\n\t\t}),\n\t\tmap(({ opening, error, ...connected }): WalletConnectWallet => {\n\t\t\tconst platforms = enabledPlatforms.filter((p) => connected[p]);\n\t\t\tconst isConnected = platforms.length > 0;\n\t\t\tconst peer = platforms[0] && liveSession(platforms[0])?.peer?.metadata;\n\t\t\treturn {\n\t\t\t\tid: WALLET_CONNECT_WALLET_ID,\n\t\t\t\ttype: \"walletconnect\",\n\t\t\t\tplatforms,\n\t\t\t\tappKit: appKitInstance,\n\t\t\t\tname: peer?.name || \"WalletConnect\",\n\t\t\t\ticon: peer?.icons?.[0] || WALLET_CONNECT_ICON,\n\t\t\t\t// One shared session: connecting opens the modal; the wallet\n\t\t\t\t// approves namespaces in that single pairing. Disconnect is\n\t\t\t\t// session-wide; re-pair to change the approved set.\n\t\t\t\tconnect: async () => {\n\t\t\t\t\tif (!isConnected) await openModal();\n\t\t\t\t},\n\t\t\t\tdisconnect: async () => {\n\t\t\t\t\tif (isConnected) await appKit.disconnect();\n\t\t\t\t},\n\t\t\t\tstatus: isConnected\n\t\t\t\t\t? \"connected\"\n\t\t\t\t\t: opening\n\t\t\t\t\t\t? \"connecting\"\n\t\t\t\t\t\t: \"disconnected\",\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn new Observable<WalletConnectWallet>((subscriber) => {\n\t\tfor (const platform of allPlatforms) dropAccountsCache(platform);\n\t\t// AppKit's subscribeProviders only reports later changes, so read the\n\t\t// state that may have changed while nobody observed.\n\t\tsyncProviders();\n\t\tconst unsubProviders = appKit.subscribeProviders(syncProviders);\n\t\t// AppKit keeps a namespace's provider registered when the wallet ends the\n\t\t// session, and registers that same object again on the next pairing, so\n\t\t// subscribeProviders reports neither.\n\t\tconst sessionSub = from(appKit.getUniversalProvider())\n\t\t\t.pipe(\n\t\t\t\tcatchError(() => EMPTY),\n\t\t\t\tswitchMap((provider) =>\n\t\t\t\t\tprovider\n\t\t\t\t\t\t? merge(\n\t\t\t\t\t\t\t\tfromEvent(provider, \"session_delete\"),\n\t\t\t\t\t\t\t\tfromEvent(provider, \"connect\"),\n\t\t\t\t\t\t\t\tof(undefined),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: EMPTY,\n\t\t\t\t),\n\t\t\t)\n\t\t\t.subscribe(syncProviders);\n\t\tconst sub = wallet$.subscribe(subscriber);\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tsessionSub.unsubscribe();\n\t\t\tunsubProviders();\n\t\t};\n\t});\n};\n\n/**\n * @remarks\n * The AppKit instance is a process-wide singleton: a second instance would\n * share AppKit's module-level controller state with the first, so it is\n * created once. The **first** call with a `walletConnect` config wins;\n * later calls with a *different* `walletConnect` config reuse that first\n * instance. Call {@link resetAppKitCache} before re-initialising if the\n * WalletConnect config must change.\n *\n * One WalletConnect session is shared across every namespace, and a namespace\n * can only be established during the initial pairing — it can't be added to a\n * live session afterwards. So this exposes ONE connector (not one per platform):\n * `connect()` opens the modal; the wallet approves whichever namespaces it\n * supports in that single pairing, and `platforms` reflects what the live\n * session carries. Per-namespace accounts are derived by each platform plugin.\n */\nconst getWalletConnectWallet$ = (\n\twalletConnect: WalletConnectOptions,\n\tdebug: boolean,\n): Observable<WalletConnectWallet | null> => {\n\t// SSR guard - don't try to load AppKit on the server\n\tif (typeof window === \"undefined\") return of(null);\n\n\tconst cachedProjectId = getCachedAppKitProjectId();\n\tif (\n\t\tcachedProjectId !== undefined &&\n\t\tcachedProjectId !== walletConnect.projectId\n\t) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] WalletConnect is already initialised with projectId %s; \" +\n\t\t\t\t\"AppKit is a process-wide singleton, so the first configuration wins and \" +\n\t\t\t\t\"projectId %s is ignored. Call resetAppKitCache() before re-initialising \" +\n\t\t\t\t\"if the WalletConnect config must change.\",\n\t\t\tcachedProjectId,\n\t\t\twalletConnect.projectId,\n\t\t);\n\t}\n\n\tlet cachedAppKit = getCachedAppKit();\n\tif (!cachedAppKit) {\n\t\t// Dynamic import avoids loading @reown/appkit at module-eval time (SSR /\n\t\t// edge runtimes like Cloudflare Workers).\n\t\tconst connectorOnce$ = from(loadAppKit()).pipe(\n\t\t\tmap((createAppKit) =>\n\t\t\t\t// @reown/appkit missing (optional peer dep) — degrade gracefully.\n\t\t\t\tcreateAppKit\n\t\t\t\t\t? createConnector$(\n\t\t\t\t\t\t\tcreateAppKit({\n\t\t\t\t\t\t\t\tallWallets: \"HIDE\",\n\t\t\t\t\t\t\t\tdebug,\n\t\t\t\t\t\t\t\tallowUnsupportedChain: true,\n\t\t\t\t\t\t\t\t...walletConnect.appKitOptions,\n\t\t\t\t\t\t\t\tprojectId: walletConnect.projectId,\n\t\t\t\t\t\t\t\tmetadata: walletConnect.metadata,\n\t\t\t\t\t\t\t\tnetworks: walletConnect.networks as never,\n\t\t\t\t\t\t\t\tthemeMode: walletConnect.themeMode,\n\t\t\t\t\t\t\t\tthemeVariables: walletConnect.themeVariables as never,\n\t\t\t\t\t\t\t\tuniversalProviderConfigOverride: {\n\t\t\t\t\t\t\t\t\tmethods: methodsFor(walletConnect.networks),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: null,\n\t\t\t),\n\t\t\tshareReplay({ refCount: false, bufferSize: 1 }),\n\t\t);\n\t\tcachedAppKit = connectorOnce$.pipe(\n\t\t\tswitchMap((wallet$) => wallet$ ?? of(null)),\n\t\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t\t);\n\t\tsetCachedAppKit(cachedAppKit, walletConnect.projectId);\n\t}\n\n\treturn cachedAppKit;\n};\n\n/**\n * The WalletConnect plugin for `config.walletConnect`. Importing this entry is\n * what brings Reown AppKit into a dapp's bundle; a dapp that never imports it\n * ships none of it.\n *\n * @example\n * ```ts\n * import { walletConnect } from \"@kheopskit/core/walletconnect\";\n *\n * createKheopskit({\n * platforms: [polkadot()],\n * walletConnect: walletConnect({ projectId, metadata, networks }),\n * });\n * ```\n */\nexport const walletConnect = (\n\toptions: WalletConnectOptions,\n): WalletConnectPlugin => ({\n\ttype: \"walletconnect\",\n\tmetadata: options.metadata,\n\tgetWallet$: ({ config }) => getWalletConnectWallet$(options, config.debug),\n});\n"],"mappings":";;;;;;;;;AAqEA,MAAM,aAAa,YAAY;CAC9B,IAAI;EACH,MAAM,EAAE,iBAAiB,MAAM,OAAO;EACtC,OAAO;CACR,SAAS,OAAO;EACf,QAAQ,MACP,8NAGA,KACD;EACA,OAAO;CACR;AACD;AAEA,MAAM,sBACL;AAKD,MAAM,gBAAgB,OAAO,IAAI,wBAAwB;AAIzD,MAAM,2BAA2B,OAAO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AAC,CAEnB,CAAC,CAAC,KAC7B,WAAW,YAAY,WAAW,GAAG,IAAI,CAAC,GAC1C,YAAY;GAAE,UAAU;GAAM,YAAY;EAAE,CAAC,CAC9C;EACA,gBAAgB,cAAc,cAAc,SAAS;CACtD;CAEA,OAAO;AACR;;;;;;;;;;;;;;;;AAiBA,MAAa,iBACZ,aAC0B;CAC1B,MAAM;CACN,UAAU,QAAQ;CAClB,aAAa,EAAE,aAAa,wBAAwB,SAAS,OAAO,KAAK;AAC1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kheopskit/core",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Framework-agnostic wallet and account discovery for Polkadot, Ethereum and Solana dapps. Upgrading from v5? Read MIGRATING_TO_V6.md, shipped in this package.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|