@kheopskit/core 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors-Caq2csKx.mjs +181 -0
- package/dist/errors-Caq2csKx.mjs.map +1 -0
- package/dist/errors-DPw6pc2H.js +222 -0
- package/dist/errors-DPw6pc2H.js.map +1 -0
- package/dist/ethereum.d.mts +39 -38
- package/dist/ethereum.d.ts +39 -38
- package/dist/ethereum.js +214 -281
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +211 -282
- package/dist/ethereum.mjs.map +1 -1
- package/dist/{getCachedObservable-C4E8dfMp.d.ts → getCachedObservable-LUq9IfEx.d.mts} +5 -2
- package/dist/{getCachedObservable-C4E8dfMp.d.mts → getCachedObservable-LUq9IfEx.d.ts} +5 -2
- package/dist/iconCache-BSa42Sui.mjs +343 -0
- package/dist/iconCache-BSa42Sui.mjs.map +1 -0
- package/dist/iconCache-DS4zNiP1.js +396 -0
- package/dist/iconCache-DS4zNiP1.js.map +1 -0
- package/dist/index.d.mts +65 -59
- package/dist/index.d.ts +65 -59
- package/dist/index.js +901 -1015
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +885 -1016
- package/dist/index.mjs.map +1 -1
- package/dist/injectedWallets-B1MCxAE9.js +148 -0
- package/dist/injectedWallets-B1MCxAE9.js.map +1 -0
- package/dist/injectedWallets-B3Vysfvr.mjs +119 -0
- package/dist/injectedWallets-B3Vysfvr.mjs.map +1 -0
- package/dist/internal.d.mts +18 -16
- package/dist/internal.d.ts +18 -16
- package/dist/internal.js +9 -20
- package/dist/internal.mjs +3 -20
- package/dist/polkadot.d.mts +37 -36
- package/dist/polkadot.d.ts +37 -36
- package/dist/polkadot.js +178 -220
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +175 -221
- package/dist/polkadot.mjs.map +1 -1
- package/dist/polkadotExtensions-BoVKhNU_.mjs +23 -0
- package/dist/polkadotExtensions-BoVKhNU_.mjs.map +1 -0
- package/dist/polkadotExtensions-y4J9UzYl.js +28 -0
- package/dist/polkadotExtensions-y4J9UzYl.js.map +1 -0
- package/dist/solana.d.mts +50 -48
- package/dist/solana.d.ts +50 -48
- package/dist/solana.js +320 -378
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +314 -379
- package/dist/solana.mjs.map +1 -1
- package/dist/types-Cb-vuEru.d.mts +330 -0
- package/dist/types-Cb-vuEru.d.ts +330 -0
- package/dist/types-DKU-SNio.js +169 -0
- package/dist/{chunk-P7BPHHVV.js.map → types-DKU-SNio.js.map} +1 -1
- package/dist/types-jnifAAA0.mjs +104 -0
- package/dist/types-jnifAAA0.mjs.map +1 -0
- package/package.json +12 -12
- package/dist/chunk-3Y5N4N3Q.mjs +0 -267
- package/dist/chunk-3Y5N4N3Q.mjs.map +0 -1
- package/dist/chunk-BWUUHUDK.mjs +0 -24
- package/dist/chunk-BWUUHUDK.mjs.map +0 -1
- package/dist/chunk-D3EQMFZ2.js +0 -24
- package/dist/chunk-D3EQMFZ2.js.map +0 -1
- package/dist/chunk-DF7EKK4G.mjs +0 -106
- package/dist/chunk-DF7EKK4G.mjs.map +0 -1
- package/dist/chunk-EH73P476.js +0 -106
- package/dist/chunk-EH73P476.js.map +0 -1
- package/dist/chunk-JVSCMJY5.mjs +0 -147
- package/dist/chunk-JVSCMJY5.mjs.map +0 -1
- package/dist/chunk-P7BPHHVV.js +0 -76
- package/dist/chunk-SO64R7Z6.js +0 -267
- package/dist/chunk-SO64R7Z6.js.map +0 -1
- package/dist/chunk-WOPCW2OX.mjs +0 -76
- package/dist/chunk-WOPCW2OX.mjs.map +0 -1
- package/dist/chunk-XOGQMEV2.js +0 -147
- package/dist/chunk-XOGQMEV2.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs.map +0 -1
- package/dist/types-0iDBydsK.d.mts +0 -327
- package/dist/types-0iDBydsK.d.ts +0 -327
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
115
|
+
function _typeof(o) {
|
|
116
|
+
"@babel/helpers - typeof";
|
|
117
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
118
|
+
return typeof o;
|
|
119
|
+
} : function(o) {
|
|
120
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
121
|
+
}, _typeof(o);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
125
|
+
function toPrimitive(t, r) {
|
|
126
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
127
|
+
var e = t[Symbol.toPrimitive];
|
|
128
|
+
if (void 0 !== e) {
|
|
129
|
+
var i = e.call(t, r || "default");
|
|
130
|
+
if ("object" != _typeof(i)) return i;
|
|
131
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
132
|
+
}
|
|
133
|
+
return ("string" === r ? String : Number)(t);
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
137
|
+
function toPropertyKey(t) {
|
|
138
|
+
var i = toPrimitive(t, "string");
|
|
139
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
143
|
+
function _defineProperty(e, r, t) {
|
|
144
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
145
|
+
value: t,
|
|
146
|
+
enumerable: !0,
|
|
147
|
+
configurable: !0,
|
|
148
|
+
writable: !0
|
|
149
|
+
}) : e[r] = t, e;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/api/errors.ts
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown by kheopskit wallet/account operations. Carries a stable
|
|
155
|
+
* {@link KheopskitErrorCode} and, when relevant, the offending wallet id.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* try {
|
|
160
|
+
* await wallet.connect();
|
|
161
|
+
* } catch (error) {
|
|
162
|
+
* if (error instanceof KheopskitError && error.code === "WALLET_ALREADY_CONNECTED") {
|
|
163
|
+
* // ignore
|
|
164
|
+
* } else throw error;
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
var KheopskitError = class extends Error {
|
|
169
|
+
constructor(code, message, options) {
|
|
170
|
+
super(`[kheopskit] ${message}`, { cause: options?.cause });
|
|
171
|
+
_defineProperty(this, "code", void 0);
|
|
172
|
+
_defineProperty(this, "walletId", void 0);
|
|
173
|
+
this.name = "KheopskitError";
|
|
174
|
+
this.code = code;
|
|
175
|
+
this.walletId = options?.walletId;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
//#endregion
|
|
179
|
+
export { isSs58Address as a, isValidAddress as i, getWalletAccountId as n, isSolanaAddress as o, parseWalletAccountId as r, isEthereumAddress as s, KheopskitError as t };
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=errors-Caq2csKx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-Caq2csKx.mjs","names":[],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts","../src/api/errors.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n","import type { WalletId } from \"../utils/WalletId\";\n\n/**\n * Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and\n * branch on `error.code` instead of matching message strings.\n */\nexport type KheopskitErrorCode =\n\t/** `connect()` called on a wallet that is already connected. */\n\t| \"WALLET_ALREADY_CONNECTED\"\n\t/** `disconnect()` called on a wallet that is not connected. */\n\t| \"WALLET_NOT_CONNECTED\"\n\t/** The wallet does not advertise a capability kheopskit needs to proceed. */\n\t| \"FEATURE_NOT_SUPPORTED\"\n\t/** No active WalletConnect session for the requested operation. */\n\t| \"NO_SESSION\"\n\t/** No provider available for the requested namespace. */\n\t| \"NO_PROVIDER\"\n\t/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */\n\t| \"UNSUPPORTED_CHAIN\";\n\n/**\n * Error thrown by kheopskit wallet/account operations. Carries a stable\n * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.\n *\n * @example\n * ```ts\n * try {\n * await wallet.connect();\n * } catch (error) {\n * if (error instanceof KheopskitError && error.code === \"WALLET_ALREADY_CONNECTED\") {\n * // ignore\n * } else throw error;\n * }\n * ```\n */\nexport class KheopskitError extends Error {\n\treadonly code: KheopskitErrorCode;\n\t/** The wallet id this error relates to, when applicable. */\n\treadonly walletId?: WalletId;\n\n\tconstructor(\n\t\tcode: KheopskitErrorCode,\n\t\tmessage: string,\n\t\toptions?: { walletId?: WalletId; cause?: unknown },\n\t) {\n\t\tsuper(`[kheopskit] ${message}`, { cause: options?.cause });\n\t\tthis.name = \"KheopskitError\";\n\t\tthis.code = code;\n\t\tthis.walletId = options?.walletId;\n\t}\n}\n"],"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,IAAI,CAAC,YAAY,KAAK,OAAO,GAAG,OAAO;C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I,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgBA,IAAa,iBAAb,cAAoC,MAAM;CAKzC,YACC,MACA,SACA,SACC;EACD,MAAM,eAAe,WAAW,EAAE,OAAO,SAAS,MAAM,CAAC;EATjD,gBAAA,MAAA,QAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,YAAA,KAAA,CAAA;EAQR,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS;CAC1B;AACD"}
|
|
@@ -0,0 +1,222 @@
|
|
|
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
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
115
|
+
function _typeof(o) {
|
|
116
|
+
"@babel/helpers - typeof";
|
|
117
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
118
|
+
return typeof o;
|
|
119
|
+
} : function(o) {
|
|
120
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
121
|
+
}, _typeof(o);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
125
|
+
function toPrimitive(t, r) {
|
|
126
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
127
|
+
var e = t[Symbol.toPrimitive];
|
|
128
|
+
if (void 0 !== e) {
|
|
129
|
+
var i = e.call(t, r || "default");
|
|
130
|
+
if ("object" != _typeof(i)) return i;
|
|
131
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
132
|
+
}
|
|
133
|
+
return ("string" === r ? String : Number)(t);
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
137
|
+
function toPropertyKey(t) {
|
|
138
|
+
var i = toPrimitive(t, "string");
|
|
139
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
143
|
+
function _defineProperty(e, r, t) {
|
|
144
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
145
|
+
value: t,
|
|
146
|
+
enumerable: !0,
|
|
147
|
+
configurable: !0,
|
|
148
|
+
writable: !0
|
|
149
|
+
}) : e[r] = t, e;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/api/errors.ts
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown by kheopskit wallet/account operations. Carries a stable
|
|
155
|
+
* {@link KheopskitErrorCode} and, when relevant, the offending wallet id.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* try {
|
|
160
|
+
* await wallet.connect();
|
|
161
|
+
* } catch (error) {
|
|
162
|
+
* if (error instanceof KheopskitError && error.code === "WALLET_ALREADY_CONNECTED") {
|
|
163
|
+
* // ignore
|
|
164
|
+
* } else throw error;
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
var KheopskitError = class extends Error {
|
|
169
|
+
constructor(code, message, options) {
|
|
170
|
+
super(`[kheopskit] ${message}`, { cause: options?.cause });
|
|
171
|
+
_defineProperty(this, "code", void 0);
|
|
172
|
+
_defineProperty(this, "walletId", void 0);
|
|
173
|
+
this.name = "KheopskitError";
|
|
174
|
+
this.code = code;
|
|
175
|
+
this.walletId = options?.walletId;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
//#endregion
|
|
179
|
+
Object.defineProperty(exports, "KheopskitError", {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
get: function() {
|
|
182
|
+
return KheopskitError;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(exports, "getWalletAccountId", {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
get: function() {
|
|
188
|
+
return getWalletAccountId;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(exports, "isEthereumAddress", {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get: function() {
|
|
194
|
+
return isEthereumAddress;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
Object.defineProperty(exports, "isSolanaAddress", {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function() {
|
|
200
|
+
return isSolanaAddress;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
Object.defineProperty(exports, "isSs58Address", {
|
|
204
|
+
enumerable: true,
|
|
205
|
+
get: function() {
|
|
206
|
+
return isSs58Address;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
Object.defineProperty(exports, "isValidAddress", {
|
|
210
|
+
enumerable: true,
|
|
211
|
+
get: function() {
|
|
212
|
+
return isValidAddress;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
Object.defineProperty(exports, "parseWalletAccountId", {
|
|
216
|
+
enumerable: true,
|
|
217
|
+
get: function() {
|
|
218
|
+
return parseWalletAccountId;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=errors-DPw6pc2H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-DPw6pc2H.js","names":["base58","base58"],"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSolanaAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts","../src/api/errors.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { blake2b } from \"@noble/hashes/blake2.js\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n","import type { WalletId } from \"../utils/WalletId\";\n\n/**\n * Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and\n * branch on `error.code` instead of matching message strings.\n */\nexport type KheopskitErrorCode =\n\t/** `connect()` called on a wallet that is already connected. */\n\t| \"WALLET_ALREADY_CONNECTED\"\n\t/** `disconnect()` called on a wallet that is not connected. */\n\t| \"WALLET_NOT_CONNECTED\"\n\t/** The wallet does not advertise a capability kheopskit needs to proceed. */\n\t| \"FEATURE_NOT_SUPPORTED\"\n\t/** No active WalletConnect session for the requested operation. */\n\t| \"NO_SESSION\"\n\t/** No provider available for the requested namespace. */\n\t| \"NO_PROVIDER\"\n\t/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */\n\t| \"UNSUPPORTED_CHAIN\";\n\n/**\n * Error thrown by kheopskit wallet/account operations. Carries a stable\n * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.\n *\n * @example\n * ```ts\n * try {\n * await wallet.connect();\n * } catch (error) {\n * if (error instanceof KheopskitError && error.code === \"WALLET_ALREADY_CONNECTED\") {\n * // ignore\n * } else throw error;\n * }\n * ```\n */\nexport class KheopskitError extends Error {\n\treadonly code: KheopskitErrorCode;\n\t/** The wallet id this error relates to, when applicable. */\n\treadonly walletId?: WalletId;\n\n\tconstructor(\n\t\tcode: KheopskitErrorCode,\n\t\tmessage: string,\n\t\toptions?: { walletId?: WalletId; cause?: unknown },\n\t) {\n\t\tsuper(`[kheopskit] ${message}`, { cause: options?.cause });\n\t\tthis.name = \"KheopskitError\";\n\t\tthis.code = code;\n\t\tthis.walletId = options?.walletId;\n\t}\n}\n"],"mappings":";;;;AAEA,MAAM,cAAc;AACpB,MAAM,UAAU,IAAI,YAAY;;;;;AAMhC,MAAM,mBAAmB,YAA6B;CACrD,MAAM,MAAM,QAAQ,MAAM,CAAC;CAC3B,MAAM,QAAA,GAAA,sBAAA,WAAA,CAAkB,QAAQ,OAAO,IAAI,Y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'rxjs';
|
|
5
|
-
|
|
1
|
+
import { C as WalletId, D as WalletAccountId, S as isWalletConnectWallet, _ as WalletConnectWallet, c as KheopskitPlatform, x as isInjectedWallet } from "./types-Cb-vuEru.mjs";
|
|
2
|
+
import { Account, CustomTransport, EIP1193Provider, WalletClient } from "viem";
|
|
3
|
+
//#region src/utils/isEthereumAddress.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* Returns true if `address` is a valid Ethereum address.
|
|
8
6
|
*
|
|
@@ -11,42 +9,44 @@ import 'rxjs';
|
|
|
11
9
|
* accepted as non-checksummed.
|
|
12
10
|
*/
|
|
13
11
|
declare const isEthereumAddress: (address: string) => boolean;
|
|
14
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/api/ethereum/types.d.ts
|
|
15
14
|
type EthereumInjectedWallet = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
platform: "ethereum";
|
|
16
|
+
type: "injected";
|
|
17
|
+
id: WalletId;
|
|
18
|
+
/**
|
|
19
|
+
* Stable identifier of the underlying wallet source. For Ethereum this is the
|
|
20
|
+
* EIP-6963 `rdns`. Named consistently across platforms (Solana: Wallet
|
|
21
|
+
* Standard name; Polkadot: extension identifier).
|
|
22
|
+
*/
|
|
23
|
+
sourceId: string;
|
|
24
|
+
provider: EIP1193Provider;
|
|
25
|
+
name: string;
|
|
26
|
+
icon: string;
|
|
27
|
+
isConnected: boolean;
|
|
28
|
+
connect: () => Promise<void>;
|
|
29
|
+
disconnect: () => Promise<void>;
|
|
31
30
|
};
|
|
32
31
|
type EthereumWallet = EthereumInjectedWallet;
|
|
33
32
|
type EthereumAccount = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
id: WalletAccountId;
|
|
34
|
+
platform: "ethereum";
|
|
35
|
+
/**
|
|
36
|
+
* Signing surface for this account: a viem {@link WalletClient} bound to the
|
|
37
|
+
* wallet's provider (sign/send via viem actions). Per-platform signing
|
|
38
|
+
* surfaces differ — Solana exposes `signer`/`getSigner(chain)`, Polkadot
|
|
39
|
+
* exposes `polkadotSigner`. Absent while `state.isHydrating` is `true`.
|
|
40
|
+
*/
|
|
41
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
42
|
+
address: `0x${string}`;
|
|
43
|
+
/** Current chain ID the wallet is connected to. `undefined` while loading or after provider disconnect. */
|
|
44
|
+
chainId: number | undefined;
|
|
45
|
+
walletName: string;
|
|
46
|
+
walletId: WalletId;
|
|
48
47
|
};
|
|
49
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/api/ethereum/plugin.d.ts
|
|
50
50
|
/**
|
|
51
51
|
* Ethereum platform plugin. Pass to `getKheopskit$({ platforms: [ethereum()] })`.
|
|
52
52
|
*
|
|
@@ -57,5 +57,6 @@ type EthereumAccount = {
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
declare const ethereum: () => KheopskitPlatform<"ethereum", EthereumWallet, EthereumAccount>;
|
|
60
|
-
|
|
61
|
-
export { type EthereumAccount, type EthereumInjectedWallet, type EthereumWallet, ethereum, isEthereumAddress };
|
|
60
|
+
//#endregion
|
|
61
|
+
export { type EthereumAccount, type EthereumInjectedWallet, type EthereumWallet, type WalletConnectWallet, ethereum, isEthereumAddress, isInjectedWallet, isWalletConnectWallet };
|
|
62
|
+
//# sourceMappingURL=ethereum.d.mts.map
|
package/dist/ethereum.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'rxjs';
|
|
5
|
-
|
|
1
|
+
import { C as WalletId, D as WalletAccountId, S as isWalletConnectWallet, _ as WalletConnectWallet, c as KheopskitPlatform, x as isInjectedWallet } from "./types-Cb-vuEru.js";
|
|
2
|
+
import { Account, CustomTransport, EIP1193Provider, WalletClient } from "viem";
|
|
3
|
+
//#region src/utils/isEthereumAddress.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* Returns true if `address` is a valid Ethereum address.
|
|
8
6
|
*
|
|
@@ -11,42 +9,44 @@ import 'rxjs';
|
|
|
11
9
|
* accepted as non-checksummed.
|
|
12
10
|
*/
|
|
13
11
|
declare const isEthereumAddress: (address: string) => boolean;
|
|
14
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/api/ethereum/types.d.ts
|
|
15
14
|
type EthereumInjectedWallet = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
platform: "ethereum";
|
|
16
|
+
type: "injected";
|
|
17
|
+
id: WalletId;
|
|
18
|
+
/**
|
|
19
|
+
* Stable identifier of the underlying wallet source. For Ethereum this is the
|
|
20
|
+
* EIP-6963 `rdns`. Named consistently across platforms (Solana: Wallet
|
|
21
|
+
* Standard name; Polkadot: extension identifier).
|
|
22
|
+
*/
|
|
23
|
+
sourceId: string;
|
|
24
|
+
provider: EIP1193Provider;
|
|
25
|
+
name: string;
|
|
26
|
+
icon: string;
|
|
27
|
+
isConnected: boolean;
|
|
28
|
+
connect: () => Promise<void>;
|
|
29
|
+
disconnect: () => Promise<void>;
|
|
31
30
|
};
|
|
32
31
|
type EthereumWallet = EthereumInjectedWallet;
|
|
33
32
|
type EthereumAccount = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
id: WalletAccountId;
|
|
34
|
+
platform: "ethereum";
|
|
35
|
+
/**
|
|
36
|
+
* Signing surface for this account: a viem {@link WalletClient} bound to the
|
|
37
|
+
* wallet's provider (sign/send via viem actions). Per-platform signing
|
|
38
|
+
* surfaces differ — Solana exposes `signer`/`getSigner(chain)`, Polkadot
|
|
39
|
+
* exposes `polkadotSigner`. Absent while `state.isHydrating` is `true`.
|
|
40
|
+
*/
|
|
41
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
42
|
+
address: `0x${string}`;
|
|
43
|
+
/** Current chain ID the wallet is connected to. `undefined` while loading or after provider disconnect. */
|
|
44
|
+
chainId: number | undefined;
|
|
45
|
+
walletName: string;
|
|
46
|
+
walletId: WalletId;
|
|
48
47
|
};
|
|
49
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/api/ethereum/plugin.d.ts
|
|
50
50
|
/**
|
|
51
51
|
* Ethereum platform plugin. Pass to `getKheopskit$({ platforms: [ethereum()] })`.
|
|
52
52
|
*
|
|
@@ -57,5 +57,6 @@ type EthereumAccount = {
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
declare const ethereum: () => KheopskitPlatform<"ethereum", EthereumWallet, EthereumAccount>;
|
|
60
|
-
|
|
61
|
-
export { type EthereumAccount, type EthereumInjectedWallet, type EthereumWallet, ethereum, isEthereumAddress };
|
|
60
|
+
//#endregion
|
|
61
|
+
export { type EthereumAccount, type EthereumInjectedWallet, type EthereumWallet, type WalletConnectWallet, ethereum, isEthereumAddress, isInjectedWallet, isWalletConnectWallet };
|
|
62
|
+
//# sourceMappingURL=ethereum.d.ts.map
|