@talismn/balances-react 0.0.0-pr596-20230306035406 → 0.0.0-pr600-20230307002741
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 +3 -3
- package/dist/declarations/src/hooks/index.d.ts +2 -2
- package/dist/declarations/src/hooks/useBalanceModules.d.ts +2 -2
- package/dist/talismn-balances-react.cjs.dev.js +43 -35
- package/dist/talismn-balances-react.cjs.prod.js +43 -35
- package/dist/talismn-balances-react.esm.js +43 -35
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @talismn/balances-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-pr600-20230307002741
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
- 6643a4e: fix: ported useDbCache related perf fixes to @talismn/balances-react
|
|
13
13
|
- Updated dependencies [6643a4e]
|
|
14
14
|
- Updated dependencies [6643a4e]
|
|
15
|
-
- @talismn/token-rates@0.0.0-
|
|
16
|
-
- @talismn/balances@0.0.0-
|
|
15
|
+
- @talismn/token-rates@0.0.0-pr600-20230307002741
|
|
16
|
+
- @talismn/balances@0.0.0-pr600-20230307002741
|
|
17
17
|
|
|
18
18
|
## 0.3.3
|
|
19
19
|
|
|
@@ -11,10 +11,10 @@ export * from "./useEvmNetworks";
|
|
|
11
11
|
export * from "./useTokenRates";
|
|
12
12
|
export * from "./useTokens";
|
|
13
13
|
export * from "./useWithTestnets";
|
|
14
|
-
import { BalanceModule } from "@talismn/balances";
|
|
14
|
+
import { BalanceModule, Hydrate } from "@talismn/balances";
|
|
15
15
|
import { ReactNode } from "react";
|
|
16
16
|
export type BalancesProviderProps = {
|
|
17
|
-
balanceModules: Array<BalanceModule<any, any, any, any, any>>;
|
|
17
|
+
balanceModules: Array<(hydrate: Hydrate) => BalanceModule<any, any, any, any, any>>;
|
|
18
18
|
onfinalityApiKey?: string;
|
|
19
19
|
withTestnets?: boolean;
|
|
20
20
|
children?: ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BalanceModule } from "@talismn/balances";
|
|
2
|
+
import { BalanceModule, Hydrate } from "@talismn/balances";
|
|
3
3
|
export type BalanceModulesProviderOptions = {
|
|
4
|
-
balanceModules: Array<BalanceModule<any, any, any, any, any>>;
|
|
4
|
+
balanceModules: Array<(hydrate: Hydrate) => BalanceModule<any, any, any, any, any>>;
|
|
5
5
|
};
|
|
6
6
|
export declare const BalanceModulesProvider: import("react").FC<BalanceModulesProviderOptions & {
|
|
7
7
|
children?: import("react").ReactNode;
|
|
@@ -4,16 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var chainConnector = require('@talismn/chain-connector');
|
|
8
|
+
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
9
|
+
var chaindataProviderExtension = require('@talismn/chaindata-provider-extension');
|
|
7
10
|
var balances = require('@talismn/balances');
|
|
8
11
|
var tokenRates = require('@talismn/token-rates');
|
|
9
12
|
var dexieReactHooks = require('dexie-react-hooks');
|
|
10
13
|
var reactUse = require('react-use');
|
|
11
|
-
var chaindataProviderExtension = require('@talismn/chaindata-provider-extension');
|
|
12
14
|
var md5 = require('blueimp-md5');
|
|
13
15
|
var anylogger = require('anylogger');
|
|
14
16
|
var rxjs = require('rxjs');
|
|
15
|
-
var chainConnector = require('@talismn/chain-connector');
|
|
16
|
-
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
17
17
|
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
19
|
|
|
@@ -48,11 +48,6 @@ const provideContext = useProviderContext => {
|
|
|
48
48
|
const useAllAddressesProvider = () => react.useState([]);
|
|
49
49
|
const [AllAddressesProvider, useAllAddresses] = provideContext(useAllAddressesProvider);
|
|
50
50
|
|
|
51
|
-
const useBalanceModulesProvider = ({
|
|
52
|
-
balanceModules
|
|
53
|
-
}) => balanceModules;
|
|
54
|
-
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
55
|
-
|
|
56
51
|
function useChaindataProvider(options = {}) {
|
|
57
52
|
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
58
53
|
|
|
@@ -66,6 +61,44 @@ function useChaindataProvider(options = {}) {
|
|
|
66
61
|
}
|
|
67
62
|
const [ChaindataProvider, useChaindata] = provideContext(useChaindataProvider);
|
|
68
63
|
|
|
64
|
+
function useChainConnectorsProvider(options) {
|
|
65
|
+
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
66
|
+
|
|
67
|
+
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
68
|
+
react.useEffect(() => {
|
|
69
|
+
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
70
|
+
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
71
|
+
|
|
72
|
+
// chaindata dependency
|
|
73
|
+
const chaindata = useChaindata();
|
|
74
|
+
|
|
75
|
+
// substrate connector
|
|
76
|
+
const substrate = react.useMemo(() => new chainConnector.ChainConnector(chaindata), [chaindata]);
|
|
77
|
+
|
|
78
|
+
// evm connector
|
|
79
|
+
const evm = react.useMemo(() => new chainConnectorEvm.ChainConnectorEvm(chaindata, {
|
|
80
|
+
onfinalityApiKey
|
|
81
|
+
}), [chaindata, onfinalityApiKey]);
|
|
82
|
+
return react.useMemo(() => ({
|
|
83
|
+
substrate,
|
|
84
|
+
evm
|
|
85
|
+
}), [substrate, evm]);
|
|
86
|
+
}
|
|
87
|
+
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
88
|
+
|
|
89
|
+
const useBalanceModulesProvider = ({
|
|
90
|
+
balanceModules
|
|
91
|
+
}) => {
|
|
92
|
+
const chainConnectors = useChainConnectors();
|
|
93
|
+
const chaindataProvider = useChaindata();
|
|
94
|
+
const hydrated = react.useMemo(() => chainConnectors.substrate && chainConnectors.evm && chaindataProvider ? balanceModules.map(mod => mod({
|
|
95
|
+
chainConnectors,
|
|
96
|
+
chaindataProvider
|
|
97
|
+
})) : [], [balanceModules, chainConnectors, chaindataProvider]);
|
|
98
|
+
return hydrated;
|
|
99
|
+
};
|
|
100
|
+
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
101
|
+
|
|
69
102
|
const filterNoTestnet = ({
|
|
70
103
|
isTestnet
|
|
71
104
|
}) => isTestnet === false;
|
|
@@ -166,7 +199,7 @@ const [DbCacheProvider, useDbCache] = provideContext(useDbCacheProvider);
|
|
|
166
199
|
|
|
167
200
|
var packageJson = {
|
|
168
201
|
name: "@talismn/balances-react",
|
|
169
|
-
version: "0.0.0-
|
|
202
|
+
version: "0.0.0-pr600-20230307002741",
|
|
170
203
|
author: "Talisman",
|
|
171
204
|
homepage: "https://talisman.xyz",
|
|
172
205
|
license: "UNLICENSED",
|
|
@@ -280,31 +313,6 @@ const useSharedSubscription = (key, subscribe) => {
|
|
|
280
313
|
}, [key, subscribe]);
|
|
281
314
|
};
|
|
282
315
|
|
|
283
|
-
function useChainConnectorsProvider(options) {
|
|
284
|
-
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
285
|
-
|
|
286
|
-
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
287
|
-
react.useEffect(() => {
|
|
288
|
-
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
289
|
-
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
290
|
-
|
|
291
|
-
// chaindata dependency
|
|
292
|
-
const chaindata = useChaindata();
|
|
293
|
-
|
|
294
|
-
// substrate connector
|
|
295
|
-
const substrate = react.useMemo(() => new chainConnector.ChainConnector(chaindata), [chaindata]);
|
|
296
|
-
|
|
297
|
-
// evm connector
|
|
298
|
-
const evm = react.useMemo(() => new chainConnectorEvm.ChainConnectorEvm(chaindata, {
|
|
299
|
-
onfinalityApiKey
|
|
300
|
-
}), [chaindata, onfinalityApiKey]);
|
|
301
|
-
return react.useMemo(() => ({
|
|
302
|
-
substrate,
|
|
303
|
-
evm
|
|
304
|
-
}), [substrate, evm]);
|
|
305
|
-
}
|
|
306
|
-
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
307
|
-
|
|
308
316
|
function useTokens(withTestnets) {
|
|
309
317
|
// keep db data up to date
|
|
310
318
|
useDbCacheSubscription("tokens");
|
|
@@ -517,7 +525,7 @@ const subscribeBalances = (tokens, addresses, chainConnectors, provider, balance
|
|
|
517
525
|
id
|
|
518
526
|
}) => id);
|
|
519
527
|
const addressesByModuleToken = Object.fromEntries(Object.entries(addressesByToken).filter(([tokenId]) => moduleTokenIds.includes(tokenId)));
|
|
520
|
-
const unsub = balances.balances(balanceModule,
|
|
528
|
+
const unsub = balances.balances(balanceModule, addressesByModuleToken, (error, balances) => {
|
|
521
529
|
// log errors
|
|
522
530
|
if (error) return log.error(`Failed to fetch ${balanceModule.type} balances`, error);
|
|
523
531
|
// ignore empty balance responses
|
|
@@ -4,16 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var chainConnector = require('@talismn/chain-connector');
|
|
8
|
+
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
9
|
+
var chaindataProviderExtension = require('@talismn/chaindata-provider-extension');
|
|
7
10
|
var balances = require('@talismn/balances');
|
|
8
11
|
var tokenRates = require('@talismn/token-rates');
|
|
9
12
|
var dexieReactHooks = require('dexie-react-hooks');
|
|
10
13
|
var reactUse = require('react-use');
|
|
11
|
-
var chaindataProviderExtension = require('@talismn/chaindata-provider-extension');
|
|
12
14
|
var md5 = require('blueimp-md5');
|
|
13
15
|
var anylogger = require('anylogger');
|
|
14
16
|
var rxjs = require('rxjs');
|
|
15
|
-
var chainConnector = require('@talismn/chain-connector');
|
|
16
|
-
var chainConnectorEvm = require('@talismn/chain-connector-evm');
|
|
17
17
|
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
19
|
|
|
@@ -48,11 +48,6 @@ const provideContext = useProviderContext => {
|
|
|
48
48
|
const useAllAddressesProvider = () => react.useState([]);
|
|
49
49
|
const [AllAddressesProvider, useAllAddresses] = provideContext(useAllAddressesProvider);
|
|
50
50
|
|
|
51
|
-
const useBalanceModulesProvider = ({
|
|
52
|
-
balanceModules
|
|
53
|
-
}) => balanceModules;
|
|
54
|
-
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
55
|
-
|
|
56
51
|
function useChaindataProvider(options = {}) {
|
|
57
52
|
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
58
53
|
|
|
@@ -66,6 +61,44 @@ function useChaindataProvider(options = {}) {
|
|
|
66
61
|
}
|
|
67
62
|
const [ChaindataProvider, useChaindata] = provideContext(useChaindataProvider);
|
|
68
63
|
|
|
64
|
+
function useChainConnectorsProvider(options) {
|
|
65
|
+
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
66
|
+
|
|
67
|
+
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
68
|
+
react.useEffect(() => {
|
|
69
|
+
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
70
|
+
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
71
|
+
|
|
72
|
+
// chaindata dependency
|
|
73
|
+
const chaindata = useChaindata();
|
|
74
|
+
|
|
75
|
+
// substrate connector
|
|
76
|
+
const substrate = react.useMemo(() => new chainConnector.ChainConnector(chaindata), [chaindata]);
|
|
77
|
+
|
|
78
|
+
// evm connector
|
|
79
|
+
const evm = react.useMemo(() => new chainConnectorEvm.ChainConnectorEvm(chaindata, {
|
|
80
|
+
onfinalityApiKey
|
|
81
|
+
}), [chaindata, onfinalityApiKey]);
|
|
82
|
+
return react.useMemo(() => ({
|
|
83
|
+
substrate,
|
|
84
|
+
evm
|
|
85
|
+
}), [substrate, evm]);
|
|
86
|
+
}
|
|
87
|
+
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
88
|
+
|
|
89
|
+
const useBalanceModulesProvider = ({
|
|
90
|
+
balanceModules
|
|
91
|
+
}) => {
|
|
92
|
+
const chainConnectors = useChainConnectors();
|
|
93
|
+
const chaindataProvider = useChaindata();
|
|
94
|
+
const hydrated = react.useMemo(() => chainConnectors.substrate && chainConnectors.evm && chaindataProvider ? balanceModules.map(mod => mod({
|
|
95
|
+
chainConnectors,
|
|
96
|
+
chaindataProvider
|
|
97
|
+
})) : [], [balanceModules, chainConnectors, chaindataProvider]);
|
|
98
|
+
return hydrated;
|
|
99
|
+
};
|
|
100
|
+
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
101
|
+
|
|
69
102
|
const filterNoTestnet = ({
|
|
70
103
|
isTestnet
|
|
71
104
|
}) => isTestnet === false;
|
|
@@ -166,7 +199,7 @@ const [DbCacheProvider, useDbCache] = provideContext(useDbCacheProvider);
|
|
|
166
199
|
|
|
167
200
|
var packageJson = {
|
|
168
201
|
name: "@talismn/balances-react",
|
|
169
|
-
version: "0.0.0-
|
|
202
|
+
version: "0.0.0-pr600-20230307002741",
|
|
170
203
|
author: "Talisman",
|
|
171
204
|
homepage: "https://talisman.xyz",
|
|
172
205
|
license: "UNLICENSED",
|
|
@@ -280,31 +313,6 @@ const useSharedSubscription = (key, subscribe) => {
|
|
|
280
313
|
}, [key, subscribe]);
|
|
281
314
|
};
|
|
282
315
|
|
|
283
|
-
function useChainConnectorsProvider(options) {
|
|
284
|
-
const [onfinalityApiKey, setOnfinalityApiKey] = react.useState(options.onfinalityApiKey);
|
|
285
|
-
|
|
286
|
-
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
287
|
-
react.useEffect(() => {
|
|
288
|
-
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
289
|
-
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
290
|
-
|
|
291
|
-
// chaindata dependency
|
|
292
|
-
const chaindata = useChaindata();
|
|
293
|
-
|
|
294
|
-
// substrate connector
|
|
295
|
-
const substrate = react.useMemo(() => new chainConnector.ChainConnector(chaindata), [chaindata]);
|
|
296
|
-
|
|
297
|
-
// evm connector
|
|
298
|
-
const evm = react.useMemo(() => new chainConnectorEvm.ChainConnectorEvm(chaindata, {
|
|
299
|
-
onfinalityApiKey
|
|
300
|
-
}), [chaindata, onfinalityApiKey]);
|
|
301
|
-
return react.useMemo(() => ({
|
|
302
|
-
substrate,
|
|
303
|
-
evm
|
|
304
|
-
}), [substrate, evm]);
|
|
305
|
-
}
|
|
306
|
-
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
307
|
-
|
|
308
316
|
function useTokens(withTestnets) {
|
|
309
317
|
// keep db data up to date
|
|
310
318
|
useDbCacheSubscription("tokens");
|
|
@@ -517,7 +525,7 @@ const subscribeBalances = (tokens, addresses, chainConnectors, provider, balance
|
|
|
517
525
|
id
|
|
518
526
|
}) => id);
|
|
519
527
|
const addressesByModuleToken = Object.fromEntries(Object.entries(addressesByToken).filter(([tokenId]) => moduleTokenIds.includes(tokenId)));
|
|
520
|
-
const unsub = balances.balances(balanceModule,
|
|
528
|
+
const unsub = balances.balances(balanceModule, addressesByModuleToken, (error, balances) => {
|
|
521
529
|
// log errors
|
|
522
530
|
if (error) return log.error(`Failed to fetch ${balanceModule.type} balances`, error);
|
|
523
531
|
// ignore empty balance responses
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useContext, createContext, useState, useEffect, useMemo, useRef, useCallback } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { ChainConnector } from '@talismn/chain-connector';
|
|
4
|
+
import { ChainConnectorEvm } from '@talismn/chain-connector-evm';
|
|
5
|
+
import { ChaindataProviderExtension } from '@talismn/chaindata-provider-extension';
|
|
3
6
|
import { db as db$1, balances, Balances } from '@talismn/balances';
|
|
4
7
|
import { db, fetchTokenRates } from '@talismn/token-rates';
|
|
5
8
|
import { useLiveQuery } from 'dexie-react-hooks';
|
|
6
9
|
import { useDebounce } from 'react-use';
|
|
7
|
-
import { ChaindataProviderExtension } from '@talismn/chaindata-provider-extension';
|
|
8
10
|
import md5 from 'blueimp-md5';
|
|
9
11
|
import anylogger from 'anylogger';
|
|
10
12
|
import { Subject, Observable, defer, shareReplay } from 'rxjs';
|
|
11
|
-
import { ChainConnector } from '@talismn/chain-connector';
|
|
12
|
-
import { ChainConnectorEvm } from '@talismn/chain-connector-evm';
|
|
13
13
|
|
|
14
14
|
const provideContext = useProviderContext => {
|
|
15
15
|
// automatic typing based on our hook's return type
|
|
@@ -39,11 +39,6 @@ const provideContext = useProviderContext => {
|
|
|
39
39
|
const useAllAddressesProvider = () => useState([]);
|
|
40
40
|
const [AllAddressesProvider, useAllAddresses] = provideContext(useAllAddressesProvider);
|
|
41
41
|
|
|
42
|
-
const useBalanceModulesProvider = ({
|
|
43
|
-
balanceModules
|
|
44
|
-
}) => balanceModules;
|
|
45
|
-
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
46
|
-
|
|
47
42
|
function useChaindataProvider(options = {}) {
|
|
48
43
|
const [onfinalityApiKey, setOnfinalityApiKey] = useState(options.onfinalityApiKey);
|
|
49
44
|
|
|
@@ -57,6 +52,44 @@ function useChaindataProvider(options = {}) {
|
|
|
57
52
|
}
|
|
58
53
|
const [ChaindataProvider, useChaindata] = provideContext(useChaindataProvider);
|
|
59
54
|
|
|
55
|
+
function useChainConnectorsProvider(options) {
|
|
56
|
+
const [onfinalityApiKey, setOnfinalityApiKey] = useState(options.onfinalityApiKey);
|
|
57
|
+
|
|
58
|
+
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
61
|
+
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
62
|
+
|
|
63
|
+
// chaindata dependency
|
|
64
|
+
const chaindata = useChaindata();
|
|
65
|
+
|
|
66
|
+
// substrate connector
|
|
67
|
+
const substrate = useMemo(() => new ChainConnector(chaindata), [chaindata]);
|
|
68
|
+
|
|
69
|
+
// evm connector
|
|
70
|
+
const evm = useMemo(() => new ChainConnectorEvm(chaindata, {
|
|
71
|
+
onfinalityApiKey
|
|
72
|
+
}), [chaindata, onfinalityApiKey]);
|
|
73
|
+
return useMemo(() => ({
|
|
74
|
+
substrate,
|
|
75
|
+
evm
|
|
76
|
+
}), [substrate, evm]);
|
|
77
|
+
}
|
|
78
|
+
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
79
|
+
|
|
80
|
+
const useBalanceModulesProvider = ({
|
|
81
|
+
balanceModules
|
|
82
|
+
}) => {
|
|
83
|
+
const chainConnectors = useChainConnectors();
|
|
84
|
+
const chaindataProvider = useChaindata();
|
|
85
|
+
const hydrated = useMemo(() => chainConnectors.substrate && chainConnectors.evm && chaindataProvider ? balanceModules.map(mod => mod({
|
|
86
|
+
chainConnectors,
|
|
87
|
+
chaindataProvider
|
|
88
|
+
})) : [], [balanceModules, chainConnectors, chaindataProvider]);
|
|
89
|
+
return hydrated;
|
|
90
|
+
};
|
|
91
|
+
const [BalanceModulesProvider, useBalanceModules] = provideContext(useBalanceModulesProvider);
|
|
92
|
+
|
|
60
93
|
const filterNoTestnet = ({
|
|
61
94
|
isTestnet
|
|
62
95
|
}) => isTestnet === false;
|
|
@@ -157,7 +190,7 @@ const [DbCacheProvider, useDbCache] = provideContext(useDbCacheProvider);
|
|
|
157
190
|
|
|
158
191
|
var packageJson = {
|
|
159
192
|
name: "@talismn/balances-react",
|
|
160
|
-
version: "0.0.0-
|
|
193
|
+
version: "0.0.0-pr600-20230307002741",
|
|
161
194
|
author: "Talisman",
|
|
162
195
|
homepage: "https://talisman.xyz",
|
|
163
196
|
license: "UNLICENSED",
|
|
@@ -271,31 +304,6 @@ const useSharedSubscription = (key, subscribe) => {
|
|
|
271
304
|
}, [key, subscribe]);
|
|
272
305
|
};
|
|
273
306
|
|
|
274
|
-
function useChainConnectorsProvider(options) {
|
|
275
|
-
const [onfinalityApiKey, setOnfinalityApiKey] = useState(options.onfinalityApiKey);
|
|
276
|
-
|
|
277
|
-
// make sure we recreate provider only when the onfinalityApiKey changes
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
if (options.onfinalityApiKey !== onfinalityApiKey) setOnfinalityApiKey(options.onfinalityApiKey);
|
|
280
|
-
}, [options.onfinalityApiKey, onfinalityApiKey]);
|
|
281
|
-
|
|
282
|
-
// chaindata dependency
|
|
283
|
-
const chaindata = useChaindata();
|
|
284
|
-
|
|
285
|
-
// substrate connector
|
|
286
|
-
const substrate = useMemo(() => new ChainConnector(chaindata), [chaindata]);
|
|
287
|
-
|
|
288
|
-
// evm connector
|
|
289
|
-
const evm = useMemo(() => new ChainConnectorEvm(chaindata, {
|
|
290
|
-
onfinalityApiKey
|
|
291
|
-
}), [chaindata, onfinalityApiKey]);
|
|
292
|
-
return useMemo(() => ({
|
|
293
|
-
substrate,
|
|
294
|
-
evm
|
|
295
|
-
}), [substrate, evm]);
|
|
296
|
-
}
|
|
297
|
-
const [ChainConnectorsProvider, useChainConnectors] = provideContext(useChainConnectorsProvider);
|
|
298
|
-
|
|
299
307
|
function useTokens(withTestnets) {
|
|
300
308
|
// keep db data up to date
|
|
301
309
|
useDbCacheSubscription("tokens");
|
|
@@ -508,7 +516,7 @@ const subscribeBalances = (tokens, addresses, chainConnectors, provider, balance
|
|
|
508
516
|
id
|
|
509
517
|
}) => id);
|
|
510
518
|
const addressesByModuleToken = Object.fromEntries(Object.entries(addressesByToken).filter(([tokenId]) => moduleTokenIds.includes(tokenId)));
|
|
511
|
-
const unsub = balances(balanceModule,
|
|
519
|
+
const unsub = balances(balanceModule, addressesByModuleToken, (error, balances) => {
|
|
512
520
|
// log errors
|
|
513
521
|
if (error) return log.error(`Failed to fetch ${balanceModule.type} balances`, error);
|
|
514
522
|
// ignore empty balance responses
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/balances-react",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-pr600-20230307002741",
|
|
4
4
|
"author": "Talisman",
|
|
5
5
|
"homepage": "https://talisman.xyz",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@talismn/balances": "^0.0.0-
|
|
29
|
+
"@talismn/balances": "^0.0.0-pr600-20230307002741",
|
|
30
30
|
"@talismn/chain-connector": "^0.4.2",
|
|
31
31
|
"@talismn/chain-connector-evm": "^0.4.2",
|
|
32
32
|
"@talismn/chaindata-provider": "^0.4.2",
|
|
33
33
|
"@talismn/chaindata-provider-extension": "^0.4.2",
|
|
34
|
-
"@talismn/token-rates": "^0.0.0-
|
|
34
|
+
"@talismn/token-rates": "^0.0.0-pr600-20230307002741",
|
|
35
35
|
"anylogger": "^1.0.11",
|
|
36
36
|
"blueimp-md5": "2.19.0",
|
|
37
37
|
"dexie": "^3.2.3",
|