@kheopskit/core 6.0.0-rc.3 → 6.0.0-rc.5
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 +26 -0
- package/MIGRATING_TO_V6.md +78 -17
- package/README.md +138 -34
- package/dist/ethereum.d.mts +2 -2
- package/dist/ethereum.d.ts +2 -2
- package/dist/ethereum.js +4 -4
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +4 -4
- package/dist/ethereum.mjs.map +1 -1
- package/dist/index.d.mts +12 -27
- package/dist/index.d.ts +12 -27
- package/dist/index.js +9 -921
- package/dist/index.mjs +4 -916
- package/dist/{injectedWallets-BQBgS-f0.js → injectedWallets-D7wzBr_f.js} +2 -2
- package/dist/{injectedWallets-BQBgS-f0.js.map → injectedWallets-D7wzBr_f.js.map} +1 -1
- package/dist/{injectedWallets-5GL1Jder.mjs → injectedWallets-DHf2lYVb.mjs} +2 -2
- package/dist/{injectedWallets-5GL1Jder.mjs.map → injectedWallets-DHf2lYVb.mjs.map} +1 -1
- package/dist/instance-1BgEld17.d.ts +109 -0
- package/dist/instance-BPAvq0v7.mjs +1457 -0
- package/dist/instance-BPAvq0v7.mjs.map +1 -0
- package/dist/instance-CCP7uJV3.js +1528 -0
- package/dist/instance-CCP7uJV3.js.map +1 -0
- package/dist/instance-DDvZiq1L.d.mts +109 -0
- package/dist/internal.d.mts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +8 -6
- package/dist/internal.mjs +3 -3
- package/dist/{platformAccounts-yyRUrnel.mjs → platformAccounts-BeMDbmUT.mjs} +2 -2
- package/dist/{platformAccounts-yyRUrnel.mjs.map → platformAccounts-BeMDbmUT.mjs.map} +1 -1
- package/dist/{platformAccounts-BjIeRcFN.js → platformAccounts-FE7oA3-Y.js} +2 -2
- package/dist/{platformAccounts-BjIeRcFN.js.map → platformAccounts-FE7oA3-Y.js.map} +1 -1
- package/dist/polkadot.d.mts +2 -2
- package/dist/polkadot.d.ts +2 -2
- package/dist/polkadot.js +6 -7
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +5 -6
- package/dist/polkadot.mjs.map +1 -1
- package/dist/{polkadotExtensions-BoVKhNU_.mjs → registryReads-30CCkmHe.js} +43 -2
- package/dist/registryReads-30CCkmHe.js.map +1 -0
- package/dist/{polkadotExtensions-y4J9UzYl.js → registryReads-HvSaXRWX.mjs} +30 -5
- package/dist/registryReads-HvSaXRWX.mjs.map +1 -0
- package/dist/solana.d.mts +2 -2
- package/dist/solana.d.ts +2 -2
- package/dist/solana.js +4 -4
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +4 -4
- package/dist/solana.mjs.map +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{types-C3I3w0jb.d.ts → types-BGeGUtxz.d.mts} +14 -4
- package/dist/{types-C3I3w0jb.d.mts → types-BGeGUtxz.d.ts} +14 -4
- package/dist/{types-BWHvNFlN.js → types-BrMtrjs9.js} +8 -1
- package/dist/types-BrMtrjs9.js.map +1 -0
- package/dist/{types-Yor672md.mjs → types-D7OWi0Td.mjs} +3 -2
- package/dist/types-D7OWi0Td.mjs.map +1 -0
- package/dist/walletconnect.d.mts +13 -2
- package/dist/walletconnect.d.ts +13 -2
- package/dist/walletconnect.js +19 -13
- package/dist/walletconnect.js.map +1 -1
- package/dist/walletconnect.mjs +19 -13
- package/dist/walletconnect.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/getCachedObservable-LUq9IfEx.d.mts +0 -23
- package/dist/getCachedObservable-LUq9IfEx.d.ts +0 -23
- package/dist/iconCache-C-U3IEbP.mjs +0 -324
- package/dist/iconCache-C-U3IEbP.mjs.map +0 -1
- package/dist/iconCache-FR4iy6go.js +0 -377
- package/dist/iconCache-FR4iy6go.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/polkadotExtensions-BoVKhNU_.mjs.map +0 -1
- package/dist/polkadotExtensions-y4J9UzYl.js.map +0 -1
- package/dist/registryReads-BpHsWLd7.js +0 -38
- package/dist/registryReads-BpHsWLd7.js.map +0 -1
- package/dist/registryReads-BvtznSo3.mjs +0 -33
- package/dist/registryReads-BvtznSo3.mjs.map +0 -1
- package/dist/types-BWHvNFlN.js.map +0 -1
- package/dist/types-Yor672md.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_types = require("./types-
|
|
1
|
+
const require_types = require("./types-BrMtrjs9.js");
|
|
2
2
|
let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
|
|
3
3
|
let _scure_base = require("@scure/base");
|
|
4
4
|
let _noble_hashes_blake2_js = require("@noble/hashes/blake2.js");
|
|
@@ -318,4 +318,4 @@ Object.defineProperty(exports, "parseWalletAccountId", {
|
|
|
318
318
|
}
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
-
//# sourceMappingURL=platformAccounts-
|
|
321
|
+
//# sourceMappingURL=platformAccounts-FE7oA3-Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccounts-BjIeRcFN.js","names":["keccak_256","base58","base58","blake2b","map","isWalletConnectWallet","Observable","Subscription","distinctUntilChanged","shareReplay","of","getCachedObservable$"],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts","../src/api/platformAccounts.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n","import {\n\tdistinctUntilChanged,\n\tmap,\n\tObservable,\n\tof,\n\tSubscription,\n\tshareReplay,\n} from \"rxjs\";\nimport { getCachedObservable$ } from \"../utils/getCachedObservable\";\nimport type { WalletId } from \"../utils/WalletId\";\nimport type {\n\tBaseWallet,\n\tBaseWalletAccount,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"./types\";\nimport { isWalletConnectWallet } from \"./types\";\n\nexport type LiveWalletConnectWallet = Exclude<\n\tWalletConnectWallet,\n\t{ isPlaceholder: true }\n>;\n\nexport type PlatformAccountsOptions<\n\tTWallet extends BaseWallet,\n\tTAccount extends BaseWalletAccount,\n> = {\n\t/** This platform's wallets plus the shared WalletConnect connector. */\n\twallets$: Observable<(TWallet | WalletConnectWallet)[]>;\n\t/** Account stream for one connected injected wallet. */\n\tgetInjectedAccounts$: (wallet: TWallet) => Observable<TAccount[]>;\n\t/** Account stream for the WalletConnect connector. */\n\tgetWalletConnectAccounts$: (\n\t\twallet: LiveWalletConnectWallet,\n\t) => Observable<TAccount[]>;\n\t/** Optional post-flatten transform (e.g. Polkadot's `accountTypes` filter). */\n\tmapAccounts?: (accounts: TAccount[]) => TAccount[];\n\t/**\n\t * Signature of the account fields that should trigger a re-emission.\n\t * Defaults to the account id; platforms add mutable fields (Ethereum\n\t * `chainId`, Solana `chains`).\n\t */\n\taccountChangeKey?: (account: TAccount) => string;\n};\n\n/** The account list plus the connected wallets whose stream has answered, an empty list included. */\nexport type PlatformAccountsFrame<TAccount> = {\n\taccounts: TAccount[];\n\tanswered: WalletId[];\n};\n\nexport type PlatformAccounts$<TAccount> = Observable<TAccount[]> & {\n\tframes$: Observable<PlatformAccountsFrame<TAccount>>;\n};\n\nconst isPlatformAccounts$ = <TAccount extends BaseWalletAccount>(\n\taccounts$: Observable<TAccount[]>,\n): accounts$ is PlatformAccounts$<TAccount> => \"frames$\" in accounts$;\n\n/** A plugin not built on `createPlatformAccounts$` reports no answered wallet. */\nexport const framesOf = <TAccount extends BaseWalletAccount>(\n\taccounts$: Observable<TAccount[]>,\n): Observable<PlatformAccountsFrame<TAccount>> =>\n\tisPlatformAccounts$(accounts$)\n\t\t? accounts$.frames$\n\t\t: accounts$.pipe(map((accounts) => ({ accounts, answered: [] })));\n\nconst idsEqual = (a: WalletId[], b: WalletId[]) =>\n\ta.length === b.length && a.every((id, i) => id === b[i]);\n\ntype WalletConnection<TAccount> = {\n\tkey: string;\n\taccounts: TAccount[];\n\tanswered: boolean;\n\tcompleted: boolean;\n\tsubscription: Subscription;\n};\n\nconst sessionKey = (wallet: WalletConnectWallet): string =>\n\t`${wallet.id}|${wallet.platforms.join(\",\")}`;\n\nconst connectionKey = (wallet: BaseWallet | WalletConnectWallet): string =>\n\tisWalletConnectWallet(wallet) ? sessionKey(wallet) : wallet.id;\n\n/** Shared engine behind every platform's `getAccounts$`. */\nexport const createPlatformAccounts$ = <\n\tTWallet extends BaseWallet,\n\tTAccount extends BaseWalletAccount,\n>({\n\twallets$,\n\tgetInjectedAccounts$,\n\tgetWalletConnectAccounts$,\n\tmapAccounts,\n\taccountChangeKey = (account) => account.id,\n}: PlatformAccountsOptions<TWallet, TAccount>): PlatformAccounts$<TAccount> => {\n\ttype Frame = PlatformAccountsFrame<TAccount>;\n\tconst nameAndChangeKey = (account: TAccount) =>\n\t\t`${account.name ?? \"\"}|${accountChangeKey(account)}`;\n\tconst accountsListEqual = (a: TAccount[], b: TAccount[]) =>\n\t\ta.length === b.length &&\n\t\ta.every((account, i) => {\n\t\t\tconst other = b[i];\n\t\t\treturn !!other && nameAndChangeKey(account) === nameAndChangeKey(other);\n\t\t});\n\tconst accountsOf = (wallet: TWallet | LiveWalletConnectWallet) =>\n\t\tisWalletConnectWallet(wallet)\n\t\t\t? getWalletConnectAccounts$(wallet)\n\t\t\t: getInjectedAccounts$(wallet);\n\n\tconst frames$ = new Observable<Frame>((subscriber) => {\n\t\tconst connections = new Map<WalletId, WalletConnection<TAccount>>();\n\t\tlet connectedIds: WalletId[] = [];\n\t\tlet walletsCompleted = false;\n\t\tlet emitted = false;\n\n\t\tconst awaitingFirstAnswers = () =>\n\t\t\t!emitted &&\n\t\t\t[...connections.values()].some((connection) => !connection.answered);\n\n\t\tconst accountsListed = () =>\n\t\t\tconnectedIds.flatMap((id) => connections.get(id)?.accounts ?? []);\n\t\tconst walletsAnswered = () =>\n\t\t\tconnectedIds.filter((id) => connections.get(id)?.answered);\n\n\t\tconst emit = () => {\n\t\t\tif (awaitingFirstAnswers()) return;\n\t\t\temitted = true;\n\t\t\tsubscriber.next({\n\t\t\t\taccounts: accountsListed(),\n\t\t\t\tanswered: walletsAnswered(),\n\t\t\t});\n\t\t};\n\n\t\tconst completeIfDone = () => {\n\t\t\tif (\n\t\t\t\twalletsCompleted &&\n\t\t\t\t[...connections.values()].every((connection) => connection.completed)\n\t\t\t)\n\t\t\t\tsubscriber.complete();\n\t\t};\n\n\t\tconst reconcile = (wallets: (TWallet | WalletConnectWallet)[]) => {\n\t\t\tconst connected = wallets.filter(\n\t\t\t\t(wallet): wallet is TWallet | LiveWalletConnectWallet =>\n\t\t\t\t\twallet.isConnected && !wallet.isPlaceholder,\n\t\t\t);\n\t\t\tconst keys = new Map(\n\t\t\t\tconnected.map((w) => [w.id, connectionKey(w)] as const),\n\t\t\t);\n\t\t\tfor (const [id, connection] of connections) {\n\t\t\t\tif (keys.get(id) === connection.key) continue;\n\t\t\t\tconnection.subscription.unsubscribe();\n\t\t\t\tconnections.delete(id);\n\t\t\t}\n\t\t\tconnectedIds = connected.map((wallet) => wallet.id);\n\t\t\tconst opened = connected\n\t\t\t\t.filter((wallet) => !connections.has(wallet.id))\n\t\t\t\t.map((wallet) => {\n\t\t\t\t\tconst connection: WalletConnection<TAccount> = {\n\t\t\t\t\t\tkey: connectionKey(wallet),\n\t\t\t\t\t\taccounts: [],\n\t\t\t\t\t\tanswered: false,\n\t\t\t\t\t\tcompleted: false,\n\t\t\t\t\t\tsubscription: new Subscription(),\n\t\t\t\t\t};\n\t\t\t\t\tconnections.set(wallet.id, connection);\n\t\t\t\t\treturn { wallet, connection };\n\t\t\t\t});\n\t\t\tfor (const { wallet, connection } of opened) {\n\t\t\t\tconnection.subscription.add(\n\t\t\t\t\taccountsOf(wallet).subscribe({\n\t\t\t\t\t\tnext: (accounts) => {\n\t\t\t\t\t\t\tconnection.accounts = accounts;\n\t\t\t\t\t\t\tconnection.answered = true;\n\t\t\t\t\t\t\temit();\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: (error) => subscriber.error(error),\n\t\t\t\t\t\tcomplete: () => {\n\t\t\t\t\t\t\tconnection.completed = true;\n\t\t\t\t\t\t\tcompleteIfDone();\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\temit();\n\t\t};\n\n\t\tconst sub = wallets$.subscribe({\n\t\t\tnext: reconcile,\n\t\t\terror: (error) => subscriber.error(error),\n\t\t\tcomplete: () => {\n\t\t\t\twalletsCompleted = true;\n\t\t\t\tcompleteIfDone();\n\t\t\t},\n\t\t});\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tfor (const connection of connections.values())\n\t\t\t\tconnection.subscription.unsubscribe();\n\t\t};\n\t}).pipe(\n\t\tmap((frame) =>\n\t\t\tmapAccounts ? { ...frame, accounts: mapAccounts(frame.accounts) } : frame,\n\t\t),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\taccountsListEqual(a.accounts, b.accounts) &&\n\t\t\t\tidsEqual(a.answered, b.answered),\n\t\t),\n\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t);\n\tconst accounts$ = frames$.pipe(\n\t\tmap((frame) => frame.accounts),\n\t\tdistinctUntilChanged(accountsListEqual),\n\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t);\n\treturn Object.assign(accounts$, { frames$ });\n};\n\n/**\n * CAIP-10 account strings (\"<namespace>:<chainRef>:<address>\") the live\n * WalletConnect session carries for a namespace.\n */\nexport const getSessionCaip10s = (\n\tsession: NonNullable<WalletConnectProvider[\"session\"]>,\n\tnamespace: string,\n): string[] =>\n\tObject.values(session.namespaces)\n\t\t.flatMap((ns) => ns.accounts ?? [])\n\t\t.filter((account) => account.startsWith(`${namespace}:`));\n\n/**\n * Unique addresses from CAIP-10 account strings (one entry per chain, so the\n * same address repeats — dedupe).\n */\nexport const getCaip10Addresses = (caip10s: string[]): string[] => [\n\t...new Set(\n\t\tcaip10s\n\t\t\t.map((account) => account.split(\":\")[2])\n\t\t\t.filter((address): address is string => !!address),\n\t),\n];\n\n/**\n * Shared shape of the Polkadot/Solana WalletConnect account streams: no-op\n * unless the session carries the platform's namespace, then a cached\n * observable that rebuilds the account list from the session on\n * `session_update` / `accountsChanged`.\n *\n * AppKit's `getAccount(namespace).allAccounts` is always empty for namespaces\n * without a native AppKit adapter — the WalletConnect session is the source of\n * truth, hence the session-driven rebuild.\n */\nexport const getWalletConnectSessionAccounts$ = <\n\tTAccount extends BaseWalletAccount,\n>(options: {\n\twallet: LiveWalletConnectWallet;\n\tplatform: WalletPlatform;\n\t/** WalletConnect namespace, e.g. \"polkadot\" | \"solana\" | \"eip155\". */\n\tnamespace: string;\n\t/** Cache key for {@link getCachedObservable$} — must be reconnect-safe. */\n\tcacheKey: string;\n\t/** Build the account list from the live session. */\n\tbuildAccounts: (provider: WalletConnectProvider) => TAccount[];\n}): Observable<TAccount[]> => {\n\tconst { wallet, platform, namespace, cacheKey, buildAccounts } = options;\n\tconst provider = wallet.appKit.getProvider(namespace);\n\n\tif (!wallet.platforms.includes(platform) || !provider?.session) return of([]);\n\n\treturn getCachedObservable$(cacheKey, () =>\n\t\tnew Observable<TAccount[]>((subscriber) => {\n\t\t\tsubscriber.next(buildAccounts(provider));\n\n\t\t\t// Re-derive when the WalletConnect session's accounts change, mirroring\n\t\t\t// the injected paths' change subscriptions.\n\t\t\tconst reemit = () => subscriber.next(buildAccounts(provider));\n\t\t\tprovider.on(\"session_update\", reemit);\n\t\t\tprovider.on(\"accountsChanged\", reemit);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"session_update\", reemit);\n\t\t\t\tprovider.off(\"accountsChanged\", reemit);\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n"],"mappings":";;;;;;AAEA,MAAM,cAAc;AACpB,MAAM,UAAU,IAAI,YAAY;;;;;AAMhC,MAAM,mBAAmB,YAA6B;CACrD,MAAM,MAAM,QAAQ,MAAM,CAAC;CAC3B,MAAM,QAAA,GAAOA,sBAAAA,WAAAA,CAAW,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC;CACzD,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC5B,MAAM,OAAO,IAAI,OAAO,CAAC;EAGzB,IAAI,EADF,QAAQ,OAAO,QAAQ,OAAS,QAAQ,OAAO,QAAQ,MAC1C;EACf,MAAM,OAAO,KAAK,KAAK,MAAM;EAC7B,MAAM,SAAS,IAAI,MAAM,IAAI,QAAQ,IAAI,OAAO;EAEhD,IADgB,QAAQ,QACR,UAAU,GAAG,OAAO;CACrC;CACA,OAAO;AACR;;;;;;;;AASA,MAAa,qBAAqB,YAA6B;CAC9D,IAAI,CAAC,YAAY,KAAK,OAAO,GAAG,OAAO;CACvC,IAAI,YAAY,QAAQ,YAAY,GAAG,OAAO;CAC9C,OAAO,gBAAgB,OAAO;AAC/B;;;;;;;;;;;AC1BA,MAAa,mBAAmB,YAA6B;CAC5D,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI;EACH,OAAOC,YAAAA,OAAO,OAAO,OAAO,CAAC,CAAC,WAAW;CAC1C,QAAQ;EACP,OAAO;CACR;AACD;;;ACbA,MAAM,UAAU,IAAI,WAAW;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,CAAC;;;;;;;;AASzE,MAAa,iBAAiB,YAA6B;CAC1D,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI;CACJ,IAAI;EACH,UAAUC,YAAAA,OAAO,OA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AAC,OAAO,UAAU,SAAS,QAAQ,KAAK,CAAC,UAAU,SAAS,QAAA,GAAOC,KAAAA,GAAAA,CAAG,CAAC,CAAC;CAE5E,OAAOC,cAAAA,qBAAqB,gBAC3B,IAAIL,KAAAA,YAAwB,eAAe;EAC1C,WAAW,KAAK,cAAc,QAAQ,CAAC;EAIvC,MAAM,eAAe,WAAW,KAAK,cAAc,QAAQ,CAAC;EAC5D,SAAS,GAAG,kBAAkB,MAAM;EACpC,SAAS,GAAG,mBAAmB,MAAM;EAErC,aAAa;GACZ,SAAS,IAAI,kBAAkB,MAAM;GACrC,SAAS,IAAI,mBAAmB,MAAM;EACvC;CACD,CAAC,CAAC,CAAC,MAAA,GAAKG,KAAAA,YAAAA,CAAY;EAAE,UAAU;EAAM,YAAY;CAAE,CAAC,CAAC,CACvD;AACD"}
|
|
1
|
+
{"version":3,"file":"platformAccounts-FE7oA3-Y.js","names":["keccak_256","base58","base58","blake2b","map","isWalletConnectWallet","Observable","Subscription","distinctUntilChanged","shareReplay","of","getCachedObservable$"],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts","../src/api/platformAccounts.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n","import {\n\tdistinctUntilChanged,\n\tmap,\n\tObservable,\n\tof,\n\tSubscription,\n\tshareReplay,\n} from \"rxjs\";\nimport { getCachedObservable$ } from \"../utils/getCachedObservable\";\nimport type { WalletId } from \"../utils/WalletId\";\nimport type {\n\tBaseWallet,\n\tBaseWalletAccount,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n\tWalletPlatform,\n} from \"./types\";\nimport { isWalletConnectWallet } from \"./types\";\n\nexport type LiveWalletConnectWallet = Exclude<\n\tWalletConnectWallet,\n\t{ isPlaceholder: true }\n>;\n\nexport type PlatformAccountsOptions<\n\tTWallet extends BaseWallet,\n\tTAccount extends BaseWalletAccount,\n> = {\n\t/** This platform's wallets plus the shared WalletConnect connector. */\n\twallets$: Observable<(TWallet | WalletConnectWallet)[]>;\n\t/** Account stream for one connected injected wallet. */\n\tgetInjectedAccounts$: (wallet: TWallet) => Observable<TAccount[]>;\n\t/** Account stream for the WalletConnect connector. */\n\tgetWalletConnectAccounts$: (\n\t\twallet: LiveWalletConnectWallet,\n\t) => Observable<TAccount[]>;\n\t/** Optional post-flatten transform (e.g. Polkadot's `accountTypes` filter). */\n\tmapAccounts?: (accounts: TAccount[]) => TAccount[];\n\t/**\n\t * Signature of the account fields that should trigger a re-emission.\n\t * Defaults to the account id; platforms add mutable fields (Ethereum\n\t * `chainId`, Solana `chains`).\n\t */\n\taccountChangeKey?: (account: TAccount) => string;\n};\n\n/** The account list plus the connected wallets whose stream has answered, an empty list included. */\nexport type PlatformAccountsFrame<TAccount> = {\n\taccounts: TAccount[];\n\tanswered: WalletId[];\n};\n\nexport type PlatformAccounts$<TAccount> = Observable<TAccount[]> & {\n\tframes$: Observable<PlatformAccountsFrame<TAccount>>;\n};\n\nconst isPlatformAccounts$ = <TAccount extends BaseWalletAccount>(\n\taccounts$: Observable<TAccount[]>,\n): accounts$ is PlatformAccounts$<TAccount> => \"frames$\" in accounts$;\n\n/** A plugin not built on `createPlatformAccounts$` reports no answered wallet. */\nexport const framesOf = <TAccount extends BaseWalletAccount>(\n\taccounts$: Observable<TAccount[]>,\n): Observable<PlatformAccountsFrame<TAccount>> =>\n\tisPlatformAccounts$(accounts$)\n\t\t? accounts$.frames$\n\t\t: accounts$.pipe(map((accounts) => ({ accounts, answered: [] })));\n\nconst idsEqual = (a: WalletId[], b: WalletId[]) =>\n\ta.length === b.length && a.every((id, i) => id === b[i]);\n\ntype WalletConnection<TAccount> = {\n\tkey: string;\n\taccounts: TAccount[];\n\tanswered: boolean;\n\tcompleted: boolean;\n\tsubscription: Subscription;\n};\n\nconst sessionKey = (wallet: WalletConnectWallet): string =>\n\t`${wallet.id}|${wallet.platforms.join(\",\")}`;\n\nconst connectionKey = (wallet: BaseWallet | WalletConnectWallet): string =>\n\tisWalletConnectWallet(wallet) ? sessionKey(wallet) : wallet.id;\n\n/** Shared engine behind every platform's `getAccounts$`. */\nexport const createPlatformAccounts$ = <\n\tTWallet extends BaseWallet,\n\tTAccount extends BaseWalletAccount,\n>({\n\twallets$,\n\tgetInjectedAccounts$,\n\tgetWalletConnectAccounts$,\n\tmapAccounts,\n\taccountChangeKey = (account) => account.id,\n}: PlatformAccountsOptions<TWallet, TAccount>): PlatformAccounts$<TAccount> => {\n\ttype Frame = PlatformAccountsFrame<TAccount>;\n\tconst nameAndChangeKey = (account: TAccount) =>\n\t\t`${account.name ?? \"\"}|${accountChangeKey(account)}`;\n\tconst accountsListEqual = (a: TAccount[], b: TAccount[]) =>\n\t\ta.length === b.length &&\n\t\ta.every((account, i) => {\n\t\t\tconst other = b[i];\n\t\t\treturn !!other && nameAndChangeKey(account) === nameAndChangeKey(other);\n\t\t});\n\tconst accountsOf = (wallet: TWallet | LiveWalletConnectWallet) =>\n\t\tisWalletConnectWallet(wallet)\n\t\t\t? getWalletConnectAccounts$(wallet)\n\t\t\t: getInjectedAccounts$(wallet);\n\n\tconst frames$ = new Observable<Frame>((subscriber) => {\n\t\tconst connections = new Map<WalletId, WalletConnection<TAccount>>();\n\t\tlet connectedIds: WalletId[] = [];\n\t\tlet walletsCompleted = false;\n\t\tlet emitted = false;\n\n\t\tconst awaitingFirstAnswers = () =>\n\t\t\t!emitted &&\n\t\t\t[...connections.values()].some((connection) => !connection.answered);\n\n\t\tconst accountsListed = () =>\n\t\t\tconnectedIds.flatMap((id) => connections.get(id)?.accounts ?? []);\n\t\tconst walletsAnswered = () =>\n\t\t\tconnectedIds.filter((id) => connections.get(id)?.answered);\n\n\t\tconst emit = () => {\n\t\t\tif (awaitingFirstAnswers()) return;\n\t\t\temitted = true;\n\t\t\tsubscriber.next({\n\t\t\t\taccounts: accountsListed(),\n\t\t\t\tanswered: walletsAnswered(),\n\t\t\t});\n\t\t};\n\n\t\tconst completeIfDone = () => {\n\t\t\tif (\n\t\t\t\twalletsCompleted &&\n\t\t\t\t[...connections.values()].every((connection) => connection.completed)\n\t\t\t)\n\t\t\t\tsubscriber.complete();\n\t\t};\n\n\t\tconst reconcile = (wallets: (TWallet | WalletConnectWallet)[]) => {\n\t\t\tconst connected = wallets.filter(\n\t\t\t\t(wallet): wallet is TWallet | LiveWalletConnectWallet =>\n\t\t\t\t\twallet.isConnected && !wallet.isPlaceholder,\n\t\t\t);\n\t\t\tconst keys = new Map(\n\t\t\t\tconnected.map((w) => [w.id, connectionKey(w)] as const),\n\t\t\t);\n\t\t\tfor (const [id, connection] of connections) {\n\t\t\t\tif (keys.get(id) === connection.key) continue;\n\t\t\t\tconnection.subscription.unsubscribe();\n\t\t\t\tconnections.delete(id);\n\t\t\t}\n\t\t\tconnectedIds = connected.map((wallet) => wallet.id);\n\t\t\tconst opened = connected\n\t\t\t\t.filter((wallet) => !connections.has(wallet.id))\n\t\t\t\t.map((wallet) => {\n\t\t\t\t\tconst connection: WalletConnection<TAccount> = {\n\t\t\t\t\t\tkey: connectionKey(wallet),\n\t\t\t\t\t\taccounts: [],\n\t\t\t\t\t\tanswered: false,\n\t\t\t\t\t\tcompleted: false,\n\t\t\t\t\t\tsubscription: new Subscription(),\n\t\t\t\t\t};\n\t\t\t\t\tconnections.set(wallet.id, connection);\n\t\t\t\t\treturn { wallet, connection };\n\t\t\t\t});\n\t\t\tfor (const { wallet, connection } of opened) {\n\t\t\t\tconnection.subscription.add(\n\t\t\t\t\taccountsOf(wallet).subscribe({\n\t\t\t\t\t\tnext: (accounts) => {\n\t\t\t\t\t\t\tconnection.accounts = accounts;\n\t\t\t\t\t\t\tconnection.answered = true;\n\t\t\t\t\t\t\temit();\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: (error) => subscriber.error(error),\n\t\t\t\t\t\tcomplete: () => {\n\t\t\t\t\t\t\tconnection.completed = true;\n\t\t\t\t\t\t\tcompleteIfDone();\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\temit();\n\t\t};\n\n\t\tconst sub = wallets$.subscribe({\n\t\t\tnext: reconcile,\n\t\t\terror: (error) => subscriber.error(error),\n\t\t\tcomplete: () => {\n\t\t\t\twalletsCompleted = true;\n\t\t\t\tcompleteIfDone();\n\t\t\t},\n\t\t});\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t\tfor (const connection of connections.values())\n\t\t\t\tconnection.subscription.unsubscribe();\n\t\t};\n\t}).pipe(\n\t\tmap((frame) =>\n\t\t\tmapAccounts ? { ...frame, accounts: mapAccounts(frame.accounts) } : frame,\n\t\t),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\taccountsListEqual(a.accounts, b.accounts) &&\n\t\t\t\tidsEqual(a.answered, b.answered),\n\t\t),\n\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t);\n\tconst accounts$ = frames$.pipe(\n\t\tmap((frame) => frame.accounts),\n\t\tdistinctUntilChanged(accountsListEqual),\n\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t);\n\treturn Object.assign(accounts$, { frames$ });\n};\n\n/**\n * CAIP-10 account strings (\"<namespace>:<chainRef>:<address>\") the live\n * WalletConnect session carries for a namespace.\n */\nexport const getSessionCaip10s = (\n\tsession: NonNullable<WalletConnectProvider[\"session\"]>,\n\tnamespace: string,\n): string[] =>\n\tObject.values(session.namespaces)\n\t\t.flatMap((ns) => ns.accounts ?? [])\n\t\t.filter((account) => account.startsWith(`${namespace}:`));\n\n/**\n * Unique addresses from CAIP-10 account strings (one entry per chain, so the\n * same address repeats — dedupe).\n */\nexport const getCaip10Addresses = (caip10s: string[]): string[] => [\n\t...new Set(\n\t\tcaip10s\n\t\t\t.map((account) => account.split(\":\")[2])\n\t\t\t.filter((address): address is string => !!address),\n\t),\n];\n\n/**\n * Shared shape of the Polkadot/Solana WalletConnect account streams: no-op\n * unless the session carries the platform's namespace, then a cached\n * observable that rebuilds the account list from the session on\n * `session_update` / `accountsChanged`.\n *\n * AppKit's `getAccount(namespace).allAccounts` is always empty for namespaces\n * without a native AppKit adapter — the WalletConnect session is the source of\n * truth, hence the session-driven rebuild.\n */\nexport const getWalletConnectSessionAccounts$ = <\n\tTAccount extends BaseWalletAccount,\n>(options: {\n\twallet: LiveWalletConnectWallet;\n\tplatform: WalletPlatform;\n\t/** WalletConnect namespace, e.g. \"polkadot\" | \"solana\" | \"eip155\". */\n\tnamespace: string;\n\t/** Cache key for {@link getCachedObservable$} — must be reconnect-safe. */\n\tcacheKey: string;\n\t/** Build the account list from the live session. */\n\tbuildAccounts: (provider: WalletConnectProvider) => TAccount[];\n}): Observable<TAccount[]> => {\n\tconst { wallet, platform, namespace, cacheKey, buildAccounts } = options;\n\tconst provider = wallet.appKit.getProvider(namespace);\n\n\tif (!wallet.platforms.includes(platform) || !provider?.session) return of([]);\n\n\treturn getCachedObservable$(cacheKey, () =>\n\t\tnew Observable<TAccount[]>((subscriber) => {\n\t\t\tsubscriber.next(buildAccounts(provider));\n\n\t\t\t// Re-derive when the WalletConnect session's accounts change, mirroring\n\t\t\t// the injected paths' change subscriptions.\n\t\t\tconst reemit = () => subscriber.next(buildAccounts(provider));\n\t\t\tprovider.on(\"session_update\", reemit);\n\t\t\tprovider.on(\"accountsChanged\", reemit);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"session_update\", reemit);\n\t\t\t\tprovider.off(\"accountsChanged\", reemit);\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\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,KAAAA,YAAwB,eAAe;EAC1C,WAAW,KAAK,cAAc,QAAQ,CAAC;EAIvC,MAAM,eAAe,WAAW,KAAK,cAAc,QAAQ,CAAC;EAC5D,SAAS,GAAG,kBAAkB,MAAM;EACpC,SAAS,GAAG,mBAAmB,MAAM;EAErC,aAAa;GACZ,SAAS,IAAI,kBAAkB,MAAM;GACrC,SAAS,IAAI,mBAAmB,MAAM;EACvC;CACD,CAAC,CAAC,CAAC,MAAA,GAAKG,KAAAA,YAAAA,CAAY;EAAE,UAAU;EAAM,YAAY;CAAE,CAAC,CAAC,CACvD;AACD"}
|
package/dist/polkadot.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, g as PolkadotAccountType, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, g as PolkadotAccountType, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BGeGUtxz.mjs";
|
|
2
2
|
import { InjectedPolkadotAccount, SignPayload } from "polkadot-api/pjs-signer";
|
|
3
3
|
//#region src/utils/isSs58Address.d.ts
|
|
4
4
|
/**
|
|
@@ -176,7 +176,7 @@ type PolkadotPluginOptions = {
|
|
|
176
176
|
accountTypes?: PolkadotAccountType[];
|
|
177
177
|
};
|
|
178
178
|
/**
|
|
179
|
-
* Polkadot platform plugin. Pass to `
|
|
179
|
+
* Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.
|
|
180
180
|
*
|
|
181
181
|
* @example
|
|
182
182
|
* ```ts
|
package/dist/polkadot.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, g as PolkadotAccountType, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, g as PolkadotAccountType, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BGeGUtxz.js";
|
|
2
2
|
import { InjectedPolkadotAccount, SignPayload } from "polkadot-api/pjs-signer";
|
|
3
3
|
//#region src/utils/isSs58Address.d.ts
|
|
4
4
|
/**
|
|
@@ -176,7 +176,7 @@ type PolkadotPluginOptions = {
|
|
|
176
176
|
accountTypes?: PolkadotAccountType[];
|
|
177
177
|
};
|
|
178
178
|
/**
|
|
179
|
-
* Polkadot platform plugin. Pass to `
|
|
179
|
+
* Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.
|
|
180
180
|
*
|
|
181
181
|
* @example
|
|
182
182
|
* ```ts
|
package/dist/polkadot.js
CHANGED
|
@@ -21,11 +21,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_types = require("./types-
|
|
25
|
-
const require_platformAccounts = require("./platformAccounts-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const require_injectedWallets = require("./injectedWallets-BQBgS-f0.js");
|
|
24
|
+
const require_types = require("./types-BrMtrjs9.js");
|
|
25
|
+
const require_platformAccounts = require("./platformAccounts-FE7oA3-Y.js");
|
|
26
|
+
const require_registryReads = require("./registryReads-30CCkmHe.js");
|
|
27
|
+
const require_injectedWallets = require("./injectedWallets-D7wzBr_f.js");
|
|
29
28
|
let _scure_base = require("@scure/base");
|
|
30
29
|
let lodash_es = require("lodash-es");
|
|
31
30
|
let rxjs = require("rxjs");
|
|
@@ -73,7 +72,7 @@ const getPolkadotWallets$ = (store, config, registryReads$ = require_registryRea
|
|
|
73
72
|
isUserRejection: require_types.isRefusalMessage,
|
|
74
73
|
buildWallet: ({ walletId, handle, status, error, isConnected, connect, disconnect }) => {
|
|
75
74
|
const { identifier } = require_types.parseWalletId(walletId);
|
|
76
|
-
const extInfo =
|
|
75
|
+
const extInfo = require_registryReads.POLKADOT_EXTENSIONS[identifier];
|
|
77
76
|
return {
|
|
78
77
|
id: walletId,
|
|
79
78
|
type: "injected",
|
|
@@ -249,7 +248,7 @@ const VALID_ACCOUNT_TYPES = /* @__PURE__ */ new Set([
|
|
|
249
248
|
"ethereum"
|
|
250
249
|
]);
|
|
251
250
|
/**
|
|
252
|
-
* Polkadot platform plugin. Pass to `
|
|
251
|
+
* Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.
|
|
253
252
|
*
|
|
254
253
|
* @example
|
|
255
254
|
* ```ts
|
package/dist/polkadot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polkadot.js","names":["getInjectedExtensions","getWalletId","createRegistryReads$","createInjectedWallets$","map","distinctUntilChanged","isEqual","parseWalletId","isRefusalMessage","POLKADOT_EXTENSIONS","hex","of","Observable","getWalletAccountId","pjs","KheopskitError","getWalletConnectSessionAccounts$","getCaip10Addresses","getSessionCaip10s","createPlatformAccounts$"],"sources":["../src/api/polkadot/wallets.ts","../src/api/polkadot/accounts.ts","../src/api/polkadot/plugin.ts"],"sourcesContent":["import { isEqual } from \"lodash-es\";\nimport { getInjectedExtensions } from \"polkadot-api/pjs-signer\";\nimport { distinctUntilChanged, map, type Observable } from \"rxjs\";\nimport { POLKADOT_EXTENSIONS } from \"../../utils/polkadotExtensions\";\nimport { createRegistryReads$ } from \"../../utils/registryReads\";\nimport {\n\tgetWalletId,\n\tparseWalletId,\n\ttype WalletId,\n} from \"../../utils/WalletId\";\nimport { isRefusalMessage } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport type { KheopskitConfig } from \"../types\";\nimport type {\n\tPolkadotInjected,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n} from \"./types\";\n\ntype EnableResult = {\n\taccounts?: Partial<PolkadotInjected[\"accounts\"]>;\n\tsigner?: Partial<PolkadotInjected[\"signer\"]>;\n\tmetadata?: unknown;\n\tprovider?: unknown;\n};\n\ntype InjectedWeb3Window = {\n\tinjectedWeb3?: Record<\n\t\tstring,\n\t\t| { enable(appName: string): Promise<EnableResult | null | undefined> }\n\t\t| undefined\n\t>;\n};\n\nconst isPolkadotInjected = (\n\tinjected: EnableResult | null | undefined,\n): injected is PolkadotInjected =>\n\ttypeof injected?.accounts?.get === \"function\" &&\n\ttypeof injected.accounts.subscribe === \"function\" &&\n\ttypeof injected.signer?.signPayload === \"function\" &&\n\ttypeof injected.signer.signRaw === \"function\";\n\n/**\n * The list each extension last reported: read when its connect was granted,\n * so the emission that first shows the wallet connected already lists it, and\n * updated by every `subscribe` callback, so an accounts stream that restarts\n * resumes from the current list rather than the connect-time one.\n */\nexport const latestAccounts = new WeakMap<\n\tPolkadotInjected,\n\tPolkadotInjectedAccount[]\n>();\n\ntype InjectedWeb3Entry = NonNullable<\n\tNonNullable<InjectedWeb3Window[\"injectedWeb3\"]>[string]\n>;\n\n/**\n * The connect each extension is still answering. An extension keeps its\n * prompt open after kheopskit abandons the attempt, and a second `enable()`\n * meanwhile fails (polkadot-js: \"Pending authorisation request already\n * exists\") or resolves unauthorised (Talisman), so a new attempt joins this\n * one instead.\n */\nconst pendingConnects = new WeakMap<\n\tInjectedWeb3Entry,\n\tPromise<PolkadotInjected>\n>();\n\nconst enableExtension = async (\n\tidentifier: string,\n\tentry: InjectedWeb3Entry,\n\tappName: string,\n) => {\n\tconst injected = await entry.enable(appName);\n\tif (!isPolkadotInjected(injected))\n\t\tthrow new Error(`Unsupported extension: \"${identifier}\"`);\n\tlatestAccounts.set(injected, await injected.accounts.get());\n\treturn injected;\n};\n\nconst connectExtension = (\n\tidentifier: string,\n\tappName: string,\n): Promise<PolkadotInjected> => {\n\tconst entry = (globalThis as InjectedWeb3Window).injectedWeb3?.[identifier];\n\tif (!entry)\n\t\treturn Promise.reject(new Error(`Unavailable extension: \"${identifier}\"`));\n\tconst pending = pendingConnects.get(entry);\n\tif (pending) return pending;\n\tconst connecting = enableExtension(identifier, entry, appName);\n\tpendingConnects.set(entry, connecting);\n\tconst settle = () => pendingConnects.delete(entry);\n\tconnecting.then(settle, settle);\n\treturn connecting;\n};\n\nconst getInjectedWalletsIds = () =>\n\ttypeof window === \"undefined\"\n\t\t? []\n\t\t: getInjectedExtensions().map((name) => getWalletId(\"polkadot\", name));\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 getPolkadotWallets$ = (\n\tstore: KheopskitStore,\n\tconfig: Pick<KheopskitConfig, \"appName\" | \"walletConnect\">,\n\tregistryReads$: Observable<void> = createRegistryReads$(),\n) =>\n\tcreateInjectedWallets$<WalletId, PolkadotInjectedWallet, PolkadotInjected>(\n\t\tstore,\n\t\t{\n\t\t\tsources$: registryReads$.pipe(\n\t\t\t\tmap(getInjectedWalletsIds),\n\t\t\t\tdistinctUntilChanged<WalletId[]>(isEqual),\n\t\t\t),\n\t\t\tgetWalletId: (walletId) => walletId,\n\t\t\tconnect: (walletId) =>\n\t\t\t\tconnectExtension(\n\t\t\t\t\tparseWalletId(walletId).identifier,\n\t\t\t\t\tconfig.appName ||\n\t\t\t\t\t\tconfig.walletConnect?.metadata.name ||\n\t\t\t\t\t\twindow.location.hostname,\n\t\t\t\t),\n\t\t\tisUserRejection: isRefusalMessage,\n\t\t\tbuildWallet: ({\n\t\t\t\twalletId,\n\t\t\t\thandle,\n\t\t\t\tstatus,\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t\tconnect,\n\t\t\t\tdisconnect,\n\t\t\t}) => {\n\t\t\t\tconst { identifier } = parseWalletId(walletId);\n\t\t\t\tconst extInfo = POLKADOT_EXTENSIONS[identifier];\n\n\t\t\t\treturn {\n\t\t\t\t\tid: walletId,\n\t\t\t\t\ttype: \"injected\",\n\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\tname: extInfo?.name ?? identifier,\n\t\t\t\t\ticon: extInfo?.icon ?? \"\",\n\t\t\t\t\tsourceId: identifier,\n\t\t\t\t\textension: handle,\n\t\t\t\t\tstatus,\n\t\t\t\t\terror,\n\t\t\t\t\tisConnected,\n\t\t\t\t\tconnect,\n\t\t\t\t\tdisconnect,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t);\n","import { hex } from \"@scure/base\";\nimport type {\n\tKeypairType,\n\tSignPayload,\n\tSignRaw,\n} from \"polkadot-api/pjs-signer\";\nimport * as pjs from \"polkadot-api/pjs-signer\";\nimport { Observable, of } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { KheopskitError } from \"../errors\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tPolkadotAccountType,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n} from \"../types\";\nimport type {\n\tPolkadotAccount,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n\tPolkadotSignRawType,\n\tPolkadotWallet,\n} from \"./types\";\nimport { latestAccounts } from \"./wallets\";\n\ntype RawSignature = `0x${string}`;\n\nconst encodeRawData = (\n\tdata: string | Uint8Array,\n\ttype?: PolkadotSignRawType,\n): { data: string; type: PolkadotSignRawType } =>\n\ttypeof data === \"string\"\n\t\t? { data, type: type ?? \"payload\" }\n\t\t: { data: `0x${hex.encode(data)}`, type: type ?? \"bytes\" };\n\n/**\n * pjs-signer's signature-type map knows ed25519, sr25519 and ecdsa only, so an\n * `ethereum` type would get a 64-byte mock signature where ecdsa needs 65.\n */\nconst toSignerType = (type: PolkadotAccountType): KeypairType =>\n\ttype === \"ethereum\" ? \"ecdsa\" : type;\n\nconst getInjectedWalletAccounts$ = (\n\twallet: PolkadotInjectedWallet,\n): Observable<PolkadotAccount[]> => {\n\tconst injected = wallet.extension;\n\tif (!wallet.isConnected || !injected) return of([]);\n\n\treturn new Observable<PolkadotAccount[]>((subscriber) => {\n\t\tconst signPayload = injected.signer.signPayload.bind(injected.signer);\n\t\tconst signRaw = injected.signer.signRaw.bind(injected.signer);\n\t\tconst { field, factory } = getPjsSignerField();\n\n\t\tconst toAccount = (account: PolkadotInjectedAccount): PolkadotAccount => {\n\t\t\tconst { address } = account;\n\t\t\tconst type = account.type ?? \"sr25519\";\n\t\t\treturn {\n\t\t\t\t...account,\n\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\ttype,\n\t\t\t\tplatform: \"polkadot\",\n\t\t\t\twalletName: wallet.name,\n\t\t\t\twalletId: wallet.id,\n\t\t\t\t[field]: factory(address, signPayload, signRaw, toSignerType(type)),\n\t\t\t\tsignRaw: async (data, options) =>\n\t\t\t\t\t(await signRaw({ address, ...encodeRawData(data, options?.type) }))\n\t\t\t\t\t\t.signature,\n\t\t\t} as Exclude<PolkadotAccount, { isPlaceholder: true }>;\n\t\t};\n\n\t\tconst toAccounts = (accounts: PolkadotInjectedAccount[]) =>\n\t\t\taccounts.flatMap((account) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn [toAccount(account)];\n\t\t\t\t} catch {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t});\n\n\t\tconst emit = (accounts: PolkadotInjectedAccount[]) => {\n\t\t\tlatestAccounts.set(injected, accounts);\n\t\t\tsubscriber.next(toAccounts(accounts));\n\t\t};\n\n\t\temit(latestAccounts.get(injected) ?? []);\n\t\treturn injected.accounts.subscribe(emit);\n\t});\n};\n\n/**\n * polkadot-api v2's `getPolkadotSignerFromPjs` takes three parameters and\n * ignores the fourth at runtime.\n */\ntype PjsSignerFactory = (\n\taddress: string,\n\tsignPayload: SignPayload,\n\tsignRaw: SignRaw,\n\ttype?: KeypairType,\n) => unknown;\n\ntype PjsSignerModule = {\n\tgetTxCreatorFromPjs?: PjsSignerFactory;\n\tgetPolkadotSignerFromPjs?: PjsSignerFactory;\n};\n\n/**\n * polkadot-api v3 replaced `polkadotSigner` (PolkadotSigner) with `txCreator`\n * (TxCreator). Which one the app's installed version provides is detected at\n * runtime so a single @kheopskit/core release supports both.\n */\nconst getPjsSignerField = (): {\n\tfield: \"txCreator\" | \"polkadotSigner\";\n\tfactory: PjsSignerFactory;\n} => {\n\tconst module = pjs as PjsSignerModule;\n\tif (module.getTxCreatorFromPjs)\n\t\treturn { field: \"txCreator\", factory: module.getTxCreatorFromPjs };\n\tif (module.getPolkadotSignerFromPjs)\n\t\treturn {\n\t\t\tfield: \"polkadotSigner\",\n\t\t\tfactory: module.getPolkadotSignerFromPjs,\n\t\t};\n\tthrow new KheopskitError(\n\t\t\"UNSUPPORTED_VERSION\",\n\t\t\"Unsupported polkadot-api/pjs-signer version\",\n\t);\n};\n\nconst requestSignMessage = (\n\tappKit: AppKitInstance,\n\tprovider: WalletConnectProvider,\n\taddress: string,\n\tmessage: string,\n) => {\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\tconst chainId = appKit.getCaipNetworks(\"polkadot\")[0]?.caipNetworkId;\n\tif (!chainId)\n\t\tthrow new KheopskitError(\n\t\t\t\"NO_SESSION\",\n\t\t\t\"No CAIP network available for polkadot\",\n\t\t);\n\n\treturn provider.client.request<{ signature: RawSignature }>({\n\t\ttopic: provider.session.topic,\n\t\tchainId,\n\t\trequest: {\n\t\t\tmethod: \"polkadot_signMessage\",\n\t\t\tparams: { address, message },\n\t\t},\n\t});\n};\n\nconst getAppKitPolkadotSigning = (appKit: AppKitInstance, address: string) => {\n\tconst provider = appKit.getProvider(\"polkadot\");\n\tif (!provider) throw new KheopskitError(\"NO_PROVIDER\", \"No provider found\");\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\tconst signMessage = (message: string) =>\n\t\trequestSignMessage(appKit, provider, address, message);\n\n\tconst { field, factory } = getPjsSignerField();\n\n\tconst signer = factory(\n\t\taddress,\n\t\t(transactionPayload) => {\n\t\t\tif (!provider.session)\n\t\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\t\t\treturn provider.client.request({\n\t\t\t\ttopic: provider.session.topic,\n\t\t\t\tchainId: `polkadot:${transactionPayload.genesisHash.substring(2, 34)}`,\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"polkadot_signTransaction\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\ttransactionPayload,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t\tasync ({ data }) => ({\n\t\t\tid: 0,\n\t\t\tsignature: (await signMessage(data)).signature,\n\t\t}),\n\t\t\"sr25519\",\n\t);\n\n\tconst signRaw: PolkadotAccount[\"signRaw\"] = async (data) =>\n\t\t(await signMessage(encodeRawData(data).data)).signature;\n\n\treturn { [field]: signer, signRaw };\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<PolkadotAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"polkadot\",\n\t\tnamespace: \"polkadot\",\n\t\tcacheKey: `accounts:${wallet.id}:polkadot:`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst addresses = getCaip10Addresses(\n\t\t\t\tgetSessionCaip10s(session, \"polkadot\"),\n\t\t\t);\n\n\t\t\treturn addresses.map(\n\t\t\t\t(address) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\t...getAppKitPolkadotSigning(wallet.appKit, address),\n\t\t\t\t\t\tgenesisHash: null,\n\t\t\t\t\t\tname: `${wallet.name} Polkadot`,\n\t\t\t\t\t\t// WalletConnect (Reown AppKit) doesn't expose account key type;\n\t\t\t\t\t\t// default to sr25519, which is the most common Polkadot key type.\n\t\t\t\t\t\ttype: \"sr25519\",\n\t\t\t\t\t}) as PolkadotAccount,\n\t\t\t);\n\t\t},\n\t});\n\nexport const getPolkadotAccounts$ = (\n\tpolkadotWallets$: Observable<(PolkadotWallet | WalletConnectWallet)[]>,\n\tpolkadotAccountTypes: PolkadotAccountType[],\n) => {\n\tif (polkadotAccountTypes.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] polkadot({ accountTypes }) is empty; all Polkadot accounts will be filtered out.\",\n\t\t);\n\t}\n\n\treturn createPlatformAccounts$({\n\t\twallets$: polkadotWallets$,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\tmapAccounts: (accounts) =>\n\t\t\taccounts.filter((account) => polkadotAccountTypes.includes(account.type)),\n\t});\n};\n","import type {\n\tKheopskitPlatform,\n\tPlatformContext,\n\tPolkadotAccountType,\n} from \"../types\";\nimport { getPolkadotAccounts$ } from \"./accounts\";\nimport type { PolkadotAccount, PolkadotWallet } from \"./types\";\nimport { getPolkadotWallets$ } from \"./wallets\";\n\nconst DEFAULT_ACCOUNT_TYPES: PolkadotAccountType[] = [\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n];\n\nconst VALID_ACCOUNT_TYPES = new Set<string>([\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n\t\"ethereum\",\n]);\n\nexport type PolkadotPluginOptions = {\n\t/**\n\t * Allowed Polkadot account key types. Accounts with other key types are\n\t * filtered out from kheopskit state.\n\t *\n\t * @default [\"sr25519\", \"ed25519\", \"ecdsa\"]\n\t */\n\taccountTypes?: PolkadotAccountType[];\n};\n\n/**\n * Polkadot platform plugin. Pass to `getKheopskit$({ platforms: [polkadot()] })`.\n *\n * @example\n * ```ts\n * import { polkadot } from \"@kheopskit/core/polkadot\";\n * polkadot({ accountTypes: [\"sr25519\", \"ed25519\", \"ecdsa\"] });\n * ```\n */\nexport const polkadot = (\n\toptions: PolkadotPluginOptions = {},\n): KheopskitPlatform<\"polkadot\", PolkadotWallet, PolkadotAccount> => {\n\tconst accountTypes = options.accountTypes ?? DEFAULT_ACCOUNT_TYPES;\n\n\tconst invalid = accountTypes.filter((t) => !VALID_ACCOUNT_TYPES.has(t));\n\tif (invalid.length > 0) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown polkadot accountTypes: ${JSON.stringify(invalid)}. Valid values: \"sr25519\", \"ed25519\", \"ecdsa\", \"ethereum\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"polkadot\",\n\t\tgetWallets$: (ctx: PlatformContext) =>\n\t\t\tgetPolkadotWallets$(ctx.store, ctx.config, ctx.registryReads$),\n\t\tgetAccounts$: (wallets$) => getPolkadotAccounts$(wallets$, accountTypes),\n\t\tacceptsCachedAccount: (cached) =>\n\t\t\taccountTypes.includes(cached.polkadotAccountType ?? \"sr25519\"),\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,sBACL,aAEA,OAAO,UAAU,UAAU,QAAQ,cACnC,OAAO,SAAS,SAAS,cAAc,cACvC,OAAO,SAAS,QAAQ,gBAAgB,cACxC,OAAO,SAAS,OAAO,YAAY;;;;;;;AAQpC,MAAa,iCAAiB,IAAI,QAGhC;;;;;;;;AAaF,MAAM,kCAAkB,IAAI,QAG1B;AAEF,MAAM,kBAAkB,OACvB,YACA,OACA,YACI;CACJ,MAAM,WAAW,MAAM,MAAM,OAAO,OAAO;CAC3C,IAAI,CAAC,mBAAmB,QAAQ,GAC/B,MAAM,IAAI,MAAM,2BAA2B,WAAW,EAAE;CACzD,e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,KAAK,UAAU,OAAO,EAAE,2DACvE;CAGD,OAAO;EACN,UAAU;EACV,cAAc,QACb,oBAAoB,IAAI,OAAO,IAAI,QAAQ,IAAI,cAAc;EAC9D,eAAe,aAAa,qBAAqB,UAAU,YAAY;EACvE,uBAAuB,WACtB,aAAa,SAAS,OAAO,uBAAuB,SAAS;CAC/D;AACD"}
|
|
1
|
+
{"version":3,"file":"polkadot.js","names":["getInjectedExtensions","getWalletId","createRegistryReads$","createInjectedWallets$","map","distinctUntilChanged","isEqual","parseWalletId","isRefusalMessage","POLKADOT_EXTENSIONS","hex","of","Observable","getWalletAccountId","pjs","KheopskitError","getWalletConnectSessionAccounts$","getCaip10Addresses","getSessionCaip10s","createPlatformAccounts$"],"sources":["../src/api/polkadot/wallets.ts","../src/api/polkadot/accounts.ts","../src/api/polkadot/plugin.ts"],"sourcesContent":["import { isEqual } from \"lodash-es\";\nimport { getInjectedExtensions } from \"polkadot-api/pjs-signer\";\nimport { distinctUntilChanged, map, type Observable } from \"rxjs\";\nimport { POLKADOT_EXTENSIONS } from \"../../utils/polkadotExtensions\";\nimport { createRegistryReads$ } from \"../../utils/registryReads\";\nimport {\n\tgetWalletId,\n\tparseWalletId,\n\ttype WalletId,\n} from \"../../utils/WalletId\";\nimport { isRefusalMessage } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport type { KheopskitConfig } from \"../types\";\nimport type {\n\tPolkadotInjected,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n} from \"./types\";\n\ntype EnableResult = {\n\taccounts?: Partial<PolkadotInjected[\"accounts\"]>;\n\tsigner?: Partial<PolkadotInjected[\"signer\"]>;\n\tmetadata?: unknown;\n\tprovider?: unknown;\n};\n\ntype InjectedWeb3Window = {\n\tinjectedWeb3?: Record<\n\t\tstring,\n\t\t| { enable(appName: string): Promise<EnableResult | null | undefined> }\n\t\t| undefined\n\t>;\n};\n\nconst isPolkadotInjected = (\n\tinjected: EnableResult | null | undefined,\n): injected is PolkadotInjected =>\n\ttypeof injected?.accounts?.get === \"function\" &&\n\ttypeof injected.accounts.subscribe === \"function\" &&\n\ttypeof injected.signer?.signPayload === \"function\" &&\n\ttypeof injected.signer.signRaw === \"function\";\n\n/**\n * The list each extension last reported: read when its connect was granted,\n * so the emission that first shows the wallet connected already lists it, and\n * updated by every `subscribe` callback, so an accounts stream that restarts\n * resumes from the current list rather than the connect-time one.\n */\nexport const latestAccounts = new WeakMap<\n\tPolkadotInjected,\n\tPolkadotInjectedAccount[]\n>();\n\ntype InjectedWeb3Entry = NonNullable<\n\tNonNullable<InjectedWeb3Window[\"injectedWeb3\"]>[string]\n>;\n\n/**\n * The connect each extension is still answering. An extension keeps its\n * prompt open after kheopskit abandons the attempt, and a second `enable()`\n * meanwhile fails (polkadot-js: \"Pending authorisation request already\n * exists\") or resolves unauthorised (Talisman), so a new attempt joins this\n * one instead.\n */\nconst pendingConnects = new WeakMap<\n\tInjectedWeb3Entry,\n\tPromise<PolkadotInjected>\n>();\n\nconst enableExtension = async (\n\tidentifier: string,\n\tentry: InjectedWeb3Entry,\n\tappName: string,\n) => {\n\tconst injected = await entry.enable(appName);\n\tif (!isPolkadotInjected(injected))\n\t\tthrow new Error(`Unsupported extension: \"${identifier}\"`);\n\tlatestAccounts.set(injected, await injected.accounts.get());\n\treturn injected;\n};\n\nconst connectExtension = (\n\tidentifier: string,\n\tappName: string,\n): Promise<PolkadotInjected> => {\n\tconst entry = (globalThis as InjectedWeb3Window).injectedWeb3?.[identifier];\n\tif (!entry)\n\t\treturn Promise.reject(new Error(`Unavailable extension: \"${identifier}\"`));\n\tconst pending = pendingConnects.get(entry);\n\tif (pending) return pending;\n\tconst connecting = enableExtension(identifier, entry, appName);\n\tpendingConnects.set(entry, connecting);\n\tconst settle = () => pendingConnects.delete(entry);\n\tconnecting.then(settle, settle);\n\treturn connecting;\n};\n\nconst getInjectedWalletsIds = () =>\n\ttypeof window === \"undefined\"\n\t\t? []\n\t\t: getInjectedExtensions().map((name) => getWalletId(\"polkadot\", name));\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 getPolkadotWallets$ = (\n\tstore: KheopskitStore,\n\tconfig: Pick<KheopskitConfig, \"appName\" | \"walletConnect\">,\n\tregistryReads$: Observable<void> = createRegistryReads$(),\n) =>\n\tcreateInjectedWallets$<WalletId, PolkadotInjectedWallet, PolkadotInjected>(\n\t\tstore,\n\t\t{\n\t\t\tsources$: registryReads$.pipe(\n\t\t\t\tmap(getInjectedWalletsIds),\n\t\t\t\tdistinctUntilChanged<WalletId[]>(isEqual),\n\t\t\t),\n\t\t\tgetWalletId: (walletId) => walletId,\n\t\t\tconnect: (walletId) =>\n\t\t\t\tconnectExtension(\n\t\t\t\t\tparseWalletId(walletId).identifier,\n\t\t\t\t\tconfig.appName ||\n\t\t\t\t\t\tconfig.walletConnect?.metadata.name ||\n\t\t\t\t\t\twindow.location.hostname,\n\t\t\t\t),\n\t\t\tisUserRejection: isRefusalMessage,\n\t\t\tbuildWallet: ({\n\t\t\t\twalletId,\n\t\t\t\thandle,\n\t\t\t\tstatus,\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t\tconnect,\n\t\t\t\tdisconnect,\n\t\t\t}) => {\n\t\t\t\tconst { identifier } = parseWalletId(walletId);\n\t\t\t\tconst extInfo = POLKADOT_EXTENSIONS[identifier];\n\n\t\t\t\treturn {\n\t\t\t\t\tid: walletId,\n\t\t\t\t\ttype: \"injected\",\n\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\tname: extInfo?.name ?? identifier,\n\t\t\t\t\ticon: extInfo?.icon ?? \"\",\n\t\t\t\t\tsourceId: identifier,\n\t\t\t\t\textension: handle,\n\t\t\t\t\tstatus,\n\t\t\t\t\terror,\n\t\t\t\t\tisConnected,\n\t\t\t\t\tconnect,\n\t\t\t\t\tdisconnect,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t);\n","import { hex } from \"@scure/base\";\nimport type {\n\tKeypairType,\n\tSignPayload,\n\tSignRaw,\n} from \"polkadot-api/pjs-signer\";\nimport * as pjs from \"polkadot-api/pjs-signer\";\nimport { Observable, of } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { KheopskitError } from \"../errors\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tPolkadotAccountType,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n} from \"../types\";\nimport type {\n\tPolkadotAccount,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n\tPolkadotSignRawType,\n\tPolkadotWallet,\n} from \"./types\";\nimport { latestAccounts } from \"./wallets\";\n\ntype RawSignature = `0x${string}`;\n\nconst encodeRawData = (\n\tdata: string | Uint8Array,\n\ttype?: PolkadotSignRawType,\n): { data: string; type: PolkadotSignRawType } =>\n\ttypeof data === \"string\"\n\t\t? { data, type: type ?? \"payload\" }\n\t\t: { data: `0x${hex.encode(data)}`, type: type ?? \"bytes\" };\n\n/**\n * pjs-signer's signature-type map knows ed25519, sr25519 and ecdsa only, so an\n * `ethereum` type would get a 64-byte mock signature where ecdsa needs 65.\n */\nconst toSignerType = (type: PolkadotAccountType): KeypairType =>\n\ttype === \"ethereum\" ? \"ecdsa\" : type;\n\nconst getInjectedWalletAccounts$ = (\n\twallet: PolkadotInjectedWallet,\n): Observable<PolkadotAccount[]> => {\n\tconst injected = wallet.extension;\n\tif (!wallet.isConnected || !injected) return of([]);\n\n\treturn new Observable<PolkadotAccount[]>((subscriber) => {\n\t\tconst signPayload = injected.signer.signPayload.bind(injected.signer);\n\t\tconst signRaw = injected.signer.signRaw.bind(injected.signer);\n\t\tconst { field, factory } = getPjsSignerField();\n\n\t\tconst toAccount = (account: PolkadotInjectedAccount): PolkadotAccount => {\n\t\t\tconst { address } = account;\n\t\t\tconst type = account.type ?? \"sr25519\";\n\t\t\treturn {\n\t\t\t\t...account,\n\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\ttype,\n\t\t\t\tplatform: \"polkadot\",\n\t\t\t\twalletName: wallet.name,\n\t\t\t\twalletId: wallet.id,\n\t\t\t\t[field]: factory(address, signPayload, signRaw, toSignerType(type)),\n\t\t\t\tsignRaw: async (data, options) =>\n\t\t\t\t\t(await signRaw({ address, ...encodeRawData(data, options?.type) }))\n\t\t\t\t\t\t.signature,\n\t\t\t} as Exclude<PolkadotAccount, { isPlaceholder: true }>;\n\t\t};\n\n\t\tconst toAccounts = (accounts: PolkadotInjectedAccount[]) =>\n\t\t\taccounts.flatMap((account) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn [toAccount(account)];\n\t\t\t\t} catch {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t});\n\n\t\tconst emit = (accounts: PolkadotInjectedAccount[]) => {\n\t\t\tlatestAccounts.set(injected, accounts);\n\t\t\tsubscriber.next(toAccounts(accounts));\n\t\t};\n\n\t\temit(latestAccounts.get(injected) ?? []);\n\t\treturn injected.accounts.subscribe(emit);\n\t});\n};\n\n/**\n * polkadot-api v2's `getPolkadotSignerFromPjs` takes three parameters and\n * ignores the fourth at runtime.\n */\ntype PjsSignerFactory = (\n\taddress: string,\n\tsignPayload: SignPayload,\n\tsignRaw: SignRaw,\n\ttype?: KeypairType,\n) => unknown;\n\ntype PjsSignerModule = {\n\tgetTxCreatorFromPjs?: PjsSignerFactory;\n\tgetPolkadotSignerFromPjs?: PjsSignerFactory;\n};\n\n/**\n * polkadot-api v3 replaced `polkadotSigner` (PolkadotSigner) with `txCreator`\n * (TxCreator). Which one the app's installed version provides is detected at\n * runtime so a single @kheopskit/core release supports both.\n */\nconst getPjsSignerField = (): {\n\tfield: \"txCreator\" | \"polkadotSigner\";\n\tfactory: PjsSignerFactory;\n} => {\n\tconst module = pjs as PjsSignerModule;\n\tif (module.getTxCreatorFromPjs)\n\t\treturn { field: \"txCreator\", factory: module.getTxCreatorFromPjs };\n\tif (module.getPolkadotSignerFromPjs)\n\t\treturn {\n\t\t\tfield: \"polkadotSigner\",\n\t\t\tfactory: module.getPolkadotSignerFromPjs,\n\t\t};\n\tthrow new KheopskitError(\n\t\t\"UNSUPPORTED_VERSION\",\n\t\t\"Unsupported polkadot-api/pjs-signer version\",\n\t);\n};\n\nconst requestSignMessage = (\n\tappKit: AppKitInstance,\n\tprovider: WalletConnectProvider,\n\taddress: string,\n\tmessage: string,\n) => {\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\tconst chainId = appKit.getCaipNetworks(\"polkadot\")[0]?.caipNetworkId;\n\tif (!chainId)\n\t\tthrow new KheopskitError(\n\t\t\t\"NO_SESSION\",\n\t\t\t\"No CAIP network available for polkadot\",\n\t\t);\n\n\treturn provider.client.request<{ signature: RawSignature }>({\n\t\ttopic: provider.session.topic,\n\t\tchainId,\n\t\trequest: {\n\t\t\tmethod: \"polkadot_signMessage\",\n\t\t\tparams: { address, message },\n\t\t},\n\t});\n};\n\nconst getAppKitPolkadotSigning = (appKit: AppKitInstance, address: string) => {\n\tconst provider = appKit.getProvider(\"polkadot\");\n\tif (!provider) throw new KheopskitError(\"NO_PROVIDER\", \"No provider found\");\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\tconst signMessage = (message: string) =>\n\t\trequestSignMessage(appKit, provider, address, message);\n\n\tconst { field, factory } = getPjsSignerField();\n\n\tconst signer = factory(\n\t\taddress,\n\t\t(transactionPayload) => {\n\t\t\tif (!provider.session)\n\t\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\t\t\treturn provider.client.request({\n\t\t\t\ttopic: provider.session.topic,\n\t\t\t\tchainId: `polkadot:${transactionPayload.genesisHash.substring(2, 34)}`,\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"polkadot_signTransaction\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\ttransactionPayload,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t\tasync ({ data }) => ({\n\t\t\tid: 0,\n\t\t\tsignature: (await signMessage(data)).signature,\n\t\t}),\n\t\t\"sr25519\",\n\t);\n\n\tconst signRaw: PolkadotAccount[\"signRaw\"] = async (data) =>\n\t\t(await signMessage(encodeRawData(data).data)).signature;\n\n\treturn { [field]: signer, signRaw };\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<PolkadotAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"polkadot\",\n\t\tnamespace: \"polkadot\",\n\t\tcacheKey: `accounts:${wallet.id}:polkadot:`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst addresses = getCaip10Addresses(\n\t\t\t\tgetSessionCaip10s(session, \"polkadot\"),\n\t\t\t);\n\n\t\t\treturn addresses.map(\n\t\t\t\t(address) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\t...getAppKitPolkadotSigning(wallet.appKit, address),\n\t\t\t\t\t\tgenesisHash: null,\n\t\t\t\t\t\tname: `${wallet.name} Polkadot`,\n\t\t\t\t\t\t// WalletConnect (Reown AppKit) doesn't expose account key type;\n\t\t\t\t\t\t// default to sr25519, which is the most common Polkadot key type.\n\t\t\t\t\t\ttype: \"sr25519\",\n\t\t\t\t\t}) as PolkadotAccount,\n\t\t\t);\n\t\t},\n\t});\n\nexport const getPolkadotAccounts$ = (\n\tpolkadotWallets$: Observable<(PolkadotWallet | WalletConnectWallet)[]>,\n\tpolkadotAccountTypes: PolkadotAccountType[],\n) => {\n\tif (polkadotAccountTypes.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] polkadot({ accountTypes }) is empty; all Polkadot accounts will be filtered out.\",\n\t\t);\n\t}\n\n\treturn createPlatformAccounts$({\n\t\twallets$: polkadotWallets$,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\tmapAccounts: (accounts) =>\n\t\t\taccounts.filter((account) => polkadotAccountTypes.includes(account.type)),\n\t});\n};\n","import type {\n\tKheopskitPlatform,\n\tPlatformContext,\n\tPolkadotAccountType,\n} from \"../types\";\nimport { getPolkadotAccounts$ } from \"./accounts\";\nimport type { PolkadotAccount, PolkadotWallet } from \"./types\";\nimport { getPolkadotWallets$ } from \"./wallets\";\n\nconst DEFAULT_ACCOUNT_TYPES: PolkadotAccountType[] = [\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n];\n\nconst VALID_ACCOUNT_TYPES = new Set<string>([\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n\t\"ethereum\",\n]);\n\nexport type PolkadotPluginOptions = {\n\t/**\n\t * Allowed Polkadot account key types. Accounts with other key types are\n\t * filtered out from kheopskit state.\n\t *\n\t * @default [\"sr25519\", \"ed25519\", \"ecdsa\"]\n\t */\n\taccountTypes?: PolkadotAccountType[];\n};\n\n/**\n * Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.\n *\n * @example\n * ```ts\n * import { polkadot } from \"@kheopskit/core/polkadot\";\n * polkadot({ accountTypes: [\"sr25519\", \"ed25519\", \"ecdsa\"] });\n * ```\n */\nexport const polkadot = (\n\toptions: PolkadotPluginOptions = {},\n): KheopskitPlatform<\"polkadot\", PolkadotWallet, PolkadotAccount> => {\n\tconst accountTypes = options.accountTypes ?? DEFAULT_ACCOUNT_TYPES;\n\n\tconst invalid = accountTypes.filter((t) => !VALID_ACCOUNT_TYPES.has(t));\n\tif (invalid.length > 0) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown polkadot accountTypes: ${JSON.stringify(invalid)}. Valid values: \"sr25519\", \"ed25519\", \"ecdsa\", \"ethereum\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"polkadot\",\n\t\tgetWallets$: (ctx: PlatformContext) =>\n\t\t\tgetPolkadotWallets$(ctx.store, ctx.config, ctx.registryReads$),\n\t\tgetAccounts$: (wallets$) => getPolkadotAccounts$(wallets$, accountTypes),\n\t\tacceptsCachedAccount: (cached) =>\n\t\t\taccountTypes.includes(cached.polkadotAccountType ?? \"sr25519\"),\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,sBACL,aAEA,OAAO,UAAU,UAAU,QAAQ,cACnC,OAAO,SAAS,SAAS,cAAc,cACvC,OAAO,SAAS,QAAQ,gBAAgB,cACxC,OAAO,SAAS,OAAO,YAAY;;;;;;;AAQpC,MAAa,iCAAiB,IAAI,QAGhC;;;;;;;;AAaF,MAAM,kCAAkB,IAAI,QAG1B;AAEF,MAAM,kBAAkB,OACvB,YACA,OACA,YACI;CACJ,MAAM,WAAW,MAAM,MAAM,OAAO,OAAO;CAC3C,IAAI,CAAC,mBAAmB,QAAQ,GAC/B,MAAM,IAAI,MAAM,2BAA2B,WAAW,EAAE;CACzD,eAAe,IAAI,UAAU,MAAM,SAAS,SAAS,IAAI,CAAC;CAC1D,OAAO;AACR;AAEA,MAAM,oBACL,YACA,YAC+B;CAC/B,MAAM,QAAS,WAAkC,eAAe;CAChE,IAAI,CAAC,OACJ,OAAO,QAAQ,uBAAO,IAAI,MAAM,2BAA2B,WAAW,EAAE,CAAC;CAC1E,MAAM,UAAU,gBAAgB,IAAI,KAAK;CACzC,IAAI,SAAS,OAAO;CACpB,MAAM,aAAa,gBAAgB,YAAY,OAAO,OAAO;CAC7D,gBAAgB,IAAI,OAAO,UAAU;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I,CAAC,SAAS,OAAO,CAAC;EAMtB,OAJkBC,yBAAAA,mBACjBC,yBAAAA,kBAAkB,SAAS,UAAU,CAGvB,CAAC,CAAC,KACf,aACC;GACA,IAAIL,yBAAAA,mBAAmB,OAAO,IAAI,OAAO;GACzC,UAAU;GACV,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB;GACA,GAAG,yBAAyB,OAAO,QAAQ,OAAO;GAClD,aAAa;GACb,MAAM,GAAG,OAAO,KAAK;GAGrB,MAAM;EACP,EACF;CACD;AACD,CAAC;AAEF,MAAa,wBACZ,kBACA,yBACI;CACJ,IAAI,qBAAqB,WAAW,GACnC,QAAQ,KACP,8FACD;CAGD,OAAOM,yBAAAA,wBAAwB;EAC9B,UAAU;EACV,sBAAsB;EACtB;EACA,cAAc,aACb,SAAS,QAAQ,YAAY,qBAAqB,SAAS,QAAQ,IAAI,CAAC;CAC1E,CAAC;AACF;;;ACrPA,MAAM,wBAA+C;CACpD;CACA;CACA;AACD;AAEA,MAAM,sCAAsB,IAAI,IAAY;CAC3C;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;AAqBD,MAAa,YACZ,UAAiC,CAAC,MACkC;CACpE,MAAM,eAAe,QAAQ,gBAAgB;CAE7C,MAAM,UAAU,aAAa,QAAQ,MAAM,CAAC,oBAAoB,IAAI,CAAC,CAAC;CACtE,IAAI,QAAQ,SAAS,GACpB,QAAQ,KACP,8CAA8C,KAAK,UAAU,OAAO,EAAE,2DACvE;CAGD,OAAO;EACN,UAAU;EACV,cAAc,QACb,oBAAoB,IAAI,OAAO,IAAI,QAAQ,IAAI,cAAc;EAC9D,eAAe,aAAa,qBAAqB,UAAU,YAAY;EACvE,uBAAuB,WACtB,aAAa,SAAS,OAAO,uBAAuB,SAAS;CAC/D;AACD"}
|
package/dist/polkadot.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as getWalletConnectSessionAccounts$, i as getSessionCaip10s, l as isSs58Address, o as getWalletAccountId, r as getCaip10Addresses, t as createPlatformAccounts$ } from "./platformAccounts-
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as createInjectedWallets$ } from "./injectedWallets-5GL1Jder.mjs";
|
|
1
|
+
import { d as getWalletId, n as isWalletConnectWallet, p as parseWalletId, r as KheopskitError, s as isRefusalMessage, t as isInjectedWallet } from "./types-D7OWi0Td.mjs";
|
|
2
|
+
import { a as getWalletConnectSessionAccounts$, i as getSessionCaip10s, l as isSs58Address, o as getWalletAccountId, r as getCaip10Addresses, t as createPlatformAccounts$ } from "./platformAccounts-BeMDbmUT.mjs";
|
|
3
|
+
import { n as POLKADOT_EXTENSIONS, t as createRegistryReads$ } from "./registryReads-HvSaXRWX.mjs";
|
|
4
|
+
import { t as createInjectedWallets$ } from "./injectedWallets-DHf2lYVb.mjs";
|
|
6
5
|
import { hex } from "@scure/base";
|
|
7
6
|
import { isEqual } from "lodash-es";
|
|
8
7
|
import { Observable, distinctUntilChanged, map, of } from "rxjs";
|
|
@@ -226,7 +225,7 @@ const VALID_ACCOUNT_TYPES = /* @__PURE__ */ new Set([
|
|
|
226
225
|
"ethereum"
|
|
227
226
|
]);
|
|
228
227
|
/**
|
|
229
|
-
* Polkadot platform plugin. Pass to `
|
|
228
|
+
* Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.
|
|
230
229
|
*
|
|
231
230
|
* @example
|
|
232
231
|
* ```ts
|
package/dist/polkadot.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polkadot.mjs","names":[],"sources":["../src/api/polkadot/wallets.ts","../src/api/polkadot/accounts.ts","../src/api/polkadot/plugin.ts"],"sourcesContent":["import { isEqual } from \"lodash-es\";\nimport { getInjectedExtensions } from \"polkadot-api/pjs-signer\";\nimport { distinctUntilChanged, map, type Observable } from \"rxjs\";\nimport { POLKADOT_EXTENSIONS } from \"../../utils/polkadotExtensions\";\nimport { createRegistryReads$ } from \"../../utils/registryReads\";\nimport {\n\tgetWalletId,\n\tparseWalletId,\n\ttype WalletId,\n} from \"../../utils/WalletId\";\nimport { isRefusalMessage } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport type { KheopskitConfig } from \"../types\";\nimport type {\n\tPolkadotInjected,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n} from \"./types\";\n\ntype EnableResult = {\n\taccounts?: Partial<PolkadotInjected[\"accounts\"]>;\n\tsigner?: Partial<PolkadotInjected[\"signer\"]>;\n\tmetadata?: unknown;\n\tprovider?: unknown;\n};\n\ntype InjectedWeb3Window = {\n\tinjectedWeb3?: Record<\n\t\tstring,\n\t\t| { enable(appName: string): Promise<EnableResult | null | undefined> }\n\t\t| undefined\n\t>;\n};\n\nconst isPolkadotInjected = (\n\tinjected: EnableResult | null | undefined,\n): injected is PolkadotInjected =>\n\ttypeof injected?.accounts?.get === \"function\" &&\n\ttypeof injected.accounts.subscribe === \"function\" &&\n\ttypeof injected.signer?.signPayload === \"function\" &&\n\ttypeof injected.signer.signRaw === \"function\";\n\n/**\n * The list each extension last reported: read when its connect was granted,\n * so the emission that first shows the wallet connected already lists it, and\n * updated by every `subscribe` callback, so an accounts stream that restarts\n * resumes from the current list rather than the connect-time one.\n */\nexport const latestAccounts = new WeakMap<\n\tPolkadotInjected,\n\tPolkadotInjectedAccount[]\n>();\n\ntype InjectedWeb3Entry = NonNullable<\n\tNonNullable<InjectedWeb3Window[\"injectedWeb3\"]>[string]\n>;\n\n/**\n * The connect each extension is still answering. An extension keeps its\n * prompt open after kheopskit abandons the attempt, and a second `enable()`\n * meanwhile fails (polkadot-js: \"Pending authorisation request already\n * exists\") or resolves unauthorised (Talisman), so a new attempt joins this\n * one instead.\n */\nconst pendingConnects = new WeakMap<\n\tInjectedWeb3Entry,\n\tPromise<PolkadotInjected>\n>();\n\nconst enableExtension = async (\n\tidentifier: string,\n\tentry: InjectedWeb3Entry,\n\tappName: string,\n) => {\n\tconst injected = await entry.enable(appName);\n\tif (!isPolkadotInjected(injected))\n\t\tthrow new Error(`Unsupported extension: \"${identifier}\"`);\n\tlatestAccounts.set(injected, await injected.accounts.get());\n\treturn injected;\n};\n\nconst connectExtension = (\n\tidentifier: string,\n\tappName: string,\n): Promise<PolkadotInjected> => {\n\tconst entry = (globalThis as InjectedWeb3Window).injectedWeb3?.[identifier];\n\tif (!entry)\n\t\treturn Promise.reject(new Error(`Unavailable extension: \"${identifier}\"`));\n\tconst pending = pendingConnects.get(entry);\n\tif (pending) return pending;\n\tconst connecting = enableExtension(identifier, entry, appName);\n\tpendingConnects.set(entry, connecting);\n\tconst settle = () => pendingConnects.delete(entry);\n\tconnecting.then(settle, settle);\n\treturn connecting;\n};\n\nconst getInjectedWalletsIds = () =>\n\ttypeof window === \"undefined\"\n\t\t? []\n\t\t: getInjectedExtensions().map((name) => getWalletId(\"polkadot\", name));\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 getPolkadotWallets$ = (\n\tstore: KheopskitStore,\n\tconfig: Pick<KheopskitConfig, \"appName\" | \"walletConnect\">,\n\tregistryReads$: Observable<void> = createRegistryReads$(),\n) =>\n\tcreateInjectedWallets$<WalletId, PolkadotInjectedWallet, PolkadotInjected>(\n\t\tstore,\n\t\t{\n\t\t\tsources$: registryReads$.pipe(\n\t\t\t\tmap(getInjectedWalletsIds),\n\t\t\t\tdistinctUntilChanged<WalletId[]>(isEqual),\n\t\t\t),\n\t\t\tgetWalletId: (walletId) => walletId,\n\t\t\tconnect: (walletId) =>\n\t\t\t\tconnectExtension(\n\t\t\t\t\tparseWalletId(walletId).identifier,\n\t\t\t\t\tconfig.appName ||\n\t\t\t\t\t\tconfig.walletConnect?.metadata.name ||\n\t\t\t\t\t\twindow.location.hostname,\n\t\t\t\t),\n\t\t\tisUserRejection: isRefusalMessage,\n\t\t\tbuildWallet: ({\n\t\t\t\twalletId,\n\t\t\t\thandle,\n\t\t\t\tstatus,\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t\tconnect,\n\t\t\t\tdisconnect,\n\t\t\t}) => {\n\t\t\t\tconst { identifier } = parseWalletId(walletId);\n\t\t\t\tconst extInfo = POLKADOT_EXTENSIONS[identifier];\n\n\t\t\t\treturn {\n\t\t\t\t\tid: walletId,\n\t\t\t\t\ttype: \"injected\",\n\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\tname: extInfo?.name ?? identifier,\n\t\t\t\t\ticon: extInfo?.icon ?? \"\",\n\t\t\t\t\tsourceId: identifier,\n\t\t\t\t\textension: handle,\n\t\t\t\t\tstatus,\n\t\t\t\t\terror,\n\t\t\t\t\tisConnected,\n\t\t\t\t\tconnect,\n\t\t\t\t\tdisconnect,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t);\n","import { hex } from \"@scure/base\";\nimport type {\n\tKeypairType,\n\tSignPayload,\n\tSignRaw,\n} from \"polkadot-api/pjs-signer\";\nimport * as pjs from \"polkadot-api/pjs-signer\";\nimport { Observable, of } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { KheopskitError } from \"../errors\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tPolkadotAccountType,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n} from \"../types\";\nimport type {\n\tPolkadotAccount,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n\tPolkadotSignRawType,\n\tPolkadotWallet,\n} from \"./types\";\nimport { latestAccounts } from \"./wallets\";\n\ntype RawSignature = `0x${string}`;\n\nconst encodeRawData = (\n\tdata: string | Uint8Array,\n\ttype?: PolkadotSignRawType,\n): { data: string; type: PolkadotSignRawType } =>\n\ttypeof data === \"string\"\n\t\t? { data, type: type ?? \"payload\" }\n\t\t: { data: `0x${hex.encode(data)}`, type: type ?? \"bytes\" };\n\n/**\n * pjs-signer's signature-type map knows ed25519, sr25519 and ecdsa only, so an\n * `ethereum` type would get a 64-byte mock signature where ecdsa needs 65.\n */\nconst toSignerType = (type: PolkadotAccountType): KeypairType =>\n\ttype === \"ethereum\" ? \"ecdsa\" : type;\n\nconst getInjectedWalletAccounts$ = (\n\twallet: PolkadotInjectedWallet,\n): Observable<PolkadotAccount[]> => {\n\tconst injected = wallet.extension;\n\tif (!wallet.isConnected || !injected) return of([]);\n\n\treturn new Observable<PolkadotAccount[]>((subscriber) => {\n\t\tconst signPayload = injected.signer.signPayload.bind(injected.signer);\n\t\tconst signRaw = injected.signer.signRaw.bind(injected.signer);\n\t\tconst { field, factory } = getPjsSignerField();\n\n\t\tconst toAccount = (account: PolkadotInjectedAccount): PolkadotAccount => {\n\t\t\tconst { address } = account;\n\t\t\tconst type = account.type ?? \"sr25519\";\n\t\t\treturn {\n\t\t\t\t...account,\n\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\ttype,\n\t\t\t\tplatform: \"polkadot\",\n\t\t\t\twalletName: wallet.name,\n\t\t\t\twalletId: wallet.id,\n\t\t\t\t[field]: factory(address, signPayload, signRaw, toSignerType(type)),\n\t\t\t\tsignRaw: async (data, options) =>\n\t\t\t\t\t(await signRaw({ address, ...encodeRawData(data, options?.type) }))\n\t\t\t\t\t\t.signature,\n\t\t\t} as Exclude<PolkadotAccount, { isPlaceholder: true }>;\n\t\t};\n\n\t\tconst toAccounts = (accounts: PolkadotInjectedAccount[]) =>\n\t\t\taccounts.flatMap((account) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn [toAccount(account)];\n\t\t\t\t} catch {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t});\n\n\t\tconst emit = (accounts: PolkadotInjectedAccount[]) => {\n\t\t\tlatestAccounts.set(injected, accounts);\n\t\t\tsubscriber.next(toAccounts(accounts));\n\t\t};\n\n\t\temit(latestAccounts.get(injected) ?? []);\n\t\treturn injected.accounts.subscribe(emit);\n\t});\n};\n\n/**\n * polkadot-api v2's `getPolkadotSignerFromPjs` takes three parameters and\n * ignores the fourth at runtime.\n */\ntype PjsSignerFactory = (\n\taddress: string,\n\tsignPayload: SignPayload,\n\tsignRaw: SignRaw,\n\ttype?: KeypairType,\n) => unknown;\n\ntype PjsSignerModule = {\n\tgetTxCreatorFromPjs?: PjsSignerFactory;\n\tgetPolkadotSignerFromPjs?: PjsSignerFactory;\n};\n\n/**\n * polkadot-api v3 replaced `polkadotSigner` (PolkadotSigner) with `txCreator`\n * (TxCreator). Which one the app's installed version provides is detected at\n * runtime so a single @kheopskit/core release supports both.\n */\nconst getPjsSignerField = (): {\n\tfield: \"txCreator\" | \"polkadotSigner\";\n\tfactory: PjsSignerFactory;\n} => {\n\tconst module = pjs as PjsSignerModule;\n\tif (module.getTxCreatorFromPjs)\n\t\treturn { field: \"txCreator\", factory: module.getTxCreatorFromPjs };\n\tif (module.getPolkadotSignerFromPjs)\n\t\treturn {\n\t\t\tfield: \"polkadotSigner\",\n\t\t\tfactory: module.getPolkadotSignerFromPjs,\n\t\t};\n\tthrow new KheopskitError(\n\t\t\"UNSUPPORTED_VERSION\",\n\t\t\"Unsupported polkadot-api/pjs-signer version\",\n\t);\n};\n\nconst requestSignMessage = (\n\tappKit: AppKitInstance,\n\tprovider: WalletConnectProvider,\n\taddress: string,\n\tmessage: string,\n) => {\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\tconst chainId = appKit.getCaipNetworks(\"polkadot\")[0]?.caipNetworkId;\n\tif (!chainId)\n\t\tthrow new KheopskitError(\n\t\t\t\"NO_SESSION\",\n\t\t\t\"No CAIP network available for polkadot\",\n\t\t);\n\n\treturn provider.client.request<{ signature: RawSignature }>({\n\t\ttopic: provider.session.topic,\n\t\tchainId,\n\t\trequest: {\n\t\t\tmethod: \"polkadot_signMessage\",\n\t\t\tparams: { address, message },\n\t\t},\n\t});\n};\n\nconst getAppKitPolkadotSigning = (appKit: AppKitInstance, address: string) => {\n\tconst provider = appKit.getProvider(\"polkadot\");\n\tif (!provider) throw new KheopskitError(\"NO_PROVIDER\", \"No provider found\");\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\tconst signMessage = (message: string) =>\n\t\trequestSignMessage(appKit, provider, address, message);\n\n\tconst { field, factory } = getPjsSignerField();\n\n\tconst signer = factory(\n\t\taddress,\n\t\t(transactionPayload) => {\n\t\t\tif (!provider.session)\n\t\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\t\t\treturn provider.client.request({\n\t\t\t\ttopic: provider.session.topic,\n\t\t\t\tchainId: `polkadot:${transactionPayload.genesisHash.substring(2, 34)}`,\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"polkadot_signTransaction\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\ttransactionPayload,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t\tasync ({ data }) => ({\n\t\t\tid: 0,\n\t\t\tsignature: (await signMessage(data)).signature,\n\t\t}),\n\t\t\"sr25519\",\n\t);\n\n\tconst signRaw: PolkadotAccount[\"signRaw\"] = async (data) =>\n\t\t(await signMessage(encodeRawData(data).data)).signature;\n\n\treturn { [field]: signer, signRaw };\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<PolkadotAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"polkadot\",\n\t\tnamespace: \"polkadot\",\n\t\tcacheKey: `accounts:${wallet.id}:polkadot:`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst addresses = getCaip10Addresses(\n\t\t\t\tgetSessionCaip10s(session, \"polkadot\"),\n\t\t\t);\n\n\t\t\treturn addresses.map(\n\t\t\t\t(address) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\t...getAppKitPolkadotSigning(wallet.appKit, address),\n\t\t\t\t\t\tgenesisHash: null,\n\t\t\t\t\t\tname: `${wallet.name} Polkadot`,\n\t\t\t\t\t\t// WalletConnect (Reown AppKit) doesn't expose account key type;\n\t\t\t\t\t\t// default to sr25519, which is the most common Polkadot key type.\n\t\t\t\t\t\ttype: \"sr25519\",\n\t\t\t\t\t}) as PolkadotAccount,\n\t\t\t);\n\t\t},\n\t});\n\nexport const getPolkadotAccounts$ = (\n\tpolkadotWallets$: Observable<(PolkadotWallet | WalletConnectWallet)[]>,\n\tpolkadotAccountTypes: PolkadotAccountType[],\n) => {\n\tif (polkadotAccountTypes.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] polkadot({ accountTypes }) is empty; all Polkadot accounts will be filtered out.\",\n\t\t);\n\t}\n\n\treturn createPlatformAccounts$({\n\t\twallets$: polkadotWallets$,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\tmapAccounts: (accounts) =>\n\t\t\taccounts.filter((account) => polkadotAccountTypes.includes(account.type)),\n\t});\n};\n","import type {\n\tKheopskitPlatform,\n\tPlatformContext,\n\tPolkadotAccountType,\n} from \"../types\";\nimport { getPolkadotAccounts$ } from \"./accounts\";\nimport type { PolkadotAccount, PolkadotWallet } from \"./types\";\nimport { getPolkadotWallets$ } from \"./wallets\";\n\nconst DEFAULT_ACCOUNT_TYPES: PolkadotAccountType[] = [\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n];\n\nconst VALID_ACCOUNT_TYPES = new Set<string>([\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n\t\"ethereum\",\n]);\n\nexport type PolkadotPluginOptions = {\n\t/**\n\t * Allowed Polkadot account key types. Accounts with other key types are\n\t * filtered out from kheopskit state.\n\t *\n\t * @default [\"sr25519\", \"ed25519\", \"ecdsa\"]\n\t */\n\taccountTypes?: PolkadotAccountType[];\n};\n\n/**\n * Polkadot platform plugin. Pass to `getKheopskit$({ platforms: [polkadot()] })`.\n *\n * @example\n * ```ts\n * import { polkadot } from \"@kheopskit/core/polkadot\";\n * polkadot({ accountTypes: [\"sr25519\", \"ed25519\", \"ecdsa\"] });\n * ```\n */\nexport const polkadot = (\n\toptions: PolkadotPluginOptions = {},\n): KheopskitPlatform<\"polkadot\", PolkadotWallet, PolkadotAccount> => {\n\tconst accountTypes = options.accountTypes ?? DEFAULT_ACCOUNT_TYPES;\n\n\tconst invalid = accountTypes.filter((t) => !VALID_ACCOUNT_TYPES.has(t));\n\tif (invalid.length > 0) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown polkadot accountTypes: ${JSON.stringify(invalid)}. Valid values: \"sr25519\", \"ed25519\", \"ecdsa\", \"ethereum\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"polkadot\",\n\t\tgetWallets$: (ctx: PlatformContext) =>\n\t\t\tgetPolkadotWallets$(ctx.store, ctx.config, ctx.registryReads$),\n\t\tgetAccounts$: (wallets$) => getPolkadotAccounts$(wallets$, accountTypes),\n\t\tacceptsCachedAccount: (cached) =>\n\t\t\taccountTypes.includes(cached.polkadotAccountType ?? \"sr25519\"),\n\t};\n};\n"],"mappings":";;;;;;;;;;;AAmCA,MAAM,sBACL,aAEA,OAAO,UAAU,UAAU,QAAQ,cACnC,OAAO,SAAS,SAAS,cAAc,cACvC,OAAO,SAAS,QAAQ,gBAAgB,cACxC,OAAO,SAAS,OAAO,YAAY;;;;;;;AAQpC,MAAa,iCAAiB,IAAI,QAGhC;;;;;;;;AAaF,MAAM,kCAAkB,IAAI,QAG1B;AAEF,MAAM,kBA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e,aAAa,qBAAqB,UAAU,YAAY;EACvE,uBAAuB,WACtB,aAAa,SAAS,OAAO,uBAAuB,SAAS;CAC/D;AACD"}
|
|
1
|
+
{"version":3,"file":"polkadot.mjs","names":[],"sources":["../src/api/polkadot/wallets.ts","../src/api/polkadot/accounts.ts","../src/api/polkadot/plugin.ts"],"sourcesContent":["import { isEqual } from \"lodash-es\";\nimport { getInjectedExtensions } from \"polkadot-api/pjs-signer\";\nimport { distinctUntilChanged, map, type Observable } from \"rxjs\";\nimport { POLKADOT_EXTENSIONS } from \"../../utils/polkadotExtensions\";\nimport { createRegistryReads$ } from \"../../utils/registryReads\";\nimport {\n\tgetWalletId,\n\tparseWalletId,\n\ttype WalletId,\n} from \"../../utils/WalletId\";\nimport { isRefusalMessage } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport type { KheopskitConfig } from \"../types\";\nimport type {\n\tPolkadotInjected,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n} from \"./types\";\n\ntype EnableResult = {\n\taccounts?: Partial<PolkadotInjected[\"accounts\"]>;\n\tsigner?: Partial<PolkadotInjected[\"signer\"]>;\n\tmetadata?: unknown;\n\tprovider?: unknown;\n};\n\ntype InjectedWeb3Window = {\n\tinjectedWeb3?: Record<\n\t\tstring,\n\t\t| { enable(appName: string): Promise<EnableResult | null | undefined> }\n\t\t| undefined\n\t>;\n};\n\nconst isPolkadotInjected = (\n\tinjected: EnableResult | null | undefined,\n): injected is PolkadotInjected =>\n\ttypeof injected?.accounts?.get === \"function\" &&\n\ttypeof injected.accounts.subscribe === \"function\" &&\n\ttypeof injected.signer?.signPayload === \"function\" &&\n\ttypeof injected.signer.signRaw === \"function\";\n\n/**\n * The list each extension last reported: read when its connect was granted,\n * so the emission that first shows the wallet connected already lists it, and\n * updated by every `subscribe` callback, so an accounts stream that restarts\n * resumes from the current list rather than the connect-time one.\n */\nexport const latestAccounts = new WeakMap<\n\tPolkadotInjected,\n\tPolkadotInjectedAccount[]\n>();\n\ntype InjectedWeb3Entry = NonNullable<\n\tNonNullable<InjectedWeb3Window[\"injectedWeb3\"]>[string]\n>;\n\n/**\n * The connect each extension is still answering. An extension keeps its\n * prompt open after kheopskit abandons the attempt, and a second `enable()`\n * meanwhile fails (polkadot-js: \"Pending authorisation request already\n * exists\") or resolves unauthorised (Talisman), so a new attempt joins this\n * one instead.\n */\nconst pendingConnects = new WeakMap<\n\tInjectedWeb3Entry,\n\tPromise<PolkadotInjected>\n>();\n\nconst enableExtension = async (\n\tidentifier: string,\n\tentry: InjectedWeb3Entry,\n\tappName: string,\n) => {\n\tconst injected = await entry.enable(appName);\n\tif (!isPolkadotInjected(injected))\n\t\tthrow new Error(`Unsupported extension: \"${identifier}\"`);\n\tlatestAccounts.set(injected, await injected.accounts.get());\n\treturn injected;\n};\n\nconst connectExtension = (\n\tidentifier: string,\n\tappName: string,\n): Promise<PolkadotInjected> => {\n\tconst entry = (globalThis as InjectedWeb3Window).injectedWeb3?.[identifier];\n\tif (!entry)\n\t\treturn Promise.reject(new Error(`Unavailable extension: \"${identifier}\"`));\n\tconst pending = pendingConnects.get(entry);\n\tif (pending) return pending;\n\tconst connecting = enableExtension(identifier, entry, appName);\n\tpendingConnects.set(entry, connecting);\n\tconst settle = () => pendingConnects.delete(entry);\n\tconnecting.then(settle, settle);\n\treturn connecting;\n};\n\nconst getInjectedWalletsIds = () =>\n\ttypeof window === \"undefined\"\n\t\t? []\n\t\t: getInjectedExtensions().map((name) => getWalletId(\"polkadot\", name));\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 getPolkadotWallets$ = (\n\tstore: KheopskitStore,\n\tconfig: Pick<KheopskitConfig, \"appName\" | \"walletConnect\">,\n\tregistryReads$: Observable<void> = createRegistryReads$(),\n) =>\n\tcreateInjectedWallets$<WalletId, PolkadotInjectedWallet, PolkadotInjected>(\n\t\tstore,\n\t\t{\n\t\t\tsources$: registryReads$.pipe(\n\t\t\t\tmap(getInjectedWalletsIds),\n\t\t\t\tdistinctUntilChanged<WalletId[]>(isEqual),\n\t\t\t),\n\t\t\tgetWalletId: (walletId) => walletId,\n\t\t\tconnect: (walletId) =>\n\t\t\t\tconnectExtension(\n\t\t\t\t\tparseWalletId(walletId).identifier,\n\t\t\t\t\tconfig.appName ||\n\t\t\t\t\t\tconfig.walletConnect?.metadata.name ||\n\t\t\t\t\t\twindow.location.hostname,\n\t\t\t\t),\n\t\t\tisUserRejection: isRefusalMessage,\n\t\t\tbuildWallet: ({\n\t\t\t\twalletId,\n\t\t\t\thandle,\n\t\t\t\tstatus,\n\t\t\t\terror,\n\t\t\t\tisConnected,\n\t\t\t\tconnect,\n\t\t\t\tdisconnect,\n\t\t\t}) => {\n\t\t\t\tconst { identifier } = parseWalletId(walletId);\n\t\t\t\tconst extInfo = POLKADOT_EXTENSIONS[identifier];\n\n\t\t\t\treturn {\n\t\t\t\t\tid: walletId,\n\t\t\t\t\ttype: \"injected\",\n\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\tname: extInfo?.name ?? identifier,\n\t\t\t\t\ticon: extInfo?.icon ?? \"\",\n\t\t\t\t\tsourceId: identifier,\n\t\t\t\t\textension: handle,\n\t\t\t\t\tstatus,\n\t\t\t\t\terror,\n\t\t\t\t\tisConnected,\n\t\t\t\t\tconnect,\n\t\t\t\t\tdisconnect,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t);\n","import { hex } from \"@scure/base\";\nimport type {\n\tKeypairType,\n\tSignPayload,\n\tSignRaw,\n} from \"polkadot-api/pjs-signer\";\nimport * as pjs from \"polkadot-api/pjs-signer\";\nimport { Observable, of } from \"rxjs\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { KheopskitError } from \"../errors\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\tgetWalletConnectSessionAccounts$,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type {\n\tAppKitInstance,\n\tPolkadotAccountType,\n\tWalletConnectProvider,\n\tWalletConnectWallet,\n} from \"../types\";\nimport type {\n\tPolkadotAccount,\n\tPolkadotInjectedAccount,\n\tPolkadotInjectedWallet,\n\tPolkadotSignRawType,\n\tPolkadotWallet,\n} from \"./types\";\nimport { latestAccounts } from \"./wallets\";\n\ntype RawSignature = `0x${string}`;\n\nconst encodeRawData = (\n\tdata: string | Uint8Array,\n\ttype?: PolkadotSignRawType,\n): { data: string; type: PolkadotSignRawType } =>\n\ttypeof data === \"string\"\n\t\t? { data, type: type ?? \"payload\" }\n\t\t: { data: `0x${hex.encode(data)}`, type: type ?? \"bytes\" };\n\n/**\n * pjs-signer's signature-type map knows ed25519, sr25519 and ecdsa only, so an\n * `ethereum` type would get a 64-byte mock signature where ecdsa needs 65.\n */\nconst toSignerType = (type: PolkadotAccountType): KeypairType =>\n\ttype === \"ethereum\" ? \"ecdsa\" : type;\n\nconst getInjectedWalletAccounts$ = (\n\twallet: PolkadotInjectedWallet,\n): Observable<PolkadotAccount[]> => {\n\tconst injected = wallet.extension;\n\tif (!wallet.isConnected || !injected) return of([]);\n\n\treturn new Observable<PolkadotAccount[]>((subscriber) => {\n\t\tconst signPayload = injected.signer.signPayload.bind(injected.signer);\n\t\tconst signRaw = injected.signer.signRaw.bind(injected.signer);\n\t\tconst { field, factory } = getPjsSignerField();\n\n\t\tconst toAccount = (account: PolkadotInjectedAccount): PolkadotAccount => {\n\t\t\tconst { address } = account;\n\t\t\tconst type = account.type ?? \"sr25519\";\n\t\t\treturn {\n\t\t\t\t...account,\n\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\ttype,\n\t\t\t\tplatform: \"polkadot\",\n\t\t\t\twalletName: wallet.name,\n\t\t\t\twalletId: wallet.id,\n\t\t\t\t[field]: factory(address, signPayload, signRaw, toSignerType(type)),\n\t\t\t\tsignRaw: async (data, options) =>\n\t\t\t\t\t(await signRaw({ address, ...encodeRawData(data, options?.type) }))\n\t\t\t\t\t\t.signature,\n\t\t\t} as Exclude<PolkadotAccount, { isPlaceholder: true }>;\n\t\t};\n\n\t\tconst toAccounts = (accounts: PolkadotInjectedAccount[]) =>\n\t\t\taccounts.flatMap((account) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn [toAccount(account)];\n\t\t\t\t} catch {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t});\n\n\t\tconst emit = (accounts: PolkadotInjectedAccount[]) => {\n\t\t\tlatestAccounts.set(injected, accounts);\n\t\t\tsubscriber.next(toAccounts(accounts));\n\t\t};\n\n\t\temit(latestAccounts.get(injected) ?? []);\n\t\treturn injected.accounts.subscribe(emit);\n\t});\n};\n\n/**\n * polkadot-api v2's `getPolkadotSignerFromPjs` takes three parameters and\n * ignores the fourth at runtime.\n */\ntype PjsSignerFactory = (\n\taddress: string,\n\tsignPayload: SignPayload,\n\tsignRaw: SignRaw,\n\ttype?: KeypairType,\n) => unknown;\n\ntype PjsSignerModule = {\n\tgetTxCreatorFromPjs?: PjsSignerFactory;\n\tgetPolkadotSignerFromPjs?: PjsSignerFactory;\n};\n\n/**\n * polkadot-api v3 replaced `polkadotSigner` (PolkadotSigner) with `txCreator`\n * (TxCreator). Which one the app's installed version provides is detected at\n * runtime so a single @kheopskit/core release supports both.\n */\nconst getPjsSignerField = (): {\n\tfield: \"txCreator\" | \"polkadotSigner\";\n\tfactory: PjsSignerFactory;\n} => {\n\tconst module = pjs as PjsSignerModule;\n\tif (module.getTxCreatorFromPjs)\n\t\treturn { field: \"txCreator\", factory: module.getTxCreatorFromPjs };\n\tif (module.getPolkadotSignerFromPjs)\n\t\treturn {\n\t\t\tfield: \"polkadotSigner\",\n\t\t\tfactory: module.getPolkadotSignerFromPjs,\n\t\t};\n\tthrow new KheopskitError(\n\t\t\"UNSUPPORTED_VERSION\",\n\t\t\"Unsupported polkadot-api/pjs-signer version\",\n\t);\n};\n\nconst requestSignMessage = (\n\tappKit: AppKitInstance,\n\tprovider: WalletConnectProvider,\n\taddress: string,\n\tmessage: string,\n) => {\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\tconst chainId = appKit.getCaipNetworks(\"polkadot\")[0]?.caipNetworkId;\n\tif (!chainId)\n\t\tthrow new KheopskitError(\n\t\t\t\"NO_SESSION\",\n\t\t\t\"No CAIP network available for polkadot\",\n\t\t);\n\n\treturn provider.client.request<{ signature: RawSignature }>({\n\t\ttopic: provider.session.topic,\n\t\tchainId,\n\t\trequest: {\n\t\t\tmethod: \"polkadot_signMessage\",\n\t\t\tparams: { address, message },\n\t\t},\n\t});\n};\n\nconst getAppKitPolkadotSigning = (appKit: AppKitInstance, address: string) => {\n\tconst provider = appKit.getProvider(\"polkadot\");\n\tif (!provider) throw new KheopskitError(\"NO_PROVIDER\", \"No provider found\");\n\tif (!provider.session)\n\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\tconst signMessage = (message: string) =>\n\t\trequestSignMessage(appKit, provider, address, message);\n\n\tconst { field, factory } = getPjsSignerField();\n\n\tconst signer = factory(\n\t\taddress,\n\t\t(transactionPayload) => {\n\t\t\tif (!provider.session)\n\t\t\t\tthrow new KheopskitError(\"NO_SESSION\", \"No session found\");\n\n\t\t\treturn provider.client.request({\n\t\t\t\ttopic: provider.session.topic,\n\t\t\t\tchainId: `polkadot:${transactionPayload.genesisHash.substring(2, 34)}`,\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"polkadot_signTransaction\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\ttransactionPayload,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t\tasync ({ data }) => ({\n\t\t\tid: 0,\n\t\t\tsignature: (await signMessage(data)).signature,\n\t\t}),\n\t\t\"sr25519\",\n\t);\n\n\tconst signRaw: PolkadotAccount[\"signRaw\"] = async (data) =>\n\t\t(await signMessage(encodeRawData(data).data)).signature;\n\n\treturn { [field]: signer, signRaw };\n};\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<PolkadotAccount[]> =>\n\tgetWalletConnectSessionAccounts$({\n\t\twallet,\n\t\tplatform: \"polkadot\",\n\t\tnamespace: \"polkadot\",\n\t\tcacheKey: `accounts:${wallet.id}:polkadot:`,\n\t\tbuildAccounts: (provider) => {\n\t\t\tconst session = provider.session;\n\t\t\tif (!session) return [];\n\n\t\t\tconst addresses = getCaip10Addresses(\n\t\t\t\tgetSessionCaip10s(session, \"polkadot\"),\n\t\t\t);\n\n\t\t\treturn addresses.map(\n\t\t\t\t(address) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\t...getAppKitPolkadotSigning(wallet.appKit, address),\n\t\t\t\t\t\tgenesisHash: null,\n\t\t\t\t\t\tname: `${wallet.name} Polkadot`,\n\t\t\t\t\t\t// WalletConnect (Reown AppKit) doesn't expose account key type;\n\t\t\t\t\t\t// default to sr25519, which is the most common Polkadot key type.\n\t\t\t\t\t\ttype: \"sr25519\",\n\t\t\t\t\t}) as PolkadotAccount,\n\t\t\t);\n\t\t},\n\t});\n\nexport const getPolkadotAccounts$ = (\n\tpolkadotWallets$: Observable<(PolkadotWallet | WalletConnectWallet)[]>,\n\tpolkadotAccountTypes: PolkadotAccountType[],\n) => {\n\tif (polkadotAccountTypes.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] polkadot({ accountTypes }) is empty; all Polkadot accounts will be filtered out.\",\n\t\t);\n\t}\n\n\treturn createPlatformAccounts$({\n\t\twallets$: polkadotWallets$,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\tmapAccounts: (accounts) =>\n\t\t\taccounts.filter((account) => polkadotAccountTypes.includes(account.type)),\n\t});\n};\n","import type {\n\tKheopskitPlatform,\n\tPlatformContext,\n\tPolkadotAccountType,\n} from \"../types\";\nimport { getPolkadotAccounts$ } from \"./accounts\";\nimport type { PolkadotAccount, PolkadotWallet } from \"./types\";\nimport { getPolkadotWallets$ } from \"./wallets\";\n\nconst DEFAULT_ACCOUNT_TYPES: PolkadotAccountType[] = [\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n];\n\nconst VALID_ACCOUNT_TYPES = new Set<string>([\n\t\"sr25519\",\n\t\"ed25519\",\n\t\"ecdsa\",\n\t\"ethereum\",\n]);\n\nexport type PolkadotPluginOptions = {\n\t/**\n\t * Allowed Polkadot account key types. Accounts with other key types are\n\t * filtered out from kheopskit state.\n\t *\n\t * @default [\"sr25519\", \"ed25519\", \"ecdsa\"]\n\t */\n\taccountTypes?: PolkadotAccountType[];\n};\n\n/**\n * Polkadot platform plugin. Pass to `createKheopskit({ platforms: [polkadot()] })`.\n *\n * @example\n * ```ts\n * import { polkadot } from \"@kheopskit/core/polkadot\";\n * polkadot({ accountTypes: [\"sr25519\", \"ed25519\", \"ecdsa\"] });\n * ```\n */\nexport const polkadot = (\n\toptions: PolkadotPluginOptions = {},\n): KheopskitPlatform<\"polkadot\", PolkadotWallet, PolkadotAccount> => {\n\tconst accountTypes = options.accountTypes ?? DEFAULT_ACCOUNT_TYPES;\n\n\tconst invalid = accountTypes.filter((t) => !VALID_ACCOUNT_TYPES.has(t));\n\tif (invalid.length > 0) {\n\t\tconsole.warn(\n\t\t\t`[kheopskit] Unknown polkadot accountTypes: ${JSON.stringify(invalid)}. Valid values: \"sr25519\", \"ed25519\", \"ecdsa\", \"ethereum\".`,\n\t\t);\n\t}\n\n\treturn {\n\t\tplatform: \"polkadot\",\n\t\tgetWallets$: (ctx: PlatformContext) =>\n\t\t\tgetPolkadotWallets$(ctx.store, ctx.config, ctx.registryReads$),\n\t\tgetAccounts$: (wallets$) => getPolkadotAccounts$(wallets$, accountTypes),\n\t\tacceptsCachedAccount: (cached) =>\n\t\t\taccountTypes.includes(cached.polkadotAccountType ?? \"sr25519\"),\n\t};\n};\n"],"mappings":";;;;;;;;;;AAmCA,MAAM,sBACL,aAEA,OAAO,UAAU,UAAU,QAAQ,cACnC,OAAO,SAAS,SAAS,cAAc,cACvC,OAAO,SAAS,QAAQ,gBAAgB,cACxC,OAAO,SAAS,OAAO,YAAY;;;;;;;AAQpC,MAAa,iCAAiB,IAAI,QAGhC;;;;;;;;AAaF,MAAM,kCAAkB,IAAI,QAG1B;AAEF,MAAM,kBAAkB,OACvB,YACA,OACA,YACI;CACJ,MAAM,WAAW,MAAM,MAAM,OAAO,OAAO;CAC3C,IAAI,CAAC,mBAAmB,QAAQ,GAC/B,MAAM,IAAI,MAAM,2BAA2B,WAAW,EAAE;CACzD,eAAe,IAAI,UAAU,MAAM,SAAS,SAAS,IAAI,CAAC;CAC1D,OAAO;AACR;AAEA,MAAM,oBACL,YACA,YAC+B;CAC/B,MAAM,QAAS,WAAkC,eAAe;CAChE,IAAI,CAAC,OACJ,OAAO,QAAQ,uBAAO,IAAI,MAAM,2BAA2B,WAAW,EAAE,CAAC;CAC1E,MAAM,UAAU,gBAAgB,IAAI,KAAK;CACzC,IAAI,SAAS,OAAO;CACpB,MAAM,aAAa,gBAAgB,YAAY,OAAO,OAAO;CAC7D,gBAAgB,IAAI,OAAO,UAAU;CACrC,MAAM,eAAe,gBAAgB,OAAO,KAAK;CACjD,WAAW,KAAK,QAAQ,MAAM;CAC9B,OAAO;AACR;AAEA,MAAM,8BACL,OAAO,WAAW,cACf,CAAC,IACD,sBAAsB,CAAC,CAAC,KAAK,SAAS,YAAY,YAAY,IAAI,CAAC;AAIvE,MAAa,uBACZ,OACA,QACA,iBAAmC,qBAAqB,MAExD,uBACC,OACA;CACC,UAAU,eAAe,KACxB,IAAI,qBAAqB,GACzB,qBAAiC,OAAO,CACzC;CACA,cAAc,aAAa;CAC3B,UAA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B,IAAI,IAAY;CAC3C;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;AAqBD,MAAa,YACZ,UAAiC,CAAC,MACkC;CACpE,MAAM,eAAe,QAAQ,gBAAgB;CAE7C,MAAM,UAAU,aAAa,QAAQ,MAAM,CAAC,oBAAoB,IAAI,CAAC,CAAC;CACtE,IAAI,QAAQ,SAAS,GACpB,QAAQ,KACP,8CAA8C,KAAK,UAAU,OAAO,EAAE,2DACvE;CAGD,OAAO;EACN,UAAU;EACV,cAAc,QACb,oBAAoB,IAAI,OAAO,IAAI,QAAQ,IAAI,cAAc;EAC9D,eAAe,aAAa,qBAAqB,UAAU,YAAY;EACvE,uBAAuB,WACtB,aAAa,SAAS,OAAO,uBAAuB,SAAS;CAC/D;AACD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let rxjs = require("rxjs");
|
|
1
2
|
//#region src/utils/polkadotExtensions.ts
|
|
2
3
|
const POLKADOT_EXTENSIONS = {
|
|
3
4
|
talisman: {
|
|
@@ -18,6 +19,46 @@ const POLKADOT_EXTENSIONS = {
|
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
21
|
-
|
|
22
|
+
//#region src/utils/pageLoad.ts
|
|
23
|
+
const pageLoaded$ = new rxjs.Observable((subscriber) => {
|
|
24
|
+
if (typeof document === "undefined") {
|
|
25
|
+
subscriber.next(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (document.readyState === "complete") {
|
|
29
|
+
subscriber.next(true);
|
|
30
|
+
subscriber.complete();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
subscriber.next(false);
|
|
34
|
+
const onLoad = () => {
|
|
35
|
+
subscriber.next(true);
|
|
36
|
+
subscriber.complete();
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("load", onLoad, { once: true });
|
|
39
|
+
return () => window.removeEventListener("load", onLoad);
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/utils/registryReads.ts
|
|
43
|
+
const tail$ = (0, rxjs.merge)((0, rxjs.of)(void 0), ...[
|
|
44
|
+
100,
|
|
45
|
+
300,
|
|
46
|
+
600,
|
|
47
|
+
1100
|
|
48
|
+
].map((ms) => (0, rxjs.timer)(ms))).pipe((0, rxjs.map)(() => void 0));
|
|
49
|
+
const createRegistryReads$ = () => typeof window === "undefined" ? (0, rxjs.concat)((0, rxjs.of)(void 0), rxjs.NEVER) : pageLoaded$.pipe((0, rxjs.switchMap)(() => tail$));
|
|
50
|
+
//#endregion
|
|
51
|
+
Object.defineProperty(exports, "POLKADOT_EXTENSIONS", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function() {
|
|
54
|
+
return POLKADOT_EXTENSIONS;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "createRegistryReads$", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return createRegistryReads$;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
22
63
|
|
|
23
|
-
//# sourceMappingURL=
|
|
64
|
+
//# sourceMappingURL=registryReads-30CCkmHe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryReads-30CCkmHe.js","names":["Observable","merge","of","timer","map","concat","NEVER","switchMap"],"sources":["../src/utils/polkadotExtensions.ts","../src/utils/pageLoad.ts","../src/utils/registryReads.ts"],"sourcesContent":["export const POLKADOT_EXTENSIONS: Record<\n\tstring,\n\t{ name: string; icon: string }\n> = {\n\ttalisman: {\n\t\tname: \"Talisman\",\n\t\ticon: \"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBmaWxsPSIjZGRmZTc2IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0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bmVhcl8yODdfMjM1OSIgeDE9IjE5LjM2MDIiIHkxPSIxNCIgeDI9IjU2Ljc2OTYiIHkyPSI2OS44MDA1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNDNTQ5RkYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNjU0QkZGIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==\",\n\t},\n};\n","import { Observable } from \"rxjs\";\n\nexport const pageLoaded$ = new Observable<boolean>((subscriber) => {\n\tif (typeof document === \"undefined\") {\n\t\tsubscriber.next(false);\n\t\treturn;\n\t}\n\n\tif (document.readyState === \"complete\") {\n\t\tsubscriber.next(true);\n\t\tsubscriber.complete();\n\t\treturn;\n\t}\n\n\tsubscriber.next(false);\n\n\tconst onLoad = () => {\n\t\tsubscriber.next(true);\n\t\tsubscriber.complete();\n\t};\n\twindow.addEventListener(\"load\", onLoad, { once: true });\n\n\treturn () => window.removeEventListener(\"load\", onLoad);\n});\n","import {\n\tconcat,\n\tmap,\n\tmerge,\n\tNEVER,\n\ttype Observable,\n\tof,\n\tswitchMap,\n\ttimer,\n} from \"rxjs\";\nimport { pageLoaded$ } from \"./pageLoad\";\n\nconst READ_TAIL_MS = [100, 300, 600, 1100];\n\nconst tail$: Observable<void> = merge(\n\tof(undefined),\n\t...READ_TAIL_MS.map((ms) => timer(ms)),\n).pipe(map(() => undefined));\n\nexport const createRegistryReads$ = (): Observable<void> =>\n\ttypeof window === \"undefined\"\n\t\t? concat(of(undefined), NEVER)\n\t\t: pageLoaded$.pipe(switchMap(() => tail$));\n"],"mappings":";;AAAA,MAAa,sBAGT;CACH,UAAU;EACT,MAAM;EACN,MAAM;CACP;CACA,eAAe;EACd,MAAM;EACN,MAAM;CACP;CACA,gBAAgB;EACf,MAAM;EACN,MAAM;CACP;CACA,SAAS;EACR,MAAM;EACN,MAAM;CACP;AACD;;;AClBA,MAAa,cAAc,IAAIA,KAAAA,YAAqB,eAAe;CAClE,IAAI,OAAO,aAAa,aAAa;EACpC,WAAW,KAAK,KAAK;EACrB;CACD;CAEA,IAAI,SAAS,eAAe,YAAY;EACvC,WAAW,KAAK,IAAI;EACpB,WAAW,SAAS;EACpB;CACD;CAEA,WAAW,KAAK,KAAK;CAErB,MAAM,eAAe;EACpB,WAAW,KAAK,IAAI;EACpB,WAAW,SAAS;CACrB;CACA,OAAO,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,KAAK,CAAC;CAEtD,aAAa,OAAO,oBAAoB,QAAQ,MAAM;AACvD,CAAC;;;ACTD,MAAM,SAAA,GAA0BC,KAAAA,MAAAA,EAAAA,GAC/BC,KAAAA,GAAAA,CAAG,KAAA,CAAS,GACZ,GAAG;CAJkB;CAAK;CAAK;CAAK;AAItB,CAAC,CAAC,KAAK,QAAA,GAAOC,KAAAA,MAAAA,CAAM,EAAE,CAAC,CACtC,CAAC,CAAC,MAAA,GAAKC,KAAAA,IAAAA,OAAU,KAAA,CAAS,CAAC;AAE3B,MAAa,6BACZ,OAAO,WAAW,eAAA,GACfC,KAAAA,OAAAA,EAAAA,GAAOH,KAAAA,GAAAA,CAAG,KAAA,CAAS,GAAGI,KAAAA,KAAK,IAC3B,YAAY,MAAA,GAAKC,KAAAA,UAAAA,OAAgB,KAAK,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NEVER, Observable, concat, map, merge, of, switchMap, timer } from "rxjs";
|
|
1
2
|
//#region src/utils/polkadotExtensions.ts
|
|
2
3
|
const POLKADOT_EXTENSIONS = {
|
|
3
4
|
talisman: {
|
|
@@ -18,11 +19,35 @@ const POLKADOT_EXTENSIONS = {
|
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
//#region src/utils/pageLoad.ts
|
|
23
|
+
const pageLoaded$ = new Observable((subscriber) => {
|
|
24
|
+
if (typeof document === "undefined") {
|
|
25
|
+
subscriber.next(false);
|
|
26
|
+
return;
|
|
25
27
|
}
|
|
28
|
+
if (document.readyState === "complete") {
|
|
29
|
+
subscriber.next(true);
|
|
30
|
+
subscriber.complete();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
subscriber.next(false);
|
|
34
|
+
const onLoad = () => {
|
|
35
|
+
subscriber.next(true);
|
|
36
|
+
subscriber.complete();
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("load", onLoad, { once: true });
|
|
39
|
+
return () => window.removeEventListener("load", onLoad);
|
|
26
40
|
});
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/utils/registryReads.ts
|
|
43
|
+
const tail$ = merge(of(void 0), ...[
|
|
44
|
+
100,
|
|
45
|
+
300,
|
|
46
|
+
600,
|
|
47
|
+
1100
|
|
48
|
+
].map((ms) => timer(ms))).pipe(map(() => void 0));
|
|
49
|
+
const createRegistryReads$ = () => typeof window === "undefined" ? concat(of(void 0), NEVER) : pageLoaded$.pipe(switchMap(() => tail$));
|
|
50
|
+
//#endregion
|
|
51
|
+
export { POLKADOT_EXTENSIONS as n, createRegistryReads$ as t };
|
|
27
52
|
|
|
28
|
-
//# sourceMappingURL=
|
|
53
|
+
//# sourceMappingURL=registryReads-HvSaXRWX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryReads-HvSaXRWX.mjs","names":[],"sources":["../src/utils/polkadotExtensions.ts","../src/utils/pageLoad.ts","../src/utils/registryReads.ts"],"sourcesContent":["export const POLKADOT_EXTENSIONS: Record<\n\tstring,\n\t{ name: string; icon: string }\n> = {\n\ttalisman: {\n\t\tname: \"Talisman\",\n\t\ticon: \"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZ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VybCgjcGFpbnQwX2xpbmVhcl8yODdfMjM1OSkiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8yODdfMjM1OSIgeDE9IjE5LjM2MDIiIHkxPSIxNCIgeDI9IjU2Ljc2OTYiIHkyPSI2OS44MDA1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNDNTQ5RkYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNjU0QkZGIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==\",\n\t},\n};\n","import { Observable } from \"rxjs\";\n\nexport const pageLoaded$ = new Observable<boolean>((subscriber) => {\n\tif (typeof document === \"undefined\") {\n\t\tsubscriber.next(false);\n\t\treturn;\n\t}\n\n\tif (document.readyState === \"complete\") {\n\t\tsubscriber.next(true);\n\t\tsubscriber.complete();\n\t\treturn;\n\t}\n\n\tsubscriber.next(false);\n\n\tconst onLoad = () => {\n\t\tsubscriber.next(true);\n\t\tsubscriber.complete();\n\t};\n\twindow.addEventListener(\"load\", onLoad, { once: true });\n\n\treturn () => window.removeEventListener(\"load\", onLoad);\n});\n","import {\n\tconcat,\n\tmap,\n\tmerge,\n\tNEVER,\n\ttype Observable,\n\tof,\n\tswitchMap,\n\ttimer,\n} from \"rxjs\";\nimport { pageLoaded$ } from \"./pageLoad\";\n\nconst READ_TAIL_MS = [100, 300, 600, 1100];\n\nconst tail$: Observable<void> = merge(\n\tof(undefined),\n\t...READ_TAIL_MS.map((ms) => timer(ms)),\n).pipe(map(() => undefined));\n\nexport const createRegistryReads$ = (): Observable<void> =>\n\ttypeof window === \"undefined\"\n\t\t? concat(of(undefined), NEVER)\n\t\t: pageLoaded$.pipe(switchMap(() => tail$));\n"],"mappings":";;AAAA,MAAa,sBAGT;CACH,UAAU;EACT,MAAM;EACN,MAAM;CACP;CACA,eAAe;EACd,MAAM;EACN,MAAM;CACP;CACA,gBAAgB;EACf,MAAM;EACN,MAAM;CACP;CACA,SAAS;EACR,MAAM;EACN,MAAM;CACP;AACD;;;AClBA,MAAa,cAAc,IAAI,YAAqB,eAAe;CAClE,IAAI,OAAO,aAAa,aAAa;EACpC,WAAW,KAAK,KAAK;EACrB;CACD;CAEA,IAAI,SAAS,eAAe,YAAY;EACvC,WAAW,KAAK,IAAI;EACpB,WAAW,SAAS;EACpB;CACD;CAEA,WAAW,KAAK,KAAK;CAErB,MAAM,eAAe;EACpB,WAAW,KAAK,IAAI;EACpB,WAAW,SAAS;CACrB;CACA,OAAO,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,KAAK,CAAC;CAEtD,aAAa,OAAO,oBAAoB,QAAQ,MAAM;AACvD,CAAC;;;ACTD,MAAM,QAA0B,MAC/B,GAAG,KAAA,CAAS,GACZ,GAAG;CAJkB;CAAK;CAAK;CAAK;AAItB,CAAC,CAAC,KAAK,OAAO,MAAM,EAAE,CAAC,CACtC,CAAC,CAAC,KAAK,UAAU,KAAA,CAAS,CAAC;AAE3B,MAAa,6BACZ,OAAO,WAAW,cACf,OAAO,GAAG,KAAA,CAAS,GAAG,KAAK,IAC3B,YAAY,KAAK,gBAAgB,KAAK,CAAC"}
|
package/dist/solana.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BGeGUtxz.mjs";
|
|
2
2
|
import { MessageModifyingSigner, TransactionModifyingSigner, TransactionSendingSigner } from "@solana/kit";
|
|
3
3
|
import { Wallet } from "@wallet-standard/base";
|
|
4
4
|
//#region src/utils/isSolanaAddress.d.ts
|
|
@@ -93,7 +93,7 @@ type SolanaPluginOptions = {
|
|
|
93
93
|
chain?: SolanaChainId;
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
|
-
* Solana platform plugin. Pass to `
|
|
96
|
+
* Solana platform plugin. Pass to `createKheopskit({ platforms: [solana()] })`.
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```ts
|
package/dist/solana.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-
|
|
1
|
+
import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BGeGUtxz.js";
|
|
2
2
|
import { MessageModifyingSigner, TransactionModifyingSigner, TransactionSendingSigner } from "@solana/kit";
|
|
3
3
|
import { Wallet } from "@wallet-standard/base";
|
|
4
4
|
//#region src/utils/isSolanaAddress.d.ts
|
|
@@ -93,7 +93,7 @@ type SolanaPluginOptions = {
|
|
|
93
93
|
chain?: SolanaChainId;
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
|
-
* Solana platform plugin. Pass to `
|
|
96
|
+
* Solana platform plugin. Pass to `createKheopskit({ platforms: [solana()] })`.
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```ts
|