@kheopskit/core 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/WalletAccountId-6ZXQM_ed.mjs +116 -0
- package/dist/WalletAccountId-6ZXQM_ed.mjs.map +1 -0
- package/dist/WalletAccountId-D8Xc13VY.js +151 -0
- package/dist/WalletAccountId-D8Xc13VY.js.map +1 -0
- package/dist/{config-Csp5p0-Z.d.ts → config-CubhhFON.d.ts} +2 -2
- package/dist/{config-qMsgD8tJ.d.mts → config-rvX2pkqc.d.mts} +2 -2
- package/dist/ethereum.d.mts +1 -1
- package/dist/ethereum.d.ts +1 -1
- package/dist/ethereum.js +11 -11
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/dist/index.mjs +3 -3
- package/dist/{instance--1tqj7s5.mjs → instance-0-PWH43j.mjs} +3 -3
- package/dist/{instance--1tqj7s5.mjs.map → instance-0-PWH43j.mjs.map} +1 -1
- package/dist/{instance-CrdktIu7.d.ts → instance-BokWUMmA.d.ts} +2 -2
- package/dist/{instance-4DgSj55G.js → instance-CegD47uC.js} +25 -25
- package/dist/{instance-4DgSj55G.js.map → instance-CegD47uC.js.map} +1 -1
- package/dist/{instance-Gv9IDCIY.d.mts → instance-DoOr7mrc.d.mts} +2 -2
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +4 -4
- package/dist/internal.mjs +2 -2
- package/dist/{platformAccounts-BcLoaZZb.js → platformAccounts-D8XmOSvD.js} +130 -113
- package/dist/platformAccounts-D8XmOSvD.js.map +1 -0
- package/dist/{platformAccounts-3jM3W1fB.mjs → platformAccounts-sy621l8C.mjs} +84 -97
- package/dist/platformAccounts-sy621l8C.mjs.map +1 -0
- package/dist/polkadot.d.mts +1 -1
- package/dist/polkadot.d.ts +1 -1
- package/dist/polkadot.js +10 -10
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +2 -2
- package/dist/solana.d.mts +1 -1
- package/dist/solana.d.ts +1 -1
- package/dist/solana.js +10 -10
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/{types-C9aw2FEm.d.mts → types-BfIzw1fd.d.mts} +7 -1
- package/dist/{types-C9aw2FEm.d.ts → types-BfIzw1fd.d.ts} +7 -1
- package/dist/walletconnect.d.mts +1 -1
- package/dist/walletconnect.d.ts +1 -1
- package/dist/walletconnect.js +20 -17
- package/dist/walletconnect.js.map +1 -1
- package/dist/walletconnect.mjs +17 -14
- package/dist/walletconnect.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/platformAccounts-3jM3W1fB.mjs.map +0 -1
- package/dist/platformAccounts-BcLoaZZb.js.map +0 -1
- package/dist/types-DaRMgleZ.js +0 -169
- package/dist/types-DaRMgleZ.js.map +0 -1
- package/dist/types-DcpmEGhO.mjs +0 -104
- package/dist/types-DcpmEGhO.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as WalletAccountId, c as KheopskitConfig, d as KheopskitStore, k as WalletId, l as KheopskitPlatform, s as ConnectOptions, t as AccountOf, u as KheopskitState } from "./types-
|
|
1
|
+
import { N as WalletAccountId, c as KheopskitConfig, d as KheopskitStore, k as WalletId, l as KheopskitPlatform, s as ConnectOptions, t as AccountOf, u as KheopskitState } from "./types-BfIzw1fd.js";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
//#region src/utils/getCachedObservable.d.ts
|
|
4
4
|
/**
|
|
@@ -106,4 +106,4 @@ declare const kheopskitInternals: (kit: Kheopskit<readonly KheopskitPlatform[]>)
|
|
|
106
106
|
declare const createKheopskit: <const P extends readonly [KheopskitPlatform, ...KheopskitPlatform[]]>(config: CreateKheopskitConfig<P>, options?: CreateKheopskitOptions) => Kheopskit<P>;
|
|
107
107
|
//#endregion
|
|
108
108
|
export { createKheopskit as a, clearAllCachedObservables as c, createInstance as i, clearCachedObservable as l, CreateKheopskitOptions as n, kheopskitInternals as o, Kheopskit as r, WalletActions as s, CreateKheopskitConfig as t, clearCachedObservablesByPrefix as u };
|
|
109
|
-
//# sourceMappingURL=instance-
|
|
109
|
+
//# sourceMappingURL=instance-BokWUMmA.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_platformAccounts = require("./platformAccounts-D8XmOSvD.js");
|
|
2
|
+
const require_WalletAccountId = require("./WalletAccountId-D8Xc13VY.js");
|
|
3
3
|
const require_errors = require("./errors-B6Z21vkI.js");
|
|
4
4
|
const require_config = require("./config-B3TqJq0m.js");
|
|
5
5
|
const require_polkadotExtensions = require("./polkadotExtensions-y4J9UzYl.js");
|
|
@@ -37,7 +37,7 @@ const hydrateWallet = (cached) => {
|
|
|
37
37
|
connect,
|
|
38
38
|
disconnect
|
|
39
39
|
};
|
|
40
|
-
const { platform, identifier } =
|
|
40
|
+
const { platform, identifier } = require_platformAccounts.parseWalletId(cached.id);
|
|
41
41
|
return {
|
|
42
42
|
id: cached.id,
|
|
43
43
|
platform: cached.platform,
|
|
@@ -69,7 +69,7 @@ const hydrateAccount = (cached) => ({
|
|
|
69
69
|
*/
|
|
70
70
|
const serializeWallet = (wallet) => ({
|
|
71
71
|
id: wallet.id,
|
|
72
|
-
platform:
|
|
72
|
+
platform: require_platformAccounts.isWalletConnectWallet(wallet) ? void 0 : wallet.platform,
|
|
73
73
|
type: wallet.type,
|
|
74
74
|
name: wallet.name,
|
|
75
75
|
isConnected: wallet.isConnected
|
|
@@ -346,7 +346,7 @@ const PLATFORM_ORDER = {
|
|
|
346
346
|
ethereum: 1,
|
|
347
347
|
solana: 2
|
|
348
348
|
};
|
|
349
|
-
const orderOf = (wallet) =>
|
|
349
|
+
const orderOf = (wallet) => require_platformAccounts.isWalletConnectWallet(wallet) ? 3 : PLATFORM_ORDER[wallet.platform];
|
|
350
350
|
const sortWallets = (w1, w2) => {
|
|
351
351
|
const o1 = orderOf(w1);
|
|
352
352
|
const o2 = orderOf(w2);
|
|
@@ -423,7 +423,7 @@ const reconnectCandidates$ = (store) => {
|
|
|
423
423
|
*/
|
|
424
424
|
const getHydratedSnapshot = (store, config, options = {}) => {
|
|
425
425
|
const cached = store.getCachedState();
|
|
426
|
-
const wallets = cached.wallets.filter((wallet) => acceptsCachedWallet(wallet, config)).map(hydrateWallet).map((wallet) => wallet.status === "connecting" &&
|
|
426
|
+
const wallets = cached.wallets.filter((wallet) => acceptsCachedWallet(wallet, config)).map(hydrateWallet).map((wallet) => wallet.status === "connecting" && require_platformAccounts.isInjectedWallet(wallet) && !reconnectAccepts(config.autoReconnect, wallet) ? {
|
|
427
427
|
...wallet,
|
|
428
428
|
status: "disconnected"
|
|
429
429
|
} : wallet).map((wallet) => {
|
|
@@ -538,7 +538,7 @@ const logObservable = (label, opts) => (0, rxjs.tap)((value) => {
|
|
|
538
538
|
//#region src/api/accounts.ts
|
|
539
539
|
const getAccounts$ = (config, wallets) => {
|
|
540
540
|
return new rxjs.Observable((subscriber) => {
|
|
541
|
-
const sources = config.platforms.map((plugin) => require_platformAccounts.framesOf(plugin.getAccounts$(wallets.pipe((0, rxjs.map)((ws) => ws.filter((w) =>
|
|
541
|
+
const sources = config.platforms.map((plugin) => require_platformAccounts.framesOf(plugin.getAccounts$(wallets.pipe((0, rxjs.map)((ws) => ws.filter((w) => require_platformAccounts.isWalletConnectWallet(w) || w.platform === plugin.platform))))));
|
|
542
542
|
const sub = (sources.length ? (0, rxjs.combineLatest)(sources).pipe((0, rxjs.map)((frames) => ({
|
|
543
543
|
accounts: frames.flatMap((frame) => frame.accounts).sort(sortAccounts),
|
|
544
544
|
answered: frames.flatMap((frame) => frame.answered)
|
|
@@ -682,14 +682,14 @@ const fromCompactStore = (data) => {
|
|
|
682
682
|
for (const item of Array.isArray(data.w) ? data.w : []) {
|
|
683
683
|
if (!Array.isArray(item)) continue;
|
|
684
684
|
const [id, name, isConnected, type] = item;
|
|
685
|
-
if (!
|
|
686
|
-
const isWalletConnect = id ===
|
|
685
|
+
if (!require_platformAccounts.isValidWalletId(id)) continue;
|
|
686
|
+
const isWalletConnect = id === require_platformAccounts.WALLET_CONNECT_WALLET_ID;
|
|
687
687
|
const walletType = type === 1 ? "walletconnect" : "injected";
|
|
688
688
|
if (isWalletConnect !== (walletType === "walletconnect")) continue;
|
|
689
689
|
walletNameMap.set(id, name);
|
|
690
690
|
wallets.push({
|
|
691
691
|
id,
|
|
692
|
-
platform: isWalletConnect ? void 0 :
|
|
692
|
+
platform: isWalletConnect ? void 0 : require_platformAccounts.parseWalletId(id).platform,
|
|
693
693
|
type: walletType,
|
|
694
694
|
name,
|
|
695
695
|
isConnected: isConnected === 1
|
|
@@ -699,11 +699,11 @@ const fromCompactStore = (data) => {
|
|
|
699
699
|
for (const item of Array.isArray(data.a) ? data.a : []) {
|
|
700
700
|
if (!Array.isArray(item)) continue;
|
|
701
701
|
const [walletId, address, name, chainId, polkadotAccountType, platformCode] = item;
|
|
702
|
-
if (!
|
|
703
|
-
const platform = platformCode != null ? fromCompactPlatform(platformCode) : walletId === "walletconnect" ? void 0 :
|
|
704
|
-
if (!
|
|
702
|
+
if (!require_platformAccounts.isValidWalletId(walletId) || typeof address !== "string" || !address) continue;
|
|
703
|
+
const platform = platformCode != null ? fromCompactPlatform(platformCode) : walletId === "walletconnect" ? void 0 : require_platformAccounts.parseWalletId(walletId).platform;
|
|
704
|
+
if (!require_platformAccounts.isWalletPlatform(platform)) continue;
|
|
705
705
|
accounts.push({
|
|
706
|
-
id:
|
|
706
|
+
id: require_WalletAccountId.getWalletAccountId(walletId, address),
|
|
707
707
|
platform,
|
|
708
708
|
address,
|
|
709
709
|
name: name ?? void 0,
|
|
@@ -778,16 +778,16 @@ const DEFAULT_SETTINGS = {};
|
|
|
778
778
|
const isValidCachedWallet = (value) => {
|
|
779
779
|
if (!value || typeof value !== "object") return false;
|
|
780
780
|
const w = value;
|
|
781
|
-
if (!
|
|
781
|
+
if (!require_platformAccounts.isValidWalletId(w.id)) return false;
|
|
782
782
|
if (typeof w.name !== "string" || typeof w.isConnected !== "boolean") return false;
|
|
783
783
|
if (w.type === "walletconnect") return w.id === "walletconnect" && w.platform === void 0;
|
|
784
|
-
return w.type === "injected" &&
|
|
784
|
+
return w.type === "injected" && require_platformAccounts.isWalletPlatform(w.platform);
|
|
785
785
|
};
|
|
786
786
|
/** Validates a cached account read from persisted storage. See {@link isValidCachedWallet}. */
|
|
787
787
|
const isValidCachedAccount = (value) => {
|
|
788
788
|
if (!value || typeof value !== "object") return false;
|
|
789
789
|
const a = value;
|
|
790
|
-
return typeof a.id === "string" && !!a.id &&
|
|
790
|
+
return typeof a.id === "string" && !!a.id && require_platformAccounts.isWalletPlatform(a.platform) && typeof a.address === "string" && !!a.address && require_platformAccounts.isValidWalletId(a.walletId) && typeof a.walletName === "string";
|
|
791
791
|
};
|
|
792
792
|
/**
|
|
793
793
|
* Creates a kheopskit store with the appropriate storage backend.
|
|
@@ -801,7 +801,7 @@ const createKheopskitStore = (options = {}) => {
|
|
|
801
801
|
const storage = options.storage ?? (ssrCookies !== void 0 ? createCompactCookieStorage(ssrCookies) : safeLocalStorage);
|
|
802
802
|
const store = createStore(storageKey, DEFAULT_SETTINGS, storage, migratePreV6StoreData);
|
|
803
803
|
const rememberWallet = (walletId) => {
|
|
804
|
-
|
|
804
|
+
require_platformAccounts.parseWalletId(walletId);
|
|
805
805
|
store.mutate((prev) => ({
|
|
806
806
|
...prev,
|
|
807
807
|
remembered: (0, lodash_es.uniq)((prev.remembered ?? []).concat(walletId))
|
|
@@ -882,7 +882,7 @@ const getWallets$ = (config, store, registryReads$, walletConnect$ = config.wall
|
|
|
882
882
|
});
|
|
883
883
|
const platformWallets$ = observables.length ? (0, rxjs.combineLatest)(observables).pipe((0, rxjs.map)((wallets) => wallets.flat())) : (0, rxjs.of)([]);
|
|
884
884
|
const rawWallets$ = (walletConnect$ ? (0, rxjs.combineLatest)([platformWallets$, walletConnect$.pipe((0, rxjs.startWith)(null))]).pipe((0, rxjs.map)(([platformWallets, walletConnect]) => walletConnect ? [...platformWallets, walletConnect] : platformWallets)) : platformWallets$).pipe((0, rxjs.map)((all) => all.sort(sortWallets)));
|
|
885
|
-
const wallets$ = rawWallets$.pipe((0, rxjs.map)((wallets) => wallets.map((wallet) =>
|
|
885
|
+
const wallets$ = rawWallets$.pipe((0, rxjs.map)((wallets) => wallets.map((wallet) => require_platformAccounts.isInjectedWallet(wallet) ? settleOnUserCall(wallet) : wallet)));
|
|
886
886
|
const reconnect = async (wallet) => {
|
|
887
887
|
try {
|
|
888
888
|
await reconnectPolicy.attempt(wallet.id, () => wallet.connect());
|
|
@@ -897,7 +897,7 @@ const getWallets$ = (config, store, registryReads$, walletConnect$ = config.wall
|
|
|
897
897
|
};
|
|
898
898
|
const subWallets = wallets$.subscribe(subscriber);
|
|
899
899
|
if (subscriber.closed) return subWallets;
|
|
900
|
-
const subAutoReconnect = rawWallets$.pipe((0, rxjs.withLatestFrom)(reconnectCandidates$(store)), (0, rxjs.filter)(([, walletIds]) => config.autoReconnect !== false && walletIds.length > 0), (0, rxjs.mergeMap)(([wallets, walletIds]) => wallets.filter(
|
|
900
|
+
const subAutoReconnect = rawWallets$.pipe((0, rxjs.withLatestFrom)(reconnectCandidates$(store)), (0, rxjs.filter)(([, walletIds]) => config.autoReconnect !== false && walletIds.length > 0), (0, rxjs.mergeMap)(([wallets, walletIds]) => wallets.filter(require_platformAccounts.isInjectedWallet).filter((wallet) => walletIds.includes(wallet.id))), (0, rxjs.tap)((wallet) => {
|
|
901
901
|
if (wallet.status === "connected") reconnectPolicy.settle(wallet.id);
|
|
902
902
|
}), (0, rxjs.filter)((wallet) => wallet.status === "disconnected" && reconnectAccepts(config.autoReconnect, wallet))).subscribe(reconnect);
|
|
903
903
|
return () => {
|
|
@@ -997,7 +997,7 @@ const kheopskitRun$ = (config, options = {}) => {
|
|
|
997
997
|
wrapped.set(wallet, deferred);
|
|
998
998
|
return deferred;
|
|
999
999
|
}
|
|
1000
|
-
if (!
|
|
1000
|
+
if (!require_platformAccounts.isInjectedWallet(wallet)) return wallet;
|
|
1001
1001
|
const settled = {
|
|
1002
1002
|
...wallet,
|
|
1003
1003
|
connect: async (options) => {
|
|
@@ -1130,7 +1130,7 @@ const kheopskitRun$ = (config, options = {}) => {
|
|
|
1130
1130
|
refCount: true
|
|
1131
1131
|
}));
|
|
1132
1132
|
};
|
|
1133
|
-
const sessionRestoring = (live, cached) =>
|
|
1133
|
+
const sessionRestoring = (live, cached) => require_platformAccounts.isWalletConnectWallet(live) && live.status === "disconnected" && cached.status === "connecting";
|
|
1134
1134
|
const flagged = /* @__PURE__ */ new WeakMap();
|
|
1135
1135
|
const asLive = (item) => {
|
|
1136
1136
|
const existing = flagged.get(item);
|
|
@@ -1190,7 +1190,7 @@ const accountPlatformKey = (account) => {
|
|
|
1190
1190
|
}
|
|
1191
1191
|
};
|
|
1192
1192
|
/** Platforms a wallet's live session carries (only the WalletConnect connector). */
|
|
1193
|
-
const walletPlatforms = (wallet) =>
|
|
1193
|
+
const walletPlatforms = (wallet) => require_platformAccounts.isWalletConnectWallet(wallet) ? wallet.platforms.join(",") : "";
|
|
1194
1194
|
/** Fields persisted to the cache for a wallet (icon is stored separately). */
|
|
1195
1195
|
const walletPersistKey = (wallet) => `${wallet.id}|${wallet.isConnected ? 1 : 0}|${wallet.name}`;
|
|
1196
1196
|
/**
|
|
@@ -1370,7 +1370,7 @@ const createInstance = (run$, store) => {
|
|
|
1370
1370
|
})));
|
|
1371
1371
|
const present = createPresenter(pipeline);
|
|
1372
1372
|
const waitForAccount = async (accountId, { signal } = {}) => {
|
|
1373
|
-
const { walletId } =
|
|
1373
|
+
const { walletId } = require_WalletAccountId.parseWalletAccountId(accountId);
|
|
1374
1374
|
await Promise.resolve();
|
|
1375
1375
|
const found = await pipeline.whenLivePicks((state) => lookUpAccount(state, accountId, walletId), signal);
|
|
1376
1376
|
if (found.end) throw new require_errors.KheopskitError("ABORTED", `waitForAccount of account ${accountId} ${didNotWait[found.end]}`, { walletId });
|
|
@@ -1493,4 +1493,4 @@ Object.defineProperty(exports, "setCachedIcons", {
|
|
|
1493
1493
|
}
|
|
1494
1494
|
});
|
|
1495
1495
|
|
|
1496
|
-
//# sourceMappingURL=instance-
|
|
1496
|
+
//# sourceMappingURL=instance-CegD47uC.js.map
|