@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @kheopskit/core
2
2
 
3
+ ## 6.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#213](https://github.com/kheopskit/kheopskit/pull/213) [`c6036ff`](https://github.com/kheopskit/kheopskit/commit/c6036ff141717c053c4fe070ddd29b2e5a6f998d) Thanks [@0xKheops](https://github.com/0xKheops)! - Fixed: when the paired wallet ends the WalletConnect session, the WalletConnect wallet now turns `disconnected` and its accounts leave the list, and pairing again connects it. Before, it stayed `connected` with the session's accounts until a page reload, signing with them failed with `NO_SESSION`, and `disconnect()` changed nothing.
8
+
3
9
  ## 6.0.3
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,116 @@
1
+ import { keccak_256 } from "@noble/hashes/sha3.js";
2
+ import { base58 } from "@scure/base";
3
+ import { blake2b } from "@noble/hashes/blake2.js";
4
+ //#region src/utils/isEthereumAddress.ts
5
+ const HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
6
+ const encoder = new TextEncoder();
7
+ /**
8
+ * Verifies the EIP-55 mixed-case checksum of an Ethereum address.
9
+ * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.
10
+ */
11
+ const isChecksumValid = (address) => {
12
+ const hex = address.slice(2);
13
+ const hash = keccak_256(encoder.encode(hex.toLowerCase()));
14
+ for (let i = 0; i < 40; i++) {
15
+ const char = hex.charAt(i);
16
+ if (!(char >= "a" && char <= "f" || char >= "A" && char <= "F")) continue;
17
+ const byte = hash[i >> 1] ?? 0;
18
+ const nibble = i % 2 === 0 ? byte >> 4 : byte & 15;
19
+ if (char <= "F" !== nibble >= 8) return false;
20
+ }
21
+ return true;
22
+ };
23
+ /**
24
+ * Returns true if `address` is a valid Ethereum address.
25
+ *
26
+ * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a
27
+ * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are
28
+ * accepted as non-checksummed.
29
+ */
30
+ const isEthereumAddress = (address) => {
31
+ if (!HEX_ADDRESS.test(address)) return false;
32
+ if (address === address.toLowerCase()) return true;
33
+ return isChecksumValid(address);
34
+ };
35
+ //#endregion
36
+ //#region src/utils/isSolanaAddress.ts
37
+ /**
38
+ * Returns true if the value is a valid Solana address: a base58-encoded
39
+ * 32-byte ed25519 public key.
40
+ *
41
+ * Solana addresses carry no checksum, so this is a pure base58 + length check.
42
+ * Dependency-free (base58 via @scure/base) so core stays decoupled from
43
+ * @solana/kit.
44
+ */
45
+ const isSolanaAddress = (address) => {
46
+ if (!address) return false;
47
+ try {
48
+ return base58.decode(address).length === 32;
49
+ } catch {
50
+ return false;
51
+ }
52
+ };
53
+ //#endregion
54
+ //#region src/utils/isSs58Address.ts
55
+ const SS58PRE = new Uint8Array([
56
+ 83,
57
+ 83,
58
+ 53,
59
+ 56,
60
+ 80,
61
+ 82,
62
+ 69
63
+ ]);
64
+ /**
65
+ * Returns true if `address` is a valid SS58-encoded 32-byte account id (the
66
+ * only form Substrate wallets inject), verifying the blake2b-512 checksum.
67
+ *
68
+ * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core
69
+ * stays decoupled from polkadot-api.
70
+ */
71
+ const isSs58Address = (address) => {
72
+ if (!address) return false;
73
+ let decoded;
74
+ try {
75
+ decoded = base58.decode(address);
76
+ } catch {
77
+ return false;
78
+ }
79
+ const firstByte = decoded[0];
80
+ if (firstByte === void 0 || firstByte & 128) return false;
81
+ const prefixLength = firstByte & 64 ? 2 : 1;
82
+ if (decoded.length !== prefixLength + 32 + 2) return false;
83
+ const body = decoded.subarray(0, decoded.length - 2);
84
+ const preimage = new Uint8Array(SS58PRE.length + body.length);
85
+ preimage.set(SS58PRE);
86
+ preimage.set(body, SS58PRE.length);
87
+ const hash = blake2b(preimage, { dkLen: 64 });
88
+ return decoded[decoded.length - 2] === hash[0] && decoded[decoded.length - 1] === hash[1];
89
+ };
90
+ //#endregion
91
+ //#region src/utils/isValidAddress.ts
92
+ const isValidAddress = (address) => {
93
+ if (address.startsWith("0x")) return isEthereumAddress(address);
94
+ return isSs58Address(address) || isSolanaAddress(address);
95
+ };
96
+ //#endregion
97
+ //#region src/utils/WalletAccountId.ts
98
+ const getWalletAccountId = (walletId, address) => {
99
+ if (!walletId) throw new Error("Missing walletId");
100
+ if (!isValidAddress(address)) throw new Error("Invalid address");
101
+ return `${walletId}::${address}`;
102
+ };
103
+ const parseWalletAccountId = (accountId) => {
104
+ if (!accountId) throw new Error("Invalid walletAccountId");
105
+ const [walletId, address] = accountId.split("::");
106
+ if (!walletId) throw new Error("Missing walletId");
107
+ if (!address || !isValidAddress(address)) throw new Error("Invalid address");
108
+ return {
109
+ walletId,
110
+ address
111
+ };
112
+ };
113
+ //#endregion
114
+ export { isSolanaAddress as a, isSs58Address as i, parseWalletAccountId as n, isEthereumAddress as o, isValidAddress as r, getWalletAccountId as t };
115
+
116
+ //# sourceMappingURL=WalletAccountId-6ZXQM_ed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletAccountId-6ZXQM_ed.mjs","names":[],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n"],"mappings":";;;;AAEA,MAAM,cAAc;AACpB,MAAM,UAAU,IAAI,YAAY;;;;;AAMhC,MAAM,mBAAmB,YAA6B;CACrD,MAAM,MAAM,QAAQ,MAAM,CAAC;CAC3B,MAAM,OAAO,WAAW,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC;CACzD,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC5B,MAAM,OAAO,IAAI,OAAO,CAAC;EAGzB,IAAI,EADF,QAAQ,OAAO,QAAQ,OAAS,QAAQ,OAAO,QAAQ,MAC1C;EACf,MAAM,OAAO,KAAK,KAAK,MAAM;EAC7B,MAAM,SAAS,IAAI,MAAM,IAAI,QAAQ,IAAI,OAAO;EAEhD,IADgB,QAAQ,QACR,UAAU,GAAG,OAAO;CACrC;CACA,OAAO;AACR;;;;;;;;AASA,MAAa,qBAAqB,YAA6B;CAC9D,I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D,IAAI,CAAC,eAAe,OAAO,GAAG,MAAM,IAAI,MAAM,iBAAiB;CAC/D,OAAO,GAAG,SAAS,IAAI;AACxB;AAEA,MAAa,wBAAwB,cAAsB;CAC1D,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,yBAAyB;CACzD,MAAM,CAAC,UAAU,WAAW,UAAU,MAAM,IAAI;CAChD,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,kBAAkB;CACjD,IAAI,CAAC,WAAW,CAAC,eAAe,OAAO,GAAG,MAAM,IAAI,MAAM,iBAAiB;CAC3E,OAAO;EAAE;EAAU;CAAQ;AAC5B"}
@@ -0,0 +1,151 @@
1
+ let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
2
+ let _scure_base = require("@scure/base");
3
+ let _noble_hashes_blake2_js = require("@noble/hashes/blake2.js");
4
+ //#region src/utils/isEthereumAddress.ts
5
+ const HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
6
+ const encoder = new TextEncoder();
7
+ /**
8
+ * Verifies the EIP-55 mixed-case checksum of an Ethereum address.
9
+ * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.
10
+ */
11
+ const isChecksumValid = (address) => {
12
+ const hex = address.slice(2);
13
+ const hash = (0, _noble_hashes_sha3_js.keccak_256)(encoder.encode(hex.toLowerCase()));
14
+ for (let i = 0; i < 40; i++) {
15
+ const char = hex.charAt(i);
16
+ if (!(char >= "a" && char <= "f" || char >= "A" && char <= "F")) continue;
17
+ const byte = hash[i >> 1] ?? 0;
18
+ const nibble = i % 2 === 0 ? byte >> 4 : byte & 15;
19
+ if (char <= "F" !== nibble >= 8) return false;
20
+ }
21
+ return true;
22
+ };
23
+ /**
24
+ * Returns true if `address` is a valid Ethereum address.
25
+ *
26
+ * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a
27
+ * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are
28
+ * accepted as non-checksummed.
29
+ */
30
+ const isEthereumAddress = (address) => {
31
+ if (!HEX_ADDRESS.test(address)) return false;
32
+ if (address === address.toLowerCase()) return true;
33
+ return isChecksumValid(address);
34
+ };
35
+ //#endregion
36
+ //#region src/utils/isSolanaAddress.ts
37
+ /**
38
+ * Returns true if the value is a valid Solana address: a base58-encoded
39
+ * 32-byte ed25519 public key.
40
+ *
41
+ * Solana addresses carry no checksum, so this is a pure base58 + length check.
42
+ * Dependency-free (base58 via @scure/base) so core stays decoupled from
43
+ * @solana/kit.
44
+ */
45
+ const isSolanaAddress = (address) => {
46
+ if (!address) return false;
47
+ try {
48
+ return _scure_base.base58.decode(address).length === 32;
49
+ } catch {
50
+ return false;
51
+ }
52
+ };
53
+ //#endregion
54
+ //#region src/utils/isSs58Address.ts
55
+ const SS58PRE = new Uint8Array([
56
+ 83,
57
+ 83,
58
+ 53,
59
+ 56,
60
+ 80,
61
+ 82,
62
+ 69
63
+ ]);
64
+ /**
65
+ * Returns true if `address` is a valid SS58-encoded 32-byte account id (the
66
+ * only form Substrate wallets inject), verifying the blake2b-512 checksum.
67
+ *
68
+ * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core
69
+ * stays decoupled from polkadot-api.
70
+ */
71
+ const isSs58Address = (address) => {
72
+ if (!address) return false;
73
+ let decoded;
74
+ try {
75
+ decoded = _scure_base.base58.decode(address);
76
+ } catch {
77
+ return false;
78
+ }
79
+ const firstByte = decoded[0];
80
+ if (firstByte === void 0 || firstByte & 128) return false;
81
+ const prefixLength = firstByte & 64 ? 2 : 1;
82
+ if (decoded.length !== prefixLength + 32 + 2) return false;
83
+ const body = decoded.subarray(0, decoded.length - 2);
84
+ const preimage = new Uint8Array(SS58PRE.length + body.length);
85
+ preimage.set(SS58PRE);
86
+ preimage.set(body, SS58PRE.length);
87
+ const hash = (0, _noble_hashes_blake2_js.blake2b)(preimage, { dkLen: 64 });
88
+ return decoded[decoded.length - 2] === hash[0] && decoded[decoded.length - 1] === hash[1];
89
+ };
90
+ //#endregion
91
+ //#region src/utils/isValidAddress.ts
92
+ const isValidAddress = (address) => {
93
+ if (address.startsWith("0x")) return isEthereumAddress(address);
94
+ return isSs58Address(address) || isSolanaAddress(address);
95
+ };
96
+ //#endregion
97
+ //#region src/utils/WalletAccountId.ts
98
+ const getWalletAccountId = (walletId, address) => {
99
+ if (!walletId) throw new Error("Missing walletId");
100
+ if (!isValidAddress(address)) throw new Error("Invalid address");
101
+ return `${walletId}::${address}`;
102
+ };
103
+ const parseWalletAccountId = (accountId) => {
104
+ if (!accountId) throw new Error("Invalid walletAccountId");
105
+ const [walletId, address] = accountId.split("::");
106
+ if (!walletId) throw new Error("Missing walletId");
107
+ if (!address || !isValidAddress(address)) throw new Error("Invalid address");
108
+ return {
109
+ walletId,
110
+ address
111
+ };
112
+ };
113
+ //#endregion
114
+ Object.defineProperty(exports, "getWalletAccountId", {
115
+ enumerable: true,
116
+ get: function() {
117
+ return getWalletAccountId;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "isEthereumAddress", {
121
+ enumerable: true,
122
+ get: function() {
123
+ return isEthereumAddress;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "isSolanaAddress", {
127
+ enumerable: true,
128
+ get: function() {
129
+ return isSolanaAddress;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "isSs58Address", {
133
+ enumerable: true,
134
+ get: function() {
135
+ return isSs58Address;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "isValidAddress", {
139
+ enumerable: true,
140
+ get: function() {
141
+ return isValidAddress;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "parseWalletAccountId", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return parseWalletAccountId;
148
+ }
149
+ });
150
+
151
+ //# sourceMappingURL=WalletAccountId-D8Xc13VY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletAccountId-D8Xc13VY.js","names":["keccak_256","base58","base58","blake2b"],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n"],"mappings":";;;;AAEA,MAAM,cAAc;AACpB,MAAM,UAAU,IAAI,YAAY;;;;;AAMhC,MAAM,mBAAmB,YAA6B;CACrD,MAAM,MAAM,QAAQ,MAAM,CAAC;CAC3B,MAAM,QAAA,GAAOA,sBAAAA,WAAAA,CAAW,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC;CACzD,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC5B,MAAM,OAAO,IAAI,OAAO,CAAC;EAGzB,IAAI,EADF,QAAQ,OAAO,QAAQ,OAAS,QAAQ,OAAO,QAAQ,MAC1C;EACf,MAAM,OAAO,KAAK,KAAK,MAAM;EAC7B,MAAM,SAAS,IAAI,MAAM,IAAI,QAAQ,IAAI,OAAO;EAEhD,IADgB,QAAQ,QACR,UAAU,GAAG,OAAO;CACrC;CACA,OAAO;AACR;;;;;;;;AASA,MAAa,qBAAqB,YAA6B;CAC9D,IAAI,CAAC,YAAY,KAAK,OAAO,GAAG,OAAO;CACvC,IAAI,YAAY,QAAQ,YAAY,GAAG,OAAO;CAC9C,OAAO,gBAAgB,OAAO;AAC/B;;;;;;;;;;;AC1BA,MAAa,mBAAmB,YAA6B;CAC5D,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI;EACH,OAAOC,YAAAA,OAAO,OAAO,OAAO,CAAC,CAAC,WAAW;CAC1C,QAAQ;EACP,OAAO;CACR;AACD;;;ACbA,MAAM,UAAU,IAAI,WAAW;CAAC;C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AAW,CAAC,eAAe,OAAO,GAAG,MAAM,IAAI,MAAM,iBAAiB;CAC3E,OAAO;EAAE;EAAU;CAAQ;AAC5B"}
@@ -1,4 +1,4 @@
1
- import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-C9aw2FEm.js";
1
+ import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-BfIzw1fd.js";
2
2
  //#region src/api/config.d.ts
3
3
  /**
4
4
  * Default storage key for persisting wallet connection state.
@@ -11,4 +11,4 @@ declare const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;
11
11
  declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
12
12
  //#endregion
13
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-Csp5p0-Z.d.ts.map
14
+ //# sourceMappingURL=config-CubhhFON.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-C9aw2FEm.mjs";
1
+ import { c as KheopskitConfig, l as KheopskitPlatform } from "./types-BfIzw1fd.mjs";
2
2
  //#region src/api/config.d.ts
3
3
  /**
4
4
  * Default storage key for persisting wallet connection state.
@@ -11,4 +11,4 @@ declare const DEFAULT_HYDRATION_TIMEOUT_MS = 3000;
11
11
  declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
12
12
  //#endregion
13
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-qMsgD8tJ.d.mts.map
14
+ //# sourceMappingURL=config-rvX2pkqc.d.mts.map
@@ -1,4 +1,4 @@
1
- import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-C9aw2FEm.mjs";
1
+ import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BfIzw1fd.mjs";
2
2
  import { Account, CustomTransport, EIP1193Provider, WalletClient } from "viem";
3
3
  //#region src/utils/isEthereumAddress.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-C9aw2FEm.js";
1
+ import { E as isWalletConnectWallet, N as WalletAccountId, T as isInjectedWallet, b as WalletConnectWallet, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, p as Placeholder, r as BaseWallet } from "./types-BfIzw1fd.js";
2
2
  import { Account, CustomTransport, EIP1193Provider, WalletClient } from "viem";
3
3
  //#region src/utils/isEthereumAddress.d.ts
4
4
  /**
package/dist/ethereum.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_types = require("./types-DaRMgleZ.js");
3
- const require_platformAccounts = require("./platformAccounts-BcLoaZZb.js");
2
+ const require_platformAccounts = require("./platformAccounts-D8XmOSvD.js");
3
+ const require_WalletAccountId = require("./WalletAccountId-D8Xc13VY.js");
4
4
  const require_errors = require("./errors-B6Z21vkI.js");
5
5
  const require_injectedWallets = require("./injectedWallets-Cfn3caW3.js");
6
6
  let rxjs = require("rxjs");
@@ -52,7 +52,7 @@ const requestAccountsOnChain = async (provider) => {
52
52
  };
53
53
  const getInjectedWalletAccounts$ = (wallet) => {
54
54
  if (!wallet.isConnected) return (0, rxjs.of)([]);
55
- return require_types.getCachedObservable$(`accounts:${wallet.id}`, () => new rxjs.Observable((subscriber) => {
55
+ return require_platformAccounts.getCachedObservable$(`accounts:${wallet.id}`, () => new rxjs.Observable((subscriber) => {
56
56
  const addresses$ = new rxjs.ReplaySubject(1);
57
57
  const chainId$ = new rxjs.ReplaySubject(1);
58
58
  const reported = lastReported.get(wallet.provider);
@@ -66,7 +66,7 @@ const getInjectedWalletAccounts$ = (wallet) => {
66
66
  transport: (0, viem.custom)(wallet.provider)
67
67
  });
68
68
  return {
69
- id: require_platformAccounts.getWalletAccountId(wallet.id, address),
69
+ id: require_WalletAccountId.getWalletAccountId(wallet.id, address),
70
70
  platform: "ethereum",
71
71
  client,
72
72
  address: (0, viem.getAddress)(address),
@@ -144,7 +144,7 @@ const sameAddresses = (a, b) => a.length === b.length && a.every((addr, i) => ad
144
144
  const getWalletConnectAccounts$ = (wallet) => {
145
145
  const provider = wallet.appKit.getProvider("eip155");
146
146
  if (!wallet.platforms.includes("ethereum") || !provider?.session) return (0, rxjs.of)([]);
147
- return require_types.getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () => new rxjs.Observable((subscriber) => {
147
+ return require_platformAccounts.getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () => new rxjs.Observable((subscriber) => {
148
148
  const caipNetworkId$ = new rxjs.ReplaySubject(1);
149
149
  const addresses$ = new rxjs.ReplaySubject(1);
150
150
  const readAddresses = () => {
@@ -184,7 +184,7 @@ const getWalletConnectAccounts$ = (wallet) => {
184
184
  transport
185
185
  });
186
186
  return {
187
- id: require_platformAccounts.getWalletAccountId(wallet.id, addr),
187
+ id: require_WalletAccountId.getWalletAccountId(wallet.id, addr),
188
188
  platform: "ethereum",
189
189
  walletName: wallet.name,
190
190
  walletId: wallet.id,
@@ -238,10 +238,10 @@ const providersDetails$ = new rxjs.Observable((subscriber) => {
238
238
  }));
239
239
  const getEthereumWallets$ = (store) => require_injectedWallets.createInjectedWallets$(store, {
240
240
  sources$: providersDetails$,
241
- getWalletId: (pd) => require_types.getWalletId("ethereum", pd.info.rdns),
241
+ getWalletId: (pd) => require_platformAccounts.getWalletId("ethereum", pd.info.rdns),
242
242
  connect: (pd) => requestAccountsOnChain(pd.provider),
243
243
  isUserRejection: require_errors.isEip1193UserRejection,
244
- onDisconnected: (walletId) => require_types.clearCachedObservable(`accounts:${walletId}`),
244
+ onDisconnected: (walletId) => require_platformAccounts.clearCachedObservable(`accounts:${walletId}`),
245
245
  buildWallet: ({ source: pd, walletId, status, error, isConnected, connect, disconnect }) => ({
246
246
  platform: "ethereum",
247
247
  type: "injected",
@@ -275,8 +275,8 @@ const ethereum = () => ({
275
275
  });
276
276
  //#endregion
277
277
  exports.ethereum = ethereum;
278
- exports.isEthereumAddress = require_platformAccounts.isEthereumAddress;
279
- exports.isInjectedWallet = require_types.isInjectedWallet;
280
- exports.isWalletConnectWallet = require_types.isWalletConnectWallet;
278
+ exports.isEthereumAddress = require_WalletAccountId.isEthereumAddress;
279
+ exports.isInjectedWallet = require_platformAccounts.isInjectedWallet;
280
+ exports.isWalletConnectWallet = require_platformAccounts.isWalletConnectWallet;
281
281
 
282
282
  //# sourceMappingURL=ethereum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum.js","names":["firstValueFrom","race","timer","map","of","getCachedObservable$","Observable","ReplaySubject","createWalletClient","custom","getWalletAccountId","getAddress","combineLatest","tap","shareReplay","getCaip10Addresses","getSessionCaip10s","distinctUntilChanged","createPlatformAccounts$","Observable","createMipdStore","shareReplay","createInjectedWallets$","getWalletId","isEip1193UserRejection","clearCachedObservable"],"sources":["../src/api/ethereum/accounts.ts","../src/api/ethereum/wallets.ts","../src/api/ethereum/plugin.ts"],"sourcesContent":["import {\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tfirstValueFrom,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\trace,\n\tshareReplay,\n\ttap,\n\ttimer,\n} from \"rxjs\";\nimport {\n\tcreateWalletClient,\n\tcustom,\n\ttype EIP1193Provider,\n\tgetAddress,\n} from \"viem\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type { WalletConnectWallet } from \"../types\";\nimport type {\n\tEthereumAccount,\n\tEthereumInjectedWallet,\n\tEthereumWallet,\n} from \"./types\";\n\nconst normalizeEvmChainId = (value: unknown): number | undefined => {\n\tlet raw = value;\n\n\tif (typeof raw === \"string\" && raw.startsWith(\"eip155:\")) {\n\t\traw = raw.slice(\"eip155:\".length);\n\t}\n\n\tif (typeof raw === \"bigint\") {\n\t\treturn raw >= 0n ? Number(raw) : undefined;\n\t}\n\n\tif (typeof raw === \"number\") {\n\t\treturn Number.isInteger(raw) && raw >= 0 ? raw : undefined;\n\t}\n\n\tif (typeof raw === \"string\") {\n\t\tconst normalized = raw.trim().toLowerCase();\n\t\tif (!normalized) return undefined;\n\t\tconst parsed = normalized.startsWith(\"0x\")\n\t\t\t? Number.parseInt(normalized, 16)\n\t\t\t: Number.parseInt(normalized, 10);\n\t\treturn Number.isNaN(parsed) ? undefined : parsed;\n\t}\n\n\treturn undefined;\n};\n\nconst toCaipNetworkId = (value: unknown): string | undefined => {\n\tconst chainId = normalizeEvmChainId(value);\n\treturn chainId === undefined ? undefined : `eip155:${chainId}`;\n};\n\ntype ReportedAccounts = { addresses: string[]; chainId: number | undefined };\n\nconst lastReported = new WeakMap<EIP1193Provider, ReportedAccounts>();\n\nconst CHAIN_ANSWER_TIMEOUT_MS = 2_000;\n\nconst readChainId = (provider: EIP1193Provider) =>\n\tfirstValueFrom(\n\t\trace(\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(normalizeEvmChainId, () => undefined),\n\t\t\ttimer(CHAIN_ANSWER_TIMEOUT_MS).pipe(map(() => undefined)),\n\t\t),\n\t);\n\nexport const requestAccountsOnChain = async (provider: EIP1193Provider) => {\n\tconst accountChanges: string[][] = [];\n\tconst chainChanges: (number | undefined)[] = [];\n\tconst handleAccountsChanged = (addresses: string[]) => {\n\t\taccountChanges.push(addresses);\n\t};\n\tconst handleChainChanged = (chainId: unknown) => {\n\t\tchainChanges.push(normalizeEvmChainId(chainId));\n\t};\n\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\tprovider.on(\"chainChanged\", handleChainChanged);\n\ttry {\n\t\tconst addresses = await provider.request({\n\t\t\tmethod: \"eth_requestAccounts\",\n\t\t});\n\t\tconst chainChangesBeforeRead = chainChanges.length;\n\t\tconst chainId = await readChainId(provider);\n\t\tlastReported.set(provider, {\n\t\t\taddresses: accountChanges.at(-1) ?? addresses,\n\t\t\tchainId:\n\t\t\t\tchainChanges.length > chainChangesBeforeRead\n\t\t\t\t\t? chainChanges.at(-1)\n\t\t\t\t\t: chainId,\n\t\t});\n\t} finally {\n\t\tprovider.removeListener(\"accountsChanged\", handleAccountsChanged);\n\t\tprovider.removeListener(\"chainChanged\", handleChainChanged);\n\t}\n};\n\nconst getInjectedWalletAccounts$ = (\n\twallet: EthereumInjectedWallet,\n): Observable<EthereumAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\t\t\tconst chainId$ = new ReplaySubject<number | undefined>(1);\n\t\t\tconst reported = lastReported.get(wallet.provider);\n\t\t\tif (reported) {\n\t\t\t\taddresses$.next(reported.addresses);\n\t\t\t\tchainId$.next(reported.chainId);\n\t\t\t}\n\n\t\t\tconst getAccount = (\n\t\t\t\taddress: string,\n\t\t\t\tchainId: number | undefined,\n\t\t\t): EthereumAccount => {\n\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\taccount: address as `0x${string}`,\n\t\t\t\t\ttransport: custom(wallet.provider as EIP1193Provider),\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\tclient,\n\t\t\t\t\taddress: getAddress(address),\n\t\t\t\t\tchainId,\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tlet accountEvents = 0;\n\t\t\tlet chainEvents = 0;\n\n\t\t\tconst handleAccountsChanged = (addrs: string[]) => {\n\t\t\t\taccountEvents++;\n\t\t\t\taddresses$.next(addrs);\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainIdHex: unknown) => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t};\n\n\t\t\tconst handleConnect = (connectInfo: { chainId?: unknown }) => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(normalizeEvmChainId(connectInfo?.chainId));\n\t\t\t};\n\n\t\t\tconst handleDisconnect = () => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(undefined);\n\t\t\t};\n\n\t\t\t// Subscribe to provider events\n\t\t\twallet.provider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\twallet.provider.on(\"chainChanged\", handleChainChanged);\n\t\t\twallet.provider.on(\"connect\", handleConnect);\n\t\t\twallet.provider.on(\"disconnect\", handleDisconnect);\n\n\t\t\tconst accountEventsBeforeRead = accountEvents;\n\t\t\tconst accountsOutdated = () => accountEvents !== accountEventsBeforeRead;\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_accounts\" })\n\t\t\t\t.then((addrs: string[]) => {\n\t\t\t\t\tif (!accountsOutdated()) addresses$.next(addrs);\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(\"Failed to get accounts\", err);\n\t\t\t\t\tif (!accountsOutdated()) addresses$.next([]);\n\t\t\t\t});\n\n\t\t\tconst chainEventsBeforeRead = chainEvents;\n\t\t\tconst chainOutdated = () => chainEvents !== chainEventsBeforeRead;\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then((chainIdHex: unknown) => {\n\t\t\t\t\tif (!chainOutdated()) chainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\tif (!chainOutdated()) chainId$.next(undefined);\n\t\t\t\t});\n\n\t\t\t// Combine addresses + chainId into account list\n\t\t\tconst sub = combineLatest([addresses$, chainId$])\n\t\t\t\t.pipe(\n\t\t\t\t\ttap(([addresses, chainId]) =>\n\t\t\t\t\t\tlastReported.set(wallet.provider, { addresses, chainId }),\n\t\t\t\t\t),\n\t\t\t\t\tmap(([addresses, chainId]) =>\n\t\t\t\t\t\taddresses.map((addr) => getAccount(addr, chainId)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\twallet.provider.removeListener(\n\t\t\t\t\t\"accountsChanged\",\n\t\t\t\t\thandleAccountsChanged,\n\t\t\t\t);\n\t\t\t\twallet.provider.removeListener(\"chainChanged\", handleChainChanged);\n\t\t\t\twallet.provider.removeListener(\"connect\", handleConnect);\n\t\t\t\twallet.provider.removeListener(\"disconnect\", handleDisconnect);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst wrapWalletConnectProvider = (\n\tprovider: EIP1193Provider,\n\tsessionTopic: string,\n\tcaipNetworkId: string | undefined,\n): EIP1193Provider => {\n\treturn new Proxy(provider, {\n\t\tget(target, prop, receiver) {\n\t\t\tif (prop !== \"request\") return Reflect.get(target, prop, receiver);\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: EIP-1193 request args\n\t\t\treturn (args: any) => {\n\t\t\t\tif (!args || typeof args !== \"object\" || !args.method)\n\t\t\t\t\treturn target.request(args);\n\t\t\t\t// Build a new object rather than mutating the caller's args: the\n\t\t\t\t// EIP-1193 request object is owned by viem and may be frozen or reused.\n\t\t\t\tconst next = { ...args };\n\t\t\t\tif (next.topic === undefined) next.topic = sessionTopic;\n\t\t\t\tif (next.chainId === undefined && caipNetworkId !== undefined)\n\t\t\t\t\tnext.chainId = caipNetworkId;\n\t\t\t\t// WalletConnect's UniversalProvider reads the target CAIP chain id from\n\t\t\t\t// the SECOND positional argument of `request(args, chainId)`, not from a\n\t\t\t\t// field on the args object. This AppKit instance has no native eip155\n\t\t\t\t// adapter, so the provider has no default chain — without the positional\n\t\t\t\t// chain id every call is rejected (\"Unsupported chains\" / \"Method not\n\t\t\t\t// found\"). Pass it positionally so the request routes to the session's\n\t\t\t\t// chain.\n\t\t\t\treturn (\n\t\t\t\t\ttarget.request as (a: unknown, chainId?: string) => Promise<unknown>\n\t\t\t\t)(next, caipNetworkId);\n\t\t\t};\n\t\t},\n\t});\n};\n\nconst sameAddresses = (a: string[], b: string[]) =>\n\ta.length === b.length && a.every((addr, i) => addr === b[i]);\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<EthereumAccount[]> => {\n\tconst provider = wallet.appKit.getProvider(\"eip155\");\n\n\tif (!wallet.platforms.includes(\"ethereum\") || !provider?.session)\n\t\treturn of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst caipNetworkId$ = new ReplaySubject<string | undefined>(1);\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\n\t\t\t// AppKit's getAccount(\"eip155\").allAccounts is empty because this AppKit\n\t\t\t// instance has no native eip155 adapter — eip155 runs through the\n\t\t\t// WalletConnect UniversalProvider, so the session is the source of truth\n\t\t\t// (mirrors the polkadot/solana AppKit paths). Accounts are CAIP-10 strings\n\t\t\t// (\"eip155:<chainRef>:<address>\"), one entry per chain, so dedupe to unique\n\t\t\t// addresses. Read live on each change so switching/adding accounts is\n\t\t\t// reflected.\n\t\t\tconst readAddresses = (): string[] => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return [];\n\t\t\t\tconst addresses = new Set<string>();\n\t\t\t\tfor (const raw of getCaip10Addresses(\n\t\t\t\t\tgetSessionCaip10s(session, \"eip155\"),\n\t\t\t\t)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\taddresses.add(getAddress(raw));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// skip malformed CAIP-10 address\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn [...addresses];\n\t\t\t};\n\n\t\t\t// Derive the CAIP network id from the session's eip155 CAIP-10 accounts\n\t\t\t// (\"eip155:<ref>:<addr>\") as a synchronous fallback for eth_chainId.\n\t\t\tconst readCaipNetworkId = (): string | undefined => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return undefined;\n\t\t\t\tfor (const account of getSessionCaip10s(session, \"eip155\")) {\n\t\t\t\t\tconst ref = account.split(\":\")[1];\n\t\t\t\t\tif (ref) return `eip155:${ref}`;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainId: unknown) => {\n\t\t\t\tconst caipNetworkId = toCaipNetworkId(chainId);\n\t\t\t\tif (caipNetworkId) {\n\t\t\t\t\tcaipNetworkId$.next(caipNetworkId);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = () => addresses$.next(readAddresses());\n\n\t\t\tprovider.on(\"chainChanged\", handleChainChanged);\n\t\t\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\tprovider.on(\"session_update\", handleAccountsChanged);\n\t\t\t// Seed the chain id from the session synchronously so the account list can\n\t\t\t// surface even if eth_chainId never resolves; eth_chainId then refines it.\n\t\t\t// Without this seed, combineLatest below never fires when eth_chainId\n\t\t\t// rejects or returns an unparseable value, and the accounts silently never\n\t\t\t// appear (the injected path seeds undefined on failure for the same reason).\n\t\t\tcaipNetworkId$.next(readCaipNetworkId());\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => {});\n\t\t\taddresses$.next(readAddresses());\n\n\t\t\tconst sub = combineLatest([\n\t\t\t\tcaipNetworkId$.pipe(distinctUntilChanged()),\n\t\t\t\taddresses$.pipe(distinctUntilChanged(sameAddresses)),\n\t\t\t])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([caipNetworkId, addresses]) => {\n\t\t\t\t\t\tconst chainId = normalizeEvmChainId(caipNetworkId);\n\t\t\t\t\t\tconst transport = custom(\n\t\t\t\t\t\t\twrapWalletConnectProvider(\n\t\t\t\t\t\t\t\tprovider as unknown as EIP1193Provider,\n\t\t\t\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: legacy\n\t\t\t\t\t\t\t\tprovider.session!.topic,\n\t\t\t\t\t\t\t\tcaipNetworkId,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn addresses.map((addr): EthereumAccount => {\n\t\t\t\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\t\t\t\taccount: addr as `0x${string}`,\n\t\t\t\t\t\t\t\ttransport,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: getWalletAccountId(wallet.id, addr),\n\t\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\t\t\taddress: addr as `0x${string}`,\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"chainChanged\", handleChainChanged);\n\t\t\t\tprovider.off(\"accountsChanged\", handleAccountsChanged);\n\t\t\t\tprovider.off(\"session_update\", handleAccountsChanged);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nexport const getEthereumAccounts$ = (\n\tethereumWallets: Observable<(EthereumWallet | WalletConnectWallet)[]>,\n) =>\n\tcreatePlatformAccounts$({\n\t\twallets$: ethereumWallets,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\t// Re-emit on chain switches, not just account id changes.\n\t\taccountChangeKey: (account) => `${account.id}|${account.chainId ?? \"\"}`,\n\t});\n","import {\n\tcreateStore as createMipdStore,\n\ttype EIP6963ProviderDetail,\n} from \"mipd\";\nimport { Observable, shareReplay } from \"rxjs\";\nimport type { EIP1193Provider } from \"viem\";\nimport { clearCachedObservable } from \"../../utils/getCachedObservable\";\nimport { getWalletId } from \"../../utils/WalletId\";\nimport { isEip1193UserRejection } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport { requestAccountsOnChain } from \"./accounts\";\nimport type { EthereumInjectedWallet } from \"./types\";\n\n/**\n * Observable that emits EIP-6963 provider details from injected wallets.\n * Returns empty array during SSR since browser wallet APIs are not available.\n */\nconst providersDetails$ = new Observable<EIP6963ProviderDetail[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - mipd requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst mipdStore = createMipdStore();\n\n\t\tconst unsubscribe = mipdStore.subscribe((providerDetails) => {\n\t\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\t\t});\n\n\t\tconst providerDetails = mipdStore.getProviders();\n\n\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tmipdStore.destroy();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getEthereumWallets$ = (store: KheopskitStore) =>\n\tcreateInjectedWallets$<EIP6963ProviderDetail, EthereumInjectedWallet>(store, {\n\t\tsources$: providersDetails$,\n\t\tgetWalletId: (pd) => getWalletId(\"ethereum\", pd.info.rdns),\n\t\tconnect: (pd) => requestAccountsOnChain(pd.provider as EIP1193Provider),\n\t\tisUserRejection: isEip1193UserRejection,\n\t\t// Drop the cached account observable so a later reconnect rebuilds it\n\t\t// against the current provider, not a stale closure.\n\t\tonDisconnected: (walletId) => clearCachedObservable(`accounts:${walletId}`),\n\t\tbuildWallet: ({\n\t\t\tsource: pd,\n\t\t\twalletId,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}) => ({\n\t\t\tplatform: \"ethereum\",\n\t\t\ttype: \"injected\",\n\t\t\tid: walletId,\n\t\t\tname: pd.info.name,\n\t\t\ticon: pd.info.icon,\n\t\t\tprovider: pd.provider as EIP1193Provider,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tsourceId: pd.info.rdns,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}),\n\t});\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getEthereumAccounts$ } from \"./accounts\";\nimport type { EthereumAccount, EthereumWallet } from \"./types\";\nimport { getEthereumWallets$ } from \"./wallets\";\n\n/**\n * Ethereum platform plugin. Pass to `createKheopskit({ platforms: [ethereum()] })`.\n *\n * @example\n * ```ts\n * import { ethereum } from \"@kheopskit/core/ethereum\";\n * ethereum();\n * ```\n */\nexport const ethereum = (): KheopskitPlatform<\n\t\"ethereum\",\n\tEthereumWallet,\n\tEthereumAccount\n> => ({\n\tplatform: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AAK,eAA0C;CAC3D,CAAC;CAED,MAAM,kBAAkB,UAAU,aAAa;CAE/C,WAAW,KAAK,eAA0C;CAE1D,aAAa;EACZ,YAAY;EACZ,UAAU,QAAQ;CACnB;AACD,CACD,CAAC,CAAC,MAAA,GAAKC,KAAAA,YAAAA,CAAY;CAAE,UAAU;CAAM,YAAY;AAAE,CAAC,CAAC;AAIrD,MAAa,uBAAuB,UACnCC,wBAAAA,uBAAsE,OAAO;CAC5E,UAAU;CACV,cAAc,OAAOC,cAAAA,YAAY,YAAY,GAAG,KAAK,IAAI;CACzD,UAAU,OAAO,uBAAuB,GAAG,QAA2B;CACtE,iBAAiBC,eAAAA;CAGjB,iBAAiB,aAAaC,cAAAA,sBAAsB,YAAY,UAAU;CAC1E,cAAc,EACb,QAAQ,IACR,UACA,QACA,OACA,aACA,SACA,kBACM;EACN,UAAU;EACV,MAAM;EACN,IAAI;EACJ,MAAM,GAAG,KAAK;EACd,MAAM,GAAG,KAAK;EACd,UAAU,GAAG;EACb;EACA;EACA;EACA,UAAU,GAAG,KAAK;EAClB;EACA;CACD;AACD,CAAC;;;;;;;;;;;;AC9DF,MAAa,kBAIP;CACL,UAAU;CACV,cAAc,QAAyB,oBAAoB,IAAI,KAAK;CACpE,eAAe,aAAa,qBAAqB,QAAQ;AAC1D"}
1
+ {"version":3,"file":"ethereum.js","names":["firstValueFrom","race","timer","map","of","getCachedObservable$","Observable","ReplaySubject","createWalletClient","custom","getWalletAccountId","getAddress","combineLatest","tap","shareReplay","getCaip10Addresses","getSessionCaip10s","distinctUntilChanged","createPlatformAccounts$","Observable","createMipdStore","shareReplay","createInjectedWallets$","getWalletId","isEip1193UserRejection","clearCachedObservable"],"sources":["../src/api/ethereum/accounts.ts","../src/api/ethereum/wallets.ts","../src/api/ethereum/plugin.ts"],"sourcesContent":["import {\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tfirstValueFrom,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\trace,\n\tshareReplay,\n\ttap,\n\ttimer,\n} from \"rxjs\";\nimport {\n\tcreateWalletClient,\n\tcustom,\n\ttype EIP1193Provider,\n\tgetAddress,\n} from \"viem\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n\ttype LiveWalletConnectWallet,\n} from \"../platformAccounts\";\nimport type { WalletConnectWallet } from \"../types\";\nimport type {\n\tEthereumAccount,\n\tEthereumInjectedWallet,\n\tEthereumWallet,\n} from \"./types\";\n\nconst normalizeEvmChainId = (value: unknown): number | undefined => {\n\tlet raw = value;\n\n\tif (typeof raw === \"string\" && raw.startsWith(\"eip155:\")) {\n\t\traw = raw.slice(\"eip155:\".length);\n\t}\n\n\tif (typeof raw === \"bigint\") {\n\t\treturn raw >= 0n ? Number(raw) : undefined;\n\t}\n\n\tif (typeof raw === \"number\") {\n\t\treturn Number.isInteger(raw) && raw >= 0 ? raw : undefined;\n\t}\n\n\tif (typeof raw === \"string\") {\n\t\tconst normalized = raw.trim().toLowerCase();\n\t\tif (!normalized) return undefined;\n\t\tconst parsed = normalized.startsWith(\"0x\")\n\t\t\t? Number.parseInt(normalized, 16)\n\t\t\t: Number.parseInt(normalized, 10);\n\t\treturn Number.isNaN(parsed) ? undefined : parsed;\n\t}\n\n\treturn undefined;\n};\n\nconst toCaipNetworkId = (value: unknown): string | undefined => {\n\tconst chainId = normalizeEvmChainId(value);\n\treturn chainId === undefined ? undefined : `eip155:${chainId}`;\n};\n\ntype ReportedAccounts = { addresses: string[]; chainId: number | undefined };\n\nconst lastReported = new WeakMap<EIP1193Provider, ReportedAccounts>();\n\nconst CHAIN_ANSWER_TIMEOUT_MS = 2_000;\n\nconst readChainId = (provider: EIP1193Provider) =>\n\tfirstValueFrom(\n\t\trace(\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(normalizeEvmChainId, () => undefined),\n\t\t\ttimer(CHAIN_ANSWER_TIMEOUT_MS).pipe(map(() => undefined)),\n\t\t),\n\t);\n\nexport const requestAccountsOnChain = async (provider: EIP1193Provider) => {\n\tconst accountChanges: string[][] = [];\n\tconst chainChanges: (number | undefined)[] = [];\n\tconst handleAccountsChanged = (addresses: string[]) => {\n\t\taccountChanges.push(addresses);\n\t};\n\tconst handleChainChanged = (chainId: unknown) => {\n\t\tchainChanges.push(normalizeEvmChainId(chainId));\n\t};\n\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\tprovider.on(\"chainChanged\", handleChainChanged);\n\ttry {\n\t\tconst addresses = await provider.request({\n\t\t\tmethod: \"eth_requestAccounts\",\n\t\t});\n\t\tconst chainChangesBeforeRead = chainChanges.length;\n\t\tconst chainId = await readChainId(provider);\n\t\tlastReported.set(provider, {\n\t\t\taddresses: accountChanges.at(-1) ?? addresses,\n\t\t\tchainId:\n\t\t\t\tchainChanges.length > chainChangesBeforeRead\n\t\t\t\t\t? chainChanges.at(-1)\n\t\t\t\t\t: chainId,\n\t\t});\n\t} finally {\n\t\tprovider.removeListener(\"accountsChanged\", handleAccountsChanged);\n\t\tprovider.removeListener(\"chainChanged\", handleChainChanged);\n\t}\n};\n\nconst getInjectedWalletAccounts$ = (\n\twallet: EthereumInjectedWallet,\n): Observable<EthereumAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\t\t\tconst chainId$ = new ReplaySubject<number | undefined>(1);\n\t\t\tconst reported = lastReported.get(wallet.provider);\n\t\t\tif (reported) {\n\t\t\t\taddresses$.next(reported.addresses);\n\t\t\t\tchainId$.next(reported.chainId);\n\t\t\t}\n\n\t\t\tconst getAccount = (\n\t\t\t\taddress: string,\n\t\t\t\tchainId: number | undefined,\n\t\t\t): EthereumAccount => {\n\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\taccount: address as `0x${string}`,\n\t\t\t\t\ttransport: custom(wallet.provider as EIP1193Provider),\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\tclient,\n\t\t\t\t\taddress: getAddress(address),\n\t\t\t\t\tchainId,\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tlet accountEvents = 0;\n\t\t\tlet chainEvents = 0;\n\n\t\t\tconst handleAccountsChanged = (addrs: string[]) => {\n\t\t\t\taccountEvents++;\n\t\t\t\taddresses$.next(addrs);\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainIdHex: unknown) => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t};\n\n\t\t\tconst handleConnect = (connectInfo: { chainId?: unknown }) => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(normalizeEvmChainId(connectInfo?.chainId));\n\t\t\t};\n\n\t\t\tconst handleDisconnect = () => {\n\t\t\t\tchainEvents++;\n\t\t\t\tchainId$.next(undefined);\n\t\t\t};\n\n\t\t\t// Subscribe to provider events\n\t\t\twallet.provider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\twallet.provider.on(\"chainChanged\", handleChainChanged);\n\t\t\twallet.provider.on(\"connect\", handleConnect);\n\t\t\twallet.provider.on(\"disconnect\", handleDisconnect);\n\n\t\t\tconst accountEventsBeforeRead = accountEvents;\n\t\t\tconst accountsOutdated = () => accountEvents !== accountEventsBeforeRead;\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_accounts\" })\n\t\t\t\t.then((addrs: string[]) => {\n\t\t\t\t\tif (!accountsOutdated()) addresses$.next(addrs);\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(\"Failed to get accounts\", err);\n\t\t\t\t\tif (!accountsOutdated()) addresses$.next([]);\n\t\t\t\t});\n\n\t\t\tconst chainEventsBeforeRead = chainEvents;\n\t\t\tconst chainOutdated = () => chainEvents !== chainEventsBeforeRead;\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then((chainIdHex: unknown) => {\n\t\t\t\t\tif (!chainOutdated()) chainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\tif (!chainOutdated()) chainId$.next(undefined);\n\t\t\t\t});\n\n\t\t\t// Combine addresses + chainId into account list\n\t\t\tconst sub = combineLatest([addresses$, chainId$])\n\t\t\t\t.pipe(\n\t\t\t\t\ttap(([addresses, chainId]) =>\n\t\t\t\t\t\tlastReported.set(wallet.provider, { addresses, chainId }),\n\t\t\t\t\t),\n\t\t\t\t\tmap(([addresses, chainId]) =>\n\t\t\t\t\t\taddresses.map((addr) => getAccount(addr, chainId)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\twallet.provider.removeListener(\n\t\t\t\t\t\"accountsChanged\",\n\t\t\t\t\thandleAccountsChanged,\n\t\t\t\t);\n\t\t\t\twallet.provider.removeListener(\"chainChanged\", handleChainChanged);\n\t\t\t\twallet.provider.removeListener(\"connect\", handleConnect);\n\t\t\t\twallet.provider.removeListener(\"disconnect\", handleDisconnect);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst wrapWalletConnectProvider = (\n\tprovider: EIP1193Provider,\n\tsessionTopic: string,\n\tcaipNetworkId: string | undefined,\n): EIP1193Provider => {\n\treturn new Proxy(provider, {\n\t\tget(target, prop, receiver) {\n\t\t\tif (prop !== \"request\") return Reflect.get(target, prop, receiver);\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: EIP-1193 request args\n\t\t\treturn (args: any) => {\n\t\t\t\tif (!args || typeof args !== \"object\" || !args.method)\n\t\t\t\t\treturn target.request(args);\n\t\t\t\t// Build a new object rather than mutating the caller's args: the\n\t\t\t\t// EIP-1193 request object is owned by viem and may be frozen or reused.\n\t\t\t\tconst next = { ...args };\n\t\t\t\tif (next.topic === undefined) next.topic = sessionTopic;\n\t\t\t\tif (next.chainId === undefined && caipNetworkId !== undefined)\n\t\t\t\t\tnext.chainId = caipNetworkId;\n\t\t\t\t// WalletConnect's UniversalProvider reads the target CAIP chain id from\n\t\t\t\t// the SECOND positional argument of `request(args, chainId)`, not from a\n\t\t\t\t// field on the args object. This AppKit instance has no native eip155\n\t\t\t\t// adapter, so the provider has no default chain — without the positional\n\t\t\t\t// chain id every call is rejected (\"Unsupported chains\" / \"Method not\n\t\t\t\t// found\"). Pass it positionally so the request routes to the session's\n\t\t\t\t// chain.\n\t\t\t\treturn (\n\t\t\t\t\ttarget.request as (a: unknown, chainId?: string) => Promise<unknown>\n\t\t\t\t)(next, caipNetworkId);\n\t\t\t};\n\t\t},\n\t});\n};\n\nconst sameAddresses = (a: string[], b: string[]) =>\n\ta.length === b.length && a.every((addr, i) => addr === b[i]);\n\nconst getWalletConnectAccounts$ = (\n\twallet: LiveWalletConnectWallet,\n): Observable<EthereumAccount[]> => {\n\tconst provider = wallet.appKit.getProvider(\"eip155\");\n\n\tif (!wallet.platforms.includes(\"ethereum\") || !provider?.session)\n\t\treturn of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst caipNetworkId$ = new ReplaySubject<string | undefined>(1);\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\n\t\t\t// AppKit's getAccount(\"eip155\").allAccounts is empty because this AppKit\n\t\t\t// instance has no native eip155 adapter — eip155 runs through the\n\t\t\t// WalletConnect UniversalProvider, so the session is the source of truth\n\t\t\t// (mirrors the polkadot/solana AppKit paths). Accounts are CAIP-10 strings\n\t\t\t// (\"eip155:<chainRef>:<address>\"), one entry per chain, so dedupe to unique\n\t\t\t// addresses. Read live on each change so switching/adding accounts is\n\t\t\t// reflected.\n\t\t\tconst readAddresses = (): string[] => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return [];\n\t\t\t\tconst addresses = new Set<string>();\n\t\t\t\tfor (const raw of getCaip10Addresses(\n\t\t\t\t\tgetSessionCaip10s(session, \"eip155\"),\n\t\t\t\t)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\taddresses.add(getAddress(raw));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// skip malformed CAIP-10 address\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn [...addresses];\n\t\t\t};\n\n\t\t\t// Derive the CAIP network id from the session's eip155 CAIP-10 accounts\n\t\t\t// (\"eip155:<ref>:<addr>\") as a synchronous fallback for eth_chainId.\n\t\t\tconst readCaipNetworkId = (): string | undefined => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return undefined;\n\t\t\t\tfor (const account of getSessionCaip10s(session, \"eip155\")) {\n\t\t\t\t\tconst ref = account.split(\":\")[1];\n\t\t\t\t\tif (ref) return `eip155:${ref}`;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainId: unknown) => {\n\t\t\t\tconst caipNetworkId = toCaipNetworkId(chainId);\n\t\t\t\tif (caipNetworkId) {\n\t\t\t\t\tcaipNetworkId$.next(caipNetworkId);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = () => addresses$.next(readAddresses());\n\n\t\t\tprovider.on(\"chainChanged\", handleChainChanged);\n\t\t\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\tprovider.on(\"session_update\", handleAccountsChanged);\n\t\t\t// Seed the chain id from the session synchronously so the account list can\n\t\t\t// surface even if eth_chainId never resolves; eth_chainId then refines it.\n\t\t\t// Without this seed, combineLatest below never fires when eth_chainId\n\t\t\t// rejects or returns an unparseable value, and the accounts silently never\n\t\t\t// appear (the injected path seeds undefined on failure for the same reason).\n\t\t\tcaipNetworkId$.next(readCaipNetworkId());\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => {});\n\t\t\taddresses$.next(readAddresses());\n\n\t\t\tconst sub = combineLatest([\n\t\t\t\tcaipNetworkId$.pipe(distinctUntilChanged()),\n\t\t\t\taddresses$.pipe(distinctUntilChanged(sameAddresses)),\n\t\t\t])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([caipNetworkId, addresses]) => {\n\t\t\t\t\t\tconst chainId = normalizeEvmChainId(caipNetworkId);\n\t\t\t\t\t\tconst transport = custom(\n\t\t\t\t\t\t\twrapWalletConnectProvider(\n\t\t\t\t\t\t\t\tprovider as unknown as EIP1193Provider,\n\t\t\t\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: legacy\n\t\t\t\t\t\t\t\tprovider.session!.topic,\n\t\t\t\t\t\t\t\tcaipNetworkId,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn addresses.map((addr): EthereumAccount => {\n\t\t\t\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\t\t\t\taccount: addr as `0x${string}`,\n\t\t\t\t\t\t\t\ttransport,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: getWalletAccountId(wallet.id, addr),\n\t\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\t\t\taddress: addr as `0x${string}`,\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"chainChanged\", handleChainChanged);\n\t\t\t\tprovider.off(\"accountsChanged\", handleAccountsChanged);\n\t\t\t\tprovider.off(\"session_update\", handleAccountsChanged);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nexport const getEthereumAccounts$ = (\n\tethereumWallets: Observable<(EthereumWallet | WalletConnectWallet)[]>,\n) =>\n\tcreatePlatformAccounts$({\n\t\twallets$: ethereumWallets,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\t// Re-emit on chain switches, not just account id changes.\n\t\taccountChangeKey: (account) => `${account.id}|${account.chainId ?? \"\"}`,\n\t});\n","import {\n\tcreateStore as createMipdStore,\n\ttype EIP6963ProviderDetail,\n} from \"mipd\";\nimport { Observable, shareReplay } from \"rxjs\";\nimport type { EIP1193Provider } from \"viem\";\nimport { clearCachedObservable } from \"../../utils/getCachedObservable\";\nimport { getWalletId } from \"../../utils/WalletId\";\nimport { isEip1193UserRejection } from \"../errors\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport { requestAccountsOnChain } from \"./accounts\";\nimport type { EthereumInjectedWallet } from \"./types\";\n\n/**\n * Observable that emits EIP-6963 provider details from injected wallets.\n * Returns empty array during SSR since browser wallet APIs are not available.\n */\nconst providersDetails$ = new Observable<EIP6963ProviderDetail[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - mipd requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst mipdStore = createMipdStore();\n\n\t\tconst unsubscribe = mipdStore.subscribe((providerDetails) => {\n\t\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\t\t});\n\n\t\tconst providerDetails = mipdStore.getProviders();\n\n\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tmipdStore.destroy();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getEthereumWallets$ = (store: KheopskitStore) =>\n\tcreateInjectedWallets$<EIP6963ProviderDetail, EthereumInjectedWallet>(store, {\n\t\tsources$: providersDetails$,\n\t\tgetWalletId: (pd) => getWalletId(\"ethereum\", pd.info.rdns),\n\t\tconnect: (pd) => requestAccountsOnChain(pd.provider as EIP1193Provider),\n\t\tisUserRejection: isEip1193UserRejection,\n\t\t// Drop the cached account observable so a later reconnect rebuilds it\n\t\t// against the current provider, not a stale closure.\n\t\tonDisconnected: (walletId) => clearCachedObservable(`accounts:${walletId}`),\n\t\tbuildWallet: ({\n\t\t\tsource: pd,\n\t\t\twalletId,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}) => ({\n\t\t\tplatform: \"ethereum\",\n\t\t\ttype: \"injected\",\n\t\t\tid: walletId,\n\t\t\tname: pd.info.name,\n\t\t\ticon: pd.info.icon,\n\t\t\tprovider: pd.provider as EIP1193Provider,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tisConnected,\n\t\t\tsourceId: pd.info.rdns,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}),\n\t});\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getEthereumAccounts$ } from \"./accounts\";\nimport type { EthereumAccount, EthereumWallet } from \"./types\";\nimport { getEthereumWallets$ } from \"./wallets\";\n\n/**\n * Ethereum platform plugin. Pass to `createKheopskit({ platforms: [ethereum()] })`.\n *\n * @example\n * ```ts\n * import { ethereum } from \"@kheopskit/core/ethereum\";\n * ethereum();\n * ```\n */\nexport const ethereum = (): KheopskitPlatform<\n\t\"ethereum\",\n\tEthereumWallet,\n\tEthereumAccount\n> => ({\n\tplatform: \"ethereum\",\n\tgetWallets$: (ctx: PlatformContext) => getEthereumWallets$(ctx.store),\n\tgetAccounts$: (wallets$) => getEthereumAccounts$(wallets$),\n});\n"],"mappings":";;;;;;;;;AAkCA,MAAM,uBAAuB,UAAuC;CACnE,IAAI,MAAM;CAEV,IAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,SAAS,GACtD,MAAM,IAAI,MAAM,CAAgB;CAGjC,IAAI,OAAO,QAAQ,UAClB,OAAO,OAAO,KAAK,OAAO,GAAG,IAAI,KAAA;CAGlC,IAAI,OAAO,QAAQ,UAClB,OAAO,OAAO,UAAU,GAAG,KAAK,OAAO,IAAI,MAAM,KAAA;CAGlD,IAAI,OAAO,QAAQ,UAAU;EAC5B,MAAM,aAAa,IAAI,KAAK,CAAC,CAAC,YAAY;EAC1C,IAAI,CAAC,YAAY,OAAO,KAAA;EACxB,MAAM,SAAS,WAAW,WAAW,IAAI,IACtC,OAAO,SAAS,YAAY,EAAE,IAC9B,OAAO,SAAS,YAAY,EAAE;EACjC,OAAO,OAAO,MAAM,MAAM,IAAI,KAAA,IAAY;CAC3C;AAGD;AAEA,MAAM,mBAAmB,UAAuC;CAC/D,MAAM,UAAU,oBAAoB,KAAK;CACzC,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY,UAAU;AACtD;AAIA,MAAM,+BAAe,IAAI,QAA2C;AAEpE,MAAM,0BAA0B;AAEhC,MAAM,eAAe,cAAA,GACpBA,KAAAA,eAAAA,EAAAA,GACCC,KAAAA,KAAAA,CACC,SACE,QAAQ,EAAE,QAAQ,cAAc,CAAC,CAAC,CAClC,KAAK,2BAA2B,KAAA,CAAS,IAAA,GAC3CC,KAAAA,MAAAA,CAAM,uBAAuB,CAAC,CAAC,MAAA,GAAKC,KAAAA,IAAAA,OAAU,KAAA,CAAS,CAAC,CACzD,CACD;AAED,MAAa,yBAAyB,OAAO,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KAAAA,YAAAA,CAAgB;CAElC,MAAM,cAAc,UAAU,WAAW,oBAAoB;EAC5D,WAAW,KAAK,eAA0C;CAC3D,CAAC;CAED,MAAM,kBAAkB,UAAU,aAAa;CAE/C,WAAW,KAAK,eAA0C;CAE1D,aAAa;EACZ,YAAY;EACZ,UAAU,QAAQ;CACnB;AACD,CACD,CAAC,CAAC,MAAA,GAAKC,KAAAA,YAAAA,CAAY;CAAE,UAAU;CAAM,YAAY;AAAE,CAAC,CAAC;AAIrD,MAAa,uBAAuB,UACnCC,wBAAAA,uBAAsE,OAAO;CAC5E,UAAU;CACV,cAAc,OAAOC,yBAAAA,YAAY,YAAY,GAAG,KAAK,IAAI;CACzD,UAAU,OAAO,uBAAuB,GAAG,QAA2B;CACtE,iBAAiBC,eAAAA;CAGjB,iBAAiB,aAAaC,yBAAAA,sBAAsB,YAAY,UAAU;CAC1E,cAAc,EACb,QAAQ,IACR,UACA,QACA,OACA,aACA,SACA,kBACM;EACN,UAAU;EACV,MAAM;EACN,IAAI;EACJ,MAAM,GAAG,KAAK;EACd,MAAM,GAAG,KAAK;EACd,UAAU,GAAG;EACb;EACA;EACA;EACA,UAAU,GAAG,KAAK;EAClB;EACA;CACD;AACD,CAAC;;;;;;;;;;;;AC9DF,MAAa,kBAIP;CACL,UAAU;CACV,cAAc,QAAyB,oBAAoB,IAAI,KAAK;CACpE,eAAe,aAAa,qBAAqB,QAAQ;AAC1D"}
package/dist/ethereum.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { d as getCachedObservable$, i as getWalletId, l as clearCachedObservable, n as isWalletConnectWallet, t as isInjectedWallet } from "./types-DcpmEGhO.mjs";
2
- import { d as isEthereumAddress, i as getSessionCaip10s, o as getWalletAccountId, r as getCaip10Addresses, t as createPlatformAccounts$ } from "./platformAccounts-3jM3W1fB.mjs";
1
+ import { g as getCachedObservable$, i as getSessionCaip10s, l as getWalletId, m as clearCachedObservable, o as isInjectedWallet, r as getCaip10Addresses, s as isWalletConnectWallet, t as createPlatformAccounts$ } from "./platformAccounts-sy621l8C.mjs";
2
+ import { o as isEthereumAddress, t as getWalletAccountId } from "./WalletAccountId-6ZXQM_ed.mjs";
3
3
  import { i as isEip1193UserRejection } from "./errors-DszTFbnO.mjs";
4
4
  import { t as createInjectedWallets$ } from "./injectedWallets-CUo7rVqB.mjs";
5
5
  import { Observable, ReplaySubject, combineLatest, distinctUntilChanged, firstValueFrom, map, of, race, shareReplay, tap, timer } from "rxjs";
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as SyncableStorage } from "./storage-D3AwNgqc.mjs";
2
- import { A as getWalletId, C as WalletStatus, D as KheopskitError, E as isWalletConnectWallet, F as parseWalletAccountId, M as parseWalletId, N as WalletAccountId, O as KheopskitErrorCode, P as getWalletAccountId, S as WalletPlatform, T as isInjectedWallet, _ as WalletConnectMetadata, a as CachedAccount, b as WalletConnectWallet, c as KheopskitConfig, d as KheopskitStore, f as KheopskitStoreData, g as PolkadotAccountType, h as PlatformContext, i as BaseWalletAccount, j as isValidWalletId, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, n as AppKitInstance, o as CachedWallet, p as Placeholder, r as BaseWallet, s as ConnectOptions, t as AccountOf, u as KheopskitState, v as WalletConnectPlugin, w as WalletType, x as WalletOf, y as WalletConnectProvider } from "./types-C9aw2FEm.mjs";
3
- import { a as createKheopskit, c as clearAllCachedObservables, n as CreateKheopskitOptions, r as Kheopskit, t as CreateKheopskitConfig } from "./instance-Gv9IDCIY.mjs";
4
- import { i as resolveConfig, r as DEFAULT_STORAGE_KEY } from "./config-qMsgD8tJ.mjs";
2
+ import { A as getWalletId, C as WalletStatus, D as KheopskitError, E as isWalletConnectWallet, F as parseWalletAccountId, M as parseWalletId, N as WalletAccountId, O as KheopskitErrorCode, P as getWalletAccountId, S as WalletPlatform, T as isInjectedWallet, _ as WalletConnectMetadata, a as CachedAccount, b as WalletConnectWallet, c as KheopskitConfig, d as KheopskitStore, f as KheopskitStoreData, g as PolkadotAccountType, h as PlatformContext, i as BaseWalletAccount, j as isValidWalletId, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, n as AppKitInstance, o as CachedWallet, p as Placeholder, r as BaseWallet, s as ConnectOptions, t as AccountOf, u as KheopskitState, v as WalletConnectPlugin, w as WalletType, x as WalletOf, y as WalletConnectProvider } from "./types-BfIzw1fd.mjs";
3
+ import { a as createKheopskit, c as clearAllCachedObservables, n as CreateKheopskitOptions, r as Kheopskit, t as CreateKheopskitConfig } from "./instance-DoOr7mrc.mjs";
4
+ import { i as resolveConfig, r as DEFAULT_STORAGE_KEY } from "./config-rvX2pkqc.mjs";
5
5
  //#region src/utils/isValidAddress.d.ts
6
6
  export declare const isValidAddress: (address: string) => boolean;
7
7
  //#endregion
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as SyncableStorage } from "./storage-D3AwNgqc.js";
2
- import { A as getWalletId, C as WalletStatus, D as KheopskitError, E as isWalletConnectWallet, F as parseWalletAccountId, M as parseWalletId, N as WalletAccountId, O as KheopskitErrorCode, P as getWalletAccountId, S as WalletPlatform, T as isInjectedWallet, _ as WalletConnectMetadata, a as CachedAccount, b as WalletConnectWallet, c as KheopskitConfig, d as KheopskitStore, f as KheopskitStoreData, g as PolkadotAccountType, h as PlatformContext, i as BaseWalletAccount, j as isValidWalletId, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, n as AppKitInstance, o as CachedWallet, p as Placeholder, r as BaseWallet, s as ConnectOptions, t as AccountOf, u as KheopskitState, v as WalletConnectPlugin, w as WalletType, x as WalletOf, y as WalletConnectProvider } from "./types-C9aw2FEm.js";
3
- import { a as createKheopskit, c as clearAllCachedObservables, n as CreateKheopskitOptions, r as Kheopskit, t as CreateKheopskitConfig } from "./instance-CrdktIu7.js";
4
- import { i as resolveConfig, r as DEFAULT_STORAGE_KEY } from "./config-Csp5p0-Z.js";
2
+ import { A as getWalletId, C as WalletStatus, D as KheopskitError, E as isWalletConnectWallet, F as parseWalletAccountId, M as parseWalletId, N as WalletAccountId, O as KheopskitErrorCode, P as getWalletAccountId, S as WalletPlatform, T as isInjectedWallet, _ as WalletConnectMetadata, a as CachedAccount, b as WalletConnectWallet, c as KheopskitConfig, d as KheopskitStore, f as KheopskitStoreData, g as PolkadotAccountType, h as PlatformContext, i as BaseWalletAccount, j as isValidWalletId, k as WalletId, l as KheopskitPlatform, m as PlaceholderWallet, n as AppKitInstance, o as CachedWallet, p as Placeholder, r as BaseWallet, s as ConnectOptions, t as AccountOf, u as KheopskitState, v as WalletConnectPlugin, w as WalletType, x as WalletOf, y as WalletConnectProvider } from "./types-BfIzw1fd.js";
3
+ import { a as createKheopskit, c as clearAllCachedObservables, n as CreateKheopskitOptions, r as Kheopskit, t as CreateKheopskitConfig } from "./instance-BokWUMmA.js";
4
+ import { i as resolveConfig, r as DEFAULT_STORAGE_KEY } from "./config-CubhhFON.js";
5
5
  //#region src/utils/isValidAddress.d.ts
6
6
  export declare const isValidAddress: (address: string) => boolean;
7
7
  //#endregion
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_types = require("./types-DaRMgleZ.js");
3
- const require_platformAccounts = require("./platformAccounts-BcLoaZZb.js");
2
+ const require_platformAccounts = require("./platformAccounts-D8XmOSvD.js");
3
+ const require_WalletAccountId = require("./WalletAccountId-D8Xc13VY.js");
4
4
  const require_errors = require("./errors-B6Z21vkI.js");
5
5
  const require_config = require("./config-B3TqJq0m.js");
6
- const require_instance = require("./instance-4DgSj55G.js");
6
+ const require_instance = require("./instance-CegD47uC.js");
7
7
  exports.DEFAULT_STORAGE_KEY = require_config.DEFAULT_STORAGE_KEY;
8
8
  exports.KheopskitError = require_errors.KheopskitError;
9
- exports.clearAllCachedObservables = require_types.clearAllCachedObservables;
9
+ exports.clearAllCachedObservables = require_platformAccounts.clearAllCachedObservables;
10
10
  exports.createKheopskit = require_instance.createKheopskit;
11
11
  exports.createKheopskitStore = require_instance.createKheopskitStore;
12
12
  exports.getDefaultStore = require_instance.getDefaultStore;
13
13
  exports.getHydratedSnapshot = require_instance.getHydratedSnapshot;
14
- exports.getWalletAccountId = require_platformAccounts.getWalletAccountId;
15
- exports.getWalletId = require_types.getWalletId;
16
- exports.isInjectedWallet = require_types.isInjectedWallet;
17
- exports.isValidAddress = require_platformAccounts.isValidAddress;
18
- exports.isValidWalletId = require_types.isValidWalletId;
19
- exports.isWalletConnectWallet = require_types.isWalletConnectWallet;
20
- exports.parseWalletAccountId = require_platformAccounts.parseWalletAccountId;
21
- exports.parseWalletId = require_types.parseWalletId;
14
+ exports.getWalletAccountId = require_WalletAccountId.getWalletAccountId;
15
+ exports.getWalletId = require_platformAccounts.getWalletId;
16
+ exports.isInjectedWallet = require_platformAccounts.isInjectedWallet;
17
+ exports.isValidAddress = require_WalletAccountId.isValidAddress;
18
+ exports.isValidWalletId = require_platformAccounts.isValidWalletId;
19
+ exports.isWalletConnectWallet = require_platformAccounts.isWalletConnectWallet;
20
+ exports.parseWalletAccountId = require_WalletAccountId.parseWalletAccountId;
21
+ exports.parseWalletId = require_platformAccounts.parseWalletId;
22
22
  exports.resolveConfig = require_config.resolveConfig;