@kheopskit/core 6.0.3 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/WalletAccountId-6ZXQM_ed.mjs +116 -0
  3. package/dist/WalletAccountId-6ZXQM_ed.mjs.map +1 -0
  4. package/dist/WalletAccountId-D8Xc13VY.js +151 -0
  5. package/dist/WalletAccountId-D8Xc13VY.js.map +1 -0
  6. package/dist/{config-Csp5p0-Z.d.ts → config-CubhhFON.d.ts} +2 -2
  7. package/dist/{config-qMsgD8tJ.d.mts → config-rvX2pkqc.d.mts} +2 -2
  8. package/dist/ethereum.d.mts +1 -1
  9. package/dist/ethereum.d.ts +1 -1
  10. package/dist/ethereum.js +11 -11
  11. package/dist/ethereum.js.map +1 -1
  12. package/dist/ethereum.mjs +2 -2
  13. package/dist/index.d.mts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +12 -12
  16. package/dist/index.mjs +3 -3
  17. package/dist/{instance--1tqj7s5.mjs → instance-0-PWH43j.mjs} +3 -3
  18. package/dist/{instance--1tqj7s5.mjs.map → instance-0-PWH43j.mjs.map} +1 -1
  19. package/dist/{instance-CrdktIu7.d.ts → instance-BokWUMmA.d.ts} +2 -2
  20. package/dist/{instance-4DgSj55G.js → instance-CegD47uC.js} +25 -25
  21. package/dist/{instance-4DgSj55G.js.map → instance-CegD47uC.js.map} +1 -1
  22. package/dist/{instance-Gv9IDCIY.d.mts → instance-DoOr7mrc.d.mts} +2 -2
  23. package/dist/internal.d.mts +2 -2
  24. package/dist/internal.d.ts +2 -2
  25. package/dist/internal.js +4 -4
  26. package/dist/internal.mjs +2 -2
  27. package/dist/{platformAccounts-BcLoaZZb.js → platformAccounts-D8XmOSvD.js} +130 -113
  28. package/dist/platformAccounts-D8XmOSvD.js.map +1 -0
  29. package/dist/{platformAccounts-3jM3W1fB.mjs → platformAccounts-sy621l8C.mjs} +84 -97
  30. package/dist/platformAccounts-sy621l8C.mjs.map +1 -0
  31. package/dist/polkadot.d.mts +1 -1
  32. package/dist/polkadot.d.ts +1 -1
  33. package/dist/polkadot.js +10 -10
  34. package/dist/polkadot.js.map +1 -1
  35. package/dist/polkadot.mjs +2 -2
  36. package/dist/solana.d.mts +1 -1
  37. package/dist/solana.d.ts +1 -1
  38. package/dist/solana.js +10 -10
  39. package/dist/solana.js.map +1 -1
  40. package/dist/solana.mjs +2 -2
  41. package/dist/testing.d.mts +2 -2
  42. package/dist/testing.d.ts +2 -2
  43. package/dist/{types-C9aw2FEm.d.mts → types-BfIzw1fd.d.mts} +7 -1
  44. package/dist/{types-C9aw2FEm.d.ts → types-BfIzw1fd.d.ts} +7 -1
  45. package/dist/walletconnect.d.mts +1 -1
  46. package/dist/walletconnect.d.ts +1 -1
  47. package/dist/walletconnect.js +20 -17
  48. package/dist/walletconnect.js.map +1 -1
  49. package/dist/walletconnect.mjs +17 -14
  50. package/dist/walletconnect.mjs.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/platformAccounts-3jM3W1fB.mjs.map +0 -1
  53. package/dist/platformAccounts-BcLoaZZb.js.map +0 -1
  54. package/dist/types-DaRMgleZ.js +0 -169
  55. package/dist/types-DaRMgleZ.js.map +0 -1
  56. package/dist/types-DcpmEGhO.mjs +0 -104
  57. package/dist/types-DcpmEGhO.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { N as WalletAccountId, c as KheopskitConfig, d as KheopskitStore, k as WalletId, l as KheopskitPlatform, s as ConnectOptions, t as AccountOf, u as KheopskitState } from "./types-C9aw2FEm.mjs";
1
+ import { N as WalletAccountId, c as KheopskitConfig, d as KheopskitStore, k as WalletId, l as KheopskitPlatform, s as ConnectOptions, t as AccountOf, u as KheopskitState } from "./types-BfIzw1fd.mjs";
2
2
  import { Observable } from "rxjs";
3
3
  //#region src/utils/getCachedObservable.d.ts
4
4
  /**
@@ -106,4 +106,4 @@ declare const kheopskitInternals: (kit: Kheopskit<readonly KheopskitPlatform[]>)
106
106
  declare const createKheopskit: <const P extends readonly [KheopskitPlatform, ...KheopskitPlatform[]]>(config: CreateKheopskitConfig<P>, options?: CreateKheopskitOptions) => Kheopskit<P>;
107
107
  //#endregion
108
108
  export { createKheopskit as a, clearAllCachedObservables as c, createInstance as i, clearCachedObservable as l, CreateKheopskitOptions as n, kheopskitInternals as o, Kheopskit as r, WalletActions as s, CreateKheopskitConfig as t, clearCachedObservablesByPrefix as u };
109
- //# sourceMappingURL=instance-Gv9IDCIY.d.mts.map
109
+ //# sourceMappingURL=instance-DoOr7mrc.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { n as getSafeLocalStorage } from "./storage-D3AwNgqc.mjs";
2
- import { a as CachedAccount, b as WalletConnectWallet, i as BaseWalletAccount, o as CachedWallet, r as BaseWallet } from "./types-C9aw2FEm.mjs";
3
- import { i as createInstance, l as clearCachedObservable, o as kheopskitInternals, s as WalletActions, u as clearCachedObservablesByPrefix } from "./instance-Gv9IDCIY.mjs";
2
+ import { a as CachedAccount, b as WalletConnectWallet, i as BaseWalletAccount, o as CachedWallet, r as BaseWallet } from "./types-BfIzw1fd.mjs";
3
+ import { i as createInstance, l as clearCachedObservable, o as kheopskitInternals, s as WalletActions, u as clearCachedObservablesByPrefix } from "./instance-DoOr7mrc.mjs";
4
4
  //#region src/utils/hydrateState.d.ts
5
5
  /**
6
6
  * Converts a wallet to a CachedWallet for storage.
@@ -1,6 +1,6 @@
1
1
  import { n as getSafeLocalStorage } from "./storage-D3AwNgqc.js";
2
- import { a as CachedAccount, b as WalletConnectWallet, i as BaseWalletAccount, o as CachedWallet, r as BaseWallet } from "./types-C9aw2FEm.js";
3
- import { i as createInstance, l as clearCachedObservable, o as kheopskitInternals, s as WalletActions, u as clearCachedObservablesByPrefix } from "./instance-CrdktIu7.js";
2
+ import { a as CachedAccount, b as WalletConnectWallet, i as BaseWalletAccount, o as CachedWallet, r as BaseWallet } from "./types-BfIzw1fd.js";
3
+ import { i as createInstance, l as clearCachedObservable, o as kheopskitInternals, s as WalletActions, u as clearCachedObservablesByPrefix } from "./instance-BokWUMmA.js";
4
4
  //#region src/utils/hydrateState.d.ts
5
5
  /**
6
6
  * Converts a wallet to a CachedWallet for storage.
package/dist/internal.js CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_types = require("./types-DaRMgleZ.js");
3
- const require_instance = require("./instance-4DgSj55G.js");
4
- exports.clearCachedObservable = require_types.clearCachedObservable;
5
- exports.clearCachedObservablesByPrefix = require_types.clearCachedObservablesByPrefix;
2
+ const require_platformAccounts = require("./platformAccounts-D8XmOSvD.js");
3
+ const require_instance = require("./instance-CegD47uC.js");
4
+ exports.clearCachedObservable = require_platformAccounts.clearCachedObservable;
5
+ exports.clearCachedObservablesByPrefix = require_platformAccounts.clearCachedObservablesByPrefix;
6
6
  exports.createInstance = require_instance.createInstance;
7
7
  exports.getSafeLocalStorage = require_instance.getSafeLocalStorage;
8
8
  exports.kheopskitInternals = require_instance.kheopskitInternals;
package/dist/internal.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { l as clearCachedObservable, u as clearCachedObservablesByPrefix } from "./types-DcpmEGhO.mjs";
2
- import { c as getSafeLocalStorage, l as serializeAccount, r as kheopskitInternals, s as setCachedIcons, t as createInstance, u as serializeWallet } from "./instance--1tqj7s5.mjs";
1
+ import { h as clearCachedObservablesByPrefix, m as clearCachedObservable } from "./platformAccounts-sy621l8C.mjs";
2
+ import { c as getSafeLocalStorage, l as serializeAccount, r as kheopskitInternals, s as setCachedIcons, t as createInstance, u as serializeWallet } from "./instance-0-PWH43j.mjs";
3
3
  export { clearCachedObservable, clearCachedObservablesByPrefix, createInstance, getSafeLocalStorage, kheopskitInternals, serializeAccount, serializeWallet, setCachedIcons };
@@ -1,117 +1,104 @@
1
- const require_types = require("./types-DaRMgleZ.js");
2
- let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
3
- let _scure_base = require("@scure/base");
4
- let _noble_hashes_blake2_js = require("@noble/hashes/blake2.js");
5
1
  let rxjs = require("rxjs");
6
- //#region src/utils/isEthereumAddress.ts
7
- const HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
8
- const encoder = new TextEncoder();
9
- /**
10
- * Verifies the EIP-55 mixed-case checksum of an Ethereum address.
11
- * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.
12
- */
13
- const isChecksumValid = (address) => {
14
- const hex = address.slice(2);
15
- const hash = (0, _noble_hashes_sha3_js.keccak_256)(encoder.encode(hex.toLowerCase()));
16
- for (let i = 0; i < 40; i++) {
17
- const char = hex.charAt(i);
18
- if (!(char >= "a" && char <= "f" || char >= "A" && char <= "F")) continue;
19
- const byte = hash[i >> 1] ?? 0;
20
- const nibble = i % 2 === 0 ? byte >> 4 : byte & 15;
21
- if (char <= "F" !== nibble >= 8) return false;
2
+ //#region src/utils/getCachedObservable.ts
3
+ const CACHE_SYMBOL = Symbol.for("kheopskit.observableCache");
4
+ const getCache = () => {
5
+ const g = globalThis;
6
+ let cache = g[CACHE_SYMBOL];
7
+ if (!cache) {
8
+ cache = /* @__PURE__ */ new Map();
9
+ g[CACHE_SYMBOL] = cache;
22
10
  }
23
- return true;
11
+ return cache;
12
+ };
13
+ const getCachedObservable$ = (key, create) => {
14
+ const cache = getCache();
15
+ if (!cache.has(key)) cache.set(key, create());
16
+ return cache.get(key);
24
17
  };
25
18
  /**
26
- * Returns true if `address` is a valid Ethereum address.
27
- *
28
- * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a
29
- * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are
30
- * accepted as non-checksummed.
19
+ * Clears an observable from the cache.
20
+ * Use when a wallet disconnects or configuration changes.
31
21
  */
32
- const isEthereumAddress = (address) => {
33
- if (!HEX_ADDRESS.test(address)) return false;
34
- if (address === address.toLowerCase()) return true;
35
- return isChecksumValid(address);
22
+ const clearCachedObservable = (key) => {
23
+ getCache().delete(key);
36
24
  };
37
- //#endregion
38
- //#region src/utils/isSolanaAddress.ts
39
25
  /**
40
- * Returns true if the value is a valid Solana address: a base58-encoded
41
- * 32-byte ed25519 public key.
26
+ * Clears all cached observables whose key starts with `prefix`.
42
27
  *
43
- * Solana addresses carry no checksum, so this is a pure base58 + length check.
44
- * Dependency-free (base58 via @scure/base) so core stays decoupled from
45
- * @solana/kit.
28
+ * Used to drop a wallet's account observables when it disconnects, so a later
29
+ * reconnect rebuilds them against the current wallet handle instead of a stale
30
+ * closure — and to keep the cache from growing unbounded across connect cycles.
46
31
  */
47
- const isSolanaAddress = (address) => {
48
- if (!address) return false;
49
- try {
50
- return _scure_base.base58.decode(address).length === 32;
51
- } catch {
52
- return false;
53
- }
32
+ const clearCachedObservablesByPrefix = (prefix) => {
33
+ const cache = getCache();
34
+ for (const key of cache.keys()) if (key.startsWith(prefix)) cache.delete(key);
54
35
  };
55
- //#endregion
56
- //#region src/utils/isSs58Address.ts
57
- const SS58PRE = new Uint8Array([
58
- 83,
59
- 83,
60
- 53,
61
- 56,
62
- 80,
63
- 82,
64
- 69
65
- ]);
66
36
  /**
67
- * Returns true if `address` is a valid SS58-encoded 32-byte account id (the
68
- * only form Substrate wallets inject), verifying the blake2b-512 checksum.
69
- *
70
- * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core
71
- * stays decoupled from polkadot-api.
37
+ * Clears all cached observables.
38
+ * Use when resetting the entire kheopskit state.
72
39
  */
73
- const isSs58Address = (address) => {
74
- if (!address) return false;
75
- let decoded;
76
- try {
77
- decoded = _scure_base.base58.decode(address);
78
- } catch {
79
- return false;
80
- }
81
- const firstByte = decoded[0];
82
- if (firstByte === void 0 || firstByte & 128) return false;
83
- const prefixLength = firstByte & 64 ? 2 : 1;
84
- if (decoded.length !== prefixLength + 32 + 2) return false;
85
- const body = decoded.subarray(0, decoded.length - 2);
86
- const preimage = new Uint8Array(SS58PRE.length + body.length);
87
- preimage.set(SS58PRE);
88
- preimage.set(body, SS58PRE.length);
89
- const hash = (0, _noble_hashes_blake2_js.blake2b)(preimage, { dkLen: 64 });
90
- return decoded[decoded.length - 2] === hash[0] && decoded[decoded.length - 1] === hash[1];
40
+ const clearAllCachedObservables = () => {
41
+ getCache().clear();
91
42
  };
92
43
  //#endregion
93
- //#region src/utils/isValidAddress.ts
94
- const isValidAddress = (address) => {
95
- if (address.startsWith("0x")) return isEthereumAddress(address);
96
- return isSs58Address(address) || isSolanaAddress(address);
97
- };
44
+ //#region src/utils/isWalletPlatform.ts
45
+ const isWalletPlatform = (platform) => typeof platform === "string" && [
46
+ "polkadot",
47
+ "ethereum",
48
+ "solana"
49
+ ].includes(platform);
98
50
  //#endregion
99
- //#region src/utils/WalletAccountId.ts
100
- const getWalletAccountId = (walletId, address) => {
101
- if (!walletId) throw new Error("Missing walletId");
102
- if (!isValidAddress(address)) throw new Error("Invalid address");
103
- return `${walletId}::${address}`;
51
+ //#region src/utils/WalletId.ts
52
+ /**
53
+ * Stable id of the single WalletConnect connector. It is platform-less: one WC
54
+ * session spans whichever namespaces the wallet approves, so it isn't tied to a
55
+ * platform (unlike injected wallet ids, which are `<platform>:<identifier>`).
56
+ */
57
+ const WALLET_CONNECT_WALLET_ID = "walletconnect";
58
+ const getWalletId = (platform, identifier) => {
59
+ if (!isWalletPlatform(platform)) throw new Error("Invalid platform");
60
+ if (!identifier) throw new Error("Invalid name");
61
+ return `${platform}:${identifier}`;
104
62
  };
105
- const parseWalletAccountId = (accountId) => {
106
- if (!accountId) throw new Error("Invalid walletAccountId");
107
- const [walletId, address] = accountId.split("::");
108
- if (!walletId) throw new Error("Missing walletId");
109
- if (!address || !isValidAddress(address)) throw new Error("Invalid address");
63
+ const parseWalletId = (walletId) => {
64
+ if (!walletId) throw new Error("Invalid walletId");
65
+ const [platform, identifier] = walletId.split(":");
66
+ if (!isWalletPlatform(platform)) throw new Error("Invalid platform");
67
+ if (!identifier) throw new Error("Invalid address");
110
68
  return {
111
- walletId,
112
- address
69
+ platform,
70
+ identifier
113
71
  };
114
72
  };
73
+ /**
74
+ * Non-throwing variant of {@link parseWalletId}. Use when validating untrusted
75
+ * input (e.g. cached state persisted by an older version) before parsing.
76
+ */
77
+ const isValidWalletId = (walletId) => {
78
+ if (typeof walletId !== "string" || !walletId) return false;
79
+ if (walletId === "walletconnect") return true;
80
+ const [platform, identifier] = walletId.split(":");
81
+ return isWalletPlatform(platform) && !!identifier;
82
+ };
83
+ //#endregion
84
+ //#region src/api/types.ts
85
+ /** Narrows a wallet to the platform-less {@link WalletConnectWallet}. */
86
+ const isWalletConnectWallet = (wallet) => wallet.type === "walletconnect";
87
+ /**
88
+ * Narrows a wallet to an injected (browser-extension / Wallet Standard) wallet,
89
+ * the complement of {@link isWalletConnectWallet}. `state.wallets` is
90
+ * `(InjectedWallet | WalletConnectWallet)[]`, so use this to recover the
91
+ * injected-only fields when iterating: `platform`, `sourceId`, and the SDK
92
+ * handle (`provider` on Ethereum, `extension` on Polkadot, `wallet` on Solana).
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * for (const wallet of wallets.filter(isInjectedWallet)) {
97
+ * console.log(wallet.platform, wallet.sourceId); // typed, no WC widening
98
+ * }
99
+ * ```
100
+ */
101
+ const isInjectedWallet = (wallet) => wallet.type === "injected";
115
102
  //#endregion
116
103
  //#region src/api/platformAccounts.ts
117
104
  const isPlatformAccounts$ = (accounts$) => "frames$" in accounts$;
@@ -122,7 +109,7 @@ const framesOf = (accounts$) => isPlatformAccounts$(accounts$) ? accounts$.frame
122
109
  })));
123
110
  const idsEqual = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
124
111
  const sessionKey = (wallet) => `${wallet.id}|${wallet.platforms.join(",")}`;
125
- const connectionKey = (wallet) => require_types.isWalletConnectWallet(wallet) ? sessionKey(wallet) : wallet.id;
112
+ const connectionKey = (wallet) => isWalletConnectWallet(wallet) ? sessionKey(wallet) : wallet.id;
126
113
  /** Shared engine behind every platform's `getAccounts$`. */
127
114
  const createPlatformAccounts$ = ({ wallets$, getInjectedAccounts$, getWalletConnectAccounts$, mapAccounts, accountChangeKey = (account) => account.id }) => {
128
115
  const nameAndChangeKey = (account) => `${account.name ?? ""}|${accountChangeKey(account)}`;
@@ -130,7 +117,7 @@ const createPlatformAccounts$ = ({ wallets$, getInjectedAccounts$, getWalletConn
130
117
  const other = b[i];
131
118
  return !!other && nameAndChangeKey(account) === nameAndChangeKey(other);
132
119
  });
133
- const accountsOf = (wallet) => require_types.isWalletConnectWallet(wallet) ? getWalletConnectAccounts$(wallet) : getInjectedAccounts$(wallet);
120
+ const accountsOf = (wallet) => isWalletConnectWallet(wallet) ? getWalletConnectAccounts$(wallet) : getInjectedAccounts$(wallet);
134
121
  const frames$ = new rxjs.Observable((subscriber) => {
135
122
  const connections = /* @__PURE__ */ new Map();
136
123
  let connectedIds = [];
@@ -244,7 +231,7 @@ const getWalletConnectSessionAccounts$ = (options) => {
244
231
  const { wallet, platform, namespace, cacheKey, buildAccounts } = options;
245
232
  const provider = wallet.appKit.getProvider(namespace);
246
233
  if (!wallet.platforms.includes(platform) || !provider?.session) return (0, rxjs.of)([]);
247
- return require_types.getCachedObservable$(cacheKey, () => new rxjs.Observable((subscriber) => {
234
+ return getCachedObservable$(cacheKey, () => new rxjs.Observable((subscriber) => {
248
235
  subscriber.next(buildAccounts(provider));
249
236
  const reemit = () => subscriber.next(buildAccounts(provider));
250
237
  provider.on("session_update", reemit);
@@ -259,6 +246,30 @@ const getWalletConnectSessionAccounts$ = (options) => {
259
246
  })));
260
247
  };
261
248
  //#endregion
249
+ Object.defineProperty(exports, "WALLET_CONNECT_WALLET_ID", {
250
+ enumerable: true,
251
+ get: function() {
252
+ return WALLET_CONNECT_WALLET_ID;
253
+ }
254
+ });
255
+ Object.defineProperty(exports, "clearAllCachedObservables", {
256
+ enumerable: true,
257
+ get: function() {
258
+ return clearAllCachedObservables;
259
+ }
260
+ });
261
+ Object.defineProperty(exports, "clearCachedObservable", {
262
+ enumerable: true,
263
+ get: function() {
264
+ return clearCachedObservable;
265
+ }
266
+ });
267
+ Object.defineProperty(exports, "clearCachedObservablesByPrefix", {
268
+ enumerable: true,
269
+ get: function() {
270
+ return clearCachedObservablesByPrefix;
271
+ }
272
+ });
262
273
  Object.defineProperty(exports, "createPlatformAccounts$", {
263
274
  enumerable: true,
264
275
  get: function() {
@@ -271,6 +282,12 @@ Object.defineProperty(exports, "framesOf", {
271
282
  return framesOf;
272
283
  }
273
284
  });
285
+ Object.defineProperty(exports, "getCachedObservable$", {
286
+ enumerable: true,
287
+ get: function() {
288
+ return getCachedObservable$;
289
+ }
290
+ });
274
291
  Object.defineProperty(exports, "getCaip10Addresses", {
275
292
  enumerable: true,
276
293
  get: function() {
@@ -283,47 +300,47 @@ Object.defineProperty(exports, "getSessionCaip10s", {
283
300
  return getSessionCaip10s;
284
301
  }
285
302
  });
286
- Object.defineProperty(exports, "getWalletAccountId", {
303
+ Object.defineProperty(exports, "getWalletConnectSessionAccounts$", {
287
304
  enumerable: true,
288
305
  get: function() {
289
- return getWalletAccountId;
306
+ return getWalletConnectSessionAccounts$;
290
307
  }
291
308
  });
292
- Object.defineProperty(exports, "getWalletConnectSessionAccounts$", {
309
+ Object.defineProperty(exports, "getWalletId", {
293
310
  enumerable: true,
294
311
  get: function() {
295
- return getWalletConnectSessionAccounts$;
312
+ return getWalletId;
296
313
  }
297
314
  });
298
- Object.defineProperty(exports, "isEthereumAddress", {
315
+ Object.defineProperty(exports, "isInjectedWallet", {
299
316
  enumerable: true,
300
317
  get: function() {
301
- return isEthereumAddress;
318
+ return isInjectedWallet;
302
319
  }
303
320
  });
304
- Object.defineProperty(exports, "isSolanaAddress", {
321
+ Object.defineProperty(exports, "isValidWalletId", {
305
322
  enumerable: true,
306
323
  get: function() {
307
- return isSolanaAddress;
324
+ return isValidWalletId;
308
325
  }
309
326
  });
310
- Object.defineProperty(exports, "isSs58Address", {
327
+ Object.defineProperty(exports, "isWalletConnectWallet", {
311
328
  enumerable: true,
312
329
  get: function() {
313
- return isSs58Address;
330
+ return isWalletConnectWallet;
314
331
  }
315
332
  });
316
- Object.defineProperty(exports, "isValidAddress", {
333
+ Object.defineProperty(exports, "isWalletPlatform", {
317
334
  enumerable: true,
318
335
  get: function() {
319
- return isValidAddress;
336
+ return isWalletPlatform;
320
337
  }
321
338
  });
322
- Object.defineProperty(exports, "parseWalletAccountId", {
339
+ Object.defineProperty(exports, "parseWalletId", {
323
340
  enumerable: true,
324
341
  get: function() {
325
- return parseWalletAccountId;
342
+ return parseWalletId;
326
343
  }
327
344
  });
328
345
 
329
- //# sourceMappingURL=platformAccounts-BcLoaZZb.js.map
346
+ //# sourceMappingURL=platformAccounts-D8XmOSvD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccounts-D8XmOSvD.js","names":["map","Observable","Subscription","distinctUntilChanged","shareReplay","of"],"sources":["../src/utils/getCachedObservable.ts","../src/utils/isWalletPlatform.ts","../src/utils/WalletId.ts","../src/api/types.ts","../src/api/platformAccounts.ts"],"sourcesContent":["import type { Observable } from \"rxjs\";\n\n// Anchored on globalThis so the cache stays a single instance even if the\n// module is duplicated across bundle chunks (e.g. CJS subpath entries).\nconst CACHE_SYMBOL = Symbol.for(\"kheopskit.observableCache\");\n\nconst getCache = (): Map<string, Observable<unknown>> => {\n\tconst g = globalThis as unknown as Record<\n\t\tsymbol,\n\t\tMap<string, Observable<unknown>> | undefined\n\t>;\n\tlet cache = g[CACHE_SYMBOL];\n\tif (!cache) {\n\t\tcache = new Map();\n\t\tg[CACHE_SYMBOL] = cache;\n\t}\n\treturn cache;\n};\n\nexport const getCachedObservable$ = <T, Obs = Observable<T>>(\n\tkey: string,\n\tcreate: () => Obs,\n): Obs => {\n\tconst cache = getCache();\n\tif (!cache.has(key)) cache.set(key, create() as Observable<unknown>);\n\n\treturn cache.get(key) as Obs;\n};\n\n/**\n * Clears an observable from the cache.\n * Use when a wallet disconnects or configuration changes.\n */\nexport const clearCachedObservable = (key: string): void => {\n\tgetCache().delete(key);\n};\n\n/**\n * Clears all cached observables whose key starts with `prefix`.\n *\n * Used to drop a wallet's account observables when it disconnects, so a later\n * reconnect rebuilds them against the current wallet handle instead of a stale\n * closure — and to keep the cache from growing unbounded across connect cycles.\n */\nexport const clearCachedObservablesByPrefix = (prefix: string): void => {\n\tconst cache = getCache();\n\tfor (const key of cache.keys()) {\n\t\tif (key.startsWith(prefix)) cache.delete(key);\n\t}\n};\n\n/**\n * Clears all cached observables.\n * Use when resetting the entire kheopskit state.\n */\nexport const clearAllCachedObservables = (): void => {\n\tgetCache().clear();\n};\n","import type { WalletPlatform } from \"../api/types\";\n\nexport const isWalletPlatform = (\n\tplatform: unknown,\n): platform is WalletPlatform =>\n\ttypeof platform === \"string\" &&\n\t[\"polkadot\", \"ethereum\", \"solana\"].includes(platform as WalletPlatform);\n","import type { WalletPlatform } from \"../api/types\";\nimport { isWalletPlatform } from \"./isWalletPlatform\";\n\nexport type WalletId = string;\n\n/**\n * Stable id of the single WalletConnect connector. It is platform-less: one WC\n * session spans whichever namespaces the wallet approves, so it isn't tied to a\n * platform (unlike injected wallet ids, which are `<platform>:<identifier>`).\n */\nexport const WALLET_CONNECT_WALLET_ID: WalletId = \"walletconnect\";\n\nexport const getWalletId = (\n\tplatform: WalletPlatform,\n\tidentifier: string,\n): WalletId => {\n\tif (!isWalletPlatform(platform)) throw new Error(\"Invalid platform\");\n\tif (!identifier) throw new Error(\"Invalid name\");\n\treturn `${platform}:${identifier}`;\n};\n\nexport const parseWalletId = (walletId: string) => {\n\tif (!walletId) throw new Error(\"Invalid walletId\");\n\tconst [platform, identifier] = walletId.split(\":\");\n\tif (!isWalletPlatform(platform)) throw new Error(\"Invalid platform\");\n\tif (!identifier) throw new Error(\"Invalid address\");\n\treturn { platform, identifier };\n};\n\n/**\n * Non-throwing variant of {@link parseWalletId}. Use when validating untrusted\n * input (e.g. cached state persisted by an older version) before parsing.\n */\nexport const isValidWalletId = (walletId: unknown): walletId is WalletId => {\n\tif (typeof walletId !== \"string\" || !walletId) return false;\n\tif (walletId === WALLET_CONNECT_WALLET_ID) return true;\n\tconst [platform, identifier] = walletId.split(\":\");\n\treturn isWalletPlatform(platform) && !!identifier;\n};\n","import type { Observable } from \"rxjs\";\nimport type { WalletAccountId } from \"../utils\";\nimport type { WalletId } from \"../utils/WalletId\";\nimport type { KheopskitError } from \"./errors\";\n\nexport type WalletPlatform = \"polkadot\" | \"ethereum\" | \"solana\";\n\n/**\n * Minimal structural view of a WalletConnect `UniversalProvider`, the subset\n * kheopskit reads. Declared locally so core never depends on\n * `@walletconnect/universal-provider`. The concrete instance comes from\n * `@reown/appkit` at runtime.\n */\nexport type WalletConnectProvider = {\n\tsession?: {\n\t\ttopic: string;\n\t\tnamespaces: Record<string, { accounts?: string[]; methods?: string[] }>;\n\t\tpeer?: { metadata: { name?: string; icons?: string[] } };\n\t};\n\tclient: {\n\t\trequest<T = unknown>(args: {\n\t\t\ttopic: string;\n\t\t\tchainId: string;\n\t\t\trequest: { method: string; params: unknown };\n\t\t}): Promise<T>;\n\t};\n\trequest(args: { method: string; params?: unknown }): Promise<unknown>;\n\ton(event: string, listener: (...args: unknown[]) => void): void;\n\toff(event: string, listener: (...args: unknown[]) => void): void;\n};\n\n/**\n * Minimal structural view of the Reown AppKit instance, the subset kheopskit's\n * account factories use. Exposed as the `appKit` escape hatch on AppKit wallets;\n * cast it to `@reown/appkit`'s `AppKit` type for the full API. Declared locally\n * so core never depends on `@reown/appkit`'s types (it's an optional peer).\n */\nexport type AppKitInstance = {\n\tgetProvider<T = WalletConnectProvider>(namespace: string): T | undefined;\n\tgetAccount(\n\t\tnamespace: string,\n\t): { allAccounts: { address: string }[] } | undefined;\n\tgetCaipNetworks(namespace: string): { caipNetworkId?: string }[];\n};\n\nexport type WalletType = \"injected\" | \"walletconnect\";\n\n/**\n * Where a wallet stands with the dapp. `connecting` covers a `connect()` call\n * in flight and an auto-reconnect in flight alike.\n */\nexport type WalletStatus = \"disconnected\" | \"connecting\" | \"connected\";\n\nexport type PolkadotAccountType = \"sr25519\" | \"ed25519\" | \"ecdsa\" | \"ethereum\";\n\n/** Options accepted by {@link BaseWallet.connect}. */\nexport type ConnectOptions = {\n\t/**\n\t * Ends this caller's wait for the platform's answer: its promise rejects\n\t * with a `KheopskitError` of code `ABORTED`. An abort after the platform\n\t * has granted the connect changes nothing, and a Polkadot extension counts\n\t * as granted only once its account list has been read. Other callers\n\t * sharing the attempt keep waiting. The extension's own prompt may stay\n\t * open: nothing can withdraw it from the page. A Polkadot `connect()`\n\t * started while that prompt is open waits for it instead of asking again,\n\t * and connects with the handle it answers. Once no caller waits any more\n\t * and no later `connect()` joined that prompt, kheopskit drops a handle\n\t * the platform hands back afterwards without revoking the platform's\n\t * grant, and the wallet is neither connected nor remembered. Kheopskit\n\t * sets no timeout of its own, because an extension prompt\n\t * pends only while the user has not answered it; pass\n\t * `AbortSignal.timeout(ms)` to cap the wait.\n\t */\n\tsignal?: AbortSignal;\n};\n\n/**\n * SDK-free fields common to every wallet, regardless of platform. Platform\n * packages (`@kheopskit/core/<platform>`) extend this with SDK-typed fields\n * (the injected provider/extension/standard-wallet handle).\n */\nexport type BaseWallet = {\n\t/** `<platform>:<identifier>`, e.g. `polkadot:talisman`. Stable across reloads. */\n\tid: WalletId;\n\t/** The platform whose registry listed the wallet. */\n\tplatform: WalletPlatform;\n\t/**\n\t * `\"injected\"`, for a browser extension or Wallet Standard wallet. The\n\t * WalletConnect connector is the separate {@link WalletConnectWallet}.\n\t */\n\ttype: WalletType;\n\t/** Display name, e.g. `Talisman`. */\n\tname: string;\n\t/** Icon URL or data URI. `\"\"` when the wallet exposes none. */\n\ticon: string;\n\t/**\n\t * `true` for a wallet restored from the cache that kheopskit has not\n\t * discovered yet: its SDK handle and `sourceId` are absent and it is never\n\t * connected. On `kheopskit$` its `connect()` waits for the live wallet and\n\t * connects that one, rejecting with `WALLET_PENDING` if hydration ends first\n\t * and `ABORTED` if its `signal` fires or the subscription ends. On\n\t * `getHydratedSnapshot` it rejects with `WALLET_PENDING`. Its `disconnect()`\n\t * resolves at once, and on `kheopskit$` forgets the wallet first so it is\n\t * not reconnected when it injects, or calls the live wallet's\n\t * `disconnect()` once that one is discovered. Set on every wallet of\n\t * `kheopskit$` and of the hydrated snapshot; plugins leave it unset.\n\t */\n\tisPlaceholder?: boolean;\n\t/**\n\t * `connecting` while a `connect()` call or an auto-reconnect waits for the\n\t * platform, `connected` once the platform granted it, `disconnected`\n\t * otherwise. On a reload, a remembered wallet kheopskit will reconnect is\n\t * `connecting` from the first frame when the cache recorded it connected,\n\t * which the cache does 1 s after the state settles.\n\t */\n\tstatus: WalletStatus;\n\t/**\n\t * The last `connect()` or auto-reconnect that the platform refused or\n\t * failed (`USER_REJECTED` or `CONNECT_FAILED`, or `FEATURE_NOT_SUPPORTED`\n\t * for a Wallet Standard wallet without `standard:connect`). Cleared when\n\t * the next attempt starts. An aborted attempt sets nothing.\n\t */\n\terror?: KheopskitError;\n\t/** `status === \"connected\"`. */\n\tisConnected: boolean;\n\t/**\n\t * Connects the wallet.\n\t *\n\t * - **Shared in flight.** Concurrent calls on one wallet share a single\n\t * platform attempt and the platform is asked once. Each call gets its own\n\t * promise: aborting a caller's `signal` rejects only that caller with code\n\t * `ABORTED`. The attempt itself is abandoned only when every caller that\n\t * passed a signal has aborted and no caller without one joined, when\n\t * `disconnect()` is called, or when the last `kheopskit$` subscriber\n\t * unsubscribes; those reject every remaining caller with `ABORTED`.\n\t * - **Idempotent.** On a connected wallet it resolves at once without\n\t * touching the platform, unless a `disconnect()` still waits for the\n\t * platform. It then waits for that disconnect to settle and connects\n\t * again if the wallet ended up disconnected.\n\t * - **Abortable.** See {@link ConnectOptions.signal}. There is no default\n\t * timeout.\n\t * - **Settles with the state.** It resolves only after `kheopskit$` has\n\t * emitted a state in which this wallet has `isConnected: true`, so the\n\t * consumer-visible state already reflects the connect. On platforms that\n\t * list accounts asynchronously (Ethereum `eth_accounts`), the accounts may\n\t * arrive in a later emission. No emission shows a disconnected wallet\n\t * still listing live accounts, or a connected wallet listing the accounts\n\t * of a previous connection. During hydration a wallet's cached\n\t * placeholder accounts stay listed whatever its status. Another wallet's\n\t * pending `eth_accounts` request never delays them. A `disconnect()` that\n\t * completes while it waits for that state rejects it with `ABORTED`. If\n\t * the platform's disconnect is still pending or refuses, it resolves once\n\t * the state shows the wallet connected (today only Solana has a platform\n\t * disconnect). A `connect()`\n\t * whose wallet disappears before the platform grants it (an extension\n\t * removed, a Wallet Standard wallet unregistered) rejects `ABORTED`;\n\t * granted first, it resolves and the wallet stays remembered. Once the last `kheopskit$`\n\t * subscriber has unsubscribed, a call on a wallet object from that\n\t * subscription rejects with `ABORTED` without asking the platform,\n\t * placeholders included.\n\t * - **Typed rejections.** A platform rejection is wrapped in a\n\t * `KheopskitError` carrying the original error as `cause` and the\n\t * `walletId`: `USER_REJECTED` when the user refused the prompt,\n\t * `CONNECT_FAILED` otherwise. A Wallet Standard wallet without\n\t * `standard:connect` rejects with `FEATURE_NOT_SUPPORTED`.\n\t */\n\tconnect: (options?: ConnectOptions) => Promise<void>;\n\t/**\n\t * Disconnects the wallet.\n\t *\n\t * It forgets the wallet at once, whatever its status, so the next load does\n\t * not reconnect it. On a disconnected wallet it then resolves. While a `connect()` waits\n\t * for the platform to grant it, it aborts that connect (its promise rejects\n\t * with `ABORTED`) and never waits for the extension prompt. Otherwise it\n\t * first waits for the platform's disconnect and rejects if that fails, so\n\t * callers can surface or retry. It then resolves once `kheopskit$` has\n\t * emitted a state in which this wallet has `isConnected: false`, or once a\n\t * later `connect()`, the wallet leaving the list or the end of the\n\t * subscription makes that emission impossible. Once the last `kheopskit$`\n\t * subscriber has unsubscribed, a call on a wallet object from that\n\t * subscription rejects with `ABORTED` without asking the platform and\n\t * without changing the remembered list, except on a placeholder, whose\n\t * `disconnect()` resolves. A `disconnect()` started before that point\n\t * settles once the platform has answered: the wallet was\n\t * forgotten when it was called, and nothing else is written once the\n\t * subscription has ended.\n\t */\n\tdisconnect: () => Promise<void>;\n};\n\n/**\n * SDK-free fields common to every account, regardless of platform. Platform\n * packages extend this with their SDK-typed signer/client.\n */\nexport type BaseWalletAccount = {\n\t/** `<walletId>::<address>`, e.g. `polkadot:talisman::5Grw…`. */\n\tid: WalletAccountId;\n\t/**\n\t * `true` for an account restored from the cache that the live wallet has\n\t * not listed yet: its signing surface is absent. Set on every account of\n\t * `kheopskit$` and of the hydrated snapshot; plugins leave it unset.\n\t */\n\tisPlaceholder?: boolean;\n\t/** The platform of the wallet that lists the account. */\n\tplatform: WalletPlatform;\n\t/** Base58 (Solana), SS58 (Polkadot) or 0x-hex (Ethereum) address. */\n\taddress: string;\n\t/**\n\t * Friendly account name, when the wallet exposes one: the extension's\n\t * account name on Polkadot, the Wallet Standard `label` on Solana. Always\n\t * `undefined` on Ethereum.\n\t */\n\tname?: string;\n\t/** `name` of the wallet that lists the account. */\n\twalletName: string;\n\t/** `id` of the wallet that lists the account. */\n\twalletId: WalletId;\n};\n\ntype LiveWalletConnectWallet = {\n\t/** See {@link BaseWallet.isPlaceholder}. */\n\tisPlaceholder?: false;\n\t/** `\"walletconnect\"`, the one connector shared by every platform. */\n\tid: WalletId;\n\t/** Narrow with {@link isWalletConnectWallet}. */\n\ttype: \"walletconnect\";\n\t/**\n\t * Platforms (namespaces) the live session currently carries. Empty until\n\t * connected; populated with whatever the wallet approved (e.g. just\n\t * `[\"ethereum\"]`, or `[\"polkadot\", \"ethereum\"]`).\n\t */\n\tplatforms: WalletPlatform[];\n\t/**\n\t * Raw Reown AppKit instance, exposed as an escape hatch for advanced use\n\t * (custom modal control, reading providers directly). Most consumers should\n\t * use `connect`/`disconnect` and the derived accounts instead.\n\t */\n\tappKit: AppKitInstance;\n\t/** The name AppKit reports for the paired wallet, `\"WalletConnect\"` when it reports none. */\n\tname: string;\n\t/** The icon AppKit reports for the paired wallet, the WalletConnect logo when it reports none. */\n\ticon: string;\n\t/**\n\t * `connecting` while `connect()` opens the modal, `connected` while a\n\t * session is live, `disconnected` otherwise. On a reload with a cached\n\t * session it is `connecting` until AppKit restores the session or hydration\n\t * ends.\n\t */\n\tstatus: WalletStatus;\n\t/** The last `connect()` whose modal failed to open. Cleared by the next call. */\n\terror?: KheopskitError;\n\t/** `status === \"connected\"`. */\n\tisConnected: boolean;\n\t/**\n\t * Opens the WalletConnect modal and resolves once it is open; `isConnected`\n\t * follows when the user approves a session. Unlike injected wallets, this\n\t * promise does not wait for the state to show the connector connected, and\n\t * `signal` is accepted for signature compatibility only.\n\t */\n\tconnect: (options?: ConnectOptions) => Promise<void>;\n\t/** Ends the live session when there is one; resolves at once otherwise. */\n\tdisconnect: () => Promise<void>;\n};\n\n/**\n * The single WalletConnect connector, shared across every platform.\n *\n * Unlike injected wallets, it is **not tied to a platform**: one WalletConnect\n * session spans whichever namespaces the remote wallet approves in a single\n * pairing (a namespace can't be added to a live session afterwards). So there is\n * exactly one of these in `wallets`, discriminated by `type: \"walletconnect\"`.\n * Its accounts appear in `accounts`, each carrying its own `platform`.\n *\n * A placeholder (see {@link BaseWallet.isPlaceholder}) has no `appKit`.\n */\nexport type WalletConnectWallet =\n\t| LiveWalletConnectWallet\n\t| PlaceholderWallet<LiveWalletConnectWallet, \"appKit\">;\n\n/**\n * The cached stand-in for a live item `T`: `isPlaceholder: true`, and the\n * fields `K`, which only the live item carries, absent. Platform account and\n * wallet types are `T | Placeholder<T, K>`, so narrow on `isPlaceholder`\n * before reading a field of `K`.\n */\nexport type Placeholder<T, K extends keyof T> = Omit<T, K | \"isPlaceholder\"> & {\n\t/** Restored from the cache and not yet replaced by the live item. */\n\tisPlaceholder: true;\n} & { [P in K]?: undefined };\n\n/** A {@link Placeholder} wallet, which is never connected. */\nexport type PlaceholderWallet<\n\tT extends { isConnected: boolean },\n\tK extends keyof T,\n> = Omit<Placeholder<T, K>, \"isConnected\"> & { isConnected: false };\n\n/** Narrows a wallet to the platform-less {@link WalletConnectWallet}. */\nexport const isWalletConnectWallet = (\n\twallet: BaseWallet | WalletConnectWallet,\n): wallet is WalletConnectWallet => wallet.type === \"walletconnect\";\n\n/**\n * Narrows a wallet to an injected (browser-extension / Wallet Standard) wallet,\n * the complement of {@link isWalletConnectWallet}. `state.wallets` is\n * `(InjectedWallet | WalletConnectWallet)[]`, so use this to recover the\n * injected-only fields when iterating: `platform`, `sourceId`, and the SDK\n * handle (`provider` on Ethereum, `extension` on Polkadot, `wallet` on Solana).\n *\n * @example\n * ```ts\n * for (const wallet of wallets.filter(isInjectedWallet)) {\n * console.log(wallet.platform, wallet.sourceId); // typed, no WC widening\n * }\n * ```\n */\nexport const isInjectedWallet = <W extends BaseWallet | WalletConnectWallet>(\n\twallet: W,\n): wallet is Exclude<W, WalletConnectWallet> => wallet.type === \"injected\";\n\n/**\n * Dapp metadata shown in the WalletConnect modal. Mirrors WalletConnect's\n * `Metadata`, declared locally so core doesn't depend on\n * `@walletconnect/universal-provider`.\n */\nexport type WalletConnectMetadata = {\n\tname: string;\n\tdescription: string;\n\turl: string;\n\ticons: string[];\n};\n\n/**\n * The WalletConnect connector for `config.walletConnect`. Create it with\n * `walletConnect()` from `@kheopskit/core/walletconnect`; that entry is the only\n * one that loads Reown AppKit.\n */\nexport type WalletConnectPlugin = {\n\treadonly type: \"walletconnect\";\n\treadonly metadata: WalletConnectMetadata;\n\tgetWallet$(ctx: PlatformContext): Observable<WalletConnectWallet | null>;\n};\n\n/**\n * Context passed to a platform plugin's `getWallets$`. Carries the shared store\n * and the resolved core config (for WalletConnect / debug).\n */\nexport type PlatformContext = {\n\tstore: KheopskitStore;\n\tconfig: KheopskitConfig;\n\t/**\n\t * Moments to re-read a registry that has no announce event. Emits at\n\t * subscribe and on a tail restarted at window `load`, and completes after\n\t * the last read. {@link KheopskitState.isDiscovering} turns `false` on the\n\t * first wallet list after that and after a WalletConnect connector loads.\n\t */\n\tregistryReads$?: Observable<void>;\n};\n\n/**\n * A platform plugin. Created by the per-platform factories exported from\n * `@kheopskit/core/polkadot`, `/ethereum`, `/solana`. Core iterates plugins\n * generically and never imports a platform SDK itself.\n *\n * @typeParam TPlatform - the platform discriminant\n * @typeParam TWallet - the platform's wallet type (extends {@link BaseWallet})\n * @typeParam TAccount - the platform's account type (extends {@link BaseWalletAccount})\n */\nexport type KheopskitPlatform<\n\tTPlatform extends WalletPlatform = WalletPlatform,\n\tTWallet extends BaseWallet = BaseWallet,\n\tTAccount extends BaseWalletAccount = BaseWalletAccount,\n> = {\n\treadonly platform: TPlatform;\n\t// Declared as methods (not arrow properties) so parameters are checked\n\t// bivariantly — this lets a specific `KheopskitPlatform<\"polkadot\", …>` be\n\t// assigned to the base `KheopskitPlatform` despite the contravariant\n\t// `wallets$` parameter.\n\tgetWallets$(ctx: PlatformContext): Observable<TWallet[]>;\n\t// Receives this platform's (injected) wallets plus the shared, platform-less\n\t// WalletConnect connector — the plugin derives its injected accounts and, if\n\t// the WC session carries its namespace, its WalletConnect accounts.\n\tgetAccounts$(\n\t\twallets$: Observable<(TWallet | WalletConnectWallet)[]>,\n\t): Observable<TAccount[]>;\n\t/**\n\t * Optional hydration filter. Cached accounts for which this returns false are\n\t * dropped during SSR hydration (Polkadot uses it to honour `accountTypes`).\n\t */\n\tacceptsCachedAccount?(cached: CachedAccount): boolean;\n};\n\ntype ElementOf<T> = T extends readonly (infer E)[] ? E : never;\n\n/** The account type produced by a plugin (inferred from its `getAccounts$`). */\nexport type AccountOf<T> = T extends {\n\tgetAccounts$: (wallets$: never) => Observable<infer R>;\n}\n\t? ElementOf<R>\n\t: never;\n\n/** The wallet type produced by a plugin (inferred from its `getWallets$`). */\nexport type WalletOf<T> = T extends {\n\tgetWallets$: (ctx: never) => Observable<infer R>;\n}\n\t? ElementOf<R>\n\t: never;\n\nexport type KheopskitConfig<\n\tP extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[],\n> = {\n\t/**\n\t * Which remembered injected wallets kheopskit reconnects after a reload.\n\t *\n\t * A wallet is remembered on every successful `connect()` and forgotten on\n\t * `disconnect()`, whatever this option says; the list is the store's\n\t * `remembered`. `true` reconnects every remembered injected wallet, `false`\n\t * none, and a function is asked for each cached connected injected wallet\n\t * on the first frame, then for each remembered one with its live object\n\t * before the attempt. The function must be synchronous and pure. It runs on\n\t * the server and on the client for the same input and both must agree, or\n\t * the markup diverges. It receives the {@link BaseWallet} fields only, so\n\t * key on `id`.\n\t *\n\t * The WalletConnect row is not governed by this option: AppKit restores its\n\t * own session on load, and the row hydrates `connecting` while it does.\n\t *\n\t * A reconnect opens no connect prompt while the site stays authorised in\n\t * the extension. When the authorisation was revoked the extension prompts\n\t * once; a refusal forgets the wallet, so the next load stays silent. A manual\n\t * `connect()` or `disconnect()` on a remembered wallet ends its automatic\n\t * reconnect for the session. A `disconnect()` forgets the wallet whatever\n\t * its status, so one made while the automatic reconnect still waits for the\n\t * extension aborts it, and the next load does not reconnect it.\n\t * Automatic reconnect also ends when the wallet disappears mid-attempt; the\n\t * wallet stays remembered for the next load.\n\t *\n\t * A cached connected wallet this accepts shows `status: \"connecting\"` from\n\t * the first frame until its attempt settles. A wallet this rejects shows\n\t * `disconnected` from the first frame, without its cached accounts, so\n\t * nothing flashes from connected to disconnected.\n\t *\n\t * @default true\n\t */\n\tautoReconnect: boolean | ((wallet: BaseWallet) => boolean);\n\t/**\n\t * Platform plugins to enable, e.g. `[polkadot(), solana({ chain })]`.\n\t * Import factories from `@kheopskit/core/<platform>`.\n\t *\n\t * Cached wallets and accounts of a platform missing here are omitted from\n\t * the first emission on, and its remembered wallets are not reconnected.\n\t * They stay remembered, so adding the platform back makes them eligible\n\t * for reconnect under `autoReconnect` again. The cached WalletConnect row\n\t * likewise requires `walletConnect`.\n\t */\n\tplatforms: P;\n\t/** Create with `walletConnect()` from `@kheopskit/core/walletconnect`. */\n\twalletConnect?: WalletConnectPlugin;\n\t/**\n\t * Dapp name sent to Polkadot injected extensions on connect. Some\n\t * extensions (e.g. polkadot.js) warn about a suspicious origin when it's\n\t * empty.\n\t *\n\t * @default walletConnect.metadata.name, then window.location.hostname\n\t */\n\tappName?: string;\n\t/**\n\t * Logs the resolved config, every state emission and the hydration and\n\t * persistence steps with `console.debug`.\n\t *\n\t * @default false\n\t */\n\tdebug: boolean;\n\t/**\n\t * Custom storage key for persisting wallet connection state.\n\t * Useful when running multiple kheopskit instances on the same domain\n\t * to prevent state conflicts between different dapps.\n\t *\n\t * @default \"kheopskit\"\n\t */\n\tstorageKey: string;\n\t/**\n\t * Minimum time in milliseconds the cached placeholders are shown after a\n\t * reload, so the wallet list does not flash while extensions inject and\n\t * remembered wallets reconnect. Hydration goes on past it until the rule\n\t * documented on {@link KheopskitConfig.hydrationTimeout} ends it, and that\n\t * timeout wins over a longer grace period. The old cap of six times this\n\t * value is gone, so an app that raises it sets `hydrationTimeout` as well.\n\t *\n\t * `0` disables placeholders: `isHydrating` is `false` from the first\n\t * emission.\n\t *\n\t * @default 500\n\t */\n\thydrationGracePeriod: number;\n\t/**\n\t * Upper bound in milliseconds on {@link KheopskitState.isHydrating}.\n\t *\n\t * `isHydrating` turns `false` once `hydrationGracePeriod` has elapsed and\n\t * every cached wallet has settled. A cached wallet missing from the\n\t * discovered wallets settles when discovery ends\n\t * ({@link KheopskitState.isDiscovering} is `false`). A discovered one\n\t * settles at once unless it hydrated as `connecting`. Then it settles when\n\t * connected once its account list has been read (an empty list counts) or\n\t * connected with no cached accounts, disconnected with `error` set, or\n\t * disconnected and not remembered (a wallet remembered after hydration\n\t * began does not count). At\n\t * `hydrationTimeout` hydration ends whatever is pending, and a wallet whose\n\t * reconnect is still pending stays `connecting`.\n\t *\n\t * - When every cached wallet is discovered and settled, hydration ends at\n\t * the grace period, without waiting for `load`. A cached wallet that has\n\t * not appeared holds hydration until discovery ends (1100 ms after `load`\n\t * or after subscribe, whichever is later, or later while a WalletConnect\n\t * connector loads), or until `hydrationTimeout`.\n\t * - A wallet that reconnects without sharing any account with the site\n\t * settles as soon as it answers; its cached accounts leave the list when\n\t * hydration ends.\n\t * - A failed reconnect ends that wallet's wait, even when the reconnect\n\t * policy still permits a retry. A retry runs only when the wallet list next\n\t * changes (a wallet discovered or removed, or any wallet's status, error\n\t * or name changing), which may never happen, so waiting for it would\n\t * hold most failed reconnects until `hydrationTimeout`. A retry that\n\t * does run shows on the live wallet's `status`, not as a placeholder.\n\t * - A prompt the extension opens for a revoked site holds hydration until\n\t * the user answers or `hydrationTimeout` elapses.\n\t *\n\t * @default 3000\n\t */\n\thydrationTimeout: number;\n};\n\n/**\n * The current kheopskit state.\n *\n * @remarks\n * While {@link KheopskitState.isHydrating} is `true`, `wallets` and `accounts`\n * may contain placeholders restored from the cache, flagged\n * `isPlaceholder: true`. Each platform type is a union on that flag: a\n * placeholder lacks the SDK handles (`account.txCreator` or `polkadotSigner`\n * on Polkadot, `account.client` on Ethereum, `account.signer` / `getSigner` on\n * Solana, `wallet.extension` / `provider` / `wallet` and `sourceId`). Reading\n * one without narrowing yields a possibly-`undefined` value, so the compiler\n * rejects using it as present until you narrow:\n *\n * ```ts\n * if (account.isPlaceholder) return;\n * account.txCreator; // TxCreator\n * ```\n *\n * A placeholder wallet's `connect()` waits for the live wallet and connects\n * it, rejecting with `WALLET_PENDING` if hydration ends first. No item is a\n * placeholder once `isHydrating` is `false`.\n *\n * The plain, serializable platform data that is persisted in the cache IS\n * restored on the placeholders (Ethereum `chainId`, Polkadot key `type`), so it\n * renders immediately on reload without flashing. Solana `chains` is not\n * cached: a placeholder account's is empty.\n */\nexport type KheopskitState<\n\tP extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[],\n> = {\n\t/**\n\t * Every discovered wallet, connected or not, then the WalletConnect\n\t * connector once AppKit has loaded, when `config.walletConnect` is set.\n\t * While `isHydrating` is `true`, also the cached placeholders. Sorted by\n\t * platform (Polkadot, Ethereum, Solana, WalletConnect), then Talisman\n\t * first, then by name.\n\t */\n\twallets: (WalletOf<P[number]> | WalletConnectWallet)[];\n\t/**\n\t * The accounts of every connected wallet. While `isHydrating` is `true`,\n\t * also the cached placeholders of every wallet that has no live account\n\t * yet. Grouped by platform, then by wallet (Talisman first, then by wallet\n\t * name); inside a wallet, in the order the wallet lists them.\n\t */\n\taccounts: AccountOf<P[number]>[];\n\t/** The resolved config, with every default filled in. */\n\tconfig: KheopskitConfig<P>;\n\t/**\n\t * Whether the state is still being hydrated from cache.\n\t *\n\t * During hydration, cached wallets/accounts may be displayed before the\n\t * actual wallet extensions have injected. See the type-level remarks: those\n\t * are flagged `isPlaceholder: true` and carry no SDK handle.\n\t */\n\tisHydrating: boolean;\n\t/**\n\t * Whether wallet discovery may still be incomplete.\n\t *\n\t * `true` until the Polkadot registry (`window.injectedWeb3`) read window\n\t * ends, 1100 ms after `load` or after subscribe, whichever is later. With\n\t * `config.walletConnect`, it also waits for the connector to load. The\n\t * emission that turns it `false` lists every Polkadot extension injected\n\t * before the last read. A wallet that injects later is not listed until\n\t * the next subscription. Always `true` on the server.\n\t *\n\t * Ethereum (EIP-6963) and Solana (Wallet Standard) registries are\n\t * event-driven and need no re-read.\n\t */\n\tisDiscovering: boolean;\n};\n\n/** Shape of the persisted store data (localStorage, or cookies in compact form). */\nexport type KheopskitStoreData = {\n\t/** Wallets the user connected and has not disconnected */\n\tremembered?: WalletId[];\n\t/** Cached wallet state for SSR hydration to prevent UI flash */\n\tcachedWallets?: CachedWallet[];\n\t/** Cached account state for SSR hydration to prevent UI flash */\n\tcachedAccounts?: CachedAccount[];\n};\n\n/**\n * The persisted settings store shared between core and framework bindings.\n * Declared structurally here (implemented by `createKheopskitStore`) so modules\n * can depend on the interface without importing the implementation.\n */\nexport type KheopskitStore = {\n\tobservable: Observable<KheopskitStoreData>;\n\trememberWallet: (walletId: WalletId) => void;\n\tforgetWallet: (walletId: WalletId) => void;\n\tgetCachedState: () => { wallets: CachedWallet[]; accounts: CachedAccount[] };\n\tsetCachedState: (wallets: CachedWallet[], accounts: CachedAccount[]) => void;\n\t/** Stops cross-tab storage sync and completes `observable`. */\n\tdestroy: () => void;\n};\n\n/**\n * Serializable wallet data for SSR hydration cache.\n * Contains only the data needed to render wallet UI without flash.\n * Note: icon is NOT stored to save cookie space - it's looked up at hydration time.\n */\nexport type CachedWallet = {\n\tid: WalletId;\n\t/** Absent for the platform-less WalletConnect connector. */\n\tplatform?: WalletPlatform;\n\ttype: WalletType;\n\tname: string;\n\tisConnected: boolean;\n};\n\n/**\n * Serializable account data for SSR hydration cache.\n * Contains only the data needed to render account UI without flash.\n */\nexport type CachedAccount = {\n\tid: string;\n\tplatform: WalletPlatform;\n\taddress: string;\n\tname?: string;\n\t/** Cached chain ID for Ethereum accounts. */\n\tchainId?: number;\n\t/** Cached key type for Polkadot accounts. */\n\tpolkadotAccountType?: PolkadotAccountType;\n\twalletId: WalletId;\n\twalletName: string;\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) => {\n\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t`[kheopskit] Could not list the accounts of ${wallet.id}`,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconnection.accounts = [];\n\t\t\t\t\t\t\tconnection.answered = true;\n\t\t\t\t\t\t\tconnection.completed = true;\n\t\t\t\t\t\t\temit();\n\t\t\t\t\t\t\tcompleteIfDone();\n\t\t\t\t\t\t},\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, limited to the entries\n * granting `method` when one is given.\n */\nexport const getSessionCaip10s = (\n\tsession: NonNullable<WalletConnectProvider[\"session\"]>,\n\tnamespace: string,\n\tmethod?: string,\n): string[] =>\n\tObject.values(session.namespaces)\n\t\t.filter((ns) => !method || ns.methods?.includes(method))\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":";;AAIA,MAAM,eAAe,OAAO,IAAI,2BAA2B;AAE3D,MAAM,iBAAmD;CACxD,MAAM,IAAI;CAIV,IAAI,QAAQ,EAAE;CACd,IAAI,CAAC,OAAO;EACX,wBAAQ,IAAI,IAAI;EAChB,EAAE,gBAAgB;CACnB;CACA,OAAO;AACR;AAEA,MAAa,wBACZ,KACA,WACS;CACT,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,MAAM,IAAI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