@talismn/balances-react 0.0.0-pr2111-20250724004118 → 0.0.0-pr2111-20251022034713
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/declarations/src/atoms/chaindata.d.ts +168 -3
- package/dist/declarations/src/atoms/chaindataProvider.d.ts +1 -0
- package/dist/declarations/src/atoms/tokenRates.d.ts +1 -3
- package/dist/declarations/src/hooks/useChaindata.d.ts +53 -521
- package/dist/declarations/src/hooks/useTokenRates.d.ts +1 -3
- package/dist/talismn-balances-react.cjs.dev.js +30 -43
- package/dist/talismn-balances-react.cjs.prod.js +30 -43
- package/dist/talismn-balances-react.esm.js +33 -47
- package/package.json +12 -15
- package/dist/declarations/src/util/dexieToRxjs.d.ts +0 -6
|
@@ -84,12 +84,40 @@ export declare const chaindataAtom: import("jotai").Atom<{
|
|
|
84
84
|
type: "scroll";
|
|
85
85
|
l1GasPriceOracle: `0x${string}`;
|
|
86
86
|
} | undefined;
|
|
87
|
-
contracts?:
|
|
87
|
+
contracts?: {
|
|
88
|
+
Erc20Aggregator?: `0x${string}` | undefined;
|
|
89
|
+
Multicall3?: `0x${string}` | undefined;
|
|
90
|
+
} | undefined;
|
|
88
91
|
balancesConfig?: {
|
|
89
92
|
"evm-native"?: undefined;
|
|
90
93
|
"evm-erc20"?: undefined;
|
|
91
94
|
"evm-uniswapv2"?: undefined;
|
|
92
95
|
} | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
nativeTokenId: string;
|
|
100
|
+
nativeCurrency: {
|
|
101
|
+
decimals: number;
|
|
102
|
+
symbol: string;
|
|
103
|
+
name: string;
|
|
104
|
+
coingeckoId?: string | undefined;
|
|
105
|
+
mirrorOf?: string | undefined;
|
|
106
|
+
logo?: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
blockExplorerUrls: string[];
|
|
109
|
+
platform: "solana";
|
|
110
|
+
genesisHash: string;
|
|
111
|
+
rpcs: string[];
|
|
112
|
+
isTestnet?: boolean | undefined;
|
|
113
|
+
isDefault?: boolean | undefined;
|
|
114
|
+
forceScan?: boolean | undefined;
|
|
115
|
+
logo?: string | undefined;
|
|
116
|
+
themeColor?: string | undefined;
|
|
117
|
+
balancesConfig?: {
|
|
118
|
+
"sol-native"?: undefined;
|
|
119
|
+
"sol-spl"?: undefined;
|
|
120
|
+
} | undefined;
|
|
93
121
|
})[];
|
|
94
122
|
tokens: ({
|
|
95
123
|
id: string;
|
|
@@ -235,6 +263,33 @@ export declare const chaindataAtom: import("jotai").Atom<{
|
|
|
235
263
|
coingeckoId?: string | undefined;
|
|
236
264
|
noDiscovery?: boolean | undefined;
|
|
237
265
|
mirrorOf?: string | undefined;
|
|
266
|
+
} | {
|
|
267
|
+
id: string;
|
|
268
|
+
networkId: string;
|
|
269
|
+
decimals: number;
|
|
270
|
+
symbol: string;
|
|
271
|
+
type: "sol-native";
|
|
272
|
+
platform: "solana";
|
|
273
|
+
isDefault?: boolean | undefined;
|
|
274
|
+
name?: string | undefined;
|
|
275
|
+
logo?: string | undefined;
|
|
276
|
+
coingeckoId?: string | undefined;
|
|
277
|
+
noDiscovery?: boolean | undefined;
|
|
278
|
+
mirrorOf?: string | undefined;
|
|
279
|
+
} | {
|
|
280
|
+
id: string;
|
|
281
|
+
networkId: string;
|
|
282
|
+
decimals: number;
|
|
283
|
+
symbol: string;
|
|
284
|
+
type: "sol-spl";
|
|
285
|
+
platform: "solana";
|
|
286
|
+
mintAddress: string;
|
|
287
|
+
isDefault?: boolean | undefined;
|
|
288
|
+
name?: string | undefined;
|
|
289
|
+
logo?: string | undefined;
|
|
290
|
+
coingeckoId?: string | undefined;
|
|
291
|
+
noDiscovery?: boolean | undefined;
|
|
292
|
+
mirrorOf?: string | undefined;
|
|
238
293
|
})[];
|
|
239
294
|
} | Promise<{
|
|
240
295
|
networks: ({
|
|
@@ -321,12 +376,40 @@ export declare const chaindataAtom: import("jotai").Atom<{
|
|
|
321
376
|
type: "scroll";
|
|
322
377
|
l1GasPriceOracle: `0x${string}`;
|
|
323
378
|
} | undefined;
|
|
324
|
-
contracts?:
|
|
379
|
+
contracts?: {
|
|
380
|
+
Erc20Aggregator?: `0x${string}` | undefined;
|
|
381
|
+
Multicall3?: `0x${string}` | undefined;
|
|
382
|
+
} | undefined;
|
|
325
383
|
balancesConfig?: {
|
|
326
384
|
"evm-native"?: undefined;
|
|
327
385
|
"evm-erc20"?: undefined;
|
|
328
386
|
"evm-uniswapv2"?: undefined;
|
|
329
387
|
} | undefined;
|
|
388
|
+
} | {
|
|
389
|
+
id: string;
|
|
390
|
+
name: string;
|
|
391
|
+
nativeTokenId: string;
|
|
392
|
+
nativeCurrency: {
|
|
393
|
+
decimals: number;
|
|
394
|
+
symbol: string;
|
|
395
|
+
name: string;
|
|
396
|
+
coingeckoId?: string | undefined;
|
|
397
|
+
mirrorOf?: string | undefined;
|
|
398
|
+
logo?: string | undefined;
|
|
399
|
+
};
|
|
400
|
+
blockExplorerUrls: string[];
|
|
401
|
+
platform: "solana";
|
|
402
|
+
genesisHash: string;
|
|
403
|
+
rpcs: string[];
|
|
404
|
+
isTestnet?: boolean | undefined;
|
|
405
|
+
isDefault?: boolean | undefined;
|
|
406
|
+
forceScan?: boolean | undefined;
|
|
407
|
+
logo?: string | undefined;
|
|
408
|
+
themeColor?: string | undefined;
|
|
409
|
+
balancesConfig?: {
|
|
410
|
+
"sol-native"?: undefined;
|
|
411
|
+
"sol-spl"?: undefined;
|
|
412
|
+
} | undefined;
|
|
330
413
|
})[];
|
|
331
414
|
tokens: ({
|
|
332
415
|
id: string;
|
|
@@ -472,6 +555,33 @@ export declare const chaindataAtom: import("jotai").Atom<{
|
|
|
472
555
|
coingeckoId?: string | undefined;
|
|
473
556
|
noDiscovery?: boolean | undefined;
|
|
474
557
|
mirrorOf?: string | undefined;
|
|
558
|
+
} | {
|
|
559
|
+
id: string;
|
|
560
|
+
networkId: string;
|
|
561
|
+
decimals: number;
|
|
562
|
+
symbol: string;
|
|
563
|
+
type: "sol-native";
|
|
564
|
+
platform: "solana";
|
|
565
|
+
isDefault?: boolean | undefined;
|
|
566
|
+
name?: string | undefined;
|
|
567
|
+
logo?: string | undefined;
|
|
568
|
+
coingeckoId?: string | undefined;
|
|
569
|
+
noDiscovery?: boolean | undefined;
|
|
570
|
+
mirrorOf?: string | undefined;
|
|
571
|
+
} | {
|
|
572
|
+
id: string;
|
|
573
|
+
networkId: string;
|
|
574
|
+
decimals: number;
|
|
575
|
+
symbol: string;
|
|
576
|
+
type: "sol-spl";
|
|
577
|
+
platform: "solana";
|
|
578
|
+
mintAddress: string;
|
|
579
|
+
isDefault?: boolean | undefined;
|
|
580
|
+
name?: string | undefined;
|
|
581
|
+
logo?: string | undefined;
|
|
582
|
+
coingeckoId?: string | undefined;
|
|
583
|
+
noDiscovery?: boolean | undefined;
|
|
584
|
+
mirrorOf?: string | undefined;
|
|
475
585
|
})[];
|
|
476
586
|
}>>;
|
|
477
587
|
export declare const networksAtom: import("jotai").Atom<Promise<({
|
|
@@ -558,12 +668,40 @@ export declare const networksAtom: import("jotai").Atom<Promise<({
|
|
|
558
668
|
type: "scroll";
|
|
559
669
|
l1GasPriceOracle: `0x${string}`;
|
|
560
670
|
} | undefined;
|
|
561
|
-
contracts?:
|
|
671
|
+
contracts?: {
|
|
672
|
+
Erc20Aggregator?: `0x${string}` | undefined;
|
|
673
|
+
Multicall3?: `0x${string}` | undefined;
|
|
674
|
+
} | undefined;
|
|
562
675
|
balancesConfig?: {
|
|
563
676
|
"evm-native"?: undefined;
|
|
564
677
|
"evm-erc20"?: undefined;
|
|
565
678
|
"evm-uniswapv2"?: undefined;
|
|
566
679
|
} | undefined;
|
|
680
|
+
} | {
|
|
681
|
+
id: string;
|
|
682
|
+
name: string;
|
|
683
|
+
nativeTokenId: string;
|
|
684
|
+
nativeCurrency: {
|
|
685
|
+
decimals: number;
|
|
686
|
+
symbol: string;
|
|
687
|
+
name: string;
|
|
688
|
+
coingeckoId?: string | undefined;
|
|
689
|
+
mirrorOf?: string | undefined;
|
|
690
|
+
logo?: string | undefined;
|
|
691
|
+
};
|
|
692
|
+
blockExplorerUrls: string[];
|
|
693
|
+
platform: "solana";
|
|
694
|
+
genesisHash: string;
|
|
695
|
+
rpcs: string[];
|
|
696
|
+
isTestnet?: boolean | undefined;
|
|
697
|
+
isDefault?: boolean | undefined;
|
|
698
|
+
forceScan?: boolean | undefined;
|
|
699
|
+
logo?: string | undefined;
|
|
700
|
+
themeColor?: string | undefined;
|
|
701
|
+
balancesConfig?: {
|
|
702
|
+
"sol-native"?: undefined;
|
|
703
|
+
"sol-spl"?: undefined;
|
|
704
|
+
} | undefined;
|
|
567
705
|
})[]>>;
|
|
568
706
|
export declare const networksByIdAtom: import("jotai").Atom<Promise<NetworkList>>;
|
|
569
707
|
export declare const dotNetworksByGenesisHashAtom: import("jotai").Atom<Promise<Record<string, {
|
|
@@ -766,5 +904,32 @@ export declare const tokensAtom: import("jotai").Atom<Promise<({
|
|
|
766
904
|
coingeckoId?: string | undefined;
|
|
767
905
|
noDiscovery?: boolean | undefined;
|
|
768
906
|
mirrorOf?: string | undefined;
|
|
907
|
+
} | {
|
|
908
|
+
id: string;
|
|
909
|
+
networkId: string;
|
|
910
|
+
decimals: number;
|
|
911
|
+
symbol: string;
|
|
912
|
+
type: "sol-native";
|
|
913
|
+
platform: "solana";
|
|
914
|
+
isDefault?: boolean | undefined;
|
|
915
|
+
name?: string | undefined;
|
|
916
|
+
logo?: string | undefined;
|
|
917
|
+
coingeckoId?: string | undefined;
|
|
918
|
+
noDiscovery?: boolean | undefined;
|
|
919
|
+
mirrorOf?: string | undefined;
|
|
920
|
+
} | {
|
|
921
|
+
id: string;
|
|
922
|
+
networkId: string;
|
|
923
|
+
decimals: number;
|
|
924
|
+
symbol: string;
|
|
925
|
+
type: "sol-spl";
|
|
926
|
+
platform: "solana";
|
|
927
|
+
mintAddress: string;
|
|
928
|
+
isDefault?: boolean | undefined;
|
|
929
|
+
name?: string | undefined;
|
|
930
|
+
logo?: string | undefined;
|
|
931
|
+
coingeckoId?: string | undefined;
|
|
932
|
+
noDiscovery?: boolean | undefined;
|
|
933
|
+
mirrorOf?: string | undefined;
|
|
769
934
|
})[]>>;
|
|
770
935
|
export declare const tokensByIdAtom: import("jotai").Atom<Promise<TokenList>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NetworkId, TokenId } from "@talismn/chaindata-provider";
|
|
1
|
+
import { DotNetwork, Network, NetworkId, NetworkList, Token, TokenId, TokenList } from "@talismn/chaindata-provider";
|
|
2
2
|
export declare const useChaindataProvider: () => import("@talismn/chaindata-provider").ChaindataProvider;
|
|
3
3
|
export declare const useChaindata: () => {
|
|
4
4
|
networks: ({
|
|
@@ -85,12 +85,40 @@ export declare const useChaindata: () => {
|
|
|
85
85
|
type: "scroll";
|
|
86
86
|
l1GasPriceOracle: `0x${string}`;
|
|
87
87
|
} | undefined;
|
|
88
|
-
contracts?:
|
|
88
|
+
contracts?: {
|
|
89
|
+
Erc20Aggregator?: `0x${string}` | undefined;
|
|
90
|
+
Multicall3?: `0x${string}` | undefined;
|
|
91
|
+
} | undefined;
|
|
89
92
|
balancesConfig?: {
|
|
90
93
|
"evm-native"?: undefined;
|
|
91
94
|
"evm-erc20"?: undefined;
|
|
92
95
|
"evm-uniswapv2"?: undefined;
|
|
93
96
|
} | undefined;
|
|
97
|
+
} | {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
nativeTokenId: string;
|
|
101
|
+
nativeCurrency: {
|
|
102
|
+
decimals: number;
|
|
103
|
+
symbol: string;
|
|
104
|
+
name: string;
|
|
105
|
+
coingeckoId?: string | undefined;
|
|
106
|
+
mirrorOf?: string | undefined;
|
|
107
|
+
logo?: string | undefined;
|
|
108
|
+
};
|
|
109
|
+
blockExplorerUrls: string[];
|
|
110
|
+
platform: "solana";
|
|
111
|
+
genesisHash: string;
|
|
112
|
+
rpcs: string[];
|
|
113
|
+
isTestnet?: boolean | undefined;
|
|
114
|
+
isDefault?: boolean | undefined;
|
|
115
|
+
forceScan?: boolean | undefined;
|
|
116
|
+
logo?: string | undefined;
|
|
117
|
+
themeColor?: string | undefined;
|
|
118
|
+
balancesConfig?: {
|
|
119
|
+
"sol-native"?: undefined;
|
|
120
|
+
"sol-spl"?: undefined;
|
|
121
|
+
} | undefined;
|
|
94
122
|
})[];
|
|
95
123
|
tokens: ({
|
|
96
124
|
id: string;
|
|
@@ -236,535 +264,39 @@ export declare const useChaindata: () => {
|
|
|
236
264
|
coingeckoId?: string | undefined;
|
|
237
265
|
noDiscovery?: boolean | undefined;
|
|
238
266
|
mirrorOf?: string | undefined;
|
|
239
|
-
})[];
|
|
240
|
-
};
|
|
241
|
-
export declare const useNetworks: () => ({
|
|
242
|
-
id: string;
|
|
243
|
-
name: string;
|
|
244
|
-
nativeTokenId: string;
|
|
245
|
-
nativeCurrency: {
|
|
246
|
-
decimals: number;
|
|
247
|
-
symbol: string;
|
|
248
|
-
name: string;
|
|
249
|
-
coingeckoId?: string | undefined;
|
|
250
|
-
mirrorOf?: string | undefined;
|
|
251
|
-
logo?: string | undefined;
|
|
252
|
-
};
|
|
253
|
-
blockExplorerUrls: string[];
|
|
254
|
-
genesisHash: `0x${string}`;
|
|
255
|
-
platform: "polkadot";
|
|
256
|
-
chainName: string;
|
|
257
|
-
specName: string;
|
|
258
|
-
specVersion: number;
|
|
259
|
-
account: "secp256k1" | "*25519";
|
|
260
|
-
prefix: number;
|
|
261
|
-
rpcs: string[];
|
|
262
|
-
topology: {
|
|
263
|
-
type: "standalone";
|
|
264
267
|
} | {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
type: "parachain";
|
|
268
|
-
relayId: string;
|
|
269
|
-
paraId: number;
|
|
270
|
-
};
|
|
271
|
-
isTestnet?: boolean | undefined;
|
|
272
|
-
isDefault?: boolean | undefined;
|
|
273
|
-
forceScan?: boolean | undefined;
|
|
274
|
-
logo?: string | undefined;
|
|
275
|
-
themeColor?: string | undefined;
|
|
276
|
-
chainspecQrUrl?: string | undefined;
|
|
277
|
-
latestMetadataQrUrl?: string | undefined;
|
|
278
|
-
oldPrefix?: number | undefined;
|
|
279
|
-
registryTypes?: any;
|
|
280
|
-
signedExtensions?: any;
|
|
281
|
-
hasCheckMetadataHash?: boolean | undefined;
|
|
282
|
-
hasExtrinsicSignatureTypePrefix?: boolean | undefined;
|
|
283
|
-
isUnknownFeeToken?: boolean | undefined;
|
|
284
|
-
balancesConfig?: {
|
|
285
|
-
"substrate-native"?: {
|
|
286
|
-
disable?: boolean | undefined;
|
|
287
|
-
} | undefined;
|
|
288
|
-
"substrate-assets"?: undefined;
|
|
289
|
-
"substrate-psp22"?: undefined;
|
|
290
|
-
"substrate-tokens"?: {
|
|
291
|
-
palletId?: string | undefined;
|
|
292
|
-
} | undefined;
|
|
293
|
-
"substrate-foreignassets"?: undefined;
|
|
294
|
-
"substrate-hydration"?: undefined;
|
|
295
|
-
} | undefined;
|
|
296
|
-
} | {
|
|
297
|
-
id: string;
|
|
298
|
-
name: string;
|
|
299
|
-
nativeTokenId: string;
|
|
300
|
-
nativeCurrency: {
|
|
268
|
+
id: string;
|
|
269
|
+
networkId: string;
|
|
301
270
|
decimals: number;
|
|
302
271
|
symbol: string;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
272
|
+
type: "sol-native";
|
|
273
|
+
platform: "solana";
|
|
274
|
+
isDefault?: boolean | undefined;
|
|
275
|
+
name?: string | undefined;
|
|
306
276
|
logo?: string | undefined;
|
|
307
|
-
};
|
|
308
|
-
blockExplorerUrls: string[];
|
|
309
|
-
platform: "ethereum";
|
|
310
|
-
rpcs: string[];
|
|
311
|
-
isTestnet?: boolean | undefined;
|
|
312
|
-
isDefault?: boolean | undefined;
|
|
313
|
-
forceScan?: boolean | undefined;
|
|
314
|
-
logo?: string | undefined;
|
|
315
|
-
themeColor?: string | undefined;
|
|
316
|
-
substrateChainId?: string | undefined;
|
|
317
|
-
preserveGasEstimate?: boolean | undefined;
|
|
318
|
-
feeType?: "legacy" | "eip-1559" | undefined;
|
|
319
|
-
l2FeeType?: {
|
|
320
|
-
type: "op-stack";
|
|
321
|
-
} | {
|
|
322
|
-
type: "scroll";
|
|
323
|
-
l1GasPriceOracle: `0x${string}`;
|
|
324
|
-
} | undefined;
|
|
325
|
-
contracts?: Partial<Record<"Erc20Aggregator" | "Multicall3", `0x${string}`>> | undefined;
|
|
326
|
-
balancesConfig?: {
|
|
327
|
-
"evm-native"?: undefined;
|
|
328
|
-
"evm-erc20"?: undefined;
|
|
329
|
-
"evm-uniswapv2"?: undefined;
|
|
330
|
-
} | undefined;
|
|
331
|
-
})[];
|
|
332
|
-
export declare const useNetworksById: () => import("@talismn/chaindata-provider").NetworkList;
|
|
333
|
-
export declare const useDotNetworksByGenesisHash: () => Record<string, {
|
|
334
|
-
id: string;
|
|
335
|
-
name: string;
|
|
336
|
-
nativeTokenId: string;
|
|
337
|
-
nativeCurrency: {
|
|
338
|
-
decimals: number;
|
|
339
|
-
symbol: string;
|
|
340
|
-
name: string;
|
|
341
277
|
coingeckoId?: string | undefined;
|
|
278
|
+
noDiscovery?: boolean | undefined;
|
|
342
279
|
mirrorOf?: string | undefined;
|
|
343
|
-
logo?: string | undefined;
|
|
344
|
-
};
|
|
345
|
-
blockExplorerUrls: string[];
|
|
346
|
-
genesisHash: `0x${string}`;
|
|
347
|
-
platform: "polkadot";
|
|
348
|
-
chainName: string;
|
|
349
|
-
specName: string;
|
|
350
|
-
specVersion: number;
|
|
351
|
-
account: "secp256k1" | "*25519";
|
|
352
|
-
prefix: number;
|
|
353
|
-
rpcs: string[];
|
|
354
|
-
topology: {
|
|
355
|
-
type: "standalone";
|
|
356
|
-
} | {
|
|
357
|
-
type: "relay";
|
|
358
280
|
} | {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
paraId: number;
|
|
362
|
-
};
|
|
363
|
-
isTestnet?: boolean | undefined;
|
|
364
|
-
isDefault?: boolean | undefined;
|
|
365
|
-
forceScan?: boolean | undefined;
|
|
366
|
-
logo?: string | undefined;
|
|
367
|
-
themeColor?: string | undefined;
|
|
368
|
-
chainspecQrUrl?: string | undefined;
|
|
369
|
-
latestMetadataQrUrl?: string | undefined;
|
|
370
|
-
oldPrefix?: number | undefined;
|
|
371
|
-
registryTypes?: any;
|
|
372
|
-
signedExtensions?: any;
|
|
373
|
-
hasCheckMetadataHash?: boolean | undefined;
|
|
374
|
-
hasExtrinsicSignatureTypePrefix?: boolean | undefined;
|
|
375
|
-
isUnknownFeeToken?: boolean | undefined;
|
|
376
|
-
balancesConfig?: {
|
|
377
|
-
"substrate-native"?: {
|
|
378
|
-
disable?: boolean | undefined;
|
|
379
|
-
} | undefined;
|
|
380
|
-
"substrate-assets"?: undefined;
|
|
381
|
-
"substrate-psp22"?: undefined;
|
|
382
|
-
"substrate-tokens"?: {
|
|
383
|
-
palletId?: string | undefined;
|
|
384
|
-
} | undefined;
|
|
385
|
-
"substrate-foreignassets"?: undefined;
|
|
386
|
-
"substrate-hydration"?: undefined;
|
|
387
|
-
} | undefined;
|
|
388
|
-
}>;
|
|
389
|
-
export declare const useNetwork: (networkId?: NetworkId) => {
|
|
390
|
-
id: string;
|
|
391
|
-
name: string;
|
|
392
|
-
nativeTokenId: string;
|
|
393
|
-
nativeCurrency: {
|
|
281
|
+
id: string;
|
|
282
|
+
networkId: string;
|
|
394
283
|
decimals: number;
|
|
395
284
|
symbol: string;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
285
|
+
type: "sol-spl";
|
|
286
|
+
platform: "solana";
|
|
287
|
+
mintAddress: string;
|
|
288
|
+
isDefault?: boolean | undefined;
|
|
289
|
+
name?: string | undefined;
|
|
399
290
|
logo?: string | undefined;
|
|
400
|
-
};
|
|
401
|
-
blockExplorerUrls: string[];
|
|
402
|
-
genesisHash: `0x${string}`;
|
|
403
|
-
platform: "polkadot";
|
|
404
|
-
chainName: string;
|
|
405
|
-
specName: string;
|
|
406
|
-
specVersion: number;
|
|
407
|
-
account: "secp256k1" | "*25519";
|
|
408
|
-
prefix: number;
|
|
409
|
-
rpcs: string[];
|
|
410
|
-
topology: {
|
|
411
|
-
type: "standalone";
|
|
412
|
-
} | {
|
|
413
|
-
type: "relay";
|
|
414
|
-
} | {
|
|
415
|
-
type: "parachain";
|
|
416
|
-
relayId: string;
|
|
417
|
-
paraId: number;
|
|
418
|
-
};
|
|
419
|
-
isTestnet?: boolean | undefined;
|
|
420
|
-
isDefault?: boolean | undefined;
|
|
421
|
-
forceScan?: boolean | undefined;
|
|
422
|
-
logo?: string | undefined;
|
|
423
|
-
themeColor?: string | undefined;
|
|
424
|
-
chainspecQrUrl?: string | undefined;
|
|
425
|
-
latestMetadataQrUrl?: string | undefined;
|
|
426
|
-
oldPrefix?: number | undefined;
|
|
427
|
-
registryTypes?: any;
|
|
428
|
-
signedExtensions?: any;
|
|
429
|
-
hasCheckMetadataHash?: boolean | undefined;
|
|
430
|
-
hasExtrinsicSignatureTypePrefix?: boolean | undefined;
|
|
431
|
-
isUnknownFeeToken?: boolean | undefined;
|
|
432
|
-
balancesConfig?: {
|
|
433
|
-
"substrate-native"?: {
|
|
434
|
-
disable?: boolean | undefined;
|
|
435
|
-
} | undefined;
|
|
436
|
-
"substrate-assets"?: undefined;
|
|
437
|
-
"substrate-psp22"?: undefined;
|
|
438
|
-
"substrate-tokens"?: {
|
|
439
|
-
palletId?: string | undefined;
|
|
440
|
-
} | undefined;
|
|
441
|
-
"substrate-foreignassets"?: undefined;
|
|
442
|
-
"substrate-hydration"?: undefined;
|
|
443
|
-
} | undefined;
|
|
444
|
-
} | {
|
|
445
|
-
id: string;
|
|
446
|
-
name: string;
|
|
447
|
-
nativeTokenId: string;
|
|
448
|
-
nativeCurrency: {
|
|
449
|
-
decimals: number;
|
|
450
|
-
symbol: string;
|
|
451
|
-
name: string;
|
|
452
291
|
coingeckoId?: string | undefined;
|
|
292
|
+
noDiscovery?: boolean | undefined;
|
|
453
293
|
mirrorOf?: string | undefined;
|
|
454
|
-
|
|
455
|
-
};
|
|
456
|
-
blockExplorerUrls: string[];
|
|
457
|
-
platform: "ethereum";
|
|
458
|
-
rpcs: string[];
|
|
459
|
-
isTestnet?: boolean | undefined;
|
|
460
|
-
isDefault?: boolean | undefined;
|
|
461
|
-
forceScan?: boolean | undefined;
|
|
462
|
-
logo?: string | undefined;
|
|
463
|
-
themeColor?: string | undefined;
|
|
464
|
-
substrateChainId?: string | undefined;
|
|
465
|
-
preserveGasEstimate?: boolean | undefined;
|
|
466
|
-
feeType?: "legacy" | "eip-1559" | undefined;
|
|
467
|
-
l2FeeType?: {
|
|
468
|
-
type: "op-stack";
|
|
469
|
-
} | {
|
|
470
|
-
type: "scroll";
|
|
471
|
-
l1GasPriceOracle: `0x${string}`;
|
|
472
|
-
} | undefined;
|
|
473
|
-
contracts?: Partial<Record<"Erc20Aggregator" | "Multicall3", `0x${string}`>> | undefined;
|
|
474
|
-
balancesConfig?: {
|
|
475
|
-
"evm-native"?: undefined;
|
|
476
|
-
"evm-erc20"?: undefined;
|
|
477
|
-
"evm-uniswapv2"?: undefined;
|
|
478
|
-
} | undefined;
|
|
479
|
-
};
|
|
480
|
-
export declare const useTokens: () => ({
|
|
481
|
-
id: string;
|
|
482
|
-
networkId: string;
|
|
483
|
-
decimals: number;
|
|
484
|
-
symbol: string;
|
|
485
|
-
type: "evm-erc20";
|
|
486
|
-
platform: "ethereum";
|
|
487
|
-
contractAddress: `0x${string}`;
|
|
488
|
-
isDefault?: boolean | undefined;
|
|
489
|
-
name?: string | undefined;
|
|
490
|
-
logo?: string | undefined;
|
|
491
|
-
coingeckoId?: string | undefined;
|
|
492
|
-
noDiscovery?: boolean | undefined;
|
|
493
|
-
mirrorOf?: string | undefined;
|
|
494
|
-
} | {
|
|
495
|
-
id: string;
|
|
496
|
-
networkId: string;
|
|
497
|
-
decimals: number;
|
|
498
|
-
symbol: string;
|
|
499
|
-
type: "evm-native";
|
|
500
|
-
platform: "ethereum";
|
|
501
|
-
isDefault?: boolean | undefined;
|
|
502
|
-
name?: string | undefined;
|
|
503
|
-
logo?: string | undefined;
|
|
504
|
-
coingeckoId?: string | undefined;
|
|
505
|
-
noDiscovery?: boolean | undefined;
|
|
506
|
-
mirrorOf?: string | undefined;
|
|
507
|
-
} | {
|
|
508
|
-
id: string;
|
|
509
|
-
networkId: string;
|
|
510
|
-
decimals: number;
|
|
511
|
-
symbol: string;
|
|
512
|
-
type: "evm-uniswapv2";
|
|
513
|
-
platform: "ethereum";
|
|
514
|
-
contractAddress: `0x${string}`;
|
|
515
|
-
symbol0: string;
|
|
516
|
-
symbol1: string;
|
|
517
|
-
decimals0: number;
|
|
518
|
-
decimals1: number;
|
|
519
|
-
tokenAddress0: `0x${string}`;
|
|
520
|
-
tokenAddress1: `0x${string}`;
|
|
521
|
-
isDefault?: boolean | undefined;
|
|
522
|
-
name?: string | undefined;
|
|
523
|
-
logo?: string | undefined;
|
|
524
|
-
coingeckoId?: string | undefined;
|
|
525
|
-
noDiscovery?: boolean | undefined;
|
|
526
|
-
mirrorOf?: string | undefined;
|
|
527
|
-
isCustom?: boolean | undefined;
|
|
528
|
-
coingeckoId0?: string | undefined;
|
|
529
|
-
coingeckoId1?: string | undefined;
|
|
530
|
-
} | {
|
|
531
|
-
id: string;
|
|
532
|
-
networkId: string;
|
|
533
|
-
decimals: number;
|
|
534
|
-
symbol: string;
|
|
535
|
-
type: "substrate-assets";
|
|
536
|
-
platform: "polkadot";
|
|
537
|
-
assetId: string;
|
|
538
|
-
isSufficient: boolean;
|
|
539
|
-
existentialDeposit: string;
|
|
540
|
-
isDefault?: boolean | undefined;
|
|
541
|
-
name?: string | undefined;
|
|
542
|
-
logo?: string | undefined;
|
|
543
|
-
coingeckoId?: string | undefined;
|
|
544
|
-
noDiscovery?: boolean | undefined;
|
|
545
|
-
mirrorOf?: string | undefined;
|
|
546
|
-
isFrozen?: boolean | undefined;
|
|
547
|
-
} | {
|
|
548
|
-
id: string;
|
|
549
|
-
networkId: string;
|
|
550
|
-
decimals: number;
|
|
551
|
-
symbol: string;
|
|
552
|
-
type: "substrate-foreignassets";
|
|
553
|
-
platform: "polkadot";
|
|
554
|
-
onChainId: string;
|
|
555
|
-
isSufficient: boolean;
|
|
556
|
-
existentialDeposit: string;
|
|
557
|
-
isDefault?: boolean | undefined;
|
|
558
|
-
name?: string | undefined;
|
|
559
|
-
logo?: string | undefined;
|
|
560
|
-
coingeckoId?: string | undefined;
|
|
561
|
-
noDiscovery?: boolean | undefined;
|
|
562
|
-
mirrorOf?: string | undefined;
|
|
563
|
-
isFrozen?: boolean | undefined;
|
|
564
|
-
} | {
|
|
565
|
-
id: string;
|
|
566
|
-
networkId: string;
|
|
567
|
-
decimals: number;
|
|
568
|
-
symbol: string;
|
|
569
|
-
type: "substrate-native";
|
|
570
|
-
platform: "polkadot";
|
|
571
|
-
existentialDeposit: string;
|
|
572
|
-
isDefault?: boolean | undefined;
|
|
573
|
-
name?: string | undefined;
|
|
574
|
-
logo?: string | undefined;
|
|
575
|
-
coingeckoId?: string | undefined;
|
|
576
|
-
noDiscovery?: boolean | undefined;
|
|
577
|
-
mirrorOf?: string | undefined;
|
|
578
|
-
} | {
|
|
579
|
-
id: string;
|
|
580
|
-
networkId: string;
|
|
581
|
-
decimals: number;
|
|
582
|
-
symbol: string;
|
|
583
|
-
type: "substrate-psp22";
|
|
584
|
-
platform: "polkadot";
|
|
585
|
-
contractAddress: string;
|
|
586
|
-
isDefault?: boolean | undefined;
|
|
587
|
-
name?: string | undefined;
|
|
588
|
-
logo?: string | undefined;
|
|
589
|
-
coingeckoId?: string | undefined;
|
|
590
|
-
noDiscovery?: boolean | undefined;
|
|
591
|
-
mirrorOf?: string | undefined;
|
|
592
|
-
} | {
|
|
593
|
-
id: string;
|
|
594
|
-
networkId: string;
|
|
595
|
-
decimals: number;
|
|
596
|
-
symbol: string;
|
|
597
|
-
type: "substrate-tokens";
|
|
598
|
-
platform: "polkadot";
|
|
599
|
-
onChainId: string | number;
|
|
600
|
-
existentialDeposit: string;
|
|
601
|
-
isDefault?: boolean | undefined;
|
|
602
|
-
name?: string | undefined;
|
|
603
|
-
logo?: string | undefined;
|
|
604
|
-
coingeckoId?: string | undefined;
|
|
605
|
-
noDiscovery?: boolean | undefined;
|
|
606
|
-
mirrorOf?: string | undefined;
|
|
607
|
-
} | {
|
|
608
|
-
id: string;
|
|
609
|
-
networkId: string;
|
|
610
|
-
decimals: number;
|
|
611
|
-
symbol: string;
|
|
612
|
-
type: "substrate-hydration";
|
|
613
|
-
platform: "polkadot";
|
|
614
|
-
onChainId: number;
|
|
615
|
-
assetType: "Token" | "Erc20" | "External";
|
|
616
|
-
isSufficient: boolean;
|
|
617
|
-
existentialDeposit: string;
|
|
618
|
-
isDefault?: boolean | undefined;
|
|
619
|
-
name?: string | undefined;
|
|
620
|
-
logo?: string | undefined;
|
|
621
|
-
coingeckoId?: string | undefined;
|
|
622
|
-
noDiscovery?: boolean | undefined;
|
|
623
|
-
mirrorOf?: string | undefined;
|
|
624
|
-
})[];
|
|
625
|
-
export declare const useTokensById: () => import("@talismn/chaindata-provider").TokenList;
|
|
626
|
-
export declare const useToken: (tokenId?: TokenId) => {
|
|
627
|
-
id: string;
|
|
628
|
-
networkId: string;
|
|
629
|
-
decimals: number;
|
|
630
|
-
symbol: string;
|
|
631
|
-
type: "evm-erc20";
|
|
632
|
-
platform: "ethereum";
|
|
633
|
-
contractAddress: `0x${string}`;
|
|
634
|
-
isDefault?: boolean | undefined;
|
|
635
|
-
name?: string | undefined;
|
|
636
|
-
logo?: string | undefined;
|
|
637
|
-
coingeckoId?: string | undefined;
|
|
638
|
-
noDiscovery?: boolean | undefined;
|
|
639
|
-
mirrorOf?: string | undefined;
|
|
640
|
-
} | {
|
|
641
|
-
id: string;
|
|
642
|
-
networkId: string;
|
|
643
|
-
decimals: number;
|
|
644
|
-
symbol: string;
|
|
645
|
-
type: "evm-native";
|
|
646
|
-
platform: "ethereum";
|
|
647
|
-
isDefault?: boolean | undefined;
|
|
648
|
-
name?: string | undefined;
|
|
649
|
-
logo?: string | undefined;
|
|
650
|
-
coingeckoId?: string | undefined;
|
|
651
|
-
noDiscovery?: boolean | undefined;
|
|
652
|
-
mirrorOf?: string | undefined;
|
|
653
|
-
} | {
|
|
654
|
-
id: string;
|
|
655
|
-
networkId: string;
|
|
656
|
-
decimals: number;
|
|
657
|
-
symbol: string;
|
|
658
|
-
type: "evm-uniswapv2";
|
|
659
|
-
platform: "ethereum";
|
|
660
|
-
contractAddress: `0x${string}`;
|
|
661
|
-
symbol0: string;
|
|
662
|
-
symbol1: string;
|
|
663
|
-
decimals0: number;
|
|
664
|
-
decimals1: number;
|
|
665
|
-
tokenAddress0: `0x${string}`;
|
|
666
|
-
tokenAddress1: `0x${string}`;
|
|
667
|
-
isDefault?: boolean | undefined;
|
|
668
|
-
name?: string | undefined;
|
|
669
|
-
logo?: string | undefined;
|
|
670
|
-
coingeckoId?: string | undefined;
|
|
671
|
-
noDiscovery?: boolean | undefined;
|
|
672
|
-
mirrorOf?: string | undefined;
|
|
673
|
-
isCustom?: boolean | undefined;
|
|
674
|
-
coingeckoId0?: string | undefined;
|
|
675
|
-
coingeckoId1?: string | undefined;
|
|
676
|
-
} | {
|
|
677
|
-
id: string;
|
|
678
|
-
networkId: string;
|
|
679
|
-
decimals: number;
|
|
680
|
-
symbol: string;
|
|
681
|
-
type: "substrate-assets";
|
|
682
|
-
platform: "polkadot";
|
|
683
|
-
assetId: string;
|
|
684
|
-
isSufficient: boolean;
|
|
685
|
-
existentialDeposit: string;
|
|
686
|
-
isDefault?: boolean | undefined;
|
|
687
|
-
name?: string | undefined;
|
|
688
|
-
logo?: string | undefined;
|
|
689
|
-
coingeckoId?: string | undefined;
|
|
690
|
-
noDiscovery?: boolean | undefined;
|
|
691
|
-
mirrorOf?: string | undefined;
|
|
692
|
-
isFrozen?: boolean | undefined;
|
|
693
|
-
} | {
|
|
694
|
-
id: string;
|
|
695
|
-
networkId: string;
|
|
696
|
-
decimals: number;
|
|
697
|
-
symbol: string;
|
|
698
|
-
type: "substrate-foreignassets";
|
|
699
|
-
platform: "polkadot";
|
|
700
|
-
onChainId: string;
|
|
701
|
-
isSufficient: boolean;
|
|
702
|
-
existentialDeposit: string;
|
|
703
|
-
isDefault?: boolean | undefined;
|
|
704
|
-
name?: string | undefined;
|
|
705
|
-
logo?: string | undefined;
|
|
706
|
-
coingeckoId?: string | undefined;
|
|
707
|
-
noDiscovery?: boolean | undefined;
|
|
708
|
-
mirrorOf?: string | undefined;
|
|
709
|
-
isFrozen?: boolean | undefined;
|
|
710
|
-
} | {
|
|
711
|
-
id: string;
|
|
712
|
-
networkId: string;
|
|
713
|
-
decimals: number;
|
|
714
|
-
symbol: string;
|
|
715
|
-
type: "substrate-native";
|
|
716
|
-
platform: "polkadot";
|
|
717
|
-
existentialDeposit: string;
|
|
718
|
-
isDefault?: boolean | undefined;
|
|
719
|
-
name?: string | undefined;
|
|
720
|
-
logo?: string | undefined;
|
|
721
|
-
coingeckoId?: string | undefined;
|
|
722
|
-
noDiscovery?: boolean | undefined;
|
|
723
|
-
mirrorOf?: string | undefined;
|
|
724
|
-
} | {
|
|
725
|
-
id: string;
|
|
726
|
-
networkId: string;
|
|
727
|
-
decimals: number;
|
|
728
|
-
symbol: string;
|
|
729
|
-
type: "substrate-psp22";
|
|
730
|
-
platform: "polkadot";
|
|
731
|
-
contractAddress: string;
|
|
732
|
-
isDefault?: boolean | undefined;
|
|
733
|
-
name?: string | undefined;
|
|
734
|
-
logo?: string | undefined;
|
|
735
|
-
coingeckoId?: string | undefined;
|
|
736
|
-
noDiscovery?: boolean | undefined;
|
|
737
|
-
mirrorOf?: string | undefined;
|
|
738
|
-
} | {
|
|
739
|
-
id: string;
|
|
740
|
-
networkId: string;
|
|
741
|
-
decimals: number;
|
|
742
|
-
symbol: string;
|
|
743
|
-
type: "substrate-tokens";
|
|
744
|
-
platform: "polkadot";
|
|
745
|
-
onChainId: string | number;
|
|
746
|
-
existentialDeposit: string;
|
|
747
|
-
isDefault?: boolean | undefined;
|
|
748
|
-
name?: string | undefined;
|
|
749
|
-
logo?: string | undefined;
|
|
750
|
-
coingeckoId?: string | undefined;
|
|
751
|
-
noDiscovery?: boolean | undefined;
|
|
752
|
-
mirrorOf?: string | undefined;
|
|
753
|
-
} | {
|
|
754
|
-
id: string;
|
|
755
|
-
networkId: string;
|
|
756
|
-
decimals: number;
|
|
757
|
-
symbol: string;
|
|
758
|
-
type: "substrate-hydration";
|
|
759
|
-
platform: "polkadot";
|
|
760
|
-
onChainId: number;
|
|
761
|
-
assetType: "Token" | "Erc20" | "External";
|
|
762
|
-
isSufficient: boolean;
|
|
763
|
-
existentialDeposit: string;
|
|
764
|
-
isDefault?: boolean | undefined;
|
|
765
|
-
name?: string | undefined;
|
|
766
|
-
logo?: string | undefined;
|
|
767
|
-
coingeckoId?: string | undefined;
|
|
768
|
-
noDiscovery?: boolean | undefined;
|
|
769
|
-
mirrorOf?: string | undefined;
|
|
294
|
+
})[];
|
|
770
295
|
};
|
|
296
|
+
export declare const useNetworks: () => Network[];
|
|
297
|
+
export declare const useNetworksById: () => NetworkList;
|
|
298
|
+
export declare const useDotNetworksByGenesisHash: () => Record<string, DotNetwork>;
|
|
299
|
+
export declare const useNetwork: (networkId?: NetworkId) => Network | null;
|
|
300
|
+
export declare const useTokens: () => Token[];
|
|
301
|
+
export declare const useTokensById: () => TokenList;
|
|
302
|
+
export declare const useToken: (tokenId?: TokenId) => Token | null;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { TokenId } from "@talismn/chaindata-provider";
|
|
2
|
-
export declare const useTokenRates: () =>
|
|
3
|
-
[k: string]: import("@talismn/token-rates").TokenRates;
|
|
4
|
-
};
|
|
2
|
+
export declare const useTokenRates: () => import("@talismn/token-rates").TokenRatesList;
|
|
5
3
|
export declare const useTokenRate: (tokenId?: TokenId) => import("@talismn/token-rates").TokenRates;
|
|
@@ -8,13 +8,11 @@ var chaindataProvider = require('@talismn/chaindata-provider');
|
|
|
8
8
|
var balances = require('@talismn/balances');
|
|
9
9
|
var jotaiEffect = require('jotai-effect');
|
|
10
10
|
var lodashEs = require('lodash-es');
|
|
11
|
-
var
|
|
12
|
-
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
11
|
+
var chainConnectors = require('@talismn/chain-connectors');
|
|
13
12
|
var connectionMeta = require('@talismn/connection-meta');
|
|
14
13
|
var util = require('@talismn/util');
|
|
15
14
|
var utils = require('jotai/utils');
|
|
16
15
|
var rxjs = require('rxjs');
|
|
17
|
-
var dexie = require('dexie');
|
|
18
16
|
var anylogger = require('anylogger');
|
|
19
17
|
var utilCrypto = require('@polkadot/util-crypto');
|
|
20
18
|
|
|
@@ -34,16 +32,30 @@ const enabledTokensAtom = jotai.atom(undefined);
|
|
|
34
32
|
const allAddressesAtom = jotai.atom([]);
|
|
35
33
|
|
|
36
34
|
const chaindataProviderAtom = jotai.atom(() => {
|
|
37
|
-
return new chaindataProvider.ChaindataProvider({
|
|
35
|
+
return new chaindataProvider.ChaindataProvider({
|
|
36
|
+
// TODO pass persistedStorage
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const useSyncSwapsChaindata = () => jotai.useAtom(syncSwapsChaindataAtomEffect);
|
|
40
|
+
const syncSwapsChaindataAtomEffect = jotaiEffect.atomEffect(get => {
|
|
41
|
+
const chaindataProvider = get(chaindataProviderAtom);
|
|
42
|
+
|
|
43
|
+
// keep subscription open when swaps modal is open
|
|
44
|
+
const subscription = chaindataProvider.networks$.subscribe();
|
|
45
|
+
|
|
46
|
+
// close susbcription when swaps modal closes
|
|
47
|
+
return () => subscription.unsubscribe();
|
|
38
48
|
});
|
|
39
49
|
|
|
40
50
|
const chainConnectorsAtom = jotai.atom(get => {
|
|
41
51
|
const chaindataProvider = get(chaindataProviderAtom);
|
|
42
|
-
const substrate = new
|
|
43
|
-
const evm = new
|
|
52
|
+
const substrate = new chainConnectors.ChainConnectorDot(chaindataProvider, connectionMeta.connectionMetaDb);
|
|
53
|
+
const evm = new chainConnectors.ChainConnectorEth(chaindataProvider);
|
|
54
|
+
const solana = new chainConnectors.ChainConnectorSol(chaindataProvider);
|
|
44
55
|
return {
|
|
45
56
|
substrate,
|
|
46
|
-
evm
|
|
57
|
+
evm,
|
|
58
|
+
solana
|
|
47
59
|
};
|
|
48
60
|
});
|
|
49
61
|
|
|
@@ -87,32 +99,17 @@ var packageJson = {
|
|
|
87
99
|
|
|
88
100
|
var log = anylogger__default.default(packageJson.name);
|
|
89
101
|
|
|
90
|
-
/**
|
|
91
|
-
* Converts a dexie Observable into an rxjs Observable.
|
|
92
|
-
*/
|
|
93
|
-
function dexieToRxjs(o) {
|
|
94
|
-
return new rxjs.Observable(observer => {
|
|
95
|
-
const subscription = o.subscribe({
|
|
96
|
-
next: value => observer.next(value),
|
|
97
|
-
error: error => observer.error(error)
|
|
98
|
-
});
|
|
99
|
-
return () => subscription.unsubscribe();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
102
|
const tokenRatesAtom = jotai.atom(async get => {
|
|
104
103
|
// runs a timer to keep tokenRates up to date
|
|
105
104
|
get(tokenRatesFetcherAtomEffect);
|
|
106
|
-
return await get(tokenRatesDbAtom);
|
|
105
|
+
return (await get(tokenRatesDbAtom)).tokenRates;
|
|
107
106
|
});
|
|
108
|
-
const tokenRatesDbAtom = utils.atomWithObservable(() => {
|
|
109
|
-
const dbRatesToMap = dbRates => Object.fromEntries(dbRates.map(({
|
|
110
|
-
tokenId,
|
|
111
|
-
rates
|
|
112
|
-
}) => [tokenId, rates]));
|
|
113
107
|
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
// TODO: Persist to storage
|
|
109
|
+
const tokenRates$ = new rxjs.ReplaySubject(1);
|
|
110
|
+
const tokenRatesDbAtom = utils.atomWithObservable(() => {
|
|
111
|
+
tokenRates.tryToDeleteOldTokenRatesDb();
|
|
112
|
+
return tokenRates$.asObservable();
|
|
116
113
|
});
|
|
117
114
|
const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
118
115
|
// lets us tear down the existing timer when the effect is restarted
|
|
@@ -123,7 +120,6 @@ const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
|
123
120
|
const tokensPromise = get(tokensAtom);
|
|
124
121
|
(async () => {
|
|
125
122
|
const tokensById = lodashEs.keyBy(await tokensPromise, "id");
|
|
126
|
-
const tokenIds = Object.keys(tokensById);
|
|
127
123
|
const loopMs = 300_000; // 300_000ms = 300s = 5 minutes
|
|
128
124
|
const retryTimeout = 5_000; // 5_000ms = 5 seconds
|
|
129
125
|
|
|
@@ -131,21 +127,11 @@ const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
|
131
127
|
try {
|
|
132
128
|
if (abort.signal.aborted) return; // don't fetch if aborted
|
|
133
129
|
const tokenRates$1 = await tokenRates.fetchTokenRates(tokensById, tokenRates.ALL_CURRENCY_IDS, coinsApiConfig);
|
|
134
|
-
const putTokenRates =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}));
|
|
130
|
+
const putTokenRates = {
|
|
131
|
+
tokenRates: tokenRates$1
|
|
132
|
+
};
|
|
138
133
|
if (abort.signal.aborted) return; // don't insert into db if aborted
|
|
139
|
-
|
|
140
|
-
// override all tokenRates
|
|
141
|
-
await tokenRates.db.tokenRates.bulkPut(putTokenRates);
|
|
142
|
-
|
|
143
|
-
// delete tokenRates for tokens which no longer exist
|
|
144
|
-
const validTokenIds = new Set(tokenIds);
|
|
145
|
-
const tokenRatesIds = await tokenRates.db.tokenRates.toCollection().primaryKeys();
|
|
146
|
-
const deleteIds = tokenRatesIds.filter(id => !validTokenIds.has(id));
|
|
147
|
-
if (deleteIds.length > 0) await tokenRates.db.tokenRates.bulkDelete(deleteIds);
|
|
148
|
-
});
|
|
134
|
+
tokenRates$.next(putTokenRates);
|
|
149
135
|
if (abort.signal.aborted) return; // don't schedule next loop if aborted
|
|
150
136
|
setTimeout(hydrate, loopMs);
|
|
151
137
|
} catch (error) {
|
|
@@ -348,6 +334,7 @@ exports.useNetwork = useNetwork;
|
|
|
348
334
|
exports.useNetworks = useNetworks;
|
|
349
335
|
exports.useNetworksById = useNetworksById;
|
|
350
336
|
exports.useSetBalancesAddresses = useSetBalancesAddresses;
|
|
337
|
+
exports.useSyncSwapsChaindata = useSyncSwapsChaindata;
|
|
351
338
|
exports.useToken = useToken;
|
|
352
339
|
exports.useTokenRate = useTokenRate;
|
|
353
340
|
exports.useTokenRates = useTokenRates;
|
|
@@ -8,13 +8,11 @@ var chaindataProvider = require('@talismn/chaindata-provider');
|
|
|
8
8
|
var balances = require('@talismn/balances');
|
|
9
9
|
var jotaiEffect = require('jotai-effect');
|
|
10
10
|
var lodashEs = require('lodash-es');
|
|
11
|
-
var
|
|
12
|
-
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
11
|
+
var chainConnectors = require('@talismn/chain-connectors');
|
|
13
12
|
var connectionMeta = require('@talismn/connection-meta');
|
|
14
13
|
var util = require('@talismn/util');
|
|
15
14
|
var utils = require('jotai/utils');
|
|
16
15
|
var rxjs = require('rxjs');
|
|
17
|
-
var dexie = require('dexie');
|
|
18
16
|
var anylogger = require('anylogger');
|
|
19
17
|
var utilCrypto = require('@polkadot/util-crypto');
|
|
20
18
|
|
|
@@ -34,16 +32,30 @@ const enabledTokensAtom = jotai.atom(undefined);
|
|
|
34
32
|
const allAddressesAtom = jotai.atom([]);
|
|
35
33
|
|
|
36
34
|
const chaindataProviderAtom = jotai.atom(() => {
|
|
37
|
-
return new chaindataProvider.ChaindataProvider({
|
|
35
|
+
return new chaindataProvider.ChaindataProvider({
|
|
36
|
+
// TODO pass persistedStorage
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const useSyncSwapsChaindata = () => jotai.useAtom(syncSwapsChaindataAtomEffect);
|
|
40
|
+
const syncSwapsChaindataAtomEffect = jotaiEffect.atomEffect(get => {
|
|
41
|
+
const chaindataProvider = get(chaindataProviderAtom);
|
|
42
|
+
|
|
43
|
+
// keep subscription open when swaps modal is open
|
|
44
|
+
const subscription = chaindataProvider.networks$.subscribe();
|
|
45
|
+
|
|
46
|
+
// close susbcription when swaps modal closes
|
|
47
|
+
return () => subscription.unsubscribe();
|
|
38
48
|
});
|
|
39
49
|
|
|
40
50
|
const chainConnectorsAtom = jotai.atom(get => {
|
|
41
51
|
const chaindataProvider = get(chaindataProviderAtom);
|
|
42
|
-
const substrate = new
|
|
43
|
-
const evm = new
|
|
52
|
+
const substrate = new chainConnectors.ChainConnectorDot(chaindataProvider, connectionMeta.connectionMetaDb);
|
|
53
|
+
const evm = new chainConnectors.ChainConnectorEth(chaindataProvider);
|
|
54
|
+
const solana = new chainConnectors.ChainConnectorSol(chaindataProvider);
|
|
44
55
|
return {
|
|
45
56
|
substrate,
|
|
46
|
-
evm
|
|
57
|
+
evm,
|
|
58
|
+
solana
|
|
47
59
|
};
|
|
48
60
|
});
|
|
49
61
|
|
|
@@ -87,32 +99,17 @@ var packageJson = {
|
|
|
87
99
|
|
|
88
100
|
var log = anylogger__default.default(packageJson.name);
|
|
89
101
|
|
|
90
|
-
/**
|
|
91
|
-
* Converts a dexie Observable into an rxjs Observable.
|
|
92
|
-
*/
|
|
93
|
-
function dexieToRxjs(o) {
|
|
94
|
-
return new rxjs.Observable(observer => {
|
|
95
|
-
const subscription = o.subscribe({
|
|
96
|
-
next: value => observer.next(value),
|
|
97
|
-
error: error => observer.error(error)
|
|
98
|
-
});
|
|
99
|
-
return () => subscription.unsubscribe();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
102
|
const tokenRatesAtom = jotai.atom(async get => {
|
|
104
103
|
// runs a timer to keep tokenRates up to date
|
|
105
104
|
get(tokenRatesFetcherAtomEffect);
|
|
106
|
-
return await get(tokenRatesDbAtom);
|
|
105
|
+
return (await get(tokenRatesDbAtom)).tokenRates;
|
|
107
106
|
});
|
|
108
|
-
const tokenRatesDbAtom = utils.atomWithObservable(() => {
|
|
109
|
-
const dbRatesToMap = dbRates => Object.fromEntries(dbRates.map(({
|
|
110
|
-
tokenId,
|
|
111
|
-
rates
|
|
112
|
-
}) => [tokenId, rates]));
|
|
113
107
|
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
// TODO: Persist to storage
|
|
109
|
+
const tokenRates$ = new rxjs.ReplaySubject(1);
|
|
110
|
+
const tokenRatesDbAtom = utils.atomWithObservable(() => {
|
|
111
|
+
tokenRates.tryToDeleteOldTokenRatesDb();
|
|
112
|
+
return tokenRates$.asObservable();
|
|
116
113
|
});
|
|
117
114
|
const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
118
115
|
// lets us tear down the existing timer when the effect is restarted
|
|
@@ -123,7 +120,6 @@ const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
|
123
120
|
const tokensPromise = get(tokensAtom);
|
|
124
121
|
(async () => {
|
|
125
122
|
const tokensById = lodashEs.keyBy(await tokensPromise, "id");
|
|
126
|
-
const tokenIds = Object.keys(tokensById);
|
|
127
123
|
const loopMs = 300_000; // 300_000ms = 300s = 5 minutes
|
|
128
124
|
const retryTimeout = 5_000; // 5_000ms = 5 seconds
|
|
129
125
|
|
|
@@ -131,21 +127,11 @@ const tokenRatesFetcherAtomEffect = jotaiEffect.atomEffect(get => {
|
|
|
131
127
|
try {
|
|
132
128
|
if (abort.signal.aborted) return; // don't fetch if aborted
|
|
133
129
|
const tokenRates$1 = await tokenRates.fetchTokenRates(tokensById, tokenRates.ALL_CURRENCY_IDS, coinsApiConfig);
|
|
134
|
-
const putTokenRates =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}));
|
|
130
|
+
const putTokenRates = {
|
|
131
|
+
tokenRates: tokenRates$1
|
|
132
|
+
};
|
|
138
133
|
if (abort.signal.aborted) return; // don't insert into db if aborted
|
|
139
|
-
|
|
140
|
-
// override all tokenRates
|
|
141
|
-
await tokenRates.db.tokenRates.bulkPut(putTokenRates);
|
|
142
|
-
|
|
143
|
-
// delete tokenRates for tokens which no longer exist
|
|
144
|
-
const validTokenIds = new Set(tokenIds);
|
|
145
|
-
const tokenRatesIds = await tokenRates.db.tokenRates.toCollection().primaryKeys();
|
|
146
|
-
const deleteIds = tokenRatesIds.filter(id => !validTokenIds.has(id));
|
|
147
|
-
if (deleteIds.length > 0) await tokenRates.db.tokenRates.bulkDelete(deleteIds);
|
|
148
|
-
});
|
|
134
|
+
tokenRates$.next(putTokenRates);
|
|
149
135
|
if (abort.signal.aborted) return; // don't schedule next loop if aborted
|
|
150
136
|
setTimeout(hydrate, loopMs);
|
|
151
137
|
} catch (error) {
|
|
@@ -348,6 +334,7 @@ exports.useNetwork = useNetwork;
|
|
|
348
334
|
exports.useNetworks = useNetworks;
|
|
349
335
|
exports.useNetworksById = useNetworksById;
|
|
350
336
|
exports.useSetBalancesAddresses = useSetBalancesAddresses;
|
|
337
|
+
exports.useSyncSwapsChaindata = useSyncSwapsChaindata;
|
|
351
338
|
exports.useToken = useToken;
|
|
352
339
|
exports.useTokenRate = useTokenRate;
|
|
353
340
|
exports.useTokenRates = useTokenRates;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { atom, useSetAtom, useAtomValue } from 'jotai';
|
|
1
|
+
import { atom, useAtom, useSetAtom, useAtomValue } from 'jotai';
|
|
2
2
|
import { useMemo, useEffect } from 'react';
|
|
3
|
-
import { DEFAULT_COINSAPI_CONFIG,
|
|
3
|
+
import { DEFAULT_COINSAPI_CONFIG, tryToDeleteOldTokenRatesDb, fetchTokenRates, ALL_CURRENCY_IDS } from '@talismn/token-rates';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { ChaindataProvider } from '@talismn/chaindata-provider';
|
|
6
6
|
export { evmErc20TokenId, evmNativeTokenId, subAssetTokenId, subNativeTokenId, subPsp22TokenId, subTokensTokenId } from '@talismn/chaindata-provider';
|
|
7
7
|
import { BalancesProvider as BalancesProvider$1, Balances } from '@talismn/balances';
|
|
8
8
|
import { atomEffect } from 'jotai-effect';
|
|
9
9
|
import { keyBy, fromPairs } from 'lodash-es';
|
|
10
|
-
import {
|
|
11
|
-
import { ChainConnectorEvm } from '@talismn/chain-connector-evm';
|
|
10
|
+
import { ChainConnectorDot, ChainConnectorEth, ChainConnectorSol } from '@talismn/chain-connectors';
|
|
12
11
|
import { connectionMetaDb } from '@talismn/connection-meta';
|
|
13
12
|
import { firstThenDebounce, isTruthy, isAbortError } from '@talismn/util';
|
|
14
13
|
import { atomWithObservable } from 'jotai/utils';
|
|
15
|
-
import { combineLatest,
|
|
16
|
-
import { liveQuery } from 'dexie';
|
|
14
|
+
import { combineLatest, ReplaySubject } from 'rxjs';
|
|
17
15
|
import anylogger from 'anylogger';
|
|
18
16
|
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
|
19
17
|
|
|
@@ -29,16 +27,30 @@ const enabledTokensAtom = atom(undefined);
|
|
|
29
27
|
const allAddressesAtom = atom([]);
|
|
30
28
|
|
|
31
29
|
const chaindataProviderAtom = atom(() => {
|
|
32
|
-
return new ChaindataProvider({
|
|
30
|
+
return new ChaindataProvider({
|
|
31
|
+
// TODO pass persistedStorage
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
const useSyncSwapsChaindata = () => useAtom(syncSwapsChaindataAtomEffect);
|
|
35
|
+
const syncSwapsChaindataAtomEffect = atomEffect(get => {
|
|
36
|
+
const chaindataProvider = get(chaindataProviderAtom);
|
|
37
|
+
|
|
38
|
+
// keep subscription open when swaps modal is open
|
|
39
|
+
const subscription = chaindataProvider.networks$.subscribe();
|
|
40
|
+
|
|
41
|
+
// close susbcription when swaps modal closes
|
|
42
|
+
return () => subscription.unsubscribe();
|
|
33
43
|
});
|
|
34
44
|
|
|
35
45
|
const chainConnectorsAtom = atom(get => {
|
|
36
46
|
const chaindataProvider = get(chaindataProviderAtom);
|
|
37
|
-
const substrate = new
|
|
38
|
-
const evm = new
|
|
47
|
+
const substrate = new ChainConnectorDot(chaindataProvider, connectionMetaDb);
|
|
48
|
+
const evm = new ChainConnectorEth(chaindataProvider);
|
|
49
|
+
const solana = new ChainConnectorSol(chaindataProvider);
|
|
39
50
|
return {
|
|
40
51
|
substrate,
|
|
41
|
-
evm
|
|
52
|
+
evm,
|
|
53
|
+
solana
|
|
42
54
|
};
|
|
43
55
|
});
|
|
44
56
|
|
|
@@ -82,32 +94,17 @@ var packageJson = {
|
|
|
82
94
|
|
|
83
95
|
var log = anylogger(packageJson.name);
|
|
84
96
|
|
|
85
|
-
/**
|
|
86
|
-
* Converts a dexie Observable into an rxjs Observable.
|
|
87
|
-
*/
|
|
88
|
-
function dexieToRxjs(o) {
|
|
89
|
-
return new Observable(observer => {
|
|
90
|
-
const subscription = o.subscribe({
|
|
91
|
-
next: value => observer.next(value),
|
|
92
|
-
error: error => observer.error(error)
|
|
93
|
-
});
|
|
94
|
-
return () => subscription.unsubscribe();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
97
|
const tokenRatesAtom = atom(async get => {
|
|
99
98
|
// runs a timer to keep tokenRates up to date
|
|
100
99
|
get(tokenRatesFetcherAtomEffect);
|
|
101
|
-
return await get(tokenRatesDbAtom);
|
|
100
|
+
return (await get(tokenRatesDbAtom)).tokenRates;
|
|
102
101
|
});
|
|
103
|
-
const tokenRatesDbAtom = atomWithObservable(() => {
|
|
104
|
-
const dbRatesToMap = dbRates => Object.fromEntries(dbRates.map(({
|
|
105
|
-
tokenId,
|
|
106
|
-
rates
|
|
107
|
-
}) => [tokenId, rates]));
|
|
108
102
|
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
// TODO: Persist to storage
|
|
104
|
+
const tokenRates$ = new ReplaySubject(1);
|
|
105
|
+
const tokenRatesDbAtom = atomWithObservable(() => {
|
|
106
|
+
tryToDeleteOldTokenRatesDb();
|
|
107
|
+
return tokenRates$.asObservable();
|
|
111
108
|
});
|
|
112
109
|
const tokenRatesFetcherAtomEffect = atomEffect(get => {
|
|
113
110
|
// lets us tear down the existing timer when the effect is restarted
|
|
@@ -118,7 +115,6 @@ const tokenRatesFetcherAtomEffect = atomEffect(get => {
|
|
|
118
115
|
const tokensPromise = get(tokensAtom);
|
|
119
116
|
(async () => {
|
|
120
117
|
const tokensById = keyBy(await tokensPromise, "id");
|
|
121
|
-
const tokenIds = Object.keys(tokensById);
|
|
122
118
|
const loopMs = 300_000; // 300_000ms = 300s = 5 minutes
|
|
123
119
|
const retryTimeout = 5_000; // 5_000ms = 5 seconds
|
|
124
120
|
|
|
@@ -126,21 +122,11 @@ const tokenRatesFetcherAtomEffect = atomEffect(get => {
|
|
|
126
122
|
try {
|
|
127
123
|
if (abort.signal.aborted) return; // don't fetch if aborted
|
|
128
124
|
const tokenRates = await fetchTokenRates(tokensById, ALL_CURRENCY_IDS, coinsApiConfig);
|
|
129
|
-
const putTokenRates =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}));
|
|
125
|
+
const putTokenRates = {
|
|
126
|
+
tokenRates
|
|
127
|
+
};
|
|
133
128
|
if (abort.signal.aborted) return; // don't insert into db if aborted
|
|
134
|
-
|
|
135
|
-
// override all tokenRates
|
|
136
|
-
await db.tokenRates.bulkPut(putTokenRates);
|
|
137
|
-
|
|
138
|
-
// delete tokenRates for tokens which no longer exist
|
|
139
|
-
const validTokenIds = new Set(tokenIds);
|
|
140
|
-
const tokenRatesIds = await db.tokenRates.toCollection().primaryKeys();
|
|
141
|
-
const deleteIds = tokenRatesIds.filter(id => !validTokenIds.has(id));
|
|
142
|
-
if (deleteIds.length > 0) await db.tokenRates.bulkDelete(deleteIds);
|
|
143
|
-
});
|
|
129
|
+
tokenRates$.next(putTokenRates);
|
|
144
130
|
if (abort.signal.aborted) return; // don't schedule next loop if aborted
|
|
145
131
|
setTimeout(hydrate, loopMs);
|
|
146
132
|
} catch (error) {
|
|
@@ -291,4 +277,4 @@ const BalancesProvider = ({
|
|
|
291
277
|
});
|
|
292
278
|
};
|
|
293
279
|
|
|
294
|
-
export { BalancesProvider, allAddressesAtom, balancesAtom, chainConnectorsAtom, chaindataAtom, chaindataProviderAtom, coinsApiConfigAtom, cryptoWaitReadyAtom, dotNetworksByGenesisHashAtom, enableTestnetsAtom, enabledChainsAtom, enabledTokensAtom, getStaleChains, networksAtom, networksByIdAtom, tokenRatesAtom, tokensAtom, tokensByIdAtom, useBalances, useBalancesStatus, useChainConnectors, useChaindata, useChaindataProvider, useDotNetworksByGenesisHash, useNetwork, useNetworks, useNetworksById, useSetBalancesAddresses, useToken, useTokenRate, useTokenRates, useTokens, useTokensById };
|
|
280
|
+
export { BalancesProvider, allAddressesAtom, balancesAtom, chainConnectorsAtom, chaindataAtom, chaindataProviderAtom, coinsApiConfigAtom, cryptoWaitReadyAtom, dotNetworksByGenesisHashAtom, enableTestnetsAtom, enabledChainsAtom, enabledTokensAtom, getStaleChains, networksAtom, networksByIdAtom, tokenRatesAtom, tokensAtom, tokensByIdAtom, useBalances, useBalancesStatus, useChainConnectors, useChaindata, useChaindataProvider, useDotNetworksByGenesisHash, useNetwork, useNetworks, useNetworksById, useSetBalancesAddresses, useSyncSwapsChaindata, useToken, useTokenRate, useTokenRates, useTokens, useTokensById };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/balances-react",
|
|
3
|
-
"version": "0.0.0-pr2111-
|
|
3
|
+
"version": "0.0.0-pr2111-20251022034713",
|
|
4
4
|
"author": "Talisman",
|
|
5
5
|
"homepage": "https://talisman.xyz",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -18,38 +18,35 @@
|
|
|
18
18
|
"/dist"
|
|
19
19
|
],
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"anylogger": "^1.0.11",
|
|
25
25
|
"blueimp-md5": "2.19.0",
|
|
26
|
-
"dexie": "^4.0.9",
|
|
27
|
-
"dexie-react-hooks": "^1.1.7",
|
|
28
26
|
"jotai": "~2",
|
|
29
27
|
"jotai-effect": "~1",
|
|
30
28
|
"lodash-es": "4.17.21",
|
|
31
29
|
"react-use": "^17.5.1",
|
|
32
30
|
"rxjs": "^7.8.1",
|
|
33
|
-
"@talismn/balances": "0.0.0-pr2111-
|
|
34
|
-
"@talismn/chain-
|
|
35
|
-
"@talismn/
|
|
36
|
-
"@talismn/
|
|
37
|
-
"@talismn/
|
|
38
|
-
"@talismn/
|
|
39
|
-
"@talismn/
|
|
40
|
-
"@talismn/util": "0.5.0"
|
|
31
|
+
"@talismn/balances": "0.0.0-pr2111-20251022034713",
|
|
32
|
+
"@talismn/chain-connectors": "0.0.7",
|
|
33
|
+
"@talismn/chaindata-provider": "1.1.6",
|
|
34
|
+
"@talismn/connection-meta": "0.2.27",
|
|
35
|
+
"@talismn/token-rates": "3.0.9",
|
|
36
|
+
"@talismn/util": "0.5.5",
|
|
37
|
+
"@talismn/scale": "0.2.2"
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|
|
43
40
|
"@types/jest": "^29.5.14",
|
|
44
|
-
"@types/lodash-es": "
|
|
41
|
+
"@types/lodash-es": "4.17.12",
|
|
45
42
|
"@types/react": "^18.3.12",
|
|
46
43
|
"eslint": "^8.57.1",
|
|
47
44
|
"jest": "^29.7.0",
|
|
48
45
|
"react": "^18.3.1",
|
|
49
46
|
"ts-jest": "^29.2.5",
|
|
50
47
|
"typescript": "^5.6.3",
|
|
51
|
-
"@talismn/
|
|
52
|
-
"@talismn/
|
|
48
|
+
"@talismn/eslint-config": "0.0.3",
|
|
49
|
+
"@talismn/tsconfig": "0.0.3"
|
|
53
50
|
},
|
|
54
51
|
"peerDependencies": {
|
|
55
52
|
"@polkadot/util-crypto": "*",
|