@kheopskit/core 6.0.0-rc.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +11 -0
  3. package/dist/config-Bb-Zz8J1.d.ts +14 -0
  4. package/dist/config-Btb40ehu.mjs +29 -0
  5. package/dist/config-Btb40ehu.mjs.map +1 -0
  6. package/dist/config-C-Xk2AP_.d.mts +14 -0
  7. package/dist/config-D1jjip6f.js +52 -0
  8. package/dist/config-D1jjip6f.js.map +1 -0
  9. package/dist/errors-BBTNA4Pk.mjs +115 -0
  10. package/dist/errors-BBTNA4Pk.mjs.map +1 -0
  11. package/dist/{types-D7OWi0Td.mjs → errors-DVaVewcH.js} +43 -103
  12. package/dist/errors-DVaVewcH.js.map +1 -0
  13. package/dist/ethereum.js +5 -4
  14. package/dist/ethereum.js.map +1 -1
  15. package/dist/ethereum.mjs +4 -3
  16. package/dist/ethereum.mjs.map +1 -1
  17. package/dist/index.d.mts +2 -10
  18. package/dist/index.d.ts +2 -10
  19. package/dist/index.js +8 -6
  20. package/dist/index.mjs +5 -3
  21. package/dist/{injectedWallets-D7wzBr_f.js → injectedWallets-CeYCeVh5.js} +8 -8
  22. package/dist/{injectedWallets-D7wzBr_f.js.map → injectedWallets-CeYCeVh5.js.map} +1 -1
  23. package/dist/{injectedWallets-DHf2lYVb.mjs → injectedWallets-Do5__knh.mjs} +2 -2
  24. package/dist/{injectedWallets-DHf2lYVb.mjs.map → injectedWallets-Do5__knh.mjs.map} +1 -1
  25. package/dist/{instance-CCP7uJV3.js → instance-CBN_ifH_.js} +22 -54
  26. package/dist/instance-CBN_ifH_.js.map +1 -0
  27. package/dist/{instance-BPAvq0v7.mjs → instance-DmBE3vtX.mjs} +8 -28
  28. package/dist/instance-DmBE3vtX.mjs.map +1 -0
  29. package/dist/internal.js +2 -2
  30. package/dist/internal.mjs +2 -2
  31. package/dist/{platformAccounts-BeMDbmUT.mjs → platformAccounts-C1sFv82e.mjs} +10 -3
  32. package/dist/{platformAccounts-BeMDbmUT.mjs.map → platformAccounts-C1sFv82e.mjs.map} +1 -1
  33. package/dist/{platformAccounts-FE7oA3-Y.js → platformAccounts-CqMSpl3X.js} +10 -3
  34. package/dist/{platformAccounts-FE7oA3-Y.js.map → platformAccounts-CqMSpl3X.js.map} +1 -1
  35. package/dist/polkadot.d.mts +13 -0
  36. package/dist/polkadot.d.ts +13 -0
  37. package/dist/polkadot.js +22 -16
  38. package/dist/polkadot.js.map +1 -1
  39. package/dist/polkadot.mjs +14 -8
  40. package/dist/polkadot.mjs.map +1 -1
  41. package/dist/{registryReads-30CCkmHe.js → polkadotExtensions-BoVKhNU_.mjs} +2 -43
  42. package/dist/polkadotExtensions-BoVKhNU_.mjs.map +1 -0
  43. package/dist/{registryReads-HvSaXRWX.mjs → polkadotExtensions-y4J9UzYl.js} +5 -30
  44. package/dist/polkadotExtensions-y4J9UzYl.js.map +1 -0
  45. package/dist/registryReads-BelydyRc.js +46 -0
  46. package/dist/registryReads-BelydyRc.js.map +1 -0
  47. package/dist/registryReads-cdob5BUy.mjs +35 -0
  48. package/dist/registryReads-cdob5BUy.mjs.map +1 -0
  49. package/dist/solana.js +9 -8
  50. package/dist/solana.js.map +1 -1
  51. package/dist/solana.mjs +4 -3
  52. package/dist/solana.mjs.map +1 -1
  53. package/dist/testing.d.mts +6 -1
  54. package/dist/testing.d.ts +6 -1
  55. package/dist/testing.js +5 -0
  56. package/dist/testing.js.map +1 -1
  57. package/dist/testing.mjs +3 -1
  58. package/dist/testing.mjs.map +1 -1
  59. package/dist/types-DaRMgleZ.js +169 -0
  60. package/dist/types-DaRMgleZ.js.map +1 -0
  61. package/dist/types-DcpmEGhO.mjs +104 -0
  62. package/dist/types-DcpmEGhO.mjs.map +1 -0
  63. package/dist/walletconnect.js +3 -2
  64. package/dist/walletconnect.js.map +1 -1
  65. package/dist/walletconnect.mjs +2 -1
  66. package/dist/walletconnect.mjs.map +1 -1
  67. package/package.json +2 -2
  68. package/dist/instance-BPAvq0v7.mjs.map +0 -1
  69. package/dist/instance-CCP7uJV3.js.map +0 -1
  70. package/dist/registryReads-30CCkmHe.js.map +0 -1
  71. package/dist/registryReads-HvSaXRWX.mjs.map +0 -1
  72. package/dist/types-BrMtrjs9.js +0 -323
  73. package/dist/types-BrMtrjs9.js.map +0 -1
  74. package/dist/types-D7OWi0Td.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # @kheopskit/core
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#135](https://github.com/kheopskit/kheopskit/pull/135) [`3afa342`](https://github.com/kheopskit/kheopskit/commit/3afa34256a14c67dfa6302743716153a511a5c4b) Thanks [@0xKheops](https://github.com/0xKheops)! - `connect()` and `disconnect()` are safe to call from UI code.
8
+
9
+ - Removed error codes `WALLET_ALREADY_CONNECTED` and `WALLET_NOT_CONNECTED`: `connect()` on a connected wallet and `disconnect()` on a disconnected wallet resolve at once.
10
+ - New error codes `ABORTED`, `USER_REJECTED` and `CONNECT_FAILED`. A platform's connect rejection is wrapped in a `KheopskitError` carrying `cause` and `walletId`.
11
+ - Concurrent `connect()` calls on one wallet share a single platform attempt; the platform is asked once. Each call gets its own promise.
12
+ - `connect(options?: { signal?: AbortSignal })`: an abort before the platform answers rejects that caller with `ABORTED` and leaves the other callers waiting. An abort after the platform granted the connect changes nothing, and a Polkadot extension counts as granted only once its account list has been read. Once no caller waits, kheopskit drops a late handle without revoking the platform's grant, and the wallet is neither connected nor remembered. No default timeout.
13
+ - `disconnect()` during a `connect()` the platform has not granted aborts it and never waits for the extension prompt. A `disconnect()` that completes while a granted `connect()` still waits for the state rejects that connect `ABORTED`; if the platform's disconnect is still pending or refuses, the connect resolves once the state shows the wallet connected (today only Solana has a platform disconnect). A waiting `disconnect()` is resolved by a `connect()`.
14
+ - `connect()` resolves once `kheopskit$` has emitted the wallet with `isConnected: true`, or once the wallet has left the list after the platform granted it. `disconnect()` resolves, after the platform has answered its disconnect, once `kheopskit$` has emitted `isConnected: false`, or once a later `connect()`, the wallet leaving the list or the end of the subscription makes that emission impossible. After the last subscriber has unsubscribed, `connect()` and `disconnect()` on an injected wallet from that subscription reject `ABORTED` without asking the platform or changing the remembered list. A placeholder's `connect()` rejects the same way and its `disconnect()` resolves; the WalletConnect connector is not wrapped and still calls AppKit.
15
+ - `disconnect()` forgets the wallet before asking the platform and remembers it again if the platform refuses. A `connect()` queued behind a pending `disconnect()` rejects `ABORTED` as soon as its `signal` fires or the last subscriber unsubscribes.
16
+ - Persistence is best-effort: a storage write that throws keeps the in-memory state while the store is observed and never rejects `connect()` or `disconnect()`.
17
+ - Wallet objects keep their identity across emissions that only change accounts.
18
+ - `kheopskit$` no longer throttles by 16 ms. A synchronous burst is coalesced into one emission, so no emission shows a disconnected wallet still listing live accounts (cached placeholder accounts stay listed during hydration). On platforms that list accounts asynchronously (Ethereum `eth_accounts`) the accounts may arrive in an emission after `connect()` resolved.
19
+ - A `connect()` whose wallet disappears before the platform grants it (extension removed, Wallet Standard unregister) rejects `ABORTED`; granted first, it resolves and the wallet stays remembered. A `disconnect()` waiting for the state resolves; one still waiting for the platform settles when the platform answers.
20
+ - Fixed: with two connected wallets, disconnecting one no longer leaves its accounts in the state while the other wallet's accounts are being re-read.
21
+
22
+ - [#141](https://github.com/kheopskit/kheopskit/pull/141) [`d8198d3`](https://github.com/kheopskit/kheopskit/commit/d8198d3af41a21dd81d8294a731684ea46427a33) Thanks [@0xKheops](https://github.com/0xKheops)! - Placeholders restored from the cache carry `isPlaceholder: true`, and each platform account and wallet type is a union on it.
23
+
24
+ - Reading `account.txCreator` (or `polkadotSigner`), `account.signRaw`, `account.client`, `account.signer`, `account.getSigner`, `wallet.provider`, `wallet.wallet` or the WalletConnect wallet's `appKit` without narrowing on `isPlaceholder` yields a possibly-`undefined` value, so calling it or using it as present fails to compile, and `wallet.sourceId` becomes `string | undefined`.
25
+ - A placeholder wallet's `connect()` waits for the live wallet and connects it, rejecting `WALLET_PENDING` if hydration ends first and `ABORTED` if its signal fires or the subscription ends. Its `disconnect()` resolves at once. `PendingWalletError` is removed.
26
+ - A cached wallet present in the live registry is not a placeholder and carries its live `connect()` and `disconnect()`. A Polkadot wallet's `extension` stays `undefined` until its reconnect succeeds.
27
+
28
+ - [#138](https://github.com/kheopskit/kheopskit/pull/138) [`4a3c02a`](https://github.com/kheopskit/kheopskit/commit/4a3c02af5009ffe01170548d33a55a9dc4b6366c) Thanks [@0xKheops](https://github.com/0xKheops)! - Polkadot raw signing and the injected handle:
29
+
30
+ - `account.signRaw(data, options?)` signs a string as text or a `Uint8Array` as hex with the wallet's raw signing call (`signer.signRaw` for an extension, `polkadot_signMessage` over WalletConnect) and resolves the hex signature. With no `options.type`, a string is sent with `type: "payload"` and a `Uint8Array` with `type: "bytes"`; an explicit `options.type` is sent as given, except over WalletConnect, which sends no `type`. A hex-looking string is sent as text; pass a `Uint8Array` for bytes. Talisman's Sign In screen follows text `data`; Enkrypt reads `type` as the encoding of `data` and so needs the matching value.
31
+ - `wallet.extension` is the raw object `enable()` returned, typed as `PolkadotInjected`, instead of pjs-signer's `InjectedExtension`. kheopskit calls `enable()` itself.
32
+ - `ethereum` accounts get their `txCreator` built with the `ecdsa` signature type, so fee estimation and dry runs use a 65-byte mock signature. polkadot-api v2's `getPolkadotSignerFromPjs` ignores the signature type, so this change does not reach `polkadotSigner`.
33
+ - The extension's account subscription is released on disconnect and when the last subscriber leaves.
34
+ - Accounts the extension lists without a `type` are now kept as `sr25519`; `polkadot({ accountTypes })` is the only type filter.
35
+ - `connect()` rejects `CONNECT_FAILED` (with an `Error` naming the extension as `cause`) when the `enable()` result lacks `accounts.get`, `accounts.subscribe`, `signer.signPayload` or `signer.signRaw`, or when `accounts.get()` rejects (a rejection whose message matches a known refusal maps to `USER_REJECTED`), and an account kheopskit cannot build is skipped instead of stalling the wallet's list.
36
+ - `readonly` and `partOfPortfolio`, which Talisman adds for its own dapp origins, are typed as optional booleans on `PolkadotAccount`.
37
+
38
+ - [#137](https://github.com/kheopskit/kheopskit/pull/137) [`13c1bba`](https://github.com/kheopskit/kheopskit/commit/13c1bba70200012f8b63e65f998b9e9d88b6d1c4) Thanks [@0xKheops](https://github.com/0xKheops)! - Rename the persisted `autoReconnect` list to `remembered` (read-migrated) and the store methods to `rememberWallet`/`forgetWallet`; add a `storage` option and `destroy()` to `createKheopskitStore`; re-emit renamed accounts; keep each wallet's accounts in extension order. The store holds its cross-tab sync only while `store.observable` is observed. See MIGRATING_TO_V6.md.
39
+
40
+ - [#140](https://github.com/kheopskit/kheopskit/pull/140) [`0b5d0c1`](https://github.com/kheopskit/kheopskit/commit/0b5d0c1c81da88a08b9284b5c14d2b6e69b2ceeb) Thanks [@0xKheops](https://github.com/0xKheops)! - Every wallet carries a `status` and its last connect `error`, and `autoReconnect` takes a predicate.
41
+
42
+ - `BaseWallet.status` is `"disconnected" | "connecting" | "connected"`; `isConnected` is `status === "connected"`. `connecting` covers a `connect()` call and an auto-reconnect alike. `BaseWallet.error` holds the last `USER_REJECTED` or `CONNECT_FAILED`, or `FEATURE_NOT_SUPPORTED` for a Wallet Standard wallet without `standard:connect`, and is cleared when the next attempt starts. The WalletConnect connector carries the same fields.
43
+ - `autoReconnect: boolean | ((wallet: BaseWallet) => boolean)` governs injected wallets. The function must be synchronous and pure; it decides per remembered injected wallet. Every successful connect is still remembered, whatever this option says. The WalletConnect row follows AppKit's own session restore and hydrates `connecting` while AppKit restores.
44
+ - A reconnect the user refuses forgets the wallet, so the next load does not prompt again. Other failures set `error`, keep the wallet remembered and are retried on later changes to the wallet list, 3 attempts in total. A manual `connect()` or `disconnect()` on a remembered wallet ends its automatic reconnect for the session. A `disconnect()` while the automatic reconnect still waits for the extension aborts it without forgetting the wallet, so the next load reconnects it. Automatic reconnect also ends when the wallet disappears mid-attempt; the wallet stays remembered for the next load. Nothing is written to `console.error`.
45
+ - On a reload, a cached connected wallet shows `status: "connecting"` with `isConnected: false` from the first frame until its reconnect settles; one the predicate rejects shows `disconnected` without its cached accounts. No emission shows `isConnected: true` with a status other than `connected`.
46
+ - `getHydratedSnapshot(store, config, options)` takes the resolved config (`platforms` and `autoReconnect`) in place of the platforms array.
47
+
48
+ - [#142](https://github.com/kheopskit/kheopskit/pull/142) [`6365290`](https://github.com/kheopskit/kheopskit/commit/63652909861336ea19986dd141102a00be524808) Thanks [@0xKheops](https://github.com/0xKheops)! - WalletConnect is a plugin from the new `@kheopskit/core/walletconnect` entry. A dapp that does not import it bundles none of kheopskit's AppKit code and no AppKit chunks.
49
+
50
+ - `config.walletConnect` takes `walletConnect({ projectId, metadata, networks })`. A raw options object is a type error, and `getKheopskit$` throws a `KheopskitError` with the new code `INVALID_CONFIG`.
51
+ - `resetAppKitCache` moved to `@kheopskit/core/walletconnect`.
52
+ - `WalletConnectConfig` is now `WalletConnectOptions`, exported from `@kheopskit/core/walletconnect`. The unused `relayUrl` option is removed.
53
+
54
+ ### Minor Changes
55
+
56
+ - [#155](https://github.com/kheopskit/kheopskit/pull/155) [`d3a05e1`](https://github.com/kheopskit/kheopskit/commit/d3a05e14f6eebebf182f3d2ddfee4057321fbab0) Thanks [@0xKheops](https://github.com/0xKheops)! - Added: `account.name` is readable on every account type. Solana accounts take it from the Wallet Standard `label`, and Ethereum accounts leave it `undefined`.
57
+
58
+ - [#166](https://github.com/kheopskit/kheopskit/pull/166) [`3c2bad1`](https://github.com/kheopskit/kheopskit/commit/3c2bad12e121cede1e95d93d7967d7bb96192180) Thanks [@0xKheops](https://github.com/0xKheops)! - Breaking: `getKheopskit$` and its `GetKheopskitOptions` type are removed from `@kheopskit/core`; create one instance with `createKheopskit(config, options)` and subscribe its `kheopskit$` once at app start. A `@kheopskit/react` provider that receives `ssrCookies` needs an instance created with `createKheopskit(config, { ssr: true })`; without it, `ssrCookies` is a type error. On the server, a store that `createKheopskit` creates ignores `rememberWallet`, `forgetWallet` and `setCachedState`, so module code shared by every request cannot change it.
59
+
60
+ Added: `createKheopskit` in `@kheopskit/core` returns `kheopskit$` and `store`. Every subscriber of `kheopskit$` shares one pipeline, which runs while something subscribes, and a wallet's `connect()` and `disconnect()` act on the pipeline running when they are called. `@kheopskit/react`'s `createKheopskit` is built on it. `@kheopskit/core/internal` gains the instance plumbing that `@kheopskit/react` uses; it is not public API.
61
+
62
+ - [#139](https://github.com/kheopskit/kheopskit/pull/139) [`28ef218`](https://github.com/kheopskit/kheopskit/commit/28ef21809d1219bc80ff385faf3625447fabbdb9) Thanks [@0xKheops](https://github.com/0xKheops)! - Add `@kheopskit/core/testing`: `createFakePolkadotExtension`, `createMemoryStorage`, `cachedWalletOf` and `cachedAccountOf`, to run kheopskit in tests without a browser extension.
63
+
64
+ - [#134](https://github.com/kheopskit/kheopskit/pull/134) [`c04ead2`](https://github.com/kheopskit/kheopskit/commit/c04ead23cfa2b4ba0f7431a510dbf46cc51a2d5c) Thanks [@0xKheops](https://github.com/0xKheops)! - Add `isDiscovering` to the kheopskit state, and read `window.injectedWeb3` again at window `load` (and 100 ms later) so Polkadot extensions that inject just before `load` are listed. `isDiscovering` is `true` until that `load` read has landed, `false` from the first emission when subscribing after `load`, and `true` on the server.
65
+
66
+ - [#143](https://github.com/kheopskit/kheopskit/pull/143) [`dd319cf`](https://github.com/kheopskit/kheopskit/commit/dd319cff47893c61ee76f6c2b87814422599499b) Thanks [@0xKheops](https://github.com/0xKheops)! - Hydration ends as soon as the facts allow, and persistence never writes an empty cache for a wallet still connecting.
67
+
68
+ - `isHydrating` turns `false` once `hydrationGracePeriod` has elapsed, discovery has ended (`isDiscovering` is `false`), and every wallet that hydrated as `connecting` has settled. A wallet has settled when it is absent from the discovered wallets, connected once its account list has been read (an empty list counts; a custom platform plugin not built on kheopskit's account engine settles on its first listed account instead, as in 5.x) or connected with no cached accounts, disconnected with `error` set, or disconnected and not remembered when hydration began. At `hydrationTimeout` hydration ends whatever is pending, and a wallet whose reconnect is still pending stays `connecting`.
69
+ - Discovery ends only after the page fires `load`, so a page with a cache hydrates until `load` or `hydrationTimeout`, whichever comes first, even when no wallet reconnects. With the extension gone, hydration no longer runs to 3 s. It ends once the grace period has elapsed and the page has loaded, or at `hydrationTimeout` if that comes first. MIGRATING_TO_V6.md section 8 lists the cases that hold hydration until the timeout.
70
+ - New `hydrationTimeout` option (default 3000 ms). `hydrationTimeout` replaces the old cap of six times `hydrationGracePeriod` and wins over a longer grace period, so an app that raised `hydrationGracePeriod` sets `hydrationTimeout` as well.
71
+ - When the cache is written, a wallet whose `status` is `connecting` keeps its previous cached entry and accounts. Every other wallet is written from live data.
72
+
73
+ - [#167](https://github.com/kheopskit/kheopskit/pull/167) [`4817131`](https://github.com/kheopskit/kheopskit/commit/4817131306f04ec74d81f95e8727a24c37f1acdb) Thanks [@0xKheops](https://github.com/0xKheops)! - Added: `createKheopskit` returns `waitForAccount(accountId, { signal })`, which resolves with the live account once the running instance lists it, rejects `ACCOUNT_UNAVAILABLE` when the account's wallet settled listing other accounts but not this one or is not connected (a connected wallet that lists no accounts keeps the wait open until `signal` fires), and rejects `ABORTED` like a wallet's `connect()`. `@kheopskit/react`'s `createKheopskit` returns it too.
74
+
75
+ - [#147](https://github.com/kheopskit/kheopskit/pull/147) [`2b197de`](https://github.com/kheopskit/kheopskit/commit/2b197deba67a66b5bbe6ef0b0e5be9a8494055e1) Thanks [@0xKheops](https://github.com/0xKheops)! - `@kheopskit/react`: `createKheopskit(config, { store? })` also returns `kheopskit$` and `store`, so code outside React shares the provider's pipeline. New hooks `useWallet`, `useAccount` and `useConnect`, and a `store` prop on `KheopskitProvider`. Unmounting the provider now stops its pipeline.
76
+
77
+ - [#162](https://github.com/kheopskit/kheopskit/pull/162) [`da040e1`](https://github.com/kheopskit/kheopskit/commit/da040e1f1e8e84a21e7abd4481111ff077c0efdb) Thanks [@0xKheops](https://github.com/0xKheops)! - Added: `walletConnect({ appKitOptions })` forwards any other Reown `createAppKit` option to AppKit, such as `featuredWalletIds`, `features` or `allWallets`. The keys kheopskit sets (`projectId`, `metadata`, `networks`, `themeMode`, `themeVariables`, `universalProviderConfigOverride`) are rejected by the type and keep their kheopskit values.
78
+
79
+ ### Patch Changes
80
+
81
+ - [#175](https://github.com/kheopskit/kheopskit/pull/175) [`1e7c03e`](https://github.com/kheopskit/kheopskit/commit/1e7c03eb6b59a22e0ba5f54b26841e5c3f8fd3bc) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: a wallet whose account stream errors, such as an extension whose `accounts.subscribe` throws, no longer stops `kheopskit$`. That wallet lists no accounts, kheopskit logs a warning, and every other wallet keeps its accounts and updates.
82
+
83
+ - [#177](https://github.com/kheopskit/kheopskit/pull/177) [`fac5d40`](https://github.com/kheopskit/kheopskit/commit/fac5d40fa222f0f496c283a8571879470643b422) Thanks [@0xKheops](https://github.com/0xKheops)! - Added: `@kheopskit/core/testing` exports `DISCOVERY_WINDOW_MS`, `DEFAULT_HYDRATION_GRACE_PERIOD_MS` and `DEFAULT_HYDRATION_TIMEOUT_MS`, so a test advances fake timers past kheopskit's timings without copying the numbers.
84
+
85
+ - [#157](https://github.com/kheopskit/kheopskit/pull/157) [`2eb5c08`](https://github.com/kheopskit/kheopskit/commit/2eb5c086c201763e84065e05785012d0a845d05d) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: Polkadot discovery now reads `window.injectedWeb3` at `load` and 100, 300, 600 and 1100 ms after it, as it already did after subscribe. `isDiscovering` is `true` until the last read, 1100 ms after `load` or after subscribe, whichever is later, so no read is pending once it turns `false`, and that emission lists every extension injected before that read. With `config.walletConnect`, it also waits for the connector to load. A subscription that starts after `load` no longer reads `false` from its first emission. On the server, the registry is read once and no timer is set.
86
+
87
+ Hydration waits for discovery only while a cached wallet has not been discovered. When every cached wallet is discovered and settled, `isHydrating` ends at the grace period without waiting for `load`.
88
+
89
+ - [#148](https://github.com/kheopskit/kheopskit/pull/148) [`ce96842`](https://github.com/kheopskit/kheopskit/commit/ce968421ad52c3ef2b0986fdf3bb7e647edd1352) Thanks [@0xKheops](https://github.com/0xKheops)! - Document the wallet lifecycle (discovery, hydration, reconnect, connect, persistence, signing, testing) with every default and delay in the core README, complete `MIGRATING_TO_V6.md`, add JSDoc to every public config, state, wallet and account field and every error code, and ship `CHANGELOG.md` in both packages.
90
+
91
+ - [#170](https://github.com/kheopskit/kheopskit/pull/170) [`98abf8d`](https://github.com/kheopskit/kheopskit/commit/98abf8d9fa298224e339a1701fab33d86703c233) Thanks [@0xKheops](https://github.com/0xKheops)! - Changed: injected Polkadot wallets that implement `signer.createTransaction` now build the transaction themselves, when the installed polkadot-api exports `getAccountTxCreator` from `polkadot-api/pjs-signer`. This signs on chains whose transaction extensions pjs-signer does not know, such as Paseo Asset Hub's `AsScarcity`. Other wallets and polkadot-api versions keep signing with `signPayload`.
92
+
93
+ - [#164](https://github.com/kheopskit/kheopskit/pull/164) [`0e03c4b`](https://github.com/kheopskit/kheopskit/commit/0e03c4bdc7aafa1d2c5649b3673e41da44d3052e) Thanks [@0xKheops](https://github.com/0xKheops)! - Docs: SSR examples and snippets forward only the `kheopskit` cookie as `ssrCookies`, never the whole cookie header. The core README adds a "Knowing when wallets have settled" recipe and states what the cookie and `localStorage` hold.
94
+
95
+ - [#145](https://github.com/kheopskit/kheopskit/pull/145) [`8878459`](https://github.com/kheopskit/kheopskit/commit/8878459cdcd36563fad908da15df8e9af0a63f8b) Thanks [@0xKheops](https://github.com/0xKheops)! - Docs: a `disconnect()` whose platform call is still pending or refused leaves a granted `connect()` to resolve once the state shows the wallet connected, and a `disconnect()` waiting for the platform settles with the platform's answer.
96
+
97
+ - [#146](https://github.com/kheopskit/kheopskit/pull/146) [`d750f01`](https://github.com/kheopskit/kheopskit/commit/d750f01414009de816d39076441a8145ec190f7d) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: in `kheopskit$`, each wallet's accounts are read on their own stream, started empty when the wallet connects and ended when it disconnects. A wallet that reconnects never shows the accounts of its previous connection and `connect()` never resolves on such an emission; one wallet's pending `eth_accounts` request no longer delays another wallet's accounts or account changes; a wallet connecting or disconnecting no longer makes its siblings re-read their accounts; a Polkadot extension's `accounts.subscribe` runs once per connection.
98
+
99
+ - [#160](https://github.com/kheopskit/kheopskit/pull/160) [`4e55488`](https://github.com/kheopskit/kheopskit/commit/4e5548833b782669f00e33452f5ed4dff9ddcac0) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: a remembered wallet forgotten before it injects is no longer reconnected when it does. A placeholder's `disconnect()` now forgets the wallet, or calls the live wallet's `disconnect()` once that one is discovered. `store.forgetWallet(walletId)` during the session cancels the automatic reconnect for good, even if the wallet is remembered again. `disconnect()` now forgets the wallet whatever its status, including while its automatic reconnect waits for the extension or after that reconnect failed, so the next load does not reconnect it. A wallet the user disconnects during hydration no longer holds `isHydrating` until `hydrationTimeout`.
100
+
101
+ - [#152](https://github.com/kheopskit/kheopskit/pull/152) [`af84029`](https://github.com/kheopskit/kheopskit/commit/af84029112400600db23a901bb8e8fea10366f2b) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: a Polkadot `connect()` started while the extension prompt of an abandoned attempt (aborted `signal` or `disconnect()`) is still open now waits for that prompt instead of calling `enable()` again, and connects when the user approves it. Before, Talisman rejected the new attempt with `USER_REJECTED` ("has not been authorised") and polkadot-js with `CONNECT_FAILED` ("Pending authorisation request already exists"), and approving the first prompt connected nothing.
102
+
103
+ - [#163](https://github.com/kheopskit/kheopskit/pull/163) [`1cc653d`](https://github.com/kheopskit/kheopskit/commit/1cc653d954f02b670f05639fd83b34da29ded5d6) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: wallets and accounts cached for a platform missing from `platforms` no longer show on the first frame, in the SSR markup or as hydration placeholders. The cached WalletConnect row and its accounts likewise need `walletConnect` in the config, and a WalletConnect account needs its platform in `platforms`. Remembered wallets of a removed platform are not reconnected and stay remembered, so adding the platform back restores their reconnect.
104
+
105
+ - [#168](https://github.com/kheopskit/kheopskit/pull/168) [`0f58896`](https://github.com/kheopskit/kheopskit/commit/0f58896af3fcf1ba2bd8d17bed40c74a60adb8be) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: with `walletConnect`, `wallets` lists the injected wallets without waiting for Reown AppKit to download and start. The WalletConnect wallet joins the list once AppKit loads, and `isDiscovering` still stays `true` until then.
106
+
107
+ - [#168](https://github.com/kheopskit/kheopskit/pull/168) [`0f58896`](https://github.com/kheopskit/kheopskit/commit/0f58896af3fcf1ba2bd8d17bed40c74a60adb8be) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: `walletConnect()` asks AppKit for Polkadot and Solana methods only when `networks` includes a network of that namespace. Before, a Polkadot-only dapp sent an empty Solana namespace, and Reown rejected the pairing, so the modal closed without a QR code.
108
+
109
+ ## 6.0.0-rc.6
110
+
111
+ ### Patch Changes
112
+
113
+ - [#170](https://github.com/kheopskit/kheopskit/pull/170) [`98abf8d`](https://github.com/kheopskit/kheopskit/commit/98abf8d9fa298224e339a1701fab33d86703c233) Thanks [@0xKheops](https://github.com/0xKheops)! - Changed: injected Polkadot wallets that implement `signer.createTransaction` now build the transaction themselves, when the installed polkadot-api exports `getAccountTxCreator` from `polkadot-api/pjs-signer`. This signs on chains whose transaction extensions pjs-signer does not know, such as Paseo Asset Hub's `AsScarcity`. Other wallets and polkadot-api versions keep signing with `signPayload`.
114
+
3
115
  ## 6.0.0-rc.5
4
116
 
5
117
  ### Patch Changes
package/README.md CHANGED
@@ -493,6 +493,12 @@ directly with wallets that are already connected, waits until each of them has
493
493
  answered. `kheopskit$` subscribes before any wallet is connected, so it never
494
494
  waits.
495
495
 
496
+ A wallet whose account stream errors, such as an extension whose
497
+ `accounts.subscribe` throws, stays `connected` and lists no accounts until it
498
+ reconnects. Kheopskit logs a warning and sets no `wallet.error`. The next cache
499
+ write stores the wallet with no accounts. Every other wallet keeps its accounts.
500
+ To retry, call `disconnect()` and then `connect()`.
501
+
496
502
  `state.accounts` is grouped by platform (Polkadot, Ethereum, Solana), then by
497
503
  wallet (Talisman first, then by wallet name). Inside a wallet, accounts keep
498
504
  the order the extension lists them in. `state.wallets` follows the same
@@ -685,6 +691,11 @@ extension. It has no test-runner dependency, so it works with vitest and jest.
685
691
  - `cachedWalletOf(walletId, name)` and `cachedAccountOf(wallet, address,
686
692
  name?)` build the entries `store.setCachedState(wallets, accounts)` takes, so
687
693
  a test seeds a previous session without writing the persisted shape.
694
+ - `DISCOVERY_WINDOW_MS`, `DEFAULT_HYDRATION_GRACE_PERIOD_MS` and
695
+ `DEFAULT_HYDRATION_TIMEOUT_MS` let a test advance fake timers past
696
+ kheopskit's timings instead of copying the numbers. `DISCOVERY_WINDOW_MS`
697
+ counts from `load` or from subscribe, whichever is later, and the
698
+ `walletConnect()` plugin can hold discovery longer, until AppKit answers.
688
699
 
689
700
  A vitest test that seeds a remembered wallet and checks that it reconnects:
690
701
 
@@ -0,0 +1,14 @@
1
+ import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-BGeGUtxz.js";
2
+ //#region src/api/config.d.ts
3
+ /**
4
+ * Default storage key for persisting wallet connection state.
5
+ * Can be overridden via config.storageKey to avoid conflicts
6
+ * when running multiple dapps on the same domain.
7
+ */
8
+ declare const DEFAULT_STORAGE_KEY = "kheopskit";
9
+ declare const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;
10
+ declare const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;
11
+ declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
12
+ //#endregion
13
+ export { resolveConfig as i, DEFAULT_HYDRATION_TIMEOUT_MS as n, DEFAULT_STORAGE_KEY as r, DEFAULT_HYDRATION_GRACE_PERIOD_MS as t };
14
+ //# sourceMappingURL=config-Bb-Zz8J1.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { t as KheopskitError } from "./errors-BBTNA4Pk.mjs";
2
+ //#region src/api/config.ts
3
+ /**
4
+ * Default storage key for persisting wallet connection state.
5
+ * Can be overridden via config.storageKey to avoid conflicts
6
+ * when running multiple dapps on the same domain.
7
+ */
8
+ const DEFAULT_STORAGE_KEY = "kheopskit";
9
+ const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;
10
+ const DEFAULT_HYDRATION_TIMEOUT_MS = 3e3;
11
+ const DEFAULTS = {
12
+ autoReconnect: true,
13
+ debug: false,
14
+ storageKey: DEFAULT_STORAGE_KEY,
15
+ hydrationGracePeriod: 500,
16
+ hydrationTimeout: DEFAULT_HYDRATION_TIMEOUT_MS
17
+ };
18
+ const resolveConfig = (config) => {
19
+ const platforms = config?.platforms ?? [];
20
+ const invalidPlatforms = platforms.filter((p) => typeof p !== "object" || p === null || typeof p.getWallets$ !== "function");
21
+ if (invalidPlatforms.length > 0) throw new Error(`[kheopskit] config.platforms must contain plugin instances created by the per-platform factories (e.g. platforms: [polkadot(), ethereum(), solana()] imported from "@kheopskit/core/<platform>"). Invalid entries: ${JSON.stringify(invalidPlatforms)}. String platform names like "polkadot" were removed in v4 — see MIGRATING_TO_V4.md.`);
22
+ if (config?.walletConnect !== void 0 && typeof config.walletConnect?.getWallet$ !== "function") throw new KheopskitError("INVALID_CONFIG", "config.walletConnect must be created by walletConnect() imported from \"@kheopskit/core/walletconnect\", e.g. walletConnect: walletConnect({ projectId, metadata, networks }). Raw WalletConnect options were removed in v6, see MIGRATING_TO_V6.md.");
23
+ if (platforms.length === 0) console.warn("[kheopskit] No platforms configured; wallets and accounts will be empty. Pass e.g. platforms: [polkadot()] from \"@kheopskit/core/polkadot\".");
24
+ return Object.assign({}, DEFAULTS, config, { platforms });
25
+ };
26
+ //#endregion
27
+ export { resolveConfig as i, DEFAULT_HYDRATION_TIMEOUT_MS as n, DEFAULT_STORAGE_KEY as r, DEFAULT_HYDRATION_GRACE_PERIOD_MS as t };
28
+
29
+ //# sourceMappingURL=config-Btb40ehu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-Btb40ehu.mjs","names":[],"sources":["../src/api/config.ts"],"sourcesContent":["import { KheopskitError } from \"./errors\";\nimport type { KheopskitConfig, KheopskitPlatform } from \"./types\";\n\n/**\n * Default storage key for persisting wallet connection state.\n * Can be overridden via config.storageKey to avoid conflicts\n * when running multiple dapps on the same domain.\n */\nexport const DEFAULT_STORAGE_KEY = \"kheopskit\";\n\nexport const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;\nexport const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;\n\nconst DEFAULTS = {\n\tautoReconnect: true,\n\tdebug: false,\n\tstorageKey: DEFAULT_STORAGE_KEY,\n\thydrationGracePeriod: DEFAULT_HYDRATION_GRACE_PERIOD_MS,\n\thydrationTimeout: DEFAULT_HYDRATION_TIMEOUT_MS,\n} satisfies Omit<KheopskitConfig, \"platforms\" | \"walletConnect\">;\n\nexport const resolveConfig = <\n\tconst P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[],\n>(\n\tconfig?: Partial<KheopskitConfig<P>>,\n): KheopskitConfig<P> => {\n\tconst platforms = (config?.platforms ?? []) as P;\n\n\t// Guard the v4 breaking change: platforms are plugin instances, not strings.\n\t// Catches JS callers (no tsc) and gives agents a fix that names the doc.\n\tconst invalidPlatforms = (platforms as readonly unknown[]).filter(\n\t\t(p) =>\n\t\t\ttypeof p !== \"object\" ||\n\t\t\tp === null ||\n\t\t\ttypeof (p as { getWallets$?: unknown }).getWallets$ !== \"function\",\n\t);\n\tif (invalidPlatforms.length > 0) {\n\t\tthrow new Error(\n\t\t\t\"[kheopskit] config.platforms must contain plugin instances created by the \" +\n\t\t\t\t\"per-platform factories (e.g. platforms: [polkadot(), ethereum(), solana()] \" +\n\t\t\t\t'imported from \"@kheopskit/core/<platform>\"). ' +\n\t\t\t\t`Invalid entries: ${JSON.stringify(invalidPlatforms)}. ` +\n\t\t\t\t'String platform names like \"polkadot\" were removed in v4 — see MIGRATING_TO_V4.md.',\n\t\t);\n\t}\n\n\tif (\n\t\tconfig?.walletConnect !== undefined &&\n\t\ttypeof (config.walletConnect as { getWallet$?: unknown } | null)\n\t\t\t?.getWallet$ !== \"function\"\n\t) {\n\t\tthrow new KheopskitError(\n\t\t\t\"INVALID_CONFIG\",\n\t\t\t\"config.walletConnect must be created by walletConnect() imported from \" +\n\t\t\t\t'\"@kheopskit/core/walletconnect\", e.g. walletConnect: walletConnect({ projectId, metadata, networks }). ' +\n\t\t\t\t\"Raw WalletConnect options were removed in v6, see MIGRATING_TO_V6.md.\",\n\t\t);\n\t}\n\n\tif (platforms.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] No platforms configured; wallets and accounts will be empty. \" +\n\t\t\t\t'Pass e.g. platforms: [polkadot()] from \"@kheopskit/core/polkadot\".',\n\t\t);\n\t}\n\n\treturn Object.assign({}, DEFAULTS, config, { platforms });\n};\n"],"mappings":";;;;;;;AAQA,MAAa,sBAAsB;AAEnC,MAAa,oCAAoC;AACjD,MAAa,+BAA+B;AAE5C,MAAM,WAAW;CAChB,eAAe;CACf,OAAO;CACP,YAAY;CACZ,sBAAA;CACA,kBAAkB;AACnB;AAEA,MAAa,iBAGZ,WACwB;CACxB,MAAM,YAAa,QAAQ,aAAa,CAAC;CAIzC,MAAM,mBAAoB,UAAiC,QACzD,MACA,OAAO,MAAM,YACb,MAAM,QACN,OAAQ,EAAgC,gBAAgB,UAC1D;CACA,IAAI,iBAAiB,SAAS,GAC7B,MAAM,IAAI,MACT,sNAGqB,KAAK,UAAU,gBAAgB,EAAE,qFAEvD;CAGD,IACC,QAAQ,kBAAkB,KAAA,KAC1B,OAAQ,OAAO,eACZ,eAAe,YAElB,MAAM,IAAI,eACT,kBACA,sPAGD;CAGD,IAAI,UAAU,WAAW,GACxB,QAAQ,KACP,+IAED;CAGD,OAAO,OAAO,OAAO,CAAC,GAAG,UAAU,QAAQ,EAAE,UAAU,CAAC;AACzD"}
@@ -0,0 +1,14 @@
1
+ import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-BGeGUtxz.mjs";
2
+ //#region src/api/config.d.ts
3
+ /**
4
+ * Default storage key for persisting wallet connection state.
5
+ * Can be overridden via config.storageKey to avoid conflicts
6
+ * when running multiple dapps on the same domain.
7
+ */
8
+ declare const DEFAULT_STORAGE_KEY = "kheopskit";
9
+ declare const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;
10
+ declare const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;
11
+ declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
12
+ //#endregion
13
+ export { resolveConfig as i, DEFAULT_HYDRATION_TIMEOUT_MS as n, DEFAULT_STORAGE_KEY as r, DEFAULT_HYDRATION_GRACE_PERIOD_MS as t };
14
+ //# sourceMappingURL=config-C-Xk2AP_.d.mts.map
@@ -0,0 +1,52 @@
1
+ const require_errors = require("./errors-DVaVewcH.js");
2
+ //#region src/api/config.ts
3
+ /**
4
+ * Default storage key for persisting wallet connection state.
5
+ * Can be overridden via config.storageKey to avoid conflicts
6
+ * when running multiple dapps on the same domain.
7
+ */
8
+ const DEFAULT_STORAGE_KEY = "kheopskit";
9
+ const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;
10
+ const DEFAULT_HYDRATION_TIMEOUT_MS = 3e3;
11
+ const DEFAULTS = {
12
+ autoReconnect: true,
13
+ debug: false,
14
+ storageKey: DEFAULT_STORAGE_KEY,
15
+ hydrationGracePeriod: 500,
16
+ hydrationTimeout: DEFAULT_HYDRATION_TIMEOUT_MS
17
+ };
18
+ const resolveConfig = (config) => {
19
+ const platforms = config?.platforms ?? [];
20
+ const invalidPlatforms = platforms.filter((p) => typeof p !== "object" || p === null || typeof p.getWallets$ !== "function");
21
+ if (invalidPlatforms.length > 0) throw new Error(`[kheopskit] config.platforms must contain plugin instances created by the per-platform factories (e.g. platforms: [polkadot(), ethereum(), solana()] imported from "@kheopskit/core/<platform>"). Invalid entries: ${JSON.stringify(invalidPlatforms)}. String platform names like "polkadot" were removed in v4 — see MIGRATING_TO_V4.md.`);
22
+ if (config?.walletConnect !== void 0 && typeof config.walletConnect?.getWallet$ !== "function") throw new require_errors.KheopskitError("INVALID_CONFIG", "config.walletConnect must be created by walletConnect() imported from \"@kheopskit/core/walletconnect\", e.g. walletConnect: walletConnect({ projectId, metadata, networks }). Raw WalletConnect options were removed in v6, see MIGRATING_TO_V6.md.");
23
+ if (platforms.length === 0) console.warn("[kheopskit] No platforms configured; wallets and accounts will be empty. Pass e.g. platforms: [polkadot()] from \"@kheopskit/core/polkadot\".");
24
+ return Object.assign({}, DEFAULTS, config, { platforms });
25
+ };
26
+ //#endregion
27
+ Object.defineProperty(exports, "DEFAULT_HYDRATION_GRACE_PERIOD_MS", {
28
+ enumerable: true,
29
+ get: function() {
30
+ return DEFAULT_HYDRATION_GRACE_PERIOD_MS;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "DEFAULT_HYDRATION_TIMEOUT_MS", {
34
+ enumerable: true,
35
+ get: function() {
36
+ return DEFAULT_HYDRATION_TIMEOUT_MS;
37
+ }
38
+ });
39
+ Object.defineProperty(exports, "DEFAULT_STORAGE_KEY", {
40
+ enumerable: true,
41
+ get: function() {
42
+ return DEFAULT_STORAGE_KEY;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, "resolveConfig", {
46
+ enumerable: true,
47
+ get: function() {
48
+ return resolveConfig;
49
+ }
50
+ });
51
+
52
+ //# sourceMappingURL=config-D1jjip6f.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-D1jjip6f.js","names":["KheopskitError"],"sources":["../src/api/config.ts"],"sourcesContent":["import { KheopskitError } from \"./errors\";\nimport type { KheopskitConfig, KheopskitPlatform } from \"./types\";\n\n/**\n * Default storage key for persisting wallet connection state.\n * Can be overridden via config.storageKey to avoid conflicts\n * when running multiple dapps on the same domain.\n */\nexport const DEFAULT_STORAGE_KEY = \"kheopskit\";\n\nexport const DEFAULT_HYDRATION_GRACE_PERIOD_MS = 500;\nexport const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;\n\nconst DEFAULTS = {\n\tautoReconnect: true,\n\tdebug: false,\n\tstorageKey: DEFAULT_STORAGE_KEY,\n\thydrationGracePeriod: DEFAULT_HYDRATION_GRACE_PERIOD_MS,\n\thydrationTimeout: DEFAULT_HYDRATION_TIMEOUT_MS,\n} satisfies Omit<KheopskitConfig, \"platforms\" | \"walletConnect\">;\n\nexport const resolveConfig = <\n\tconst P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[],\n>(\n\tconfig?: Partial<KheopskitConfig<P>>,\n): KheopskitConfig<P> => {\n\tconst platforms = (config?.platforms ?? []) as P;\n\n\t// Guard the v4 breaking change: platforms are plugin instances, not strings.\n\t// Catches JS callers (no tsc) and gives agents a fix that names the doc.\n\tconst invalidPlatforms = (platforms as readonly unknown[]).filter(\n\t\t(p) =>\n\t\t\ttypeof p !== \"object\" ||\n\t\t\tp === null ||\n\t\t\ttypeof (p as { getWallets$?: unknown }).getWallets$ !== \"function\",\n\t);\n\tif (invalidPlatforms.length > 0) {\n\t\tthrow new Error(\n\t\t\t\"[kheopskit] config.platforms must contain plugin instances created by the \" +\n\t\t\t\t\"per-platform factories (e.g. platforms: [polkadot(), ethereum(), solana()] \" +\n\t\t\t\t'imported from \"@kheopskit/core/<platform>\"). ' +\n\t\t\t\t`Invalid entries: ${JSON.stringify(invalidPlatforms)}. ` +\n\t\t\t\t'String platform names like \"polkadot\" were removed in v4 — see MIGRATING_TO_V4.md.',\n\t\t);\n\t}\n\n\tif (\n\t\tconfig?.walletConnect !== undefined &&\n\t\ttypeof (config.walletConnect as { getWallet$?: unknown } | null)\n\t\t\t?.getWallet$ !== \"function\"\n\t) {\n\t\tthrow new KheopskitError(\n\t\t\t\"INVALID_CONFIG\",\n\t\t\t\"config.walletConnect must be created by walletConnect() imported from \" +\n\t\t\t\t'\"@kheopskit/core/walletconnect\", e.g. walletConnect: walletConnect({ projectId, metadata, networks }). ' +\n\t\t\t\t\"Raw WalletConnect options were removed in v6, see MIGRATING_TO_V6.md.\",\n\t\t);\n\t}\n\n\tif (platforms.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] No platforms configured; wallets and accounts will be empty. \" +\n\t\t\t\t'Pass e.g. platforms: [polkadot()] from \"@kheopskit/core/polkadot\".',\n\t\t);\n\t}\n\n\treturn Object.assign({}, DEFAULTS, config, { platforms });\n};\n"],"mappings":";;;;;;;AAQA,MAAa,sBAAsB;AAEnC,MAAa,oCAAoC;AACjD,MAAa,+BAA+B;AAE5C,MAAM,WAAW;CAChB,eAAe;CACf,OAAO;CACP,YAAY;CACZ,sBAAA;CACA,kBAAkB;AACnB;AAEA,MAAa,iBAGZ,WACwB;CACxB,MAAM,YAAa,QAAQ,aAAa,CAAC;CAIzC,MAAM,mBAAoB,UAAiC,QACzD,MACA,OAAO,MAAM,YACb,MAAM,QACN,OAAQ,EAAgC,gBAAgB,UAC1D;CACA,IAAI,iBAAiB,SAAS,GAC7B,MAAM,IAAI,MACT,sNAGqB,KAAK,UAAU,gBAAgB,EAAE,qFAEvD;CAGD,IACC,QAAQ,kBAAkB,KAAA,KAC1B,OAAQ,OAAO,eACZ,eAAe,YAElB,MAAM,IAAIA,eAAAA,eACT,kBACA,sPAGD;CAGD,IAAI,UAAU,WAAW,GACxB,QAAQ,KACP,+IAED;CAGD,OAAO,OAAO,OAAO,CAAC,GAAG,UAAU,QAAQ,EAAE,UAAU,CAAC;AACzD"}
@@ -0,0 +1,115 @@
1
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
2
+ function _typeof(o) {
3
+ "@babel/helpers - typeof";
4
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
+ return typeof o;
6
+ } : function(o) {
7
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
+ }, _typeof(o);
9
+ }
10
+ //#endregion
11
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
12
+ function toPrimitive(t, r) {
13
+ if ("object" != _typeof(t) || !t) return t;
14
+ var e = t[Symbol.toPrimitive];
15
+ if (void 0 !== e) {
16
+ var i = e.call(t, r || "default");
17
+ if ("object" != _typeof(i)) return i;
18
+ throw new TypeError("@@toPrimitive must return a primitive value.");
19
+ }
20
+ return ("string" === r ? String : Number)(t);
21
+ }
22
+ //#endregion
23
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
24
+ function toPropertyKey(t) {
25
+ var i = toPrimitive(t, "string");
26
+ return "symbol" == _typeof(i) ? i : i + "";
27
+ }
28
+ //#endregion
29
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
30
+ function _defineProperty(e, r, t) {
31
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
+ value: t,
33
+ enumerable: !0,
34
+ configurable: !0,
35
+ writable: !0
36
+ }) : e[r] = t, e;
37
+ }
38
+ //#endregion
39
+ //#region src/api/errors.ts
40
+ /**
41
+ * Error thrown by kheopskit wallet/account operations. Carries a stable
42
+ * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * try {
47
+ * await wallet.connect();
48
+ * } catch (error) {
49
+ * if (error instanceof KheopskitError && error.code === "USER_REJECTED") {
50
+ * // the user closed or refused the wallet prompt
51
+ * } else throw error;
52
+ * }
53
+ * ```
54
+ */
55
+ var KheopskitError = class extends Error {
56
+ constructor(code, message, options) {
57
+ super(`[kheopskit] ${message}`, { cause: options?.cause });
58
+ _defineProperty(this, "code", void 0);
59
+ _defineProperty(this, "walletId", void 0);
60
+ this.name = "KheopskitError";
61
+ this.code = code;
62
+ this.walletId = options?.walletId;
63
+ }
64
+ };
65
+ const abortedError = (walletId, operation) => new KheopskitError("ABORTED", `${operation} of wallet ${walletId} was aborted`, { walletId });
66
+ const walletPendingError = (walletId) => new KheopskitError("WALLET_PENDING", `wallet ${walletId} was not discovered before hydration ended`, { walletId });
67
+ const accountUnavailableError = (accountId, walletId) => new KheopskitError("ACCOUNT_UNAVAILABLE", `wallet ${walletId} settled without listing account ${accountId}`, { walletId });
68
+ const toConnectError = (error, walletId, isUserRejection) => {
69
+ if (error instanceof KheopskitError) return error;
70
+ return isUserRejection(error) ? new KheopskitError("USER_REJECTED", `the user rejected the connect request of wallet ${walletId}`, {
71
+ walletId,
72
+ cause: error
73
+ }) : new KheopskitError("CONNECT_FAILED", `wallet ${walletId} failed to connect`, {
74
+ walletId,
75
+ cause: error
76
+ });
77
+ };
78
+ const EIP1193_USER_REJECTED_REQUEST = 4001;
79
+ const isEip1193UserRejection = (error) => typeof error === "object" && error !== null && error.code === EIP1193_USER_REJECTED_REQUEST;
80
+ /**
81
+ * How Polkadot extensions and Wallet Standard wallets reject a refused connect
82
+ * prompt. They send a plain `Error`, so the message is the only signal.
83
+ * `evidence` records whether the row was observed live or inferred from the
84
+ * wallet's source or documentation.
85
+ */
86
+ const REFUSAL_MESSAGES = [
87
+ {
88
+ pattern: /^Site .+ has not been authorised for Talisman yet$/,
89
+ wallet: "Talisman 3.11.0, Reject button or prompt window closed",
90
+ evidence: "live"
91
+ },
92
+ {
93
+ pattern: /^Connection request was (rejected|cancelled) by the user\.$/,
94
+ wallet: "polkadot-js extension (extension-base 0.64 State.ts)",
95
+ evidence: "inferred"
96
+ },
97
+ {
98
+ pattern: /^(Rejected|Cancelled)$/,
99
+ wallet: "SubWallet (Extension.ts)",
100
+ evidence: "inferred"
101
+ },
102
+ {
103
+ pattern: /^User rejected the request\.$/,
104
+ wallet: "Phantom (Wallet Standard)",
105
+ evidence: "inferred"
106
+ }
107
+ ];
108
+ const isRefusalMessage = (error) => {
109
+ const message = error?.message;
110
+ return typeof message === "string" && REFUSAL_MESSAGES.some((row) => row.pattern.test(message));
111
+ };
112
+ //#endregion
113
+ export { isRefusalMessage as a, isEip1193UserRejection as i, abortedError as n, toConnectError as o, accountUnavailableError as r, walletPendingError as s, KheopskitError as t };
114
+
115
+ //# sourceMappingURL=errors-BBTNA4Pk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BBTNA4Pk.mjs","names":[],"sources":["../src/api/errors.ts"],"sourcesContent":["import type { WalletAccountId } from \"../utils/WalletAccountId\";\nimport type { WalletId } from \"../utils/WalletId\";\n\n/**\n * Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and\n * branch on `error.code` instead of matching message strings.\n */\nexport type KheopskitErrorCode =\n\t/**\n\t * This `connect()` or `disconnect()` call was abandoned. For `connect()`:\n\t * its `signal` fired before the platform answered, `disconnect()` was\n\t * called while it pended, its wallet disappeared, or the last `kheopskit$`\n\t * subscriber unsubscribed.\n\t * For either call on an injected wallet: the wallet object came from a\n\t * subscription that had already ended, in which case the call rejects\n\t * without asking the platform and without changing the remembered list. A\n\t * placeholder's `connect()` rejects the same way, its `disconnect()`\n\t * resolves, and the WalletConnect connector still calls AppKit.\n\t */\n\t| \"ABORTED\"\n\t/** The user refused the wallet's connect prompt. `cause` holds the platform error. */\n\t| \"USER_REJECTED\"\n\t/** The wallet's connect call failed for another reason. `cause` holds the platform error. */\n\t| \"CONNECT_FAILED\"\n\t/**\n\t * `connect()` was called on a placeholder wallet restored from the cache:\n\t * on `kheopskit$`, hydration ended without kheopskit discovering that\n\t * wallet; on `getHydratedSnapshot` and the React provider's initial\n\t * snapshot, always.\n\t */\n\t| \"WALLET_PENDING\"\n\t/**\n\t * `waitForAccount()` found the account's wallet settled without listing it\n\t * as a live account, or not connected.\n\t */\n\t| \"ACCOUNT_UNAVAILABLE\"\n\t/** The wallet does not advertise a capability kheopskit needs to proceed. */\n\t| \"FEATURE_NOT_SUPPORTED\"\n\t/** No active WalletConnect session for the requested operation. */\n\t| \"NO_SESSION\"\n\t/** No provider available for the requested namespace. */\n\t| \"NO_PROVIDER\"\n\t/** The installed polkadot-api version exposes neither `getTxCreatorFromPjs` (v3) nor `getPolkadotSignerFromPjs` (v2). */\n\t| \"UNSUPPORTED_VERSION\"\n\t/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */\n\t| \"UNSUPPORTED_CHAIN\"\n\t/** `createKheopskit` received a config value it cannot use. The message names the fix. */\n\t| \"INVALID_CONFIG\";\n\n/**\n * Error thrown by kheopskit wallet/account operations. Carries a stable\n * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.\n *\n * @example\n * ```ts\n * try {\n * await wallet.connect();\n * } catch (error) {\n * if (error instanceof KheopskitError && error.code === \"USER_REJECTED\") {\n * // the user closed or refused the wallet prompt\n * } else throw error;\n * }\n * ```\n */\nexport class KheopskitError extends Error {\n\treadonly code: KheopskitErrorCode;\n\t/** The wallet id this error relates to, when applicable. */\n\treadonly walletId?: WalletId;\n\n\tconstructor(\n\t\tcode: KheopskitErrorCode,\n\t\tmessage: string,\n\t\toptions?: { walletId?: WalletId; cause?: unknown },\n\t) {\n\t\tsuper(`[kheopskit] ${message}`, { cause: options?.cause });\n\t\tthis.name = \"KheopskitError\";\n\t\tthis.code = code;\n\t\tthis.walletId = options?.walletId;\n\t}\n}\n\nexport const abortedError = (\n\twalletId: WalletId,\n\toperation: \"connect\" | \"disconnect\",\n): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"ABORTED\",\n\t\t`${operation} of wallet ${walletId} was aborted`,\n\t\t{ walletId },\n\t);\n\nexport const walletPendingError = (walletId: WalletId): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"WALLET_PENDING\",\n\t\t`wallet ${walletId} was not discovered before hydration ended`,\n\t\t{ walletId },\n\t);\n\nexport const accountUnavailableError = (\n\taccountId: WalletAccountId,\n\twalletId: WalletId,\n): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"ACCOUNT_UNAVAILABLE\",\n\t\t`wallet ${walletId} settled without listing account ${accountId}`,\n\t\t{ walletId },\n\t);\n\nexport const toConnectError = (\n\terror: unknown,\n\twalletId: WalletId,\n\tisUserRejection: (error: unknown) => boolean,\n): KheopskitError => {\n\tif (error instanceof KheopskitError) return error;\n\treturn isUserRejection(error)\n\t\t? new KheopskitError(\n\t\t\t\t\"USER_REJECTED\",\n\t\t\t\t`the user rejected the connect request of wallet ${walletId}`,\n\t\t\t\t{ walletId, cause: error },\n\t\t\t)\n\t\t: new KheopskitError(\n\t\t\t\t\"CONNECT_FAILED\",\n\t\t\t\t`wallet ${walletId} failed to connect`,\n\t\t\t\t{ walletId, cause: error },\n\t\t\t);\n};\n\nconst EIP1193_USER_REJECTED_REQUEST = 4001;\n\nexport const isEip1193UserRejection = (error: unknown): boolean =>\n\ttypeof error === \"object\" &&\n\terror !== null &&\n\t(error as { code?: unknown }).code === EIP1193_USER_REJECTED_REQUEST;\n\ntype RefusalMessage = {\n\tpattern: RegExp;\n\twallet: string;\n\tevidence: \"live\" | \"inferred\";\n};\n\n/**\n * How Polkadot extensions and Wallet Standard wallets reject a refused connect\n * prompt. They send a plain `Error`, so the message is the only signal.\n * `evidence` records whether the row was observed live or inferred from the\n * wallet's source or documentation.\n */\nconst REFUSAL_MESSAGES: readonly RefusalMessage[] = [\n\t{\n\t\tpattern: /^Site .+ has not been authorised for Talisman yet$/,\n\t\twallet: \"Talisman 3.11.0, Reject button or prompt window closed\",\n\t\tevidence: \"live\",\n\t},\n\t{\n\t\tpattern: /^Connection request was (rejected|cancelled) by the user\\.$/,\n\t\twallet: \"polkadot-js extension (extension-base 0.64 State.ts)\",\n\t\tevidence: \"inferred\",\n\t},\n\t{\n\t\tpattern: /^(Rejected|Cancelled)$/,\n\t\twallet: \"SubWallet (Extension.ts)\",\n\t\tevidence: \"inferred\",\n\t},\n\t{\n\t\tpattern: /^User rejected the request\\.$/,\n\t\twallet: \"Phantom (Wallet Standard)\",\n\t\tevidence: \"inferred\",\n\t},\n];\n\nexport const isRefusalMessage = (error: unknown): boolean => {\n\tconst message = (error as { message?: unknown } | null | undefined)?.message;\n\treturn (\n\t\ttypeof message === \"string\" &&\n\t\tREFUSAL_MESSAGES.some((row) => row.pattern.test(message))\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,iBAAb,cAAoC,MAAM;CAKzC,YACC,MACA,SACA,SACC;EACD,MAAM,eAAe,WAAW,EAAE,OAAO,SAAS,MAAM,CAAC;EATjD,gBAAA,MAAA,QAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,YAAA,KAAA,CAAA;EAQR,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS;CAC1B;AACD;AAEA,MAAa,gBACZ,UACA,cAEA,IAAI,eACH,WACA,GAAG,UAAU,aAAa,SAAS,eACnC,EAAE,SAAS,CACZ;AAED,MAAa,sBAAsB,aAClC,IAAI,eACH,kBACA,UAAU,SAAS,6CACnB,EAAE,SAAS,CACZ;AAED,MAAa,2BACZ,WACA,aAEA,IAAI,eACH,uBACA,UAAU,SAAS,mCAAmC,aACtD,EAAE,SAAS,CACZ;AAED,MAAa,kBACZ,OACA,UACA,oBACoB;CACpB,IAAI,iBAAiB,gBAAgB,OAAO;CAC5C,OAAO,gBAAgB,KAAK,IACzB,IAAI,eACJ,iBACA,mDAAmD,YACnD;EAAE;EAAU,OAAO;CAAM,CAC1B,IACC,IAAI,eACJ,kBACA,UAAU,SAAS,qBACnB;EAAE;EAAU,OAAO;CAAM,CAC1B;AACH;AAEA,MAAM,gCAAgC;AAEtC,MAAa,0BAA0B,UACtC,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS;;;;;;;AAcxC,MAAM,mBAA8C;CACnD;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;AACD;AAEA,MAAa,oBAAoB,UAA4B;CAC5D,MAAM,UAAW,OAAoD;CACrE,OACC,OAAO,YAAY,YACnB,iBAAiB,MAAM,QAAQ,IAAI,QAAQ,KAAK,OAAO,CAAC;AAE1D"}
@@ -1,85 +1,3 @@
1
- //#region src/utils/getCachedObservable.ts
2
- const CACHE_SYMBOL = Symbol.for("kheopskit.observableCache");
3
- const getCache = () => {
4
- const g = globalThis;
5
- let cache = g[CACHE_SYMBOL];
6
- if (!cache) {
7
- cache = /* @__PURE__ */ new Map();
8
- g[CACHE_SYMBOL] = cache;
9
- }
10
- return cache;
11
- };
12
- const getCachedObservable$ = (key, create) => {
13
- const cache = getCache();
14
- if (!cache.has(key)) cache.set(key, create());
15
- return cache.get(key);
16
- };
17
- /**
18
- * Clears an observable from the cache.
19
- * Use when a wallet disconnects or configuration changes.
20
- */
21
- const clearCachedObservable = (key) => {
22
- getCache().delete(key);
23
- };
24
- /**
25
- * Clears all cached observables whose key starts with `prefix`.
26
- *
27
- * Used to drop a wallet's account observables when it disconnects, so a later
28
- * reconnect rebuilds them against the current wallet handle instead of a stale
29
- * closure — and to keep the cache from growing unbounded across connect cycles.
30
- */
31
- const clearCachedObservablesByPrefix = (prefix) => {
32
- const cache = getCache();
33
- for (const key of cache.keys()) if (key.startsWith(prefix)) cache.delete(key);
34
- };
35
- /**
36
- * Clears all cached observables.
37
- * Use when resetting the entire kheopskit state.
38
- */
39
- const clearAllCachedObservables = () => {
40
- getCache().clear();
41
- };
42
- //#endregion
43
- //#region src/utils/isWalletPlatform.ts
44
- const isWalletPlatform = (platform) => typeof platform === "string" && [
45
- "polkadot",
46
- "ethereum",
47
- "solana"
48
- ].includes(platform);
49
- //#endregion
50
- //#region src/utils/WalletId.ts
51
- /**
52
- * Stable id of the single WalletConnect connector. It is platform-less: one WC
53
- * session spans whichever namespaces the wallet approves, so it isn't tied to a
54
- * platform (unlike injected wallet ids, which are `<platform>:<identifier>`).
55
- */
56
- const WALLET_CONNECT_WALLET_ID = "walletconnect";
57
- const getWalletId = (platform, identifier) => {
58
- if (!isWalletPlatform(platform)) throw new Error("Invalid platform");
59
- if (!identifier) throw new Error("Invalid name");
60
- return `${platform}:${identifier}`;
61
- };
62
- const parseWalletId = (walletId) => {
63
- if (!walletId) throw new Error("Invalid walletId");
64
- const [platform, identifier] = walletId.split(":");
65
- if (!isWalletPlatform(platform)) throw new Error("Invalid platform");
66
- if (!identifier) throw new Error("Invalid address");
67
- return {
68
- platform,
69
- identifier
70
- };
71
- };
72
- /**
73
- * Non-throwing variant of {@link parseWalletId}. Use when validating untrusted
74
- * input (e.g. cached state persisted by an older version) before parsing.
75
- */
76
- const isValidWalletId = (walletId) => {
77
- if (typeof walletId !== "string" || !walletId) return false;
78
- if (walletId === "walletconnect") return true;
79
- const [platform, identifier] = walletId.split(":");
80
- return isWalletPlatform(platform) && !!identifier;
81
- };
82
- //#endregion
83
1
  //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
84
2
  function _typeof(o) {
85
3
  "@babel/helpers - typeof";
@@ -192,25 +110,47 @@ const isRefusalMessage = (error) => {
192
110
  return typeof message === "string" && REFUSAL_MESSAGES.some((row) => row.pattern.test(message));
193
111
  };
194
112
  //#endregion
195
- //#region src/api/types.ts
196
- /** Narrows a wallet to the platform-less {@link WalletConnectWallet}. */
197
- const isWalletConnectWallet = (wallet) => wallet.type === "walletconnect";
198
- /**
199
- * Narrows a wallet to an injected (browser-extension / Wallet Standard) wallet,
200
- * the complement of {@link isWalletConnectWallet}. `state.wallets` is
201
- * `(InjectedWallet | WalletConnectWallet)[]`, so use this to recover the
202
- * injected-only fields when iterating: `platform`, `sourceId`, and the SDK
203
- * handle (`provider` on Ethereum, `extension` on Polkadot, `wallet` on Solana).
204
- *
205
- * @example
206
- * ```ts
207
- * for (const wallet of wallets.filter(isInjectedWallet)) {
208
- * console.log(wallet.platform, wallet.sourceId); // typed, no WC widening
209
- * }
210
- * ```
211
- */
212
- const isInjectedWallet = (wallet) => wallet.type === "injected";
213
- //#endregion
214
- export { clearCachedObservablesByPrefix as _, accountUnavailableError as a, toConnectError as c, getWalletId as d, isValidWalletId as f, clearCachedObservable as g, clearAllCachedObservables as h, abortedError as i, walletPendingError as l, isWalletPlatform as m, isWalletConnectWallet as n, isEip1193UserRejection as o, parseWalletId as p, KheopskitError as r, isRefusalMessage as s, isInjectedWallet as t, WALLET_CONNECT_WALLET_ID as u, getCachedObservable$ as v };
113
+ Object.defineProperty(exports, "KheopskitError", {
114
+ enumerable: true,
115
+ get: function() {
116
+ return KheopskitError;
117
+ }
118
+ });
119
+ Object.defineProperty(exports, "abortedError", {
120
+ enumerable: true,
121
+ get: function() {
122
+ return abortedError;
123
+ }
124
+ });
125
+ Object.defineProperty(exports, "accountUnavailableError", {
126
+ enumerable: true,
127
+ get: function() {
128
+ return accountUnavailableError;
129
+ }
130
+ });
131
+ Object.defineProperty(exports, "isEip1193UserRejection", {
132
+ enumerable: true,
133
+ get: function() {
134
+ return isEip1193UserRejection;
135
+ }
136
+ });
137
+ Object.defineProperty(exports, "isRefusalMessage", {
138
+ enumerable: true,
139
+ get: function() {
140
+ return isRefusalMessage;
141
+ }
142
+ });
143
+ Object.defineProperty(exports, "toConnectError", {
144
+ enumerable: true,
145
+ get: function() {
146
+ return toConnectError;
147
+ }
148
+ });
149
+ Object.defineProperty(exports, "walletPendingError", {
150
+ enumerable: true,
151
+ get: function() {
152
+ return walletPendingError;
153
+ }
154
+ });
215
155
 
216
- //# sourceMappingURL=types-D7OWi0Td.mjs.map
156
+ //# sourceMappingURL=errors-DVaVewcH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DVaVewcH.js","names":[],"sources":["../src/api/errors.ts"],"sourcesContent":["import type { WalletAccountId } from \"../utils/WalletAccountId\";\nimport type { WalletId } from \"../utils/WalletId\";\n\n/**\n * Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and\n * branch on `error.code` instead of matching message strings.\n */\nexport type KheopskitErrorCode =\n\t/**\n\t * This `connect()` or `disconnect()` call was abandoned. For `connect()`:\n\t * its `signal` fired before the platform answered, `disconnect()` was\n\t * called while it pended, its wallet disappeared, or the last `kheopskit$`\n\t * subscriber unsubscribed.\n\t * For either call on an injected wallet: the wallet object came from a\n\t * subscription that had already ended, in which case the call rejects\n\t * without asking the platform and without changing the remembered list. A\n\t * placeholder's `connect()` rejects the same way, its `disconnect()`\n\t * resolves, and the WalletConnect connector still calls AppKit.\n\t */\n\t| \"ABORTED\"\n\t/** The user refused the wallet's connect prompt. `cause` holds the platform error. */\n\t| \"USER_REJECTED\"\n\t/** The wallet's connect call failed for another reason. `cause` holds the platform error. */\n\t| \"CONNECT_FAILED\"\n\t/**\n\t * `connect()` was called on a placeholder wallet restored from the cache:\n\t * on `kheopskit$`, hydration ended without kheopskit discovering that\n\t * wallet; on `getHydratedSnapshot` and the React provider's initial\n\t * snapshot, always.\n\t */\n\t| \"WALLET_PENDING\"\n\t/**\n\t * `waitForAccount()` found the account's wallet settled without listing it\n\t * as a live account, or not connected.\n\t */\n\t| \"ACCOUNT_UNAVAILABLE\"\n\t/** The wallet does not advertise a capability kheopskit needs to proceed. */\n\t| \"FEATURE_NOT_SUPPORTED\"\n\t/** No active WalletConnect session for the requested operation. */\n\t| \"NO_SESSION\"\n\t/** No provider available for the requested namespace. */\n\t| \"NO_PROVIDER\"\n\t/** The installed polkadot-api version exposes neither `getTxCreatorFromPjs` (v3) nor `getPolkadotSignerFromPjs` (v2). */\n\t| \"UNSUPPORTED_VERSION\"\n\t/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */\n\t| \"UNSUPPORTED_CHAIN\"\n\t/** `createKheopskit` received a config value it cannot use. The message names the fix. */\n\t| \"INVALID_CONFIG\";\n\n/**\n * Error thrown by kheopskit wallet/account operations. Carries a stable\n * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.\n *\n * @example\n * ```ts\n * try {\n * await wallet.connect();\n * } catch (error) {\n * if (error instanceof KheopskitError && error.code === \"USER_REJECTED\") {\n * // the user closed or refused the wallet prompt\n * } else throw error;\n * }\n * ```\n */\nexport class KheopskitError extends Error {\n\treadonly code: KheopskitErrorCode;\n\t/** The wallet id this error relates to, when applicable. */\n\treadonly walletId?: WalletId;\n\n\tconstructor(\n\t\tcode: KheopskitErrorCode,\n\t\tmessage: string,\n\t\toptions?: { walletId?: WalletId; cause?: unknown },\n\t) {\n\t\tsuper(`[kheopskit] ${message}`, { cause: options?.cause });\n\t\tthis.name = \"KheopskitError\";\n\t\tthis.code = code;\n\t\tthis.walletId = options?.walletId;\n\t}\n}\n\nexport const abortedError = (\n\twalletId: WalletId,\n\toperation: \"connect\" | \"disconnect\",\n): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"ABORTED\",\n\t\t`${operation} of wallet ${walletId} was aborted`,\n\t\t{ walletId },\n\t);\n\nexport const walletPendingError = (walletId: WalletId): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"WALLET_PENDING\",\n\t\t`wallet ${walletId} was not discovered before hydration ended`,\n\t\t{ walletId },\n\t);\n\nexport const accountUnavailableError = (\n\taccountId: WalletAccountId,\n\twalletId: WalletId,\n): KheopskitError =>\n\tnew KheopskitError(\n\t\t\"ACCOUNT_UNAVAILABLE\",\n\t\t`wallet ${walletId} settled without listing account ${accountId}`,\n\t\t{ walletId },\n\t);\n\nexport const toConnectError = (\n\terror: unknown,\n\twalletId: WalletId,\n\tisUserRejection: (error: unknown) => boolean,\n): KheopskitError => {\n\tif (error instanceof KheopskitError) return error;\n\treturn isUserRejection(error)\n\t\t? new KheopskitError(\n\t\t\t\t\"USER_REJECTED\",\n\t\t\t\t`the user rejected the connect request of wallet ${walletId}`,\n\t\t\t\t{ walletId, cause: error },\n\t\t\t)\n\t\t: new KheopskitError(\n\t\t\t\t\"CONNECT_FAILED\",\n\t\t\t\t`wallet ${walletId} failed to connect`,\n\t\t\t\t{ walletId, cause: error },\n\t\t\t);\n};\n\nconst EIP1193_USER_REJECTED_REQUEST = 4001;\n\nexport const isEip1193UserRejection = (error: unknown): boolean =>\n\ttypeof error === \"object\" &&\n\terror !== null &&\n\t(error as { code?: unknown }).code === EIP1193_USER_REJECTED_REQUEST;\n\ntype RefusalMessage = {\n\tpattern: RegExp;\n\twallet: string;\n\tevidence: \"live\" | \"inferred\";\n};\n\n/**\n * How Polkadot extensions and Wallet Standard wallets reject a refused connect\n * prompt. They send a plain `Error`, so the message is the only signal.\n * `evidence` records whether the row was observed live or inferred from the\n * wallet's source or documentation.\n */\nconst REFUSAL_MESSAGES: readonly RefusalMessage[] = [\n\t{\n\t\tpattern: /^Site .+ has not been authorised for Talisman yet$/,\n\t\twallet: \"Talisman 3.11.0, Reject button or prompt window closed\",\n\t\tevidence: \"live\",\n\t},\n\t{\n\t\tpattern: /^Connection request was (rejected|cancelled) by the user\\.$/,\n\t\twallet: \"polkadot-js extension (extension-base 0.64 State.ts)\",\n\t\tevidence: \"inferred\",\n\t},\n\t{\n\t\tpattern: /^(Rejected|Cancelled)$/,\n\t\twallet: \"SubWallet (Extension.ts)\",\n\t\tevidence: \"inferred\",\n\t},\n\t{\n\t\tpattern: /^User rejected the request\\.$/,\n\t\twallet: \"Phantom (Wallet Standard)\",\n\t\tevidence: \"inferred\",\n\t},\n];\n\nexport const isRefusalMessage = (error: unknown): boolean => {\n\tconst message = (error as { message?: unknown } | null | undefined)?.message;\n\treturn (\n\t\ttypeof message === \"string\" &&\n\t\tREFUSAL_MESSAGES.some((row) => row.pattern.test(message))\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,iBAAb,cAAoC,MAAM;CAKzC,YACC,MACA,SACA,SACC;EACD,MAAM,eAAe,WAAW,EAAE,OAAO,SAAS,MAAM,CAAC;EATjD,gBAAA,MAAA,QAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,YAAA,KAAA,CAAA;EAQR,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS;CAC1B;AACD;AAEA,MAAa,gBACZ,UACA,cAEA,IAAI,eACH,WACA,GAAG,UAAU,aAAa,SAAS,eACnC,EAAE,SAAS,CACZ;AAED,MAAa,sBAAsB,aAClC,IAAI,eACH,kBACA,UAAU,SAAS,6CACnB,EAAE,SAAS,CACZ;AAED,MAAa,2BACZ,WACA,aAEA,IAAI,eACH,uBACA,UAAU,SAAS,mCAAmC,aACtD,EAAE,SAAS,CACZ;AAED,MAAa,kBACZ,OACA,UACA,oBACoB;CACpB,IAAI,iBAAiB,gBAAgB,OAAO;CAC5C,OAAO,gBAAgB,KAAK,IACzB,IAAI,eACJ,iBACA,mDAAmD,YACnD;EAAE;EAAU,OAAO;CAAM,CAC1B,IACC,IAAI,eACJ,kBACA,UAAU,SAAS,qBACnB;EAAE;EAAU,OAAO;CAAM,CAC1B;AACH;AAEA,MAAM,gCAAgC;AAEtC,MAAa,0BAA0B,UACtC,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS;;;;;;;AAcxC,MAAM,mBAA8C;CACnD;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;CACA;EACC,SAAS;EACT,QAAQ;EACR,UAAU;CACX;AACD;AAEA,MAAa,oBAAoB,UAA4B;CAC5D,MAAM,UAAW,OAAoD;CACrE,OACC,OAAO,YAAY,YACnB,iBAAiB,MAAM,QAAQ,IAAI,QAAQ,KAAK,OAAO,CAAC;AAE1D"}