@kheopskit/core 5.0.1 → 5.1.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/dist/{chunk-7QSGAJ4A.mjs → chunk-3Y5N4N3Q.mjs} +119 -62
- package/dist/chunk-3Y5N4N3Q.mjs.map +1 -0
- package/dist/chunk-DF7EKK4G.mjs +106 -0
- package/dist/chunk-DF7EKK4G.mjs.map +1 -0
- package/dist/chunk-EH73P476.js +106 -0
- package/dist/chunk-EH73P476.js.map +1 -0
- package/dist/chunk-JVSCMJY5.mjs +147 -0
- package/dist/chunk-JVSCMJY5.mjs.map +1 -0
- package/dist/chunk-P7BPHHVV.js +76 -0
- package/dist/chunk-P7BPHHVV.js.map +1 -0
- package/dist/{chunk-4ENHC7G4.js → chunk-SO64R7Z6.js} +114 -57
- package/dist/chunk-SO64R7Z6.js.map +1 -0
- package/dist/chunk-WOPCW2OX.mjs +76 -0
- package/dist/chunk-WOPCW2OX.mjs.map +1 -0
- package/dist/chunk-XOGQMEV2.js +147 -0
- package/dist/chunk-XOGQMEV2.js.map +1 -0
- package/dist/ethereum.d.mts +2 -2
- package/dist/ethereum.d.ts +2 -2
- package/dist/ethereum.js +55 -115
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +55 -115
- package/dist/ethereum.mjs.map +1 -1
- package/dist/index.d.mts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +442 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +429 -48
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +2 -39
- package/dist/internal.d.ts +2 -39
- package/dist/internal.js +3 -15
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +6 -18
- package/dist/polkadot.d.mts +2 -2
- package/dist/polkadot.d.ts +2 -2
- package/dist/polkadot.js +75 -148
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +76 -149
- package/dist/polkadot.mjs.map +1 -1
- package/dist/solana.d.mts +2 -2
- package/dist/solana.d.ts +2 -2
- package/dist/solana.js +90 -158
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +86 -154
- package/dist/solana.mjs.map +1 -1
- package/dist/{types-C7V7DGlg.d.ts → types-0iDBydsK.d.mts} +24 -46
- package/dist/{types-C7V7DGlg.d.mts → types-0iDBydsK.d.ts} +24 -46
- package/package.json +1 -1
- 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.map +0 -1
- package/dist/chunk-B4L6GAYD.js +0 -179
- package/dist/chunk-B4L6GAYD.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/ethereum.mjs
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createInjectedWallets$,
|
|
3
|
+
createPlatformAccounts$,
|
|
4
|
+
getCaip10Addresses,
|
|
5
|
+
getSessionCaip10s
|
|
6
|
+
} from "./chunk-JVSCMJY5.mjs";
|
|
7
|
+
import {
|
|
3
8
|
getWalletAccountId,
|
|
4
|
-
isEthereumAddress
|
|
5
|
-
|
|
6
|
-
} from "./chunk-6XAZANB5.mjs";
|
|
9
|
+
isEthereumAddress
|
|
10
|
+
} from "./chunk-DF7EKK4G.mjs";
|
|
7
11
|
import {
|
|
8
12
|
clearCachedObservable,
|
|
9
13
|
getCachedObservable$,
|
|
10
14
|
getWalletId,
|
|
11
15
|
isInjectedWallet,
|
|
12
16
|
isWalletConnectWallet
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WOPCW2OX.mjs";
|
|
14
18
|
|
|
15
19
|
// src/api/ethereum/accounts.ts
|
|
16
20
|
import {
|
|
@@ -20,8 +24,7 @@ import {
|
|
|
20
24
|
Observable,
|
|
21
25
|
of,
|
|
22
26
|
ReplaySubject,
|
|
23
|
-
shareReplay
|
|
24
|
-
switchMap
|
|
27
|
+
shareReplay
|
|
25
28
|
} from "rxjs";
|
|
26
29
|
import {
|
|
27
30
|
createWalletClient,
|
|
@@ -137,15 +140,12 @@ var getWalletConnectAccounts$ = (wallet) => {
|
|
|
137
140
|
const session = provider.session;
|
|
138
141
|
if (!session) return [];
|
|
139
142
|
const addresses = /* @__PURE__ */ new Set();
|
|
140
|
-
for (const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
addresses.add(getAddress(raw));
|
|
147
|
-
} catch {
|
|
148
|
-
}
|
|
143
|
+
for (const raw of getCaip10Addresses(
|
|
144
|
+
getSessionCaip10s(session, "eip155")
|
|
145
|
+
)) {
|
|
146
|
+
try {
|
|
147
|
+
addresses.add(getAddress(raw));
|
|
148
|
+
} catch {
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
return [...addresses];
|
|
@@ -153,12 +153,9 @@ var getWalletConnectAccounts$ = (wallet) => {
|
|
|
153
153
|
const readCaipNetworkId = () => {
|
|
154
154
|
const session = provider.session;
|
|
155
155
|
if (!session) return void 0;
|
|
156
|
-
for (const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const ref = account.split(":")[1];
|
|
160
|
-
if (ref) return `eip155:${ref}`;
|
|
161
|
-
}
|
|
156
|
+
for (const account of getSessionCaip10s(session, "eip155")) {
|
|
157
|
+
const ref = account.split(":")[1];
|
|
158
|
+
if (ref) return `eip155:${ref}`;
|
|
162
159
|
}
|
|
163
160
|
return void 0;
|
|
164
161
|
};
|
|
@@ -216,44 +213,19 @@ var getWalletConnectAccounts$ = (wallet) => {
|
|
|
216
213
|
}).pipe(shareReplay({ refCount: true, bufferSize: 1 }))
|
|
217
214
|
);
|
|
218
215
|
};
|
|
219
|
-
var getEthereumAccounts$ = (ethereumWallets) =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
]) : of([]);
|
|
227
|
-
}),
|
|
228
|
-
map((accounts) => accounts.flat()),
|
|
229
|
-
distinctUntilChanged(isSameAccountsList)
|
|
230
|
-
).subscribe(subscriber);
|
|
231
|
-
return () => {
|
|
232
|
-
sub.unsubscribe();
|
|
233
|
-
};
|
|
234
|
-
}).pipe(
|
|
235
|
-
// logObservable("ethereumAccounts$", true),
|
|
236
|
-
shareReplay({ refCount: true, bufferSize: 1 })
|
|
237
|
-
);
|
|
238
|
-
var isSameAccountsList = (a, b) => {
|
|
239
|
-
if (a.length !== b.length) return false;
|
|
240
|
-
return a.every(
|
|
241
|
-
(account, i) => account.id === b[i]?.id && account.chainId === b[i]?.chainId
|
|
242
|
-
);
|
|
243
|
-
};
|
|
216
|
+
var getEthereumAccounts$ = (ethereumWallets) => createPlatformAccounts$({
|
|
217
|
+
wallets$: ethereumWallets,
|
|
218
|
+
getInjectedAccounts$: getInjectedWalletAccounts$,
|
|
219
|
+
getWalletConnectAccounts$,
|
|
220
|
+
// Re-emit on chain switches, not just account id changes.
|
|
221
|
+
accountChangeKey: (account) => `${account.id}|${account.chainId ?? ""}`
|
|
222
|
+
});
|
|
244
223
|
|
|
245
224
|
// src/api/ethereum/wallets.ts
|
|
246
225
|
import {
|
|
247
226
|
createStore as createMipdStore
|
|
248
227
|
} from "mipd";
|
|
249
|
-
import {
|
|
250
|
-
BehaviorSubject,
|
|
251
|
-
combineLatest as combineLatest2,
|
|
252
|
-
distinctUntilChanged as distinctUntilChanged2,
|
|
253
|
-
map as map2,
|
|
254
|
-
Observable as Observable2,
|
|
255
|
-
shareReplay as shareReplay2
|
|
256
|
-
} from "rxjs";
|
|
228
|
+
import { Observable as Observable2, shareReplay as shareReplay2 } from "rxjs";
|
|
257
229
|
var providersDetails$ = new Observable2(
|
|
258
230
|
(subscriber) => {
|
|
259
231
|
if (typeof window === "undefined") {
|
|
@@ -273,68 +245,36 @@ var providersDetails$ = new Observable2(
|
|
|
273
245
|
};
|
|
274
246
|
}
|
|
275
247
|
).pipe(shareReplay2({ refCount: true, bufferSize: 1 }));
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
"WALLET_ALREADY_CONNECTED",
|
|
282
|
-
`wallet ${walletId} is already connected`,
|
|
283
|
-
{ walletId }
|
|
284
|
-
);
|
|
285
|
-
await provider.request({
|
|
248
|
+
var getEthereumWallets$ = (store) => createInjectedWallets$(store, {
|
|
249
|
+
sources$: providersDetails$,
|
|
250
|
+
getWalletId: (pd) => getWalletId("ethereum", pd.info.rdns),
|
|
251
|
+
connect: async (pd) => {
|
|
252
|
+
await pd.provider.request({
|
|
286
253
|
method: "eth_requestAccounts"
|
|
287
254
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
platform: "ethereum",
|
|
313
|
-
type: "injected",
|
|
314
|
-
id: walletId,
|
|
315
|
-
name: pd.info.name,
|
|
316
|
-
icon: pd.info.icon,
|
|
317
|
-
provider,
|
|
318
|
-
isConnected: enabledWalletIds.has(walletId),
|
|
319
|
-
sourceId: pd.info.rdns,
|
|
320
|
-
connect: () => connectWallet(walletId, provider),
|
|
321
|
-
disconnect: () => disconnectWallet(walletId)
|
|
322
|
-
};
|
|
323
|
-
});
|
|
324
|
-
}),
|
|
325
|
-
distinctUntilChanged2(walletsEqual)
|
|
326
|
-
).subscribe(subscriber);
|
|
327
|
-
return () => {
|
|
328
|
-
sub.unsubscribe();
|
|
329
|
-
};
|
|
330
|
-
}).pipe(shareReplay2({ refCount: true, bufferSize: 1 }));
|
|
331
|
-
var getEthereumWallets$ = (store2 = store) => createEthereumInjectedWallets$(store2);
|
|
332
|
-
var walletsEqual = (a, b) => {
|
|
333
|
-
if (a.length !== b.length) return false;
|
|
334
|
-
return a.every(
|
|
335
|
-
(w, i) => w.id === b[i]?.id && w.isConnected === b[i]?.isConnected && w.name === b[i]?.name
|
|
336
|
-
);
|
|
337
|
-
};
|
|
255
|
+
},
|
|
256
|
+
// Drop the cached account observable so a later reconnect rebuilds it
|
|
257
|
+
// against the current provider, not a stale closure.
|
|
258
|
+
onDisconnected: (walletId) => clearCachedObservable(`accounts:${walletId}`),
|
|
259
|
+
buildWallet: ({
|
|
260
|
+
source: pd,
|
|
261
|
+
walletId,
|
|
262
|
+
isConnected,
|
|
263
|
+
connect,
|
|
264
|
+
disconnect
|
|
265
|
+
}) => ({
|
|
266
|
+
platform: "ethereum",
|
|
267
|
+
type: "injected",
|
|
268
|
+
id: walletId,
|
|
269
|
+
name: pd.info.name,
|
|
270
|
+
icon: pd.info.icon,
|
|
271
|
+
provider: pd.provider,
|
|
272
|
+
isConnected,
|
|
273
|
+
sourceId: pd.info.rdns,
|
|
274
|
+
connect,
|
|
275
|
+
disconnect
|
|
276
|
+
})
|
|
277
|
+
});
|
|
338
278
|
|
|
339
279
|
// src/api/ethereum/plugin.ts
|
|
340
280
|
var ethereum = () => ({
|
package/dist/ethereum.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/ethereum/accounts.ts","../src/api/ethereum/wallets.ts","../src/api/ethereum/plugin.ts"],"sourcesContent":["import {\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\tshareReplay,\n\tswitchMap,\n} from \"rxjs\";\nimport {\n\tcreateWalletClient,\n\tcustom,\n\ttype EIP1193Provider,\n\tgetAddress,\n} from \"viem\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport type { WalletConnectWallet } from \"../types\";\nimport { isWalletConnectWallet } from \"../types\";\nimport type {\n\tEthereumAccount,\n\tEthereumInjectedWallet,\n\tEthereumWallet,\n} from \"./types\";\n\nconst normalizeEvmChainId = (value: unknown): number | undefined => {\n\tlet raw = value;\n\n\tif (typeof raw === \"string\" && raw.startsWith(\"eip155:\")) {\n\t\traw = raw.slice(\"eip155:\".length);\n\t}\n\n\tif (typeof raw === \"bigint\") {\n\t\treturn raw >= 0n ? Number(raw) : undefined;\n\t}\n\n\tif (typeof raw === \"number\") {\n\t\treturn Number.isInteger(raw) && raw >= 0 ? raw : undefined;\n\t}\n\n\tif (typeof raw === \"string\") {\n\t\tconst normalized = raw.trim().toLowerCase();\n\t\tif (!normalized) return undefined;\n\t\tconst parsed = normalized.startsWith(\"0x\")\n\t\t\t? Number.parseInt(normalized, 16)\n\t\t\t: Number.parseInt(normalized, 10);\n\t\treturn Number.isNaN(parsed) ? undefined : parsed;\n\t}\n\n\treturn undefined;\n};\n\nconst toCaipNetworkId = (value: unknown): string | undefined => {\n\tconst chainId = normalizeEvmChainId(value);\n\treturn chainId === undefined ? undefined : `eip155:${chainId}`;\n};\n\nconst getInjectedWalletAccounts$ = (\n\twallet: EthereumInjectedWallet,\n): Observable<EthereumAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\t\t\tconst chainId$ = new ReplaySubject<number | undefined>(1);\n\n\t\t\tconst getAccount = (\n\t\t\t\taddress: string,\n\t\t\t\tchainId: number | undefined,\n\t\t\t): EthereumAccount => {\n\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\taccount: address as `0x${string}`,\n\t\t\t\t\ttransport: custom(wallet.provider as EIP1193Provider),\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\tclient,\n\t\t\t\t\taddress: getAddress(address),\n\t\t\t\t\tchainId,\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = (addrs: string[]) => {\n\t\t\t\taddresses$.next(addrs);\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainIdHex: unknown) => {\n\t\t\t\tchainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t};\n\n\t\t\tconst handleDisconnect = () => {\n\t\t\t\tchainId$.next(undefined);\n\t\t\t};\n\n\t\t\t// Subscribe to provider events\n\t\t\twallet.provider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\twallet.provider.on(\"chainChanged\", handleChainChanged);\n\t\t\twallet.provider.on(\"disconnect\", handleDisconnect);\n\n\t\t\t// Fetch initial values\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_accounts\" })\n\t\t\t\t.then((addrs: string[]) => addresses$.next(addrs))\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(\"Failed to get accounts\", err);\n\t\t\t\t\taddresses$.next([]);\n\t\t\t\t});\n\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => chainId$.next(undefined));\n\n\t\t\t// Combine addresses + chainId into account list\n\t\t\tconst sub = combineLatest([addresses$, chainId$])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([addresses, chainId]) =>\n\t\t\t\t\t\taddresses.map((addr) => getAccount(addr, chainId)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\twallet.provider.removeListener(\n\t\t\t\t\t\"accountsChanged\",\n\t\t\t\t\thandleAccountsChanged,\n\t\t\t\t);\n\t\t\t\twallet.provider.removeListener(\"chainChanged\", handleChainChanged);\n\t\t\t\twallet.provider.removeListener(\"disconnect\", handleDisconnect);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst wrapWalletConnectProvider = (\n\tprovider: EIP1193Provider,\n\tsessionTopic: string,\n\tcaipNetworkId: string | undefined,\n): EIP1193Provider => {\n\treturn new Proxy(provider, {\n\t\tget(target, prop, receiver) {\n\t\t\tif (prop !== \"request\") return Reflect.get(target, prop, receiver);\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: EIP-1193 request args\n\t\t\treturn (args: any) => {\n\t\t\t\tif (!args || typeof args !== \"object\" || !args.method)\n\t\t\t\t\treturn target.request(args);\n\t\t\t\t// Build a new object rather than mutating the caller's args: the\n\t\t\t\t// EIP-1193 request object is owned by viem and may be frozen or reused.\n\t\t\t\tconst next = { ...args };\n\t\t\t\tif (next.topic === undefined) next.topic = sessionTopic;\n\t\t\t\tif (next.chainId === undefined && caipNetworkId !== undefined)\n\t\t\t\t\tnext.chainId = caipNetworkId;\n\t\t\t\t// WalletConnect's UniversalProvider reads the target CAIP chain id from\n\t\t\t\t// the SECOND positional argument of `request(args, chainId)`, not from a\n\t\t\t\t// field on the args object. This AppKit instance has no native eip155\n\t\t\t\t// adapter, so the provider has no default chain — without the positional\n\t\t\t\t// chain id every call is rejected (\"Unsupported chains\" / \"Method not\n\t\t\t\t// found\"). Pass it positionally so the request routes to the session's\n\t\t\t\t// chain.\n\t\t\t\treturn (\n\t\t\t\t\ttarget.request as (a: unknown, chainId?: string) => Promise<unknown>\n\t\t\t\t)(next, caipNetworkId);\n\t\t\t};\n\t\t},\n\t});\n};\n\nconst sameAddresses = (a: string[], b: string[]) =>\n\ta.length === b.length && a.every((addr, i) => addr === b[i]);\n\nconst getWalletConnectAccounts$ = (\n\twallet: WalletConnectWallet,\n): Observable<EthereumAccount[]> => {\n\tconst provider = wallet.appKit.getProvider(\"eip155\");\n\n\tif (!wallet.platforms.includes(\"ethereum\") || !provider?.session)\n\t\treturn of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst caipNetworkId$ = new ReplaySubject<string | undefined>(1);\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\n\t\t\t// AppKit's getAccount(\"eip155\").allAccounts is empty because this AppKit\n\t\t\t// instance has no native eip155 adapter — eip155 runs through the\n\t\t\t// WalletConnect UniversalProvider, so the session is the source of truth\n\t\t\t// (mirrors the polkadot/solana AppKit paths). Accounts are CAIP-10 strings\n\t\t\t// (\"eip155:<chainRef>:<address>\"), one entry per chain, so dedupe to unique\n\t\t\t// addresses. Read live on each change so switching/adding accounts is\n\t\t\t// reflected.\n\t\t\tconst readAddresses = (): string[] => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return [];\n\t\t\t\tconst addresses = new Set<string>();\n\t\t\t\tfor (const namespace of Object.values(session.namespaces)) {\n\t\t\t\t\tfor (const account of namespace.accounts ?? []) {\n\t\t\t\t\t\tif (!account.startsWith(\"eip155:\")) continue;\n\t\t\t\t\t\tconst raw = account.split(\":\")[2];\n\t\t\t\t\t\tif (!raw) continue;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\taddresses.add(getAddress(raw));\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// skip malformed CAIP-10 address\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn [...addresses];\n\t\t\t};\n\n\t\t\t// Derive the CAIP network id from the session's eip155 CAIP-10 accounts\n\t\t\t// (\"eip155:<ref>:<addr>\") as a synchronous fallback for eth_chainId.\n\t\t\tconst readCaipNetworkId = (): string | undefined => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return undefined;\n\t\t\t\tfor (const namespace of Object.values(session.namespaces)) {\n\t\t\t\t\tfor (const account of namespace.accounts ?? []) {\n\t\t\t\t\t\tif (!account.startsWith(\"eip155:\")) continue;\n\t\t\t\t\t\tconst ref = account.split(\":\")[1];\n\t\t\t\t\t\tif (ref) return `eip155:${ref}`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainId: unknown) => {\n\t\t\t\tconst caipNetworkId = toCaipNetworkId(chainId);\n\t\t\t\tif (caipNetworkId) {\n\t\t\t\t\tcaipNetworkId$.next(caipNetworkId);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = () => addresses$.next(readAddresses());\n\n\t\t\tprovider.on(\"chainChanged\", handleChainChanged);\n\t\t\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\tprovider.on(\"session_update\", handleAccountsChanged);\n\t\t\t// Seed the chain id from the session synchronously so the account list can\n\t\t\t// surface even if eth_chainId never resolves; eth_chainId then refines it.\n\t\t\t// Without this seed, combineLatest below never fires when eth_chainId\n\t\t\t// rejects or returns an unparseable value, and the accounts silently never\n\t\t\t// appear (the injected path seeds undefined on failure for the same reason).\n\t\t\tcaipNetworkId$.next(readCaipNetworkId());\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => {});\n\t\t\taddresses$.next(readAddresses());\n\n\t\t\tconst sub = combineLatest([\n\t\t\t\tcaipNetworkId$.pipe(distinctUntilChanged()),\n\t\t\t\taddresses$.pipe(distinctUntilChanged(sameAddresses)),\n\t\t\t])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([caipNetworkId, addresses]) => {\n\t\t\t\t\t\tconst chainId = normalizeEvmChainId(caipNetworkId);\n\t\t\t\t\t\tconst transport = custom(\n\t\t\t\t\t\t\twrapWalletConnectProvider(\n\t\t\t\t\t\t\t\tprovider as unknown as EIP1193Provider,\n\t\t\t\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: legacy\n\t\t\t\t\t\t\t\tprovider.session!.topic,\n\t\t\t\t\t\t\t\tcaipNetworkId,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn addresses.map((addr): EthereumAccount => {\n\t\t\t\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\t\t\t\taccount: addr as `0x${string}`,\n\t\t\t\t\t\t\t\ttransport,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: getWalletAccountId(wallet.id, addr),\n\t\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\t\t\taddress: addr as `0x${string}`,\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"chainChanged\", handleChainChanged);\n\t\t\t\tprovider.off(\"accountsChanged\", handleAccountsChanged);\n\t\t\t\tprovider.off(\"session_update\", handleAccountsChanged);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nexport const getEthereumAccounts$ = (\n\tethereumWallets: Observable<(EthereumWallet | WalletConnectWallet)[]>,\n) =>\n\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\tconst sub = ethereumWallets\n\t\t\t.pipe(\n\t\t\t\tmap((wallets) => wallets.filter((w) => w.isConnected)),\n\t\t\t\tswitchMap((wallets) => {\n\t\t\t\t\treturn wallets.length\n\t\t\t\t\t\t? combineLatest([\n\t\t\t\t\t\t\t\t...wallets\n\t\t\t\t\t\t\t\t\t.filter((w) => w.type === \"injected\")\n\t\t\t\t\t\t\t\t\t.map(getInjectedWalletAccounts$),\n\t\t\t\t\t\t\t\t...wallets\n\t\t\t\t\t\t\t\t\t.filter(isWalletConnectWallet)\n\t\t\t\t\t\t\t\t\t.map(getWalletConnectAccounts$),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: of([]);\n\t\t\t\t}),\n\t\t\t\tmap((accounts) => accounts.flat()),\n\t\t\t\tdistinctUntilChanged(isSameAccountsList),\n\t\t\t)\n\t\t\t.subscribe(subscriber);\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t};\n\t}).pipe(\n\t\t// logObservable(\"ethereumAccounts$\", true),\n\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t);\n\nconst isSameAccountsList = (a: EthereumAccount[], b: EthereumAccount[]) => {\n\tif (a.length !== b.length) return false;\n\treturn a.every(\n\t\t(account, i) =>\n\t\t\taccount.id === b[i]?.id && account.chainId === b[i]?.chainId,\n\t);\n};\n","import {\n\tcreateStore as createMipdStore,\n\ttype EIP6963ProviderDetail,\n} from \"mipd\";\nimport {\n\tBehaviorSubject,\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tmap,\n\tObservable,\n\tshareReplay,\n} from \"rxjs\";\nimport type { EIP1193Provider } from \"viem\";\nimport { clearCachedObservable } from \"../../utils/getCachedObservable\";\nimport { getWalletId, type WalletId } from \"../../utils/WalletId\";\nimport { KheopskitError } from \"../errors\";\nimport { store as defaultStore, type KheopskitStore } from \"../store\";\nimport type { EthereumInjectedWallet } from \"./types\";\n\n/**\n * Observable that emits EIP-6963 provider details from injected wallets.\n * Returns empty array during SSR since browser wallet APIs are not available.\n */\nconst providersDetails$ = new Observable<EIP6963ProviderDetail[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - mipd requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst mipdStore = createMipdStore();\n\n\t\tconst unsubscribe = mipdStore.subscribe((providerDetails) => {\n\t\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\t\t});\n\n\t\tconst providerDetails = mipdStore.getProviders();\n\n\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tmipdStore.destroy();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\nconst createEthereumInjectedWallets$ = (store: KheopskitStore) =>\n\tnew Observable<EthereumInjectedWallet[]>((subscriber) => {\n\t\tconst enabledWalletIds$ = new BehaviorSubject<Set<WalletId>>(new Set());\n\n\t\tconst connectWallet = async (\n\t\t\twalletId: WalletId,\n\t\t\tprovider: EIP1193Provider,\n\t\t) => {\n\t\t\tif (enabledWalletIds$.value.has(walletId))\n\t\t\t\tthrow new KheopskitError(\n\t\t\t\t\t\"WALLET_ALREADY_CONNECTED\",\n\t\t\t\t\t`wallet ${walletId} is already connected`,\n\t\t\t\t\t{ walletId },\n\t\t\t\t);\n\n\t\t\tawait provider.request({\n\t\t\t\tmethod: \"eth_requestAccounts\",\n\t\t\t});\n\n\t\t\tconst newSet = new Set(enabledWalletIds$.value);\n\t\t\tnewSet.add(walletId);\n\t\t\tenabledWalletIds$.next(newSet);\n\n\t\t\tstore.addEnabledWalletId(walletId);\n\t\t};\n\n\t\tconst disconnectWallet = async (walletId: WalletId) => {\n\t\t\tif (!enabledWalletIds$.value.has(walletId))\n\t\t\t\tthrow new KheopskitError(\n\t\t\t\t\t\"WALLET_NOT_CONNECTED\",\n\t\t\t\t\t`wallet ${walletId} is not connected`,\n\t\t\t\t\t{ walletId },\n\t\t\t\t);\n\t\t\tconst newSet = new Set(enabledWalletIds$.value);\n\t\t\tnewSet.delete(walletId);\n\t\t\tenabledWalletIds$.next(newSet);\n\n\t\t\tstore.removeEnabledWalletId(walletId);\n\n\t\t\t// Drop the cached account observable so a later reconnect rebuilds it\n\t\t\t// against the current provider, not a stale closure.\n\t\t\tclearCachedObservable(`accounts:${walletId}`);\n\t\t};\n\n\t\tconst sub = combineLatest([providersDetails$, enabledWalletIds$])\n\t\t\t.pipe(\n\t\t\t\tmap(([providerDetails, enabledWalletIds]) => {\n\t\t\t\t\treturn providerDetails.map((pd): EthereumInjectedWallet => {\n\t\t\t\t\t\tconst walletId = getWalletId(\"ethereum\", pd.info.rdns);\n\t\t\t\t\t\tconst provider = pd.provider as EIP1193Provider;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\ttype: \"injected\",\n\t\t\t\t\t\t\tid: walletId,\n\t\t\t\t\t\t\tname: pd.info.name,\n\t\t\t\t\t\t\ticon: pd.info.icon,\n\t\t\t\t\t\t\tprovider,\n\t\t\t\t\t\t\tisConnected: enabledWalletIds.has(walletId),\n\t\t\t\t\t\t\tsourceId: pd.info.rdns,\n\t\t\t\t\t\t\tconnect: () => connectWallet(walletId, provider),\n\t\t\t\t\t\t\tdisconnect: () => disconnectWallet(walletId),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t\tdistinctUntilChanged(walletsEqual),\n\t\t\t)\n\t\t\t.subscribe(subscriber);\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t};\n\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getEthereumWallets$ = (store: KheopskitStore = defaultStore) =>\n\tcreateEthereumInjectedWallets$(store);\n\n/**\n * Compare two wallet arrays by their relevant properties (not functions).\n */\nconst walletsEqual = (\n\ta: EthereumInjectedWallet[],\n\tb: EthereumInjectedWallet[],\n): boolean => {\n\tif (a.length !== b.length) return false;\n\treturn a.every(\n\t\t(w, i) =>\n\t\t\tw.id === b[i]?.id &&\n\t\t\tw.isConnected === b[i]?.isConnected &&\n\t\t\tw.name === b[i]?.name,\n\t);\n};\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getEthereumAccounts$ } from \"./accounts\";\nimport type { EthereumAccount, EthereumWallet } from \"./types\";\nimport { getEthereumWallets$ } from \"./wallets\";\n\n/**\n * Ethereum platform plugin. Pass to `getKheopskit$({ platforms: [ethereum()] })`.\n *\n * @example\n * ```ts\n * import { ethereum } from \"@kheopskit/core/ethereum\";\n * ethereum();\n * ```\n */\nexport const ethereum = (): KheopskitPlatform<\n\t\"ethereum\",\n\tEthereumWallet,\n\tEthereumAccount\n> => ({\n\tplatform: \"ethereum\",\n\tgetWallets$: (ctx: PlatformContext) => getEthereumWallets$(ctx.store),\n\tgetAccounts$: (wallets$) => getEthereumAccounts$(wallets$),\n});\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EAEA;AAAA,OACM;AAWP,IAAM,sBAAsB,CAAC,UAAuC;AACnE,MAAI,MAAM;AAEV,MAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,SAAS,GAAG;AACzD,UAAM,IAAI,MAAM,UAAU,MAAM;AAAA,EACjC;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,OAAO,KAAK,OAAO,GAAG,IAAI;AAAA,EAClC;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,OAAO,UAAU,GAAG,KAAK,OAAO,IAAI,MAAM;AAAA,EAClD;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC5B,UAAM,aAAa,IAAI,KAAK,EAAE,YAAY;AAC1C,QAAI,CAAC,WAAY,QAAO;AACxB,UAAM,SAAS,WAAW,WAAW,IAAI,IACtC,OAAO,SAAS,YAAY,EAAE,IAC9B,OAAO,SAAS,YAAY,EAAE;AACjC,WAAO,OAAO,MAAM,MAAM,IAAI,SAAY;AAAA,E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BAAiB,CAAC,EAC9D;AAAA,IACAC,KAAI,CAAC,CAAC,iBAAiB,gBAAgB,MAAM;AAC5C,aAAO,gBAAgB,IAAI,CAAC,OAA+B;AAC1D,cAAM,WAAW,YAAY,YAAY,GAAG,KAAK,IAAI;AACrD,cAAM,WAAW,GAAG;AAEpB,eAAO;AAAA,UACN,UAAU;AAAA,UACV,MAAM;AAAA,UACN,IAAI;AAAA,UACJ,MAAM,GAAG,KAAK;AAAA,UACd,MAAM,GAAG,KAAK;AAAA,UACd;AAAA,UACA,aAAa,iBAAiB,IAAI,QAAQ;AAAA,UAC1C,UAAU,GAAG,KAAK;AAAA,UAClB,SAAS,MAAM,cAAc,UAAU,QAAQ;AAAA,UAC/C,YAAY,MAAM,iBAAiB,QAAQ;AAAA,QAC5C;AAAA,MACD,CAAC;AAAA,IACF,CAAC;AAAA,IACDC,sBAAqB,YAAY;AAAA,EAClC,EACC,UAAU,UAAU;AAEtB,SAAO,MAAM;AACZ,QAAI,YAAY;AAAA,EACjB;AACD,CAAC,EAAE,KAAKJ,aAAY,EAAE,UAAU,MAAM,YAAY,EAAE,CAAC,CAAC;AAIhD,IAAM,sBAAsB,CAACC,SAAwB,UAC3D,+BAA+BA,MAAK;AAKrC,IAAM,eAAe,CACpB,GACA,MACa;AACb,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,SAAO,EAAE;AAAA,IACR,CAAC,GAAG,MACH,EAAE,OAAO,EAAE,CAAC,GAAG,MACf,EAAE,gBAAgB,EAAE,CAAC,GAAG,eACxB,EAAE,SAAS,EAAE,CAAC,GAAG;AAAA,EACnB;AACD;;;AC/HO,IAAM,WAAW,OAIlB;AAAA,EACL,UAAU;AAAA,EACV,aAAa,CAAC,QAAyB,oBAAoB,IAAI,KAAK;AAAA,EACpE,cAAc,CAAC,aAAa,qBAAqB,QAAQ;AAC1D;","names":["combineLatest","distinctUntilChanged","map","Observable","shareReplay","Observable","providerDetails","shareReplay","store","combineLatest","map","distinctUntilChanged"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/ethereum/accounts.ts","../src/api/ethereum/wallets.ts","../src/api/ethereum/plugin.ts"],"sourcesContent":["import {\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\tshareReplay,\n} from \"rxjs\";\nimport {\n\tcreateWalletClient,\n\tcustom,\n\ttype EIP1193Provider,\n\tgetAddress,\n} from \"viem\";\nimport { getWalletAccountId } from \"../../utils\";\nimport { getCachedObservable$ } from \"../../utils/getCachedObservable\";\nimport {\n\tcreatePlatformAccounts$,\n\tgetCaip10Addresses,\n\tgetSessionCaip10s,\n} from \"../platformAccounts\";\nimport type { WalletConnectWallet } from \"../types\";\nimport type {\n\tEthereumAccount,\n\tEthereumInjectedWallet,\n\tEthereumWallet,\n} from \"./types\";\n\nconst normalizeEvmChainId = (value: unknown): number | undefined => {\n\tlet raw = value;\n\n\tif (typeof raw === \"string\" && raw.startsWith(\"eip155:\")) {\n\t\traw = raw.slice(\"eip155:\".length);\n\t}\n\n\tif (typeof raw === \"bigint\") {\n\t\treturn raw >= 0n ? Number(raw) : undefined;\n\t}\n\n\tif (typeof raw === \"number\") {\n\t\treturn Number.isInteger(raw) && raw >= 0 ? raw : undefined;\n\t}\n\n\tif (typeof raw === \"string\") {\n\t\tconst normalized = raw.trim().toLowerCase();\n\t\tif (!normalized) return undefined;\n\t\tconst parsed = normalized.startsWith(\"0x\")\n\t\t\t? Number.parseInt(normalized, 16)\n\t\t\t: Number.parseInt(normalized, 10);\n\t\treturn Number.isNaN(parsed) ? undefined : parsed;\n\t}\n\n\treturn undefined;\n};\n\nconst toCaipNetworkId = (value: unknown): string | undefined => {\n\tconst chainId = normalizeEvmChainId(value);\n\treturn chainId === undefined ? undefined : `eip155:${chainId}`;\n};\n\nconst getInjectedWalletAccounts$ = (\n\twallet: EthereumInjectedWallet,\n): Observable<EthereumAccount[]> => {\n\tif (!wallet.isConnected) return of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\t\t\tconst chainId$ = new ReplaySubject<number | undefined>(1);\n\n\t\t\tconst getAccount = (\n\t\t\t\taddress: string,\n\t\t\t\tchainId: number | undefined,\n\t\t\t): EthereumAccount => {\n\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\taccount: address as `0x${string}`,\n\t\t\t\t\ttransport: custom(wallet.provider as EIP1193Provider),\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tid: getWalletAccountId(wallet.id, address),\n\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\tclient,\n\t\t\t\t\taddress: getAddress(address),\n\t\t\t\t\tchainId,\n\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = (addrs: string[]) => {\n\t\t\t\taddresses$.next(addrs);\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainIdHex: unknown) => {\n\t\t\t\tchainId$.next(normalizeEvmChainId(chainIdHex));\n\t\t\t};\n\n\t\t\tconst handleDisconnect = () => {\n\t\t\t\tchainId$.next(undefined);\n\t\t\t};\n\n\t\t\t// Subscribe to provider events\n\t\t\twallet.provider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\twallet.provider.on(\"chainChanged\", handleChainChanged);\n\t\t\twallet.provider.on(\"disconnect\", handleDisconnect);\n\n\t\t\t// Fetch initial values\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_accounts\" })\n\t\t\t\t.then((addrs: string[]) => addresses$.next(addrs))\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(\"Failed to get accounts\", err);\n\t\t\t\t\taddresses$.next([]);\n\t\t\t\t});\n\n\t\t\twallet.provider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => chainId$.next(undefined));\n\n\t\t\t// Combine addresses + chainId into account list\n\t\t\tconst sub = combineLatest([addresses$, chainId$])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([addresses, chainId]) =>\n\t\t\t\t\t\taddresses.map((addr) => getAccount(addr, chainId)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\twallet.provider.removeListener(\n\t\t\t\t\t\"accountsChanged\",\n\t\t\t\t\thandleAccountsChanged,\n\t\t\t\t);\n\t\t\t\twallet.provider.removeListener(\"chainChanged\", handleChainChanged);\n\t\t\t\twallet.provider.removeListener(\"disconnect\", handleDisconnect);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nconst wrapWalletConnectProvider = (\n\tprovider: EIP1193Provider,\n\tsessionTopic: string,\n\tcaipNetworkId: string | undefined,\n): EIP1193Provider => {\n\treturn new Proxy(provider, {\n\t\tget(target, prop, receiver) {\n\t\t\tif (prop !== \"request\") return Reflect.get(target, prop, receiver);\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: EIP-1193 request args\n\t\t\treturn (args: any) => {\n\t\t\t\tif (!args || typeof args !== \"object\" || !args.method)\n\t\t\t\t\treturn target.request(args);\n\t\t\t\t// Build a new object rather than mutating the caller's args: the\n\t\t\t\t// EIP-1193 request object is owned by viem and may be frozen or reused.\n\t\t\t\tconst next = { ...args };\n\t\t\t\tif (next.topic === undefined) next.topic = sessionTopic;\n\t\t\t\tif (next.chainId === undefined && caipNetworkId !== undefined)\n\t\t\t\t\tnext.chainId = caipNetworkId;\n\t\t\t\t// WalletConnect's UniversalProvider reads the target CAIP chain id from\n\t\t\t\t// the SECOND positional argument of `request(args, chainId)`, not from a\n\t\t\t\t// field on the args object. This AppKit instance has no native eip155\n\t\t\t\t// adapter, so the provider has no default chain — without the positional\n\t\t\t\t// chain id every call is rejected (\"Unsupported chains\" / \"Method not\n\t\t\t\t// found\"). Pass it positionally so the request routes to the session's\n\t\t\t\t// chain.\n\t\t\t\treturn (\n\t\t\t\t\ttarget.request as (a: unknown, chainId?: string) => Promise<unknown>\n\t\t\t\t)(next, caipNetworkId);\n\t\t\t};\n\t\t},\n\t});\n};\n\nconst sameAddresses = (a: string[], b: string[]) =>\n\ta.length === b.length && a.every((addr, i) => addr === b[i]);\n\nconst getWalletConnectAccounts$ = (\n\twallet: WalletConnectWallet,\n): Observable<EthereumAccount[]> => {\n\tconst provider = wallet.appKit.getProvider(\"eip155\");\n\n\tif (!wallet.platforms.includes(\"ethereum\") || !provider?.session)\n\t\treturn of([]);\n\n\treturn getCachedObservable$(`accounts:${wallet.id}:ethereum:`, () =>\n\t\tnew Observable<EthereumAccount[]>((subscriber) => {\n\t\t\tconst caipNetworkId$ = new ReplaySubject<string | undefined>(1);\n\t\t\tconst addresses$ = new ReplaySubject<string[]>(1);\n\n\t\t\t// AppKit's getAccount(\"eip155\").allAccounts is empty because this AppKit\n\t\t\t// instance has no native eip155 adapter — eip155 runs through the\n\t\t\t// WalletConnect UniversalProvider, so the session is the source of truth\n\t\t\t// (mirrors the polkadot/solana AppKit paths). Accounts are CAIP-10 strings\n\t\t\t// (\"eip155:<chainRef>:<address>\"), one entry per chain, so dedupe to unique\n\t\t\t// addresses. Read live on each change so switching/adding accounts is\n\t\t\t// reflected.\n\t\t\tconst readAddresses = (): string[] => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return [];\n\t\t\t\tconst addresses = new Set<string>();\n\t\t\t\tfor (const raw of getCaip10Addresses(\n\t\t\t\t\tgetSessionCaip10s(session, \"eip155\"),\n\t\t\t\t)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\taddresses.add(getAddress(raw));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// skip malformed CAIP-10 address\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn [...addresses];\n\t\t\t};\n\n\t\t\t// Derive the CAIP network id from the session's eip155 CAIP-10 accounts\n\t\t\t// (\"eip155:<ref>:<addr>\") as a synchronous fallback for eth_chainId.\n\t\t\tconst readCaipNetworkId = (): string | undefined => {\n\t\t\t\tconst session = provider.session;\n\t\t\t\tif (!session) return undefined;\n\t\t\t\tfor (const account of getSessionCaip10s(session, \"eip155\")) {\n\t\t\t\t\tconst ref = account.split(\":\")[1];\n\t\t\t\t\tif (ref) return `eip155:${ref}`;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\tconst handleChainChanged = (chainId: unknown) => {\n\t\t\t\tconst caipNetworkId = toCaipNetworkId(chainId);\n\t\t\t\tif (caipNetworkId) {\n\t\t\t\t\tcaipNetworkId$.next(caipNetworkId);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst handleAccountsChanged = () => addresses$.next(readAddresses());\n\n\t\t\tprovider.on(\"chainChanged\", handleChainChanged);\n\t\t\tprovider.on(\"accountsChanged\", handleAccountsChanged);\n\t\t\tprovider.on(\"session_update\", handleAccountsChanged);\n\t\t\t// Seed the chain id from the session synchronously so the account list can\n\t\t\t// surface even if eth_chainId never resolves; eth_chainId then refines it.\n\t\t\t// Without this seed, combineLatest below never fires when eth_chainId\n\t\t\t// rejects or returns an unparseable value, and the accounts silently never\n\t\t\t// appear (the injected path seeds undefined on failure for the same reason).\n\t\t\tcaipNetworkId$.next(readCaipNetworkId());\n\t\t\tprovider\n\t\t\t\t.request({ method: \"eth_chainId\" })\n\t\t\t\t.then(handleChainChanged)\n\t\t\t\t.catch(() => {});\n\t\t\taddresses$.next(readAddresses());\n\n\t\t\tconst sub = combineLatest([\n\t\t\t\tcaipNetworkId$.pipe(distinctUntilChanged()),\n\t\t\t\taddresses$.pipe(distinctUntilChanged(sameAddresses)),\n\t\t\t])\n\t\t\t\t.pipe(\n\t\t\t\t\tmap(([caipNetworkId, addresses]) => {\n\t\t\t\t\t\tconst chainId = normalizeEvmChainId(caipNetworkId);\n\t\t\t\t\t\tconst transport = custom(\n\t\t\t\t\t\t\twrapWalletConnectProvider(\n\t\t\t\t\t\t\t\tprovider as unknown as EIP1193Provider,\n\t\t\t\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: legacy\n\t\t\t\t\t\t\t\tprovider.session!.topic,\n\t\t\t\t\t\t\t\tcaipNetworkId,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn addresses.map((addr): EthereumAccount => {\n\t\t\t\t\t\t\tconst client = createWalletClient({\n\t\t\t\t\t\t\t\taccount: addr as `0x${string}`,\n\t\t\t\t\t\t\t\ttransport,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: getWalletAccountId(wallet.id, addr),\n\t\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\t\twalletName: wallet.name,\n\t\t\t\t\t\t\t\twalletId: wallet.id,\n\t\t\t\t\t\t\t\taddress: addr as `0x${string}`,\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\treturn () => {\n\t\t\t\tprovider.off(\"chainChanged\", handleChainChanged);\n\t\t\t\tprovider.off(\"accountsChanged\", handleAccountsChanged);\n\t\t\t\tprovider.off(\"session_update\", handleAccountsChanged);\n\t\t\t\tsub.unsubscribe();\n\t\t\t};\n\t\t}).pipe(shareReplay({ refCount: true, bufferSize: 1 })),\n\t);\n};\n\nexport const getEthereumAccounts$ = (\n\tethereumWallets: Observable<(EthereumWallet | WalletConnectWallet)[]>,\n) =>\n\tcreatePlatformAccounts$({\n\t\twallets$: ethereumWallets,\n\t\tgetInjectedAccounts$: getInjectedWalletAccounts$,\n\t\tgetWalletConnectAccounts$,\n\t\t// Re-emit on chain switches, not just account id changes.\n\t\taccountChangeKey: (account) => `${account.id}|${account.chainId ?? \"\"}`,\n\t});\n","import {\n\tcreateStore as createMipdStore,\n\ttype EIP6963ProviderDetail,\n} from \"mipd\";\nimport { Observable, shareReplay } from \"rxjs\";\nimport type { EIP1193Provider } from \"viem\";\nimport { clearCachedObservable } from \"../../utils/getCachedObservable\";\nimport { getWalletId } from \"../../utils/WalletId\";\nimport { createInjectedWallets$ } from \"../injectedWallets\";\nimport type { KheopskitStore } from \"../store\";\nimport type { EthereumInjectedWallet } from \"./types\";\n\n/**\n * Observable that emits EIP-6963 provider details from injected wallets.\n * Returns empty array during SSR since browser wallet APIs are not available.\n */\nconst providersDetails$ = new Observable<EIP6963ProviderDetail[]>(\n\t(subscriber) => {\n\t\t// Guard against SSR - mipd requires browser APIs\n\t\tif (typeof window === \"undefined\") {\n\t\t\tsubscriber.next([]);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst mipdStore = createMipdStore();\n\n\t\tconst unsubscribe = mipdStore.subscribe((providerDetails) => {\n\t\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\t\t});\n\n\t\tconst providerDetails = mipdStore.getProviders();\n\n\t\tsubscriber.next(providerDetails as EIP6963ProviderDetail[]);\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tmipdStore.destroy();\n\t\t};\n\t},\n).pipe(shareReplay({ refCount: true, bufferSize: 1 }));\n\n// The shared WalletConnect connector is emitted once by core (see\n// `getWallets$`), not per platform — so this returns only injected wallets.\nexport const getEthereumWallets$ = (store: KheopskitStore) =>\n\tcreateInjectedWallets$<EIP6963ProviderDetail, EthereumInjectedWallet>(store, {\n\t\tsources$: providersDetails$,\n\t\tgetWalletId: (pd) => getWalletId(\"ethereum\", pd.info.rdns),\n\t\tconnect: async (pd) => {\n\t\t\tawait (pd.provider as EIP1193Provider).request({\n\t\t\t\tmethod: \"eth_requestAccounts\",\n\t\t\t});\n\t\t},\n\t\t// Drop the cached account observable so a later reconnect rebuilds it\n\t\t// against the current provider, not a stale closure.\n\t\tonDisconnected: (walletId) => clearCachedObservable(`accounts:${walletId}`),\n\t\tbuildWallet: ({\n\t\t\tsource: pd,\n\t\t\twalletId,\n\t\t\tisConnected,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}) => ({\n\t\t\tplatform: \"ethereum\",\n\t\t\ttype: \"injected\",\n\t\t\tid: walletId,\n\t\t\tname: pd.info.name,\n\t\t\ticon: pd.info.icon,\n\t\t\tprovider: pd.provider as EIP1193Provider,\n\t\t\tisConnected,\n\t\t\tsourceId: pd.info.rdns,\n\t\t\tconnect,\n\t\t\tdisconnect,\n\t\t}),\n\t});\n","import type { KheopskitPlatform, PlatformContext } from \"../types\";\nimport { getEthereumAccounts$ } from \"./accounts\";\nimport type { EthereumAccount, EthereumWallet } from \"./types\";\nimport { getEthereumWallets$ } from \"./wallets\";\n\n/**\n * Ethereum platform plugin. Pass to `getKheopskit$({ platforms: [ethereum()] })`.\n *\n * @example\n * ```ts\n * import { ethereum } from \"@kheopskit/core/ethereum\";\n * ethereum();\n * ```\n */\nexport const ethereum = (): KheopskitPlatform<\n\t\"ethereum\",\n\tEthereumWallet,\n\tEthereumAccount\n> => ({\n\tplatform: \"ethereum\",\n\tgetWallets$: (ctx: PlatformContext) => getEthereumWallets$(ctx.store),\n\tgetAccounts$: (wallets$) => getEthereumAccounts$(wallets$),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EAEA;AAAA,OACM;AAeP,IAAM,sBAAsB,CAAC,UAAuC;AACnE,MAAI,MAAM;AAEV,MAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,SAAS,GAAG;AACzD,UAAM,IAAI,MAAM,UAAU,MAAM;AAAA,EACjC;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,OAAO,KAAK,OAA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BAAsB,YAAY,QAAQ,EAAE;AAAA,EAC1E,aAAa,CAAC;AAAA,IACb,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,OAAO;AAAA,IACN,UAAU;AAAA,IACV,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM,GAAG,KAAK;AAAA,IACd,MAAM,GAAG,KAAK;AAAA,IACd,UAAU,GAAG;AAAA,IACb;AAAA,IACA,UAAU,GAAG,KAAK;AAAA,IAClB;AAAA,IACA;AAAA,EACD;AACD,CAAC;;;AC3DK,IAAM,WAAW,OAIlB;AAAA,EACL,UAAU;AAAA,EACV,aAAa,CAAC,QAAyB,oBAAoB,IAAI,KAAK;AAAA,EACpE,cAAc,CAAC,aAAa,qBAAqB,QAAQ;AAC1D;","names":["Observable","shareReplay","Observable","providerDetails","shareReplay"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { c as clearAllCachedObservables } from './getCachedObservable-C4E8dfMp.mjs';
|
|
2
|
-
import { K as KheopskitPlatform, d as KheopskitConfig, a as WalletId, e as
|
|
3
|
-
export { A as AccountOf,
|
|
2
|
+
import { K as KheopskitPlatform, d as KheopskitConfig, a as WalletId, e as KheopskitStore, B as BaseWallet, b as WalletConnectWallet, f as BaseWalletAccount, g as KheopskitState } from './types-0iDBydsK.mjs';
|
|
3
|
+
export { A as AccountOf, h as AppKitInstance, C as CachedAccount, j as CachedWallet, k as KheopskitStoreData, P as PlatformContext, l as PolkadotAccountType, W as WalletAccountId, m as WalletConnectConfig, n as WalletConnectMetadata, o as WalletConnectProvider, p as WalletOf, q as WalletPlatform, r as WalletType, s as getWalletAccountId, t as getWalletId, i as isInjectedWallet, u as isValidWalletId, c as isWalletConnectWallet, v as parseWalletAccountId, w as parseWalletId } from './types-0iDBydsK.mjs';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
|
|
6
6
|
declare const isValidAddress: (address: string) => boolean;
|
|
@@ -62,6 +62,62 @@ declare class KheopskitError extends Error {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
type CreateKheopskitStoreOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* Cookie string for SSR hydration.
|
|
68
|
+
* When provided, uses cookieStorage instead of localStorage.
|
|
69
|
+
*/
|
|
70
|
+
ssrCookies?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Custom storage key to namespace the stored data.
|
|
73
|
+
* @default "kheopskit"
|
|
74
|
+
*/
|
|
75
|
+
storageKey?: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a kheopskit store with the appropriate storage backend.
|
|
79
|
+
* Uses cookieStorage when ssrCookies is provided (for SSR hydration),
|
|
80
|
+
* otherwise falls back to safeLocalStorage.
|
|
81
|
+
*
|
|
82
|
+
* @param options - Configuration options for the store
|
|
83
|
+
*/
|
|
84
|
+
declare const createKheopskitStore: (options?: CreateKheopskitStoreOptions) => KheopskitStore;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the default store, creating it on first access.
|
|
87
|
+
* Uses localStorage on client, noop on server.
|
|
88
|
+
* Lazily initialized to avoid SSR issues with module-level code.
|
|
89
|
+
*/
|
|
90
|
+
declare const getDefaultStore: () => KheopskitStore;
|
|
91
|
+
|
|
92
|
+
/** Result of {@link getHydratedSnapshot}: placeholder wallets and accounts built from the cache. */
|
|
93
|
+
type HydratedSnapshot = {
|
|
94
|
+
wallets: (BaseWallet | WalletConnectWallet)[];
|
|
95
|
+
accounts: BaseWalletAccount[];
|
|
96
|
+
};
|
|
97
|
+
type GetHydratedSnapshotOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* Enrich wallets that have no icon from the localStorage icon cache.
|
|
100
|
+
*
|
|
101
|
+
* Must stay `false` for any snapshot that has to match server-rendered markup
|
|
102
|
+
* (React's `getServerSnapshot` runs on the client during hydration, where the
|
|
103
|
+
* icon cache is populated — enriching there would diverge from the server,
|
|
104
|
+
* which always sees an empty cache).
|
|
105
|
+
*/
|
|
106
|
+
icons?: boolean;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Builds the cached-state snapshot every consumer must agree on: read the
|
|
110
|
+
* store's cached state, hydrate wallets/accounts into placeholders, filter
|
|
111
|
+
* accounts through each platform plugin's `acceptsCachedAccount` hook, and sort
|
|
112
|
+
* with the same comparators the live pipeline uses.
|
|
113
|
+
*
|
|
114
|
+
* This is the single implementation behind the observable's initial seed and
|
|
115
|
+
* both React snapshot sources (`serverValue`/`initialValue`). They must produce
|
|
116
|
+
* the same shape in the same order or the UI flickers/reorders on reload — by
|
|
117
|
+
* sharing this helper, that agreement holds by construction.
|
|
118
|
+
*/
|
|
119
|
+
declare const getHydratedSnapshot: (store: KheopskitStore, platforms: readonly KheopskitPlatform[], options?: GetHydratedSnapshotOptions) => HydratedSnapshot;
|
|
120
|
+
|
|
65
121
|
/** Options for {@link getKheopskit$}. */
|
|
66
122
|
type GetKheopskitOptions = {
|
|
67
123
|
/**
|
|
@@ -78,4 +134,4 @@ type GetKheopskitOptions = {
|
|
|
78
134
|
};
|
|
79
135
|
declare const getKheopskit$: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>, options?: GetKheopskitOptions) => Observable<KheopskitState<P>>;
|
|
80
136
|
|
|
81
|
-
export { DEFAULT_STORAGE_KEY, type GetKheopskitOptions, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, WalletId, createKheopskitStore, getKheopskit$, isValidAddress, resetAppKitCache, resolveConfig };
|
|
137
|
+
export { BaseWallet, BaseWalletAccount, DEFAULT_STORAGE_KEY, type GetHydratedSnapshotOptions, type GetKheopskitOptions, type HydratedSnapshot, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, WalletConnectWallet, WalletId, createKheopskitStore, getDefaultStore, getHydratedSnapshot, getKheopskit$, isValidAddress, resetAppKitCache, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { c as clearAllCachedObservables } from './getCachedObservable-C4E8dfMp.js';
|
|
2
|
-
import { K as KheopskitPlatform, d as KheopskitConfig, a as WalletId, e as
|
|
3
|
-
export { A as AccountOf,
|
|
2
|
+
import { K as KheopskitPlatform, d as KheopskitConfig, a as WalletId, e as KheopskitStore, B as BaseWallet, b as WalletConnectWallet, f as BaseWalletAccount, g as KheopskitState } from './types-0iDBydsK.js';
|
|
3
|
+
export { A as AccountOf, h as AppKitInstance, C as CachedAccount, j as CachedWallet, k as KheopskitStoreData, P as PlatformContext, l as PolkadotAccountType, W as WalletAccountId, m as WalletConnectConfig, n as WalletConnectMetadata, o as WalletConnectProvider, p as WalletOf, q as WalletPlatform, r as WalletType, s as getWalletAccountId, t as getWalletId, i as isInjectedWallet, u as isValidWalletId, c as isWalletConnectWallet, v as parseWalletAccountId, w as parseWalletId } from './types-0iDBydsK.js';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
|
|
6
6
|
declare const isValidAddress: (address: string) => boolean;
|
|
@@ -62,6 +62,62 @@ declare class KheopskitError extends Error {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
type CreateKheopskitStoreOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* Cookie string for SSR hydration.
|
|
68
|
+
* When provided, uses cookieStorage instead of localStorage.
|
|
69
|
+
*/
|
|
70
|
+
ssrCookies?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Custom storage key to namespace the stored data.
|
|
73
|
+
* @default "kheopskit"
|
|
74
|
+
*/
|
|
75
|
+
storageKey?: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a kheopskit store with the appropriate storage backend.
|
|
79
|
+
* Uses cookieStorage when ssrCookies is provided (for SSR hydration),
|
|
80
|
+
* otherwise falls back to safeLocalStorage.
|
|
81
|
+
*
|
|
82
|
+
* @param options - Configuration options for the store
|
|
83
|
+
*/
|
|
84
|
+
declare const createKheopskitStore: (options?: CreateKheopskitStoreOptions) => KheopskitStore;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the default store, creating it on first access.
|
|
87
|
+
* Uses localStorage on client, noop on server.
|
|
88
|
+
* Lazily initialized to avoid SSR issues with module-level code.
|
|
89
|
+
*/
|
|
90
|
+
declare const getDefaultStore: () => KheopskitStore;
|
|
91
|
+
|
|
92
|
+
/** Result of {@link getHydratedSnapshot}: placeholder wallets and accounts built from the cache. */
|
|
93
|
+
type HydratedSnapshot = {
|
|
94
|
+
wallets: (BaseWallet | WalletConnectWallet)[];
|
|
95
|
+
accounts: BaseWalletAccount[];
|
|
96
|
+
};
|
|
97
|
+
type GetHydratedSnapshotOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* Enrich wallets that have no icon from the localStorage icon cache.
|
|
100
|
+
*
|
|
101
|
+
* Must stay `false` for any snapshot that has to match server-rendered markup
|
|
102
|
+
* (React's `getServerSnapshot` runs on the client during hydration, where the
|
|
103
|
+
* icon cache is populated — enriching there would diverge from the server,
|
|
104
|
+
* which always sees an empty cache).
|
|
105
|
+
*/
|
|
106
|
+
icons?: boolean;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Builds the cached-state snapshot every consumer must agree on: read the
|
|
110
|
+
* store's cached state, hydrate wallets/accounts into placeholders, filter
|
|
111
|
+
* accounts through each platform plugin's `acceptsCachedAccount` hook, and sort
|
|
112
|
+
* with the same comparators the live pipeline uses.
|
|
113
|
+
*
|
|
114
|
+
* This is the single implementation behind the observable's initial seed and
|
|
115
|
+
* both React snapshot sources (`serverValue`/`initialValue`). They must produce
|
|
116
|
+
* the same shape in the same order or the UI flickers/reorders on reload — by
|
|
117
|
+
* sharing this helper, that agreement holds by construction.
|
|
118
|
+
*/
|
|
119
|
+
declare const getHydratedSnapshot: (store: KheopskitStore, platforms: readonly KheopskitPlatform[], options?: GetHydratedSnapshotOptions) => HydratedSnapshot;
|
|
120
|
+
|
|
65
121
|
/** Options for {@link getKheopskit$}. */
|
|
66
122
|
type GetKheopskitOptions = {
|
|
67
123
|
/**
|
|
@@ -78,4 +134,4 @@ type GetKheopskitOptions = {
|
|
|
78
134
|
};
|
|
79
135
|
declare const getKheopskit$: <const P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]>(config?: Partial<KheopskitConfig<P>>, options?: GetKheopskitOptions) => Observable<KheopskitState<P>>;
|
|
80
136
|
|
|
81
|
-
export { DEFAULT_STORAGE_KEY, type GetKheopskitOptions, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, WalletId, createKheopskitStore, getKheopskit$, isValidAddress, resetAppKitCache, resolveConfig };
|
|
137
|
+
export { BaseWallet, BaseWalletAccount, DEFAULT_STORAGE_KEY, type GetHydratedSnapshotOptions, type GetKheopskitOptions, type HydratedSnapshot, KheopskitConfig, KheopskitError, type KheopskitErrorCode, KheopskitPlatform, KheopskitState, KheopskitStore, WalletConnectWallet, WalletId, createKheopskitStore, getDefaultStore, getHydratedSnapshot, getKheopskit$, isValidAddress, resetAppKitCache, resolveConfig };
|