@kheopskit/core 5.2.1 → 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +426 -0
- package/MIGRATING_TO_V6.md +837 -0
- package/README.md +628 -11
- package/dist/ethereum.d.mts +12 -6
- package/dist/ethereum.d.ts +12 -6
- package/dist/ethereum.js +13 -10
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +7 -4
- package/dist/ethereum.mjs.map +1 -1
- package/dist/{iconCache-pP2ES4pJ.mjs → iconCache-C-U3IEbP.mjs} +21 -40
- package/dist/iconCache-C-U3IEbP.mjs.map +1 -0
- package/dist/{iconCache-DUtkJlaX.js → iconCache-FR4iy6go.js} +21 -40
- package/dist/iconCache-FR4iy6go.js.map +1 -0
- package/dist/index.d.mts +17 -63
- package/dist/index.d.ts +17 -63
- package/dist/index.js +387 -373
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -369
- package/dist/index.mjs.map +1 -1
- package/dist/injectedWallets-48L-AL1I.mjs +173 -0
- package/dist/injectedWallets-48L-AL1I.mjs.map +1 -0
- package/dist/injectedWallets-Dy8YGKL-.js +178 -0
- package/dist/injectedWallets-Dy8YGKL-.js.map +1 -0
- package/dist/internal.d.mts +3 -27
- package/dist/internal.d.ts +3 -27
- package/dist/internal.js +2 -2
- package/dist/internal.mjs +2 -2
- package/dist/pageLoad-BZ7o8p5R.mjs +24 -0
- package/dist/pageLoad-BZ7o8p5R.mjs.map +1 -0
- package/dist/pageLoad-D1wLeuFG.js +28 -0
- package/dist/pageLoad-D1wLeuFG.js.map +1 -0
- package/dist/platformAccounts-BjIeRcFN.js +321 -0
- package/dist/platformAccounts-BjIeRcFN.js.map +1 -0
- package/dist/platformAccounts-yyRUrnel.mjs +256 -0
- package/dist/platformAccounts-yyRUrnel.mjs.map +1 -0
- package/dist/polkadot.d.mts +127 -11
- package/dist/polkadot.d.ts +127 -11
- package/dist/polkadot.js +171 -107
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +164 -100
- package/dist/polkadot.mjs.map +1 -1
- package/dist/solana.d.mts +11 -5
- package/dist/solana.d.ts +11 -5
- package/dist/solana.js +18 -15
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +7 -4
- package/dist/solana.mjs.map +1 -1
- package/dist/storage-D3AwNgqc.d.mts +27 -0
- package/dist/storage-D3AwNgqc.d.ts +27 -0
- package/dist/testing.d.mts +71 -0
- package/dist/testing.d.ts +71 -0
- package/dist/testing.js +136 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.mjs +131 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/{types-DKU-SNio.js → types-BWHvNFlN.js} +149 -2
- package/dist/types-BWHvNFlN.js.map +1 -0
- package/dist/types-Dkyt9bf4.d.mts +683 -0
- package/dist/types-Dkyt9bf4.d.ts +683 -0
- package/dist/types-Yor672md.mjs +215 -0
- package/dist/types-Yor672md.mjs.map +1 -0
- package/dist/walletconnect.d.mts +41 -0
- package/dist/walletconnect.d.ts +41 -0
- package/dist/walletconnect.js +219 -0
- package/dist/walletconnect.js.map +1 -0
- package/dist/walletconnect.mjs +216 -0
- package/dist/walletconnect.mjs.map +1 -0
- package/package.json +33 -9
- package/dist/errors-BLFP1dQI.mjs +0 -181
- package/dist/errors-BLFP1dQI.mjs.map +0 -1
- package/dist/errors-DYWVPHrR.js +0 -222
- package/dist/errors-DYWVPHrR.js.map +0 -1
- package/dist/iconCache-DUtkJlaX.js.map +0 -1
- package/dist/iconCache-pP2ES4pJ.mjs.map +0 -1
- package/dist/injectedWallets-BqR-_aAy.js +0 -148
- package/dist/injectedWallets-BqR-_aAy.js.map +0 -1
- package/dist/injectedWallets-Uz4hPuoW.mjs +0 -119
- package/dist/injectedWallets-Uz4hPuoW.mjs.map +0 -1
- package/dist/types-Cb-vuEru.d.mts +0 -330
- package/dist/types-Cb-vuEru.d.ts +0 -330
- package/dist/types-DKU-SNio.js.map +0 -1
- package/dist/types-jnifAAA0.mjs +0 -104
- package/dist/types-jnifAAA0.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_types = require("./types-
|
|
1
|
+
const require_types = require("./types-BWHvNFlN.js");
|
|
2
2
|
const require_polkadotExtensions = require("./polkadotExtensions-y4J9UzYl.js");
|
|
3
3
|
//#region src/utils/hydrateState.ts
|
|
4
4
|
/**
|
|
@@ -14,35 +14,22 @@ const lookupWalletIcon = (platform, identifier) => {
|
|
|
14
14
|
if (platform === "polkadot") return require_polkadotExtensions.POLKADOT_EXTENSIONS[identifier]?.icon ?? "";
|
|
15
15
|
return "";
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Error thrown when trying to use a placeholder wallet that hasn't fully loaded yet.
|
|
19
|
-
*/
|
|
20
|
-
var PendingWalletError = class extends Error {
|
|
21
|
-
constructor(walletId) {
|
|
22
|
-
super(`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`);
|
|
23
|
-
this.name = "PendingWalletError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Converts a CachedWallet to a placeholder wallet for SSR hydration display.
|
|
28
|
-
*
|
|
29
|
-
* The placeholder carries only the SDK-free {@link BaseWallet} fields; the real
|
|
30
|
-
* wallet (with its injected provider/extension/standard-wallet handle) replaces
|
|
31
|
-
* it once it loads. connect/disconnect throw until then.
|
|
32
|
-
*/
|
|
33
17
|
const hydrateWallet = (cached) => {
|
|
34
|
-
const
|
|
35
|
-
throw
|
|
18
|
+
const connect = async () => {
|
|
19
|
+
throw require_types.walletPendingError(cached.id);
|
|
36
20
|
};
|
|
21
|
+
const disconnect = async () => {};
|
|
37
22
|
if (cached.type === "walletconnect") return {
|
|
38
23
|
id: cached.id,
|
|
39
24
|
type: "walletconnect",
|
|
40
25
|
platforms: [],
|
|
41
26
|
name: cached.name,
|
|
42
27
|
icon: "",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
status: cached.isConnected ? "connecting" : "disconnected",
|
|
29
|
+
isPlaceholder: true,
|
|
30
|
+
isConnected: false,
|
|
31
|
+
connect,
|
|
32
|
+
disconnect
|
|
46
33
|
};
|
|
47
34
|
const { platform, identifier } = require_types.parseWalletId(cached.id);
|
|
48
35
|
return {
|
|
@@ -51,30 +38,24 @@ const hydrateWallet = (cached) => {
|
|
|
51
38
|
type: cached.type,
|
|
52
39
|
name: cached.name,
|
|
53
40
|
icon: lookupWalletIcon(platform, identifier),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
status: cached.isConnected ? "connecting" : "disconnected",
|
|
42
|
+
isPlaceholder: true,
|
|
43
|
+
isConnected: false,
|
|
44
|
+
connect,
|
|
45
|
+
disconnect
|
|
57
46
|
};
|
|
58
47
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Converts a CachedAccount to a placeholder account for SSR hydration display.
|
|
61
|
-
*
|
|
62
|
-
* The placeholder carries the SDK-free {@link BaseWalletAccount} fields plus the
|
|
63
|
-
* plain, serializable platform data that lives in the cache — Ethereum `chainId`
|
|
64
|
-
* and the Polkadot key `type`. Those render immediately on reload (no blank →
|
|
65
|
-
* value flicker) and match what the live account will report. Only the SDK
|
|
66
|
-
* handles (`client`/`signer`/`txCreator`) are absent until the real account
|
|
67
|
-
* replaces this placeholder; signing stays gated on `isHydrating` until then.
|
|
68
|
-
*/
|
|
69
48
|
const hydrateAccount = (cached) => ({
|
|
70
49
|
id: cached.id,
|
|
50
|
+
isPlaceholder: true,
|
|
71
51
|
platform: cached.platform,
|
|
72
52
|
address: cached.address,
|
|
73
53
|
name: cached.name,
|
|
74
54
|
walletId: cached.walletId,
|
|
75
55
|
walletName: cached.walletName,
|
|
76
56
|
...cached.platform === "ethereum" && { chainId: cached.chainId },
|
|
77
|
-
...cached.platform === "polkadot" && { type: cached.polkadotAccountType }
|
|
57
|
+
...cached.platform === "polkadot" && { type: cached.polkadotAccountType },
|
|
58
|
+
...cached.platform === "solana" && { chains: [] }
|
|
78
59
|
});
|
|
79
60
|
/**
|
|
80
61
|
* Converts a wallet to a CachedWallet for storage.
|
|
@@ -158,14 +139,14 @@ const getSafeLocalStorage = () => {
|
|
|
158
139
|
};
|
|
159
140
|
/**
|
|
160
141
|
* @deprecated Use getSafeLocalStorage() instead. This is kept for backward compatibility.
|
|
161
|
-
* Returns a proxy that lazily initializes on first
|
|
142
|
+
* Returns a proxy that lazily initializes on first use.
|
|
162
143
|
*/
|
|
163
144
|
const safeLocalStorage = {
|
|
164
145
|
getItem: (key) => getSafeLocalStorage().getItem(key),
|
|
165
146
|
setItem: (key, value) => getSafeLocalStorage().setItem(key, value),
|
|
166
147
|
removeItem: (key) => getSafeLocalStorage().removeItem(key),
|
|
167
|
-
subscribe
|
|
168
|
-
return getSafeLocalStorage().subscribe
|
|
148
|
+
get subscribe() {
|
|
149
|
+
return getSafeLocalStorage().subscribe;
|
|
169
150
|
}
|
|
170
151
|
};
|
|
171
152
|
/**
|
|
@@ -393,4 +374,4 @@ Object.defineProperty(exports, "setCachedIcons", {
|
|
|
393
374
|
}
|
|
394
375
|
});
|
|
395
376
|
|
|
396
|
-
//# sourceMappingURL=iconCache-
|
|
377
|
+
//# sourceMappingURL=iconCache-FR4iy6go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconCache-FR4iy6go.js","names":["POLKADOT_EXTENSIONS","walletPendingError","parseWalletId","isWalletConnectWallet"],"sources":["../src/utils/hydrateState.ts","../src/utils/storage.ts","../src/utils/iconCache.ts"],"sourcesContent":["import { walletPendingError } from \"../api/errors\";\nimport {\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\ntype PlaceholderOf<W> = W & { isPlaceholder: true; isConnected: false };\n\nexport const hydrateWallet = (\n\tcached: CachedWallet,\n): PlaceholderOf<BaseWallet | WalletConnectWallet> => {\n\tconst connect = async () => {\n\t\tthrow walletPendingError(cached.id);\n\t};\n\tconst disconnect = async () => {};\n\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\tstatus: cached.isConnected ? \"connecting\" : \"disconnected\",\n\t\t\tisPlaceholder: true,\n\t\t\tisConnected: false,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t};\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\tstatus: cached.isConnected ? \"connecting\" : \"disconnected\",\n\t\tisPlaceholder: true,\n\t\tisConnected: false,\n\t\tconnect,\n\t\tdisconnect,\n\t};\n};\n\nexport const hydrateAccount = (\n\tcached: CachedAccount,\n): BaseWalletAccount & { isPlaceholder: true } => ({\n\tid: cached.id as WalletAccountId,\n\tisPlaceholder: true,\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\t...(cached.platform === \"solana\" && { chains: [] }),\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","export type Storage = {\n\tgetItem: (key: string) => string | null;\n\tsetItem: (key: string, value: string) => void;\n\tremoveItem: (key: string) => void;\n};\n\n/**\n * Extended storage interface with cross-tab sync support.\n */\nexport type SyncableStorage = Storage & {\n\t/**\n\t * Subscribe to storage changes from other tabs.\n\t * Returns an unsubscribe function.\n\t */\n\tsubscribe?: (\n\t\tkey: string,\n\t\tcallback: (value: string | null) => void,\n\t) => () => void;\n};\n\n/**\n * A no-op storage implementation that does nothing.\n * Useful for testing or SSR environments where no storage is needed.\n */\nexport const noopStorage: SyncableStorage = {\n\tgetItem: () => null,\n\tsetItem: () => {},\n\tremoveItem: () => {},\n};\n\n/**\n * Cached localStorage wrapper instance.\n * Lazily initialized on first access to avoid SSR issues.\n */\nlet _safeLocalStorage: SyncableStorage | null = null;\n\n/**\n * Creates the localStorage wrapper, testing for availability.\n * Returns noopStorage if localStorage is unavailable (SSR, private browsing, etc.)\n */\nconst createSafeLocalStorage = (): SyncableStorage => {\n\tif (typeof window === \"undefined\") return noopStorage;\n\n\ttry {\n\t\t// Test that localStorage is accessible (may throw in private browsing)\n\t\tconst testKey = \"__kheopskit_test__\";\n\t\twindow.localStorage.setItem(testKey, testKey);\n\t\twindow.localStorage.removeItem(testKey);\n\n\t\treturn {\n\t\t\tgetItem: (key: string) => window.localStorage.getItem(key),\n\t\t\tsetItem: (key: string, value: string) =>\n\t\t\t\twindow.localStorage.setItem(key, value),\n\t\t\tremoveItem: (key: string) => window.localStorage.removeItem(key),\n\t\t\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\t\t\tconst handler = (event: StorageEvent) => {\n\t\t\t\t\tif (event.key === key) {\n\t\t\t\t\t\tcallback(event.newValue);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.addEventListener(\"storage\", handler);\n\t\t\t\treturn () => window.removeEventListener(\"storage\", handler);\n\t\t\t},\n\t\t};\n\t} catch {\n\t\treturn noopStorage;\n\t}\n};\n\n/**\n * A safe localStorage wrapper that falls back to noopStorage\n * when localStorage is not available (e.g., during SSR).\n * Includes cross-tab sync via the native 'storage' event.\n *\n * Lazily initialized on first access to be SSR-safe.\n */\nexport const getSafeLocalStorage = (): SyncableStorage => {\n\tif (_safeLocalStorage === null) {\n\t\t_safeLocalStorage = createSafeLocalStorage();\n\t}\n\treturn _safeLocalStorage;\n};\n\n/**\n * @deprecated Use getSafeLocalStorage() instead. This is kept for backward compatibility.\n * Returns a proxy that lazily initializes on first use.\n */\nexport const safeLocalStorage: SyncableStorage = {\n\tgetItem: (key: string) => getSafeLocalStorage().getItem(key),\n\tsetItem: (key: string, value: string) =>\n\t\tgetSafeLocalStorage().setItem(key, value),\n\tremoveItem: (key: string) => getSafeLocalStorage().removeItem(key),\n\tget subscribe() {\n\t\treturn getSafeLocalStorage().subscribe;\n\t},\n};\n\n/**\n * Parse a cookie string to extract the value for a specific key.\n * @param cookieString - The full cookie header string (e.g., document.cookie or req.headers.cookie)\n * @param key - The cookie key to find\n * @returns The cookie value or null if not found\n */\nexport const parseCookie = (\n\tcookieString: string | undefined,\n\tkey: string,\n): string | null => {\n\tif (!cookieString) return null;\n\n\tfor (const cookie of cookieString.split(\";\")) {\n\t\tconst [k, ...v] = cookie.split(\"=\");\n\t\tconst cookieKey = k?.trim();\n\t\tif (cookieKey === key) {\n\t\t\ttry {\n\t\t\t\treturn decodeURIComponent(v.join(\"=\").trim());\n\t\t\t} catch {\n\t\t\t\treturn null; // Malformed cookie value\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n};\n\n/**\n * Maximum recommended size for cookie storage (3KB to stay well under 4KB limit).\n *\n * @remarks\n * Cookie storage is subject to browser limits (typically 4KB per cookie).\n * When users connect many wallets, the auto-reconnect list may exceed this limit.\n * If this happens:\n * - A console warning will be logged\n * - Some browsers may silently reject the cookie\n * - Consider using fewer simultaneous wallet connections\n *\n * The stored data includes wallet IDs in format `platform:identifier`\n * (e.g., `polkadot:talisman`, `ethereum:io.metamask`).\n */\nexport const COOKIE_MAX_SIZE = 3 * 1024;\n\n/**\n * BroadcastChannel name for cross-tab cookie sync.\n */\nconst BROADCAST_CHANNEL_NAME = \"kheopskit-storage-sync\";\n\n/**\n * Singleton BroadcastChannel for cross-tab cookie sync.\n * Created once and shared across all cookieStorage instances.\n */\nlet sharedBroadcastChannel: BroadcastChannel | null = null;\n\nconst getBroadcastChannel = (): BroadcastChannel | null => {\n\tif (sharedBroadcastChannel) return sharedBroadcastChannel;\n\tif (typeof BroadcastChannel === \"undefined\") return null;\n\n\ttry {\n\t\tsharedBroadcastChannel = new BroadcastChannel(BROADCAST_CHANNEL_NAME);\n\t} catch {\n\t\t// BroadcastChannel not supported or failed\n\t}\n\treturn sharedBroadcastChannel;\n};\n\n/**\n * Check if the current connection is secure (HTTPS).\n * Must be called at runtime (inside methods) to work correctly after SSR hydration.\n */\nconst isSecureConnection = (): boolean =>\n\ttypeof window !== \"undefined\" && window.location.protocol === \"https:\";\n\n/**\n * A cookie-based storage implementation for SSR environments.\n * Reads cookies from an optional initial cookie string (for SSR hydration),\n * writes to document.cookie on the client.\n *\n * Features:\n * - Secure flag automatically added for HTTPS connections\n * - Cross-tab synchronization via BroadcastChannel API\n * - Size limit warning when data exceeds recommended limits\n *\n * @param initialCookies - Optional cookie string for server-side hydration\n */\nexport const cookieStorage = (initialCookies?: string): SyncableStorage => {\n\treturn {\n\t\tgetItem: (key: string) => {\n\t\t\t// On server, use initialCookies. On client, read from document.cookie\n\t\t\tconst cookieString =\n\t\t\t\ttypeof document !== \"undefined\" ? document.cookie : initialCookies;\n\t\t\treturn parseCookie(cookieString, key);\n\t\t},\n\t\tsetItem: (key: string, value: string) => {\n\t\t\tif (typeof document === \"undefined\") return;\n\n\t\t\t// Warn if value exceeds recommended size\n\t\t\tconst encodedValue = encodeURIComponent(value);\n\t\t\tif (encodedValue.length > COOKIE_MAX_SIZE) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[kheopskit] Cookie value for \"${key}\" exceeds recommended size limit (${encodedValue.length} > ${COOKIE_MAX_SIZE} bytes). ` +\n\t\t\t\t\t\t\"This may cause issues with cookie storage. Consider reducing the number of connected wallets.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set cookie with 1 year expiry\n\t\t\tconst expires = new Date();\n\t\t\texpires.setFullYear(expires.getFullYear() + 1);\n\n\t\t\t// Build cookie string with security attributes\n\t\t\tlet cookieStr = `${key}=${encodedValue};expires=${expires.toUTCString()};path=/;SameSite=Lax`;\n\t\t\tif (isSecureConnection()) {\n\t\t\t\tcookieStr += \";Secure\";\n\t\t\t}\n\n\t\t\t// biome-ignore lint: necessary for cookie storage - direct cookie assignment is the standard API\n\t\t\tdocument.cookie = cookieStr;\n\n\t\t\t// Broadcast change to other tabs\n\t\t\tgetBroadcastChannel()?.postMessage({ type: \"set\", key, value });\n\t\t},\n\t\tremoveItem: (key: string) => {\n\t\t\tif (typeof document === \"undefined\") return;\n\n\t\t\t// Build delete cookie string\n\t\t\tlet cookieStr = `${key}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=Lax`;\n\t\t\tif (isSecureConnection()) {\n\t\t\t\tcookieStr += \";Secure\";\n\t\t\t}\n\n\t\t\t// biome-ignore lint: necessary for cookie storage - direct cookie assignment is the standard API\n\t\t\tdocument.cookie = cookieStr;\n\n\t\t\t// Broadcast change to other tabs\n\t\t\tgetBroadcastChannel()?.postMessage({ type: \"remove\", key });\n\t\t},\n\t\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\t\tconst channel = getBroadcastChannel();\n\t\t\tif (!channel) return () => {};\n\n\t\t\tconst handler = (event: MessageEvent) => {\n\t\t\t\tconst data = event.data as {\n\t\t\t\t\ttype: string;\n\t\t\t\t\tkey: string;\n\t\t\t\t\tvalue?: string;\n\t\t\t\t};\n\t\t\t\tif (data.key === key) {\n\t\t\t\t\tif (data.type === \"set\") {\n\t\t\t\t\t\tcallback(data.value ?? null);\n\t\t\t\t\t} else if (data.type === \"remove\") {\n\t\t\t\t\t\tcallback(null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tchannel.addEventListener(\"message\", handler);\n\t\t\treturn () => {\n\t\t\t\tchannel.removeEventListener(\"message\", handler);\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Cleanup the shared BroadcastChannel used for cross-tab cookie sync.\n * Call this when you're done using cookie storage (e.g., in tests or when unmounting).\n *\n * @remarks\n * In normal browser usage, you typically don't need to call this -\n * the channel will be cleaned up when the page is closed.\n * This is primarily useful for testing environments where multiple\n * test runs may accumulate channels.\n */\nexport const cleanupBroadcastChannel = (): void => {\n\tif (sharedBroadcastChannel) {\n\t\tsharedBroadcastChannel.close();\n\t\tsharedBroadcastChannel = null;\n\t}\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"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,oBAAoB,UAAkB,eAA+B;CAE1E,IAAI,aAAa,YAChB,OAAOA,2BAAAA,oBAAoB,WAAW,EAAE,QAAQ;CAGjD,OAAO;AACR;AAIA,MAAa,iBACZ,WACqD;CACrD,MAAM,UAAU,YAAY;EAC3B,MAAMC,cAAAA,mBAAmB,OAAO,EAAE;CACnC;CACA,MAAM,aAAa,YAAY,CAAC;CAEhC,IAAI,OAAO,SAAS,iBACnB,OAAO;EACN,IAAI,OAAO;EACX,MAAM;EACN,WAAW,CAAC;EACZ,MAAM,OAAO;EACb,MAAM;EACN,QAAQ,OAAO,cAAc,eAAe;EAC5C,eAAe;EACf,aAAa;EACb;EACA;CACD;CAGD,MAAM,EAAE,UAAU,eAAeC,cAAAA,cAAc,OAAO,EAAE;CAExD,OAAO;EACN,IAAI,OAAO;EACX,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,MAAM,OAAO;EACb,MAAM,iBAAiB,UAAU,UAAU;EAC3C,QAAQ,OAAO,cAAc,eAAe;EAC5C,eAAe;EACf,aAAa;EACb;EACA;CACD;AACD;AAEA,MAAa,kBACZ,YACkD;CAClD,IAAI,OAAO;CACX,eAAe;CACf,UAAU,OAAO;CACjB,SAAS,OAAO;CAChB,MAAM,OAAO;CACb,UAAU,OAAO;CACjB,YAAY,OAAO;CAInB,GAAI,OAAO,aAAa,cAAc,EAAE,SAAS,OAAO,QAAQ;CAChE,GAAI,OAAO,aAAa,cAAc,EACrC,MAAM,OAAO,oBACd;CACA,GAAI,OAAO,aAAa,YAAY,EAAE,QAAQ,CAAC,EAAE;AAClD;;;;;AAMA,MAAa,mBACZ,YACmB;CACnB,IAAI,OAAO;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AAOA,MAAa,kBAAkB,UAAwC;CACtE,MAAM,QAAQ,UAAU;CACxB,IAAI,UAAU;CAEd,KAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,KAAK,GAClD,IAAI,QAAQ,MAAM,cAAc,MAAM;EACrC,MAAM,YAAY;EAClB,UAAU;CACX;CAGD,IAAI,SACH,UAAU,KAAK;AAEjB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
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-Dkyt9bf4.mjs";
|
|
2
3
|
import { t as clearAllCachedObservables } from "./getCachedObservable-LUq9IfEx.mjs";
|
|
3
4
|
import { Observable } from "rxjs";
|
|
4
5
|
//#region src/utils/isValidAddress.d.ts
|
|
5
6
|
export declare const isValidAddress: (address: string) => boolean;
|
|
6
7
|
//#endregion
|
|
7
|
-
//#region src/api/appKit.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Clears the cached AppKit observable.
|
|
10
|
-
* Use when configuration changes or for testing purposes.
|
|
11
|
-
* Note: This does NOT destroy the appKit instance created by Reown.
|
|
12
|
-
*/
|
|
13
|
-
export declare const resetAppKitCache: () => void;
|
|
14
|
-
//#endregion
|
|
15
8
|
//#region src/api/config.d.ts
|
|
16
9
|
/**
|
|
17
10
|
* Default storage key for persisting wallet connection state.
|
|
@@ -21,53 +14,13 @@ export declare const resetAppKitCache: () => void;
|
|
|
21
14
|
export declare const DEFAULT_STORAGE_KEY = "kheopskit";
|
|
22
15
|
export declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
|
|
23
16
|
//#endregion
|
|
24
|
-
//#region src/api/errors.d.ts
|
|
25
|
-
/**
|
|
26
|
-
* Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and
|
|
27
|
-
* branch on `error.code` instead of matching message strings.
|
|
28
|
-
*/
|
|
29
|
-
type KheopskitErrorCode =
|
|
30
|
-
/** `connect()` called on a wallet that is already connected. */
|
|
31
|
-
"WALLET_ALREADY_CONNECTED" |
|
|
32
|
-
/** `disconnect()` called on a wallet that is not connected. */
|
|
33
|
-
"WALLET_NOT_CONNECTED" |
|
|
34
|
-
/** The wallet does not advertise a capability kheopskit needs to proceed. */
|
|
35
|
-
"FEATURE_NOT_SUPPORTED" |
|
|
36
|
-
/** No active WalletConnect session for the requested operation. */
|
|
37
|
-
"NO_SESSION" |
|
|
38
|
-
/** No provider available for the requested namespace. */
|
|
39
|
-
"NO_PROVIDER" |
|
|
40
|
-
/** The installed polkadot-api version exposes neither `getTxCreatorFromPjs` (v3) nor `getPolkadotSignerFromPjs` (v2). */
|
|
41
|
-
"UNSUPPORTED_VERSION" |
|
|
42
|
-
/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */
|
|
43
|
-
"UNSUPPORTED_CHAIN";
|
|
44
|
-
/**
|
|
45
|
-
* Error thrown by kheopskit wallet/account operations. Carries a stable
|
|
46
|
-
* {@link KheopskitErrorCode} and, when relevant, the offending wallet id.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* try {
|
|
51
|
-
* await wallet.connect();
|
|
52
|
-
* } catch (error) {
|
|
53
|
-
* if (error instanceof KheopskitError && error.code === "WALLET_ALREADY_CONNECTED") {
|
|
54
|
-
* // ignore
|
|
55
|
-
* } else throw error;
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare class KheopskitError extends Error {
|
|
60
|
-
readonly code: KheopskitErrorCode;
|
|
61
|
-
/** The wallet id this error relates to, when applicable. */
|
|
62
|
-
readonly walletId?: WalletId;
|
|
63
|
-
constructor(code: KheopskitErrorCode, message: string, options?: {
|
|
64
|
-
walletId?: WalletId;
|
|
65
|
-
cause?: unknown;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
17
|
//#region src/api/store.d.ts
|
|
70
18
|
type CreateKheopskitStoreOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Storage backend to persist into. When provided, it takes precedence over
|
|
21
|
+
* `ssrCookies` and localStorage.
|
|
22
|
+
*/
|
|
23
|
+
storage?: SyncableStorage;
|
|
71
24
|
/**
|
|
72
25
|
* Cookie string for SSR hydration.
|
|
73
26
|
* When provided, uses cookieStorage instead of localStorage.
|
|
@@ -81,8 +34,8 @@ type CreateKheopskitStoreOptions = {
|
|
|
81
34
|
};
|
|
82
35
|
/**
|
|
83
36
|
* Creates a kheopskit store with the appropriate storage backend.
|
|
84
|
-
* Uses
|
|
85
|
-
*
|
|
37
|
+
* Uses the given `storage` when provided, else cookieStorage when ssrCookies is
|
|
38
|
+
* provided (for SSR hydration), otherwise safeLocalStorage.
|
|
86
39
|
*
|
|
87
40
|
* @param options - Configuration options for the store
|
|
88
41
|
*/
|
|
@@ -113,16 +66,18 @@ type GetHydratedSnapshotOptions = {
|
|
|
113
66
|
};
|
|
114
67
|
/**
|
|
115
68
|
* Builds the cached-state snapshot every consumer must agree on: read the
|
|
116
|
-
* store's cached state, hydrate wallets/accounts into placeholders,
|
|
117
|
-
*
|
|
118
|
-
*
|
|
69
|
+
* store's cached state, hydrate wallets/accounts into placeholders, apply the
|
|
70
|
+
* `autoReconnect` rule (a cached connected wallet it rejects becomes
|
|
71
|
+
* `disconnected` and loses its cached accounts), filter accounts through each
|
|
72
|
+
* platform plugin's `acceptsCachedAccount` hook, and sort with the same
|
|
73
|
+
* comparators the live pipeline uses.
|
|
119
74
|
*
|
|
120
75
|
* This is the single implementation behind the observable's initial seed and
|
|
121
76
|
* both React snapshot sources (`serverValue`/`initialValue`). They must produce
|
|
122
77
|
* the same shape in the same order or the UI flickers/reorders on reload — by
|
|
123
78
|
* sharing this helper, that agreement holds by construction.
|
|
124
79
|
*/
|
|
125
|
-
export declare const getHydratedSnapshot: (store: KheopskitStore,
|
|
80
|
+
export declare const getHydratedSnapshot: (store: KheopskitStore, config: Pick<KheopskitConfig, "platforms" | "autoReconnect">, options?: GetHydratedSnapshotOptions) => HydratedSnapshot;
|
|
126
81
|
//#endregion
|
|
127
82
|
//#region src/api/kheopskit.d.ts
|
|
128
83
|
/** Options for {@link getKheopskit$}. */
|
|
@@ -134,12 +89,11 @@ export type GetKheopskitOptions = {
|
|
|
134
89
|
*/
|
|
135
90
|
ssrCookies?: string;
|
|
136
91
|
/**
|
|
137
|
-
* An existing store to reuse instead of creating one.
|
|
138
|
-
* most callers omit it. (`@kheopskit/react` passes its provider-scoped store.)
|
|
92
|
+
* An existing store to reuse instead of creating one.
|
|
139
93
|
*/
|
|
140
94
|
store?: ReturnType<typeof createKheopskitStore>;
|
|
141
95
|
};
|
|
142
96
|
export declare const getKheopskit$: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>, options?: GetKheopskitOptions) => Observable<KheopskitState<P>>;
|
|
143
97
|
//#endregion
|
|
144
|
-
export { AccountOf, AppKitInstance, BaseWallet, BaseWalletAccount, CachedAccount, CachedWallet, type GetHydratedSnapshotOptions, type HydratedSnapshot, KheopskitConfig, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, KheopskitStoreData, PlatformContext, PolkadotAccountType, type
|
|
98
|
+
export { AccountOf, AppKitInstance, BaseWallet, BaseWalletAccount, CachedAccount, CachedWallet, ConnectOptions, type GetHydratedSnapshotOptions, type HydratedSnapshot, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, KheopskitStoreData, Placeholder, PlaceholderWallet, PlatformContext, PolkadotAccountType, type SyncableStorage, type WalletAccountId, WalletConnectMetadata, WalletConnectPlugin, WalletConnectProvider, WalletConnectWallet, type WalletId, WalletOf, WalletPlatform, WalletStatus, WalletType, clearAllCachedObservables, getWalletAccountId, getWalletId, isInjectedWallet, isValidWalletId, isWalletConnectWallet, parseWalletAccountId, parseWalletId };
|
|
145
99
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
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-Dkyt9bf4.js";
|
|
2
3
|
import { t as clearAllCachedObservables } from "./getCachedObservable-LUq9IfEx.js";
|
|
3
4
|
import { Observable } from "rxjs";
|
|
4
5
|
//#region src/utils/isValidAddress.d.ts
|
|
5
6
|
export declare const isValidAddress: (address: string) => boolean;
|
|
6
7
|
//#endregion
|
|
7
|
-
//#region src/api/appKit.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Clears the cached AppKit observable.
|
|
10
|
-
* Use when configuration changes or for testing purposes.
|
|
11
|
-
* Note: This does NOT destroy the appKit instance created by Reown.
|
|
12
|
-
*/
|
|
13
|
-
export declare const resetAppKitCache: () => void;
|
|
14
|
-
//#endregion
|
|
15
8
|
//#region src/api/config.d.ts
|
|
16
9
|
/**
|
|
17
10
|
* Default storage key for persisting wallet connection state.
|
|
@@ -21,53 +14,13 @@ export declare const resetAppKitCache: () => void;
|
|
|
21
14
|
export declare const DEFAULT_STORAGE_KEY = "kheopskit";
|
|
22
15
|
export declare const resolveConfig: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>) => KheopskitConfig<P>;
|
|
23
16
|
//#endregion
|
|
24
|
-
//#region src/api/errors.d.ts
|
|
25
|
-
/**
|
|
26
|
-
* Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and
|
|
27
|
-
* branch on `error.code` instead of matching message strings.
|
|
28
|
-
*/
|
|
29
|
-
type KheopskitErrorCode =
|
|
30
|
-
/** `connect()` called on a wallet that is already connected. */
|
|
31
|
-
"WALLET_ALREADY_CONNECTED" |
|
|
32
|
-
/** `disconnect()` called on a wallet that is not connected. */
|
|
33
|
-
"WALLET_NOT_CONNECTED" |
|
|
34
|
-
/** The wallet does not advertise a capability kheopskit needs to proceed. */
|
|
35
|
-
"FEATURE_NOT_SUPPORTED" |
|
|
36
|
-
/** No active WalletConnect session for the requested operation. */
|
|
37
|
-
"NO_SESSION" |
|
|
38
|
-
/** No provider available for the requested namespace. */
|
|
39
|
-
"NO_PROVIDER" |
|
|
40
|
-
/** The installed polkadot-api version exposes neither `getTxCreatorFromPjs` (v3) nor `getPolkadotSignerFromPjs` (v2). */
|
|
41
|
-
"UNSUPPORTED_VERSION" |
|
|
42
|
-
/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */
|
|
43
|
-
"UNSUPPORTED_CHAIN";
|
|
44
|
-
/**
|
|
45
|
-
* Error thrown by kheopskit wallet/account operations. Carries a stable
|
|
46
|
-
* {@link KheopskitErrorCode} and, when relevant, the offending wallet id.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* try {
|
|
51
|
-
* await wallet.connect();
|
|
52
|
-
* } catch (error) {
|
|
53
|
-
* if (error instanceof KheopskitError && error.code === "WALLET_ALREADY_CONNECTED") {
|
|
54
|
-
* // ignore
|
|
55
|
-
* } else throw error;
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare class KheopskitError extends Error {
|
|
60
|
-
readonly code: KheopskitErrorCode;
|
|
61
|
-
/** The wallet id this error relates to, when applicable. */
|
|
62
|
-
readonly walletId?: WalletId;
|
|
63
|
-
constructor(code: KheopskitErrorCode, message: string, options?: {
|
|
64
|
-
walletId?: WalletId;
|
|
65
|
-
cause?: unknown;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
17
|
//#region src/api/store.d.ts
|
|
70
18
|
type CreateKheopskitStoreOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Storage backend to persist into. When provided, it takes precedence over
|
|
21
|
+
* `ssrCookies` and localStorage.
|
|
22
|
+
*/
|
|
23
|
+
storage?: SyncableStorage;
|
|
71
24
|
/**
|
|
72
25
|
* Cookie string for SSR hydration.
|
|
73
26
|
* When provided, uses cookieStorage instead of localStorage.
|
|
@@ -81,8 +34,8 @@ type CreateKheopskitStoreOptions = {
|
|
|
81
34
|
};
|
|
82
35
|
/**
|
|
83
36
|
* Creates a kheopskit store with the appropriate storage backend.
|
|
84
|
-
* Uses
|
|
85
|
-
*
|
|
37
|
+
* Uses the given `storage` when provided, else cookieStorage when ssrCookies is
|
|
38
|
+
* provided (for SSR hydration), otherwise safeLocalStorage.
|
|
86
39
|
*
|
|
87
40
|
* @param options - Configuration options for the store
|
|
88
41
|
*/
|
|
@@ -113,16 +66,18 @@ type GetHydratedSnapshotOptions = {
|
|
|
113
66
|
};
|
|
114
67
|
/**
|
|
115
68
|
* Builds the cached-state snapshot every consumer must agree on: read the
|
|
116
|
-
* store's cached state, hydrate wallets/accounts into placeholders,
|
|
117
|
-
*
|
|
118
|
-
*
|
|
69
|
+
* store's cached state, hydrate wallets/accounts into placeholders, apply the
|
|
70
|
+
* `autoReconnect` rule (a cached connected wallet it rejects becomes
|
|
71
|
+
* `disconnected` and loses its cached accounts), filter accounts through each
|
|
72
|
+
* platform plugin's `acceptsCachedAccount` hook, and sort with the same
|
|
73
|
+
* comparators the live pipeline uses.
|
|
119
74
|
*
|
|
120
75
|
* This is the single implementation behind the observable's initial seed and
|
|
121
76
|
* both React snapshot sources (`serverValue`/`initialValue`). They must produce
|
|
122
77
|
* the same shape in the same order or the UI flickers/reorders on reload — by
|
|
123
78
|
* sharing this helper, that agreement holds by construction.
|
|
124
79
|
*/
|
|
125
|
-
export declare const getHydratedSnapshot: (store: KheopskitStore,
|
|
80
|
+
export declare const getHydratedSnapshot: (store: KheopskitStore, config: Pick<KheopskitConfig, "platforms" | "autoReconnect">, options?: GetHydratedSnapshotOptions) => HydratedSnapshot;
|
|
126
81
|
//#endregion
|
|
127
82
|
//#region src/api/kheopskit.d.ts
|
|
128
83
|
/** Options for {@link getKheopskit$}. */
|
|
@@ -134,12 +89,11 @@ export type GetKheopskitOptions = {
|
|
|
134
89
|
*/
|
|
135
90
|
ssrCookies?: string;
|
|
136
91
|
/**
|
|
137
|
-
* An existing store to reuse instead of creating one.
|
|
138
|
-
* most callers omit it. (`@kheopskit/react` passes its provider-scoped store.)
|
|
92
|
+
* An existing store to reuse instead of creating one.
|
|
139
93
|
*/
|
|
140
94
|
store?: ReturnType<typeof createKheopskitStore>;
|
|
141
95
|
};
|
|
142
96
|
export declare const getKheopskit$: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>, options?: GetKheopskitOptions) => Observable<KheopskitState<P>>;
|
|
143
97
|
//#endregion
|
|
144
|
-
export { AccountOf, AppKitInstance, BaseWallet, BaseWalletAccount, CachedAccount, CachedWallet, type GetHydratedSnapshotOptions, type HydratedSnapshot, KheopskitConfig, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, KheopskitStoreData, PlatformContext, PolkadotAccountType, type
|
|
98
|
+
export { AccountOf, AppKitInstance, BaseWallet, BaseWalletAccount, CachedAccount, CachedWallet, ConnectOptions, type GetHydratedSnapshotOptions, type HydratedSnapshot, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, KheopskitStoreData, Placeholder, PlaceholderWallet, PlatformContext, PolkadotAccountType, type SyncableStorage, type WalletAccountId, WalletConnectMetadata, WalletConnectPlugin, WalletConnectProvider, WalletConnectWallet, type WalletId, WalletOf, WalletPlatform, WalletStatus, WalletType, clearAllCachedObservables, getWalletAccountId, getWalletId, isInjectedWallet, isValidWalletId, isWalletConnectWallet, parseWalletAccountId, parseWalletId };
|
|
145
99
|
//# sourceMappingURL=index.d.ts.map
|