@kheopskit/core 5.0.1 → 5.1.1
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 +216 -343
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +213 -344
- 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 +98 -36
- package/dist/index.d.ts +98 -36
- package/dist/index.js +897 -630
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +881 -631
- 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 -53
- package/dist/internal.d.ts +18 -53
- package/dist/internal.js +9 -32
- package/dist/internal.mjs +3 -32
- package/dist/polkadot.d.mts +37 -36
- package/dist/polkadot.d.ts +37 -36
- package/dist/polkadot.js +179 -294
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +176 -295
- 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 +323 -449
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +316 -449
- 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/types-DKU-SNio.js.map +1 -0
- package/dist/types-jnifAAA0.mjs +104 -0
- package/dist/types-jnifAAA0.mjs.map +1 -0
- package/package.json +12 -12
- package/dist/chunk-4ENHC7G4.js +0 -210
- package/dist/chunk-4ENHC7G4.js.map +0 -1
- package/dist/chunk-6XAZANB5.mjs +0 -450
- package/dist/chunk-6XAZANB5.mjs.map +0 -1
- package/dist/chunk-7QSGAJ4A.mjs +0 -210
- package/dist/chunk-7QSGAJ4A.mjs.map +0 -1
- package/dist/chunk-B4L6GAYD.js +0 -179
- package/dist/chunk-B4L6GAYD.js.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-XQWJM3KC.js +0 -450
- package/dist/chunk-XQWJM3KC.js.map +0 -1
- package/dist/chunk-YDLCHYHH.mjs +0 -179
- package/dist/chunk-YDLCHYHH.mjs.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs.map +0 -1
- package/dist/types-C7V7DGlg.d.mts +0 -349
- package/dist/types-C7V7DGlg.d.ts +0 -349
package/dist/chunk-YDLCHYHH.mjs
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
POLKADOT_EXTENSIONS
|
|
3
|
-
} from "./chunk-BWUUHUDK.mjs";
|
|
4
|
-
import {
|
|
5
|
-
isWalletConnectWallet,
|
|
6
|
-
parseWalletId,
|
|
7
|
-
safeLocalStorage
|
|
8
|
-
} from "./chunk-7QSGAJ4A.mjs";
|
|
9
|
-
|
|
10
|
-
// src/utils/hydrateState.ts
|
|
11
|
-
var lookupWalletIcon = (platform, identifier) => {
|
|
12
|
-
if (platform === "polkadot") {
|
|
13
|
-
return POLKADOT_EXTENSIONS[identifier]?.icon ?? "";
|
|
14
|
-
}
|
|
15
|
-
return "";
|
|
16
|
-
};
|
|
17
|
-
var PendingWalletError = class extends Error {
|
|
18
|
-
constructor(walletId) {
|
|
19
|
-
super(
|
|
20
|
-
`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`
|
|
21
|
-
);
|
|
22
|
-
this.name = "PendingWalletError";
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var hydrateWallet = (cached) => {
|
|
26
|
-
const throwPending = () => {
|
|
27
|
-
throw new PendingWalletError(cached.id);
|
|
28
|
-
};
|
|
29
|
-
if (cached.type === "walletconnect") {
|
|
30
|
-
return {
|
|
31
|
-
id: cached.id,
|
|
32
|
-
type: "walletconnect",
|
|
33
|
-
platforms: [],
|
|
34
|
-
name: cached.name,
|
|
35
|
-
icon: "",
|
|
36
|
-
isConnected: cached.isConnected,
|
|
37
|
-
connect: throwPending,
|
|
38
|
-
disconnect: throwPending
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const { platform, identifier } = parseWalletId(cached.id);
|
|
42
|
-
return {
|
|
43
|
-
id: cached.id,
|
|
44
|
-
platform: cached.platform,
|
|
45
|
-
type: cached.type,
|
|
46
|
-
name: cached.name,
|
|
47
|
-
icon: lookupWalletIcon(platform, identifier),
|
|
48
|
-
isConnected: cached.isConnected,
|
|
49
|
-
connect: throwPending,
|
|
50
|
-
disconnect: throwPending
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
var hydrateAccount = (cached) => ({
|
|
54
|
-
id: cached.id,
|
|
55
|
-
platform: cached.platform,
|
|
56
|
-
address: cached.address,
|
|
57
|
-
name: cached.name,
|
|
58
|
-
walletId: cached.walletId,
|
|
59
|
-
walletName: cached.walletName,
|
|
60
|
-
// Spread (not direct keys) so the extra platform fields don't trip the
|
|
61
|
-
// excess-property check against BaseWalletAccount; they're read back via the
|
|
62
|
-
// platform-specific account types once narrowed by `platform`.
|
|
63
|
-
...cached.platform === "ethereum" && { chainId: cached.chainId },
|
|
64
|
-
...cached.platform === "polkadot" && {
|
|
65
|
-
type: cached.polkadotAccountType
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var serializeWallet = (wallet) => ({
|
|
69
|
-
id: wallet.id,
|
|
70
|
-
// The WalletConnect connector has no platform.
|
|
71
|
-
platform: isWalletConnectWallet(wallet) ? void 0 : wallet.platform,
|
|
72
|
-
type: wallet.type,
|
|
73
|
-
name: wallet.name,
|
|
74
|
-
// Note: icon is NOT stored to save cookie space
|
|
75
|
-
isConnected: wallet.isConnected
|
|
76
|
-
});
|
|
77
|
-
var serializeAccount = (account) => ({
|
|
78
|
-
id: account.id,
|
|
79
|
-
platform: account.platform,
|
|
80
|
-
address: account.address,
|
|
81
|
-
name: account.name,
|
|
82
|
-
chainId: account.platform === "ethereum" ? account.chainId : void 0,
|
|
83
|
-
polkadotAccountType: account.platform === "polkadot" ? account.type : void 0,
|
|
84
|
-
walletId: account.walletId,
|
|
85
|
-
walletName: account.walletName
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// src/utils/iconCache.ts
|
|
89
|
-
var ICON_CACHE_KEY = "kheopskit-icons";
|
|
90
|
-
var memoryCache = null;
|
|
91
|
-
var loadCache = () => {
|
|
92
|
-
if (memoryCache !== null) return memoryCache;
|
|
93
|
-
try {
|
|
94
|
-
const stored = safeLocalStorage.getItem(ICON_CACHE_KEY);
|
|
95
|
-
memoryCache = stored ? JSON.parse(stored) : {};
|
|
96
|
-
} catch {
|
|
97
|
-
memoryCache = {};
|
|
98
|
-
}
|
|
99
|
-
return memoryCache;
|
|
100
|
-
};
|
|
101
|
-
var saveCache = (cache) => {
|
|
102
|
-
try {
|
|
103
|
-
safeLocalStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cache));
|
|
104
|
-
memoryCache = cache;
|
|
105
|
-
} catch {
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var getCachedIcon = (walletId) => {
|
|
109
|
-
const cache = loadCache();
|
|
110
|
-
return cache[walletId] || void 0;
|
|
111
|
-
};
|
|
112
|
-
var setCachedIcons = (icons) => {
|
|
113
|
-
const cache = loadCache();
|
|
114
|
-
let changed = false;
|
|
115
|
-
for (const [walletId, icon] of Object.entries(icons)) {
|
|
116
|
-
if (icon && cache[walletId] !== icon) {
|
|
117
|
-
cache[walletId] = icon;
|
|
118
|
-
changed = true;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (changed) {
|
|
122
|
-
saveCache(cache);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/utils/sortAccounts.ts
|
|
127
|
-
var PLATFORM_ORDER = {
|
|
128
|
-
polkadot: 0,
|
|
129
|
-
ethereum: 1,
|
|
130
|
-
solana: 2
|
|
131
|
-
};
|
|
132
|
-
var byWalletName = (a1, a2) => {
|
|
133
|
-
if (a1.walletName.toLowerCase() === "talisman") return -1;
|
|
134
|
-
if (a2.walletName.toLowerCase() === "talisman") return 1;
|
|
135
|
-
return a1.walletName.localeCompare(a2.walletName);
|
|
136
|
-
};
|
|
137
|
-
var sortAccounts = (a1, a2) => {
|
|
138
|
-
if (a1.platform !== a2.platform)
|
|
139
|
-
return PLATFORM_ORDER[a1.platform] - PLATFORM_ORDER[a2.platform];
|
|
140
|
-
if (a1.walletName !== a2.walletName) return byWalletName(a1, a2);
|
|
141
|
-
if (a1.platform === "polkadot" && a2.platform === "polkadot")
|
|
142
|
-
return a1.name !== a2.name ? (a1.name ?? "").localeCompare(a2.name ?? "") : a1.address.localeCompare(a2.address);
|
|
143
|
-
return a1.id.localeCompare(a2.id);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// src/utils/sortWallets.ts
|
|
147
|
-
var PLATFORM_ORDER2 = {
|
|
148
|
-
polkadot: 0,
|
|
149
|
-
ethereum: 1,
|
|
150
|
-
solana: 2
|
|
151
|
-
};
|
|
152
|
-
var orderOf = (wallet) => isWalletConnectWallet(wallet) ? 3 : PLATFORM_ORDER2[wallet.platform];
|
|
153
|
-
var sortWallets = (w1, w2) => {
|
|
154
|
-
const o1 = orderOf(w1);
|
|
155
|
-
const o2 = orderOf(w2);
|
|
156
|
-
if (o1 !== o2) return o1 - o2;
|
|
157
|
-
if (w1.name.toLowerCase() === "talisman") return -1;
|
|
158
|
-
if (w2.name.toLowerCase() === "talisman") return 1;
|
|
159
|
-
return w1.name.localeCompare(w2.name);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// src/api/platform.ts
|
|
163
|
-
var acceptsCachedAccount = (cached, platforms) => {
|
|
164
|
-
const plugin = platforms.find((p) => p.platform === cached.platform);
|
|
165
|
-
return plugin?.acceptsCachedAccount?.(cached) ?? true;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export {
|
|
169
|
-
hydrateWallet,
|
|
170
|
-
hydrateAccount,
|
|
171
|
-
serializeWallet,
|
|
172
|
-
serializeAccount,
|
|
173
|
-
getCachedIcon,
|
|
174
|
-
setCachedIcons,
|
|
175
|
-
sortAccounts,
|
|
176
|
-
sortWallets,
|
|
177
|
-
acceptsCachedAccount
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=chunk-YDLCHYHH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/hydrateState.ts","../src/utils/iconCache.ts","../src/utils/sortAccounts.ts","../src/utils/sortWallets.ts","../src/api/platform.ts"],"sourcesContent":["import {\n\ttype BaseWallet,\n\ttype BaseWalletAccount,\n\ttype CachedAccount,\n\ttype CachedWallet,\n\tisWalletConnectWallet,\n\ttype PolkadotAccountType,\n\ttype WalletConnectWallet,\n} from \"../api/types\";\nimport { POLKADOT_EXTENSIONS } from \"./polkadotExtensions\";\nimport type { WalletAccountId } from \"./WalletAccountId\";\nimport { parseWalletId, type WalletId } from \"./WalletId\";\n\n/**\n * Looks up the icon for a wallet from known Polkadot extensions only.\n * Ethereum icons will be populated from the localStorage icon cache via the merge function.\n *\n * Note: We DON'T use localStorage icon cache here because hydrateWallet is called\n * during SSR (server) and client hydration. localStorage isn't available on server,\n * so using it would cause a hydration mismatch. Icons for Ethereum wallets will be\n * populated when the hydration buffer merges cached wallets with live wallets.\n */\nconst lookupWalletIcon = (platform: string, identifier: string): string => {\n\t// Only Polkadot extensions have hardcoded icons that are safe for SSR\n\tif (platform === \"polkadot\") {\n\t\treturn POLKADOT_EXTENSIONS[identifier]?.icon ?? \"\";\n\t}\n\t// Ethereum icons come from localStorage or live wallets - not here\n\treturn \"\";\n};\n\n/**\n * Error thrown when trying to use a placeholder wallet that hasn't fully loaded yet.\n */\nclass PendingWalletError extends Error {\n\tconstructor(walletId: string) {\n\t\tsuper(\n\t\t\t`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`,\n\t\t);\n\t\tthis.name = \"PendingWalletError\";\n\t}\n}\n\n/**\n * Converts a CachedWallet to a placeholder wallet for SSR hydration display.\n *\n * The placeholder carries only the SDK-free {@link BaseWallet} fields; the real\n * wallet (with its injected provider/extension/standard-wallet handle) replaces\n * it once it loads. connect/disconnect throw until then.\n */\nexport const hydrateWallet = (\n\tcached: CachedWallet,\n): BaseWallet | WalletConnectWallet => {\n\tconst throwPending = () => {\n\t\tthrow new PendingWalletError(cached.id);\n\t};\n\n\t// The platform-less WalletConnect connector. `appKit`/`platforms` are SDK\n\t// state absent until the live connector loads (cast like other placeholder\n\t// SDK handles); icon is filled from the localStorage cache by the caller.\n\tif (cached.type === \"walletconnect\") {\n\t\treturn {\n\t\t\tid: cached.id,\n\t\t\ttype: \"walletconnect\",\n\t\t\tplatforms: [],\n\t\t\tname: cached.name,\n\t\t\ticon: \"\",\n\t\t\tisConnected: cached.isConnected,\n\t\t\tconnect: throwPending,\n\t\t\tdisconnect: throwPending,\n\t\t} as unknown as WalletConnectWallet;\n\t}\n\n\tconst { platform, identifier } = parseWalletId(cached.id);\n\n\treturn {\n\t\tid: cached.id,\n\t\tplatform: cached.platform as BaseWallet[\"platform\"],\n\t\ttype: cached.type,\n\t\tname: cached.name,\n\t\ticon: lookupWalletIcon(platform, identifier),\n\t\tisConnected: cached.isConnected,\n\t\tconnect: throwPending,\n\t\tdisconnect: throwPending,\n\t};\n};\n\n/**\n * Converts a CachedAccount to a placeholder account for SSR hydration display.\n *\n * The placeholder carries the SDK-free {@link BaseWalletAccount} fields plus the\n * plain, serializable platform data that lives in the cache — Ethereum `chainId`\n * and the Polkadot key `type`. Those render immediately on reload (no blank →\n * value flicker) and match what the live account will report. Only the SDK\n * handles (`client`/`signer`/`polkadotSigner`) are absent until the real account\n * replaces this placeholder; signing stays gated on `isHydrating` until then.\n */\nexport const hydrateAccount = (cached: CachedAccount): BaseWalletAccount => ({\n\tid: cached.id as WalletAccountId,\n\tplatform: cached.platform,\n\taddress: cached.address,\n\tname: cached.name,\n\twalletId: cached.walletId,\n\twalletName: cached.walletName,\n\t// Spread (not direct keys) so the extra platform fields don't trip the\n\t// excess-property check against BaseWalletAccount; they're read back via the\n\t// platform-specific account types once narrowed by `platform`.\n\t...(cached.platform === \"ethereum\" && { chainId: cached.chainId }),\n\t...(cached.platform === \"polkadot\" && {\n\t\ttype: cached.polkadotAccountType,\n\t}),\n});\n\n/**\n * Converts a wallet to a CachedWallet for storage.\n * Only extracts the serializable properties needed for hydration.\n */\nexport const serializeWallet = (\n\twallet: BaseWallet | WalletConnectWallet,\n): CachedWallet => ({\n\tid: wallet.id,\n\t// The WalletConnect connector has no platform.\n\tplatform: isWalletConnectWallet(wallet) ? undefined : wallet.platform,\n\ttype: wallet.type,\n\tname: wallet.name,\n\t// Note: icon is NOT stored to save cookie space\n\tisConnected: wallet.isConnected,\n});\n\n/**\n * Converts an account to a CachedAccount for storage.\n * Only extracts the serializable properties needed for hydration. Platform-only\n * fields (Ethereum chainId, Polkadot key type) are read defensively so this\n * stays SDK-free.\n */\nexport const serializeAccount = (\n\taccount: BaseWalletAccount,\n): CachedAccount => ({\n\tid: account.id,\n\tplatform: account.platform,\n\taddress: account.address,\n\tname: account.name,\n\tchainId:\n\t\taccount.platform === \"ethereum\"\n\t\t\t? (account as { chainId?: number }).chainId\n\t\t\t: undefined,\n\tpolkadotAccountType:\n\t\taccount.platform === \"polkadot\"\n\t\t\t? (account as { type?: PolkadotAccountType }).type\n\t\t\t: undefined,\n\twalletId: account.walletId as WalletId,\n\twalletName: account.walletName,\n});\n","import { safeLocalStorage } from \"./storage\";\n\n/**\n * Storage key for the icon cache in localStorage.\n */\nconst ICON_CACHE_KEY = \"kheopskit-icons\";\n\n/**\n * Icon cache type: a map of wallet ID to icon data URI or URL.\n */\ntype IconCache = Record<string, string>;\n\n/**\n * In-memory cache to avoid repeated localStorage reads.\n */\nlet memoryCache: IconCache | null = null;\n\n/**\n * Loads the icon cache from localStorage.\n */\nconst loadCache = (): IconCache => {\n\tif (memoryCache !== null) return memoryCache;\n\n\ttry {\n\t\tconst stored = safeLocalStorage.getItem(ICON_CACHE_KEY);\n\t\tmemoryCache = stored ? (JSON.parse(stored) as IconCache) : {};\n\t} catch {\n\t\tmemoryCache = {};\n\t}\n\treturn memoryCache;\n};\n\n/**\n * Saves the icon cache to localStorage.\n */\nconst saveCache = (cache: IconCache): void => {\n\ttry {\n\t\tsafeLocalStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cache));\n\t\tmemoryCache = cache;\n\t} catch {\n\t\t// localStorage may be full or unavailable\n\t}\n};\n\n/**\n * Gets a cached icon for a wallet.\n * @param walletId - The wallet ID (e.g., \"ethereum:io.talisman\")\n * @returns The cached icon data URI, or undefined if not cached\n */\nexport const getCachedIcon = (walletId: string): string | undefined => {\n\tconst cache = loadCache();\n\treturn cache[walletId] || undefined;\n};\n\n/**\n * Sets multiple cached icons at once.\n * More efficient than calling setCachedIcon multiple times.\n * @param icons - Map of wallet ID to icon\n */\nexport const setCachedIcons = (icons: Record<string, string>): void => {\n\tconst cache = loadCache();\n\tlet changed = false;\n\n\tfor (const [walletId, icon] of Object.entries(icons)) {\n\t\tif (icon && cache[walletId] !== icon) {\n\t\t\tcache[walletId] = icon;\n\t\t\tchanged = true;\n\t\t}\n\t}\n\n\tif (changed) {\n\t\tsaveCache(cache);\n\t}\n};\n","import type { BaseWalletAccount, WalletPlatform } from \"../api/types\";\n\nconst PLATFORM_ORDER: Record<WalletPlatform, number> = {\n\tpolkadot: 0,\n\tethereum: 1,\n\tsolana: 2,\n};\n\n// Group accounts by wallet, surfacing Talisman first (case-insensitive).\nconst byWalletName = (a1: BaseWalletAccount, a2: BaseWalletAccount) => {\n\tif (a1.walletName.toLowerCase() === \"talisman\") return -1;\n\tif (a2.walletName.toLowerCase() === \"talisman\") return 1;\n\treturn a1.walletName.localeCompare(a2.walletName);\n};\n\nexport const sortAccounts = (a1: BaseWalletAccount, a2: BaseWalletAccount) => {\n\t// Sort by platform first: polkadot, then ethereum, then solana\n\tif (a1.platform !== a2.platform)\n\t\treturn PLATFORM_ORDER[a1.platform] - PLATFORM_ORDER[a2.platform];\n\n\t// Then group by wallet name\n\tif (a1.walletName !== a2.walletName) return byWalletName(a1, a2);\n\n\t// Polkadot accounts expose a friendly name; fall back to address\n\tif (a1.platform === \"polkadot\" && a2.platform === \"polkadot\")\n\t\treturn a1.name !== a2.name\n\t\t\t? (a1.name ?? \"\").localeCompare(a2.name ?? \"\")\n\t\t\t: a1.address.localeCompare(a2.address);\n\n\t// Ethereum and Solana accounts disambiguate by id\n\treturn a1.id.localeCompare(a2.id);\n};\n","import {\n\ttype BaseWallet,\n\tisWalletConnectWallet,\n\ttype WalletConnectWallet,\n\ttype WalletPlatform,\n} from \"../api/types\";\n\nconst PLATFORM_ORDER: Record<WalletPlatform, number> = {\n\tpolkadot: 0,\n\tethereum: 1,\n\tsolana: 2,\n};\n\n// The platform-less WalletConnect connector sorts after all platform wallets.\nconst orderOf = (wallet: BaseWallet | WalletConnectWallet) =>\n\tisWalletConnectWallet(wallet) ? 3 : PLATFORM_ORDER[wallet.platform];\n\nexport const sortWallets = (\n\tw1: BaseWallet | WalletConnectWallet,\n\tw2: BaseWallet | WalletConnectWallet,\n) => {\n\t// Sort by platform first: polkadot, then ethereum, then solana, then WC\n\tconst o1 = orderOf(w1);\n\tconst o2 = orderOf(w2);\n\tif (o1 !== o2) return o1 - o2;\n\n\t// Sort by name, but Talisman first\n\tif (w1.name.toLowerCase() === \"talisman\") return -1;\n\tif (w2.name.toLowerCase() === \"talisman\") return 1;\n\n\treturn w1.name.localeCompare(w2.name);\n};\n","import type { CachedAccount, KheopskitPlatform } from \"./types\";\n\n/**\n * Whether a cached account should survive SSR hydration, per its platform\n * plugin's `acceptsCachedAccount` hook. Plugins without the hook (and platforms\n * with no enabled plugin) accept all — matching the pre-plugin behavior where\n * only Polkadot accounts were filtered (by key type).\n */\nexport const acceptsCachedAccount = (\n\tcached: CachedAccount,\n\tplatforms: readonly KheopskitPlatform[],\n): boolean => {\n\tconst plugin = platforms.find((p) => p.platform === cached.platform);\n\treturn plugin?.acceptsCachedAccount?.(cached) ?? true;\n};\n"],"mappings":"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","names":["PLATFORM_ORDER"]}
|
package/dist/internal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kheopskit/kheopskit/packages/core/dist/internal.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,mvBAAC","file":"/home/runner/work/kheopskit/kheopskit/packages/core/dist/internal.js"}
|
package/dist/internal.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import * as rxjs from 'rxjs';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
type WalletAccountId = string;
|
|
5
|
-
declare const getWalletAccountId: (walletId: string, address: string) => WalletAccountId;
|
|
6
|
-
declare const parseWalletAccountId: (accountId: string) => {
|
|
7
|
-
walletId: string;
|
|
8
|
-
address: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type WalletId = string;
|
|
12
|
-
declare const getWalletId: (platform: WalletPlatform, identifier: string) => WalletId;
|
|
13
|
-
declare const parseWalletId: (walletId: string) => {
|
|
14
|
-
platform: WalletPlatform;
|
|
15
|
-
identifier: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Non-throwing variant of {@link parseWalletId}. Use when validating untrusted
|
|
19
|
-
* input (e.g. cached state persisted by an older version) before parsing.
|
|
20
|
-
*/
|
|
21
|
-
declare const isValidWalletId: (walletId: unknown) => walletId is WalletId;
|
|
22
|
-
|
|
23
|
-
type KheopskitStoreData = {
|
|
24
|
-
autoReconnect?: WalletId[];
|
|
25
|
-
/** Cached wallet state for SSR hydration to prevent UI flash */
|
|
26
|
-
cachedWallets?: CachedWallet[];
|
|
27
|
-
/** Cached account state for SSR hydration to prevent UI flash */
|
|
28
|
-
cachedAccounts?: CachedAccount[];
|
|
29
|
-
};
|
|
30
|
-
type CreateKheopskitStoreOptions = {
|
|
31
|
-
/**
|
|
32
|
-
* Cookie string for SSR hydration.
|
|
33
|
-
* When provided, uses cookieStorage instead of localStorage.
|
|
34
|
-
*/
|
|
35
|
-
ssrCookies?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Custom storage key to namespace the stored data.
|
|
38
|
-
* @default "kheopskit"
|
|
39
|
-
*/
|
|
40
|
-
storageKey?: string;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Creates a kheopskit store with the appropriate storage backend.
|
|
44
|
-
* Uses cookieStorage when ssrCookies is provided (for SSR hydration),
|
|
45
|
-
* otherwise falls back to safeLocalStorage.
|
|
46
|
-
*
|
|
47
|
-
* @param options - Configuration options for the store
|
|
48
|
-
*/
|
|
49
|
-
declare const createKheopskitStore: (options?: CreateKheopskitStoreOptions) => {
|
|
50
|
-
observable: rxjs.Observable<KheopskitStoreData>;
|
|
51
|
-
addEnabledWalletId: (walletId: WalletId) => void;
|
|
52
|
-
removeEnabledWalletId: (walletId: WalletId) => void;
|
|
53
|
-
getCachedState: () => {
|
|
54
|
-
wallets: CachedWallet[];
|
|
55
|
-
accounts: CachedAccount[];
|
|
56
|
-
};
|
|
57
|
-
setCachedState: (wallets: CachedWallet[], accounts: CachedAccount[]) => void;
|
|
58
|
-
};
|
|
59
|
-
type KheopskitStore = ReturnType<typeof createKheopskitStore>;
|
|
60
|
-
/**
|
|
61
|
-
* Gets the default store, creating it on first access.
|
|
62
|
-
* Uses localStorage on client, noop on server.
|
|
63
|
-
* Lazily initialized to avoid SSR issues with module-level code.
|
|
64
|
-
*/
|
|
65
|
-
declare const getDefaultStore: () => KheopskitStore;
|
|
66
|
-
|
|
67
|
-
type WalletPlatform = "polkadot" | "ethereum" | "solana";
|
|
68
|
-
/**
|
|
69
|
-
* Minimal structural view of a WalletConnect `UniversalProvider` — the subset
|
|
70
|
-
* kheopskit reads. Declared locally so core never depends on
|
|
71
|
-
* `@walletconnect/universal-provider`. The concrete instance comes from
|
|
72
|
-
* `@reown/appkit` at runtime.
|
|
73
|
-
*/
|
|
74
|
-
type WalletConnectProvider = {
|
|
75
|
-
session?: {
|
|
76
|
-
topic: string;
|
|
77
|
-
namespaces: Record<string, {
|
|
78
|
-
accounts?: string[];
|
|
79
|
-
}>;
|
|
80
|
-
};
|
|
81
|
-
client: {
|
|
82
|
-
request<T = unknown>(args: {
|
|
83
|
-
topic: string;
|
|
84
|
-
chainId: string;
|
|
85
|
-
request: {
|
|
86
|
-
method: string;
|
|
87
|
-
params: unknown;
|
|
88
|
-
};
|
|
89
|
-
}): Promise<T>;
|
|
90
|
-
};
|
|
91
|
-
request(args: {
|
|
92
|
-
method: string;
|
|
93
|
-
params?: unknown;
|
|
94
|
-
}): Promise<unknown>;
|
|
95
|
-
on(event: string, listener: (...args: unknown[]) => void): void;
|
|
96
|
-
off(event: string, listener: (...args: unknown[]) => void): void;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Minimal structural view of the Reown AppKit instance — the subset kheopskit's
|
|
100
|
-
* account factories use. Exposed as the `appKit` escape hatch on AppKit wallets;
|
|
101
|
-
* cast it to `@reown/appkit`'s `AppKit` type for the full API. Declared locally
|
|
102
|
-
* so core never depends on `@reown/appkit`'s types (it's an optional peer).
|
|
103
|
-
*/
|
|
104
|
-
type AppKitInstance = {
|
|
105
|
-
getProvider<T = WalletConnectProvider>(namespace: string): T | undefined;
|
|
106
|
-
getAccount(namespace: string): {
|
|
107
|
-
allAccounts: {
|
|
108
|
-
address: string;
|
|
109
|
-
}[];
|
|
110
|
-
} | undefined;
|
|
111
|
-
getCaipNetworks(namespace: string): {
|
|
112
|
-
caipNetworkId?: string;
|
|
113
|
-
}[];
|
|
114
|
-
};
|
|
115
|
-
type WalletType = "injected" | "walletconnect";
|
|
116
|
-
type PolkadotAccountType = "sr25519" | "ed25519" | "ecdsa" | "ethereum";
|
|
117
|
-
/**
|
|
118
|
-
* SDK-free fields common to every wallet, regardless of platform. Platform
|
|
119
|
-
* packages (`@kheopskit/core/<platform>`) extend this with SDK-typed fields
|
|
120
|
-
* (the injected provider/extension/standard-wallet handle).
|
|
121
|
-
*/
|
|
122
|
-
type BaseWallet = {
|
|
123
|
-
id: WalletId;
|
|
124
|
-
platform: WalletPlatform;
|
|
125
|
-
type: WalletType;
|
|
126
|
-
name: string;
|
|
127
|
-
icon: string;
|
|
128
|
-
isConnected: boolean;
|
|
129
|
-
connect: () => Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Disconnect the wallet. Resolves once the underlying provider/extension
|
|
132
|
-
* disconnect completes; rejects if it fails so callers can surface or retry.
|
|
133
|
-
*/
|
|
134
|
-
disconnect: () => Promise<void>;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* SDK-free fields common to every account, regardless of platform. Platform
|
|
138
|
-
* packages extend this with their SDK-typed signer/client.
|
|
139
|
-
*/
|
|
140
|
-
type BaseWalletAccount = {
|
|
141
|
-
id: WalletAccountId;
|
|
142
|
-
platform: WalletPlatform;
|
|
143
|
-
/** Base58 (Solana), SS58 (Polkadot) or 0x-hex (Ethereum) address. */
|
|
144
|
-
address: string;
|
|
145
|
-
/** Friendly account name, when the wallet exposes one (e.g. Polkadot). */
|
|
146
|
-
name?: string;
|
|
147
|
-
walletName: string;
|
|
148
|
-
walletId: WalletId;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* The single WalletConnect connector, shared across every platform.
|
|
152
|
-
*
|
|
153
|
-
* Unlike injected wallets, it is **not tied to a platform**: one WalletConnect
|
|
154
|
-
* session spans whichever namespaces the remote wallet approves in a single
|
|
155
|
-
* pairing (a namespace can't be added to a live session afterwards). So there is
|
|
156
|
-
* exactly one of these in `wallets`, discriminated by `type: "walletconnect"`.
|
|
157
|
-
* Its accounts appear in `accounts`, each carrying its own `platform`.
|
|
158
|
-
*/
|
|
159
|
-
type WalletConnectWallet = {
|
|
160
|
-
id: WalletId;
|
|
161
|
-
type: "walletconnect";
|
|
162
|
-
/**
|
|
163
|
-
* Platforms (namespaces) the live session currently carries. Empty until
|
|
164
|
-
* connected; populated with whatever the wallet approved (e.g. just
|
|
165
|
-
* `["ethereum"]`, or `["polkadot", "ethereum"]`).
|
|
166
|
-
*/
|
|
167
|
-
platforms: WalletPlatform[];
|
|
168
|
-
/**
|
|
169
|
-
* Raw Reown AppKit instance, exposed as an escape hatch for advanced use
|
|
170
|
-
* (custom modal control, reading providers directly). Most consumers should
|
|
171
|
-
* use `connect`/`disconnect` and the derived accounts instead.
|
|
172
|
-
*/
|
|
173
|
-
appKit: AppKitInstance;
|
|
174
|
-
name: string;
|
|
175
|
-
icon: string;
|
|
176
|
-
isConnected: boolean;
|
|
177
|
-
connect: () => Promise<void>;
|
|
178
|
-
disconnect: () => Promise<void>;
|
|
179
|
-
};
|
|
180
|
-
/** Narrows a wallet to the platform-less {@link WalletConnectWallet}. */
|
|
181
|
-
declare const isWalletConnectWallet: (wallet: BaseWallet | WalletConnectWallet) => wallet is WalletConnectWallet;
|
|
182
|
-
/**
|
|
183
|
-
* Narrows a wallet to an injected (browser-extension / Wallet Standard) wallet —
|
|
184
|
-
* the complement of {@link isWalletConnectWallet}. `state.wallets` is
|
|
185
|
-
* `(InjectedWallet | WalletConnectWallet)[]`, so use this to recover the
|
|
186
|
-
* injected-only fields when iterating: `platform`, `sourceId`, and the SDK
|
|
187
|
-
* handle (`provider` on Ethereum, `extension` on Polkadot, `wallet` on Solana).
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```ts
|
|
191
|
-
* for (const wallet of wallets.filter(isInjectedWallet)) {
|
|
192
|
-
* console.log(wallet.platform, wallet.sourceId); // typed, no WC widening
|
|
193
|
-
* }
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
declare const isInjectedWallet: <W extends BaseWallet | WalletConnectWallet>(wallet: W) => wallet is Exclude<W, WalletConnectWallet>;
|
|
197
|
-
/**
|
|
198
|
-
* Dapp metadata shown in the WalletConnect modal. Mirrors WalletConnect's
|
|
199
|
-
* `Metadata`, declared locally so core doesn't depend on
|
|
200
|
-
* `@walletconnect/universal-provider`.
|
|
201
|
-
*/
|
|
202
|
-
type WalletConnectMetadata = {
|
|
203
|
-
name: string;
|
|
204
|
-
description: string;
|
|
205
|
-
url: string;
|
|
206
|
-
icons: string[];
|
|
207
|
-
};
|
|
208
|
-
type WalletConnectConfig = {
|
|
209
|
-
projectId: string;
|
|
210
|
-
metadata: WalletConnectMetadata;
|
|
211
|
-
/** Defaults to wss://relay.walletconnect.com */
|
|
212
|
-
relayUrl?: string;
|
|
213
|
-
/**
|
|
214
|
-
* Networks AppKit should enable. Pass `AppKitNetwork[]` from
|
|
215
|
-
* `@reown/appkit/networks` (see
|
|
216
|
-
* https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup).
|
|
217
|
-
* Loosely typed (`unknown`) so core doesn't depend on `@reown/appkit`'s
|
|
218
|
-
* types — the value is forwarded to AppKit as-is.
|
|
219
|
-
*/
|
|
220
|
-
networks: [unknown, ...unknown[]];
|
|
221
|
-
themeMode?: "light" | "dark";
|
|
222
|
-
themeVariables?: Record<string, string | number>;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Context passed to a platform plugin's `getWallets$`. Carries the shared store
|
|
226
|
-
* and the resolved core config (for WalletConnect / debug).
|
|
227
|
-
*/
|
|
228
|
-
type PlatformContext = {
|
|
229
|
-
store: KheopskitStore;
|
|
230
|
-
config: KheopskitConfig;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* A platform plugin. Created by the per-platform factories exported from
|
|
234
|
-
* `@kheopskit/core/polkadot`, `/ethereum`, `/solana`. Core iterates plugins
|
|
235
|
-
* generically and never imports a platform SDK itself.
|
|
236
|
-
*
|
|
237
|
-
* @typeParam TPlatform - the platform discriminant
|
|
238
|
-
* @typeParam TWallet - the platform's wallet type (extends {@link BaseWallet})
|
|
239
|
-
* @typeParam TAccount - the platform's account type (extends {@link BaseWalletAccount})
|
|
240
|
-
*/
|
|
241
|
-
type KheopskitPlatform<TPlatform extends WalletPlatform = WalletPlatform, TWallet extends BaseWallet = BaseWallet, TAccount extends BaseWalletAccount = BaseWalletAccount> = {
|
|
242
|
-
readonly platform: TPlatform;
|
|
243
|
-
getWallets$(ctx: PlatformContext): Observable<TWallet[]>;
|
|
244
|
-
getAccounts$(wallets$: Observable<(TWallet | WalletConnectWallet)[]>): Observable<TAccount[]>;
|
|
245
|
-
/**
|
|
246
|
-
* Optional hydration filter. Cached accounts for which this returns false are
|
|
247
|
-
* dropped during SSR hydration (Polkadot uses it to honour `accountTypes`).
|
|
248
|
-
*/
|
|
249
|
-
acceptsCachedAccount?(cached: CachedAccount): boolean;
|
|
250
|
-
};
|
|
251
|
-
type ElementOf<T> = T extends readonly (infer E)[] ? E : never;
|
|
252
|
-
/** The account type produced by a plugin (inferred from its `getAccounts$`). */
|
|
253
|
-
type AccountOf<T> = T extends {
|
|
254
|
-
getAccounts$: (wallets$: never) => Observable<infer R>;
|
|
255
|
-
} ? ElementOf<R> : never;
|
|
256
|
-
/** The wallet type produced by a plugin (inferred from its `getWallets$`). */
|
|
257
|
-
type WalletOf<T> = T extends {
|
|
258
|
-
getWallets$: (ctx: never) => Observable<infer R>;
|
|
259
|
-
} ? ElementOf<R> : never;
|
|
260
|
-
type KheopskitConfig<P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]> = {
|
|
261
|
-
autoReconnect: boolean;
|
|
262
|
-
/**
|
|
263
|
-
* Platform plugins to enable, e.g. `[polkadot(), solana({ chain })]`.
|
|
264
|
-
* Import factories from `@kheopskit/core/<platform>`.
|
|
265
|
-
*/
|
|
266
|
-
platforms: P;
|
|
267
|
-
walletConnect?: WalletConnectConfig;
|
|
268
|
-
debug: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Custom storage key for persisting wallet connection state.
|
|
271
|
-
* Useful when running multiple kheopskit instances on the same domain
|
|
272
|
-
* to prevent state conflicts between different dapps.
|
|
273
|
-
*
|
|
274
|
-
* @default "kheopskit"
|
|
275
|
-
*/
|
|
276
|
-
storageKey: string;
|
|
277
|
-
/**
|
|
278
|
-
* Grace period in milliseconds to wait for wallets to inject before
|
|
279
|
-
* syncing to actual state. During this period, cached wallet/account
|
|
280
|
-
* state from storage is preserved to prevent UI flashing.
|
|
281
|
-
*
|
|
282
|
-
* Set to 0 to disable hydration buffering.
|
|
283
|
-
*
|
|
284
|
-
* @default 500
|
|
285
|
-
*/
|
|
286
|
-
hydrationGracePeriod: number;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* The current kheopskit state.
|
|
290
|
-
*
|
|
291
|
-
* @remarks
|
|
292
|
-
* While {@link KheopskitState.isHydrating} is `true`, `wallets` and `accounts`
|
|
293
|
-
* may contain cached placeholders restored from storage. The **SDK handles** the
|
|
294
|
-
* platform types advertise (e.g. `account.signer` / `getSigner` on Solana,
|
|
295
|
-
* `account.client` on Ethereum, `wallet.provider` / `extension`) are **absent at
|
|
296
|
-
* runtime even though the types claim them**, and placeholder wallets throw if
|
|
297
|
-
* `connect`/`disconnect` is called. Guard all access to those behind
|
|
298
|
-
* `!isHydrating`.
|
|
299
|
-
*
|
|
300
|
-
* The plain, serializable platform data that is persisted in the cache IS
|
|
301
|
-
* restored on the placeholders (Ethereum `chainId`, Polkadot key `type`), so it
|
|
302
|
-
* renders immediately on reload without flashing. Solana `chains` is not cached,
|
|
303
|
-
* so it remains absent until the live account loads.
|
|
304
|
-
*/
|
|
305
|
-
type KheopskitState<P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]> = {
|
|
306
|
-
wallets: (WalletOf<P[number]> | WalletConnectWallet)[];
|
|
307
|
-
accounts: AccountOf<P[number]>[];
|
|
308
|
-
config: KheopskitConfig<P>;
|
|
309
|
-
/**
|
|
310
|
-
* Whether the state is still being hydrated from cache.
|
|
311
|
-
*
|
|
312
|
-
* During hydration, cached wallets/accounts may be displayed before the
|
|
313
|
-
* actual wallet extensions have injected. See the type-level remarks: while
|
|
314
|
-
* this is `true`, SDK-typed fields (signer/client/provider/extension) are not
|
|
315
|
-
* present at runtime — guard all access behind `!isHydrating`.
|
|
316
|
-
*/
|
|
317
|
-
isHydrating: boolean;
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* Serializable wallet data for SSR hydration cache.
|
|
321
|
-
* Contains only the data needed to render wallet UI without flash.
|
|
322
|
-
* Note: icon is NOT stored to save cookie space - it's looked up at hydration time.
|
|
323
|
-
*/
|
|
324
|
-
type CachedWallet = {
|
|
325
|
-
id: WalletId;
|
|
326
|
-
/** Absent for the platform-less WalletConnect connector. */
|
|
327
|
-
platform?: WalletPlatform;
|
|
328
|
-
type: WalletType;
|
|
329
|
-
name: string;
|
|
330
|
-
isConnected: boolean;
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* Serializable account data for SSR hydration cache.
|
|
334
|
-
* Contains only the data needed to render account UI without flash.
|
|
335
|
-
*/
|
|
336
|
-
type CachedAccount = {
|
|
337
|
-
id: string;
|
|
338
|
-
platform: WalletPlatform;
|
|
339
|
-
address: string;
|
|
340
|
-
name?: string;
|
|
341
|
-
/** Cached chain ID for Ethereum accounts. */
|
|
342
|
-
chainId?: number;
|
|
343
|
-
/** Cached key type for Polkadot accounts. */
|
|
344
|
-
polkadotAccountType?: PolkadotAccountType;
|
|
345
|
-
walletId: WalletId;
|
|
346
|
-
walletName: string;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
export { type AccountOf as A, type BaseWallet as B, type CachedAccount as C, type KheopskitPlatform as K, type PlatformContext as P, type WalletAccountId as W, type WalletId as a, type WalletConnectWallet as b, isWalletConnectWallet as c, type KheopskitConfig as d, createKheopskitStore as e, type KheopskitState as f, type AppKitInstance as g, type BaseWalletAccount as h, isInjectedWallet as i, type CachedWallet as j, type PolkadotAccountType as k, type WalletConnectConfig as l, type WalletConnectMetadata as m, type WalletConnectProvider as n, type WalletOf as o, type WalletPlatform as p, type WalletType as q, getDefaultStore as r, getWalletAccountId as s, getWalletId as t, isValidWalletId as u, parseWalletAccountId as v, parseWalletId as w };
|