@talismn/balances 0.0.0-pr2043-20250619052729 → 0.0.0-pr2043-20250619091841
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.
@@ -7,7 +7,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
7
7
|
type: "evm-erc20";
|
8
8
|
platform: "ethereum";
|
9
9
|
contractAddress: `0x${string}`;
|
10
|
-
isTestnet?: boolean | undefined;
|
11
10
|
isDefault?: boolean | undefined;
|
12
11
|
logo?: string | undefined;
|
13
12
|
coingeckoId?: string | undefined;
|
@@ -24,7 +23,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
24
23
|
platform: "ethereum";
|
25
24
|
contractAddress: `0x${string}`;
|
26
25
|
isCustom: true;
|
27
|
-
isTestnet?: boolean | undefined;
|
28
26
|
isDefault?: boolean | undefined;
|
29
27
|
logo?: string | undefined;
|
30
28
|
coingeckoId?: string | undefined;
|
@@ -38,7 +36,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
38
36
|
networkId: string;
|
39
37
|
type: "evm-native";
|
40
38
|
platform: "ethereum";
|
41
|
-
isTestnet?: boolean | undefined;
|
42
39
|
isDefault?: boolean | undefined;
|
43
40
|
logo?: string | undefined;
|
44
41
|
coingeckoId?: string | undefined;
|
@@ -53,7 +50,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
53
50
|
type: "evm-native";
|
54
51
|
platform: "ethereum";
|
55
52
|
isCustom: true;
|
56
|
-
isTestnet?: boolean | undefined;
|
57
53
|
isDefault?: boolean | undefined;
|
58
54
|
logo?: string | undefined;
|
59
55
|
coingeckoId?: string | undefined;
|
@@ -74,7 +70,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
74
70
|
decimals1: number;
|
75
71
|
tokenAddress0: `0x${string}`;
|
76
72
|
tokenAddress1: `0x${string}`;
|
77
|
-
isTestnet?: boolean | undefined;
|
78
73
|
isDefault?: boolean | undefined;
|
79
74
|
logo?: string | undefined;
|
80
75
|
coingeckoId?: string | undefined;
|
@@ -99,7 +94,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
99
94
|
tokenAddress0: `0x${string}`;
|
100
95
|
tokenAddress1: `0x${string}`;
|
101
96
|
isCustom: true;
|
102
|
-
isTestnet?: boolean | undefined;
|
103
97
|
isDefault?: boolean | undefined;
|
104
98
|
logo?: string | undefined;
|
105
99
|
coingeckoId?: string | undefined;
|
@@ -117,7 +111,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
117
111
|
platform: "polkadot";
|
118
112
|
assetId: string;
|
119
113
|
existentialDeposit: string;
|
120
|
-
isTestnet?: boolean | undefined;
|
121
114
|
isDefault?: boolean | undefined;
|
122
115
|
logo?: string | undefined;
|
123
116
|
coingeckoId?: string | undefined;
|
@@ -134,7 +127,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
134
127
|
platform: "polkadot";
|
135
128
|
onChainId: string;
|
136
129
|
existentialDeposit: string;
|
137
|
-
isTestnet?: boolean | undefined;
|
138
130
|
isDefault?: boolean | undefined;
|
139
131
|
logo?: string | undefined;
|
140
132
|
coingeckoId?: string | undefined;
|
@@ -150,7 +142,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
150
142
|
type: "substrate-native";
|
151
143
|
platform: "polkadot";
|
152
144
|
existentialDeposit: string;
|
153
|
-
isTestnet?: boolean | undefined;
|
154
145
|
isDefault?: boolean | undefined;
|
155
146
|
logo?: string | undefined;
|
156
147
|
coingeckoId?: string | undefined;
|
@@ -166,7 +157,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
166
157
|
platform: "polkadot";
|
167
158
|
existentialDeposit: string;
|
168
159
|
isCustom: true;
|
169
|
-
isTestnet?: boolean | undefined;
|
170
160
|
isDefault?: boolean | undefined;
|
171
161
|
logo?: string | undefined;
|
172
162
|
coingeckoId?: string | undefined;
|
@@ -182,7 +172,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
182
172
|
platform: "polkadot";
|
183
173
|
existentialDeposit: string;
|
184
174
|
contractAddress: string;
|
185
|
-
isTestnet?: boolean | undefined;
|
186
175
|
isDefault?: boolean | undefined;
|
187
176
|
logo?: string | undefined;
|
188
177
|
coingeckoId?: string | undefined;
|
@@ -198,7 +187,6 @@ export declare const defaultBalanceModules: (import("..").NewBalanceModule<"evm-
|
|
198
187
|
platform: "polkadot";
|
199
188
|
onChainId: string | number;
|
200
189
|
existentialDeposit: string;
|
201
|
-
isTestnet?: boolean | undefined;
|
202
190
|
isDefault?: boolean | undefined;
|
203
191
|
logo?: string | undefined;
|
204
192
|
coingeckoId?: string | undefined;
|
@@ -216,7 +216,6 @@ export declare class Balance {
|
|
216
216
|
type: "evm-erc20";
|
217
217
|
platform: "ethereum";
|
218
218
|
contractAddress: `0x${string}`;
|
219
|
-
isTestnet?: boolean | undefined;
|
220
219
|
isDefault?: boolean | undefined;
|
221
220
|
logo?: string | undefined;
|
222
221
|
coingeckoId?: string | undefined;
|
@@ -231,7 +230,6 @@ export declare class Balance {
|
|
231
230
|
networkId: string;
|
232
231
|
type: "evm-native";
|
233
232
|
platform: "ethereum";
|
234
|
-
isTestnet?: boolean | undefined;
|
235
233
|
isDefault?: boolean | undefined;
|
236
234
|
logo?: string | undefined;
|
237
235
|
coingeckoId?: string | undefined;
|
@@ -252,7 +250,6 @@ export declare class Balance {
|
|
252
250
|
decimals1: number;
|
253
251
|
tokenAddress0: `0x${string}`;
|
254
252
|
tokenAddress1: `0x${string}`;
|
255
|
-
isTestnet?: boolean | undefined;
|
256
253
|
isDefault?: boolean | undefined;
|
257
254
|
logo?: string | undefined;
|
258
255
|
coingeckoId?: string | undefined;
|
@@ -271,7 +268,6 @@ export declare class Balance {
|
|
271
268
|
platform: "polkadot";
|
272
269
|
assetId: string;
|
273
270
|
existentialDeposit: string;
|
274
|
-
isTestnet?: boolean | undefined;
|
275
271
|
isDefault?: boolean | undefined;
|
276
272
|
logo?: string | undefined;
|
277
273
|
coingeckoId?: string | undefined;
|
@@ -288,7 +284,6 @@ export declare class Balance {
|
|
288
284
|
platform: "polkadot";
|
289
285
|
onChainId: string;
|
290
286
|
existentialDeposit: string;
|
291
|
-
isTestnet?: boolean | undefined;
|
292
287
|
isDefault?: boolean | undefined;
|
293
288
|
logo?: string | undefined;
|
294
289
|
coingeckoId?: string | undefined;
|
@@ -304,7 +299,6 @@ export declare class Balance {
|
|
304
299
|
type: "substrate-native";
|
305
300
|
platform: "polkadot";
|
306
301
|
existentialDeposit: string;
|
307
|
-
isTestnet?: boolean | undefined;
|
308
302
|
isDefault?: boolean | undefined;
|
309
303
|
logo?: string | undefined;
|
310
304
|
coingeckoId?: string | undefined;
|
@@ -320,7 +314,6 @@ export declare class Balance {
|
|
320
314
|
platform: "polkadot";
|
321
315
|
existentialDeposit: string;
|
322
316
|
contractAddress: string;
|
323
|
-
isTestnet?: boolean | undefined;
|
324
317
|
isDefault?: boolean | undefined;
|
325
318
|
logo?: string | undefined;
|
326
319
|
coingeckoId?: string | undefined;
|
@@ -336,7 +329,6 @@ export declare class Balance {
|
|
336
329
|
platform: "polkadot";
|
337
330
|
onChainId: string | number;
|
338
331
|
existentialDeposit: string;
|
339
|
-
isTestnet?: boolean | undefined;
|
340
332
|
isDefault?: boolean | undefined;
|
341
333
|
logo?: string | undefined;
|
342
334
|
coingeckoId?: string | undefined;
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
var dexie = require('dexie');
|
4
4
|
var anylogger = require('anylogger');
|
5
|
+
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
6
|
var tokenRates = require('@talismn/token-rates');
|
6
7
|
var util = require('@talismn/util');
|
7
8
|
var BigNumber = require('bignumber.js');
|
8
9
|
var util$1 = require('@polkadot/util');
|
9
10
|
var utilCrypto = require('@polkadot/util-crypto');
|
10
11
|
var pako = require('pako');
|
11
|
-
var chaindataProvider = require('@talismn/chaindata-provider');
|
12
12
|
var viem = require('viem');
|
13
13
|
var isEqual = require('lodash/isEqual');
|
14
14
|
var txwrapperCore = require('@substrate/txwrapper-core');
|
@@ -126,7 +126,7 @@ class EvmTokenFetcher {
|
|
126
126
|
|
127
127
|
var pkg = {
|
128
128
|
name: "@talismn/balances",
|
129
|
-
version: "0.0.0-pr2043-
|
129
|
+
version: "0.0.0-pr2043-20250619091841"};
|
130
130
|
|
131
131
|
var log = anylogger__default.default(pkg.name);
|
132
132
|
|
@@ -410,13 +410,13 @@ class Balance {
|
|
410
410
|
return this.#storage.networkId;
|
411
411
|
}
|
412
412
|
get network() {
|
413
|
-
return this.#db?.networks
|
413
|
+
return this.#db?.networks?.[this.networkId] || null;
|
414
414
|
}
|
415
415
|
get tokenId() {
|
416
416
|
return this.#storage.tokenId;
|
417
417
|
}
|
418
418
|
get token() {
|
419
|
-
return this.#db?.tokens
|
419
|
+
return this.#db?.tokens?.[this.tokenId] || null;
|
420
420
|
}
|
421
421
|
get decimals() {
|
422
422
|
return this.token?.decimals || null;
|
@@ -432,8 +432,8 @@ class Balance {
|
|
432
432
|
if (this.isSource("evm-uniswapv2") && this.token?.type === "evm-uniswapv2" // &&
|
433
433
|
//this.evmNetworkId
|
434
434
|
) {
|
435
|
-
const tokenId0 = evmErc20TokenId(this.networkId, this.token.tokenAddress0);
|
436
|
-
const tokenId1 = evmErc20TokenId(this.networkId, this.token.tokenAddress1);
|
435
|
+
const tokenId0 = chaindataProvider.evmErc20TokenId(this.networkId, this.token.tokenAddress0);
|
436
|
+
const tokenId1 = chaindataProvider.evmErc20TokenId(this.networkId, this.token.tokenAddress1);
|
437
437
|
const decimals = this.token.decimals;
|
438
438
|
const decimals0 = this.token.decimals0;
|
439
439
|
const decimals1 = this.token.decimals1;
|
@@ -866,10 +866,6 @@ const filterMirrorTokens = (balance, i, balances) => {
|
|
866
866
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
867
867
|
};
|
868
868
|
|
869
|
-
// TODO: Move this into a common module which can then be imported both here and into EvmErc20Module
|
870
|
-
// We can't import this directly from EvmErc20Module because then we'd have a circular dependency
|
871
|
-
const evmErc20TokenId = (chainId, tokenContractAddress) => `${chainId}-evm-erc20-${tokenContractAddress}`.toLowerCase();
|
872
|
-
|
873
869
|
/**
|
874
870
|
* `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
|
875
871
|
*
|
@@ -5401,12 +5397,9 @@ const SubNativeModule = hydrate => {
|
|
5401
5397
|
return acc;
|
5402
5398
|
}, {});
|
5403
5399
|
const initialBalancesByNetwork = lodash.groupBy(initialBalances ?? [], "networkId");
|
5404
|
-
const
|
5405
|
-
abort,
|
5406
|
-
signal
|
5407
|
-
} = new AbortController();
|
5400
|
+
const controller = new AbortController();
|
5408
5401
|
const safeCallback = (error, result) => {
|
5409
|
-
if (signal.aborted) return;
|
5402
|
+
if (controller.signal.aborted) return;
|
5410
5403
|
// typescript isnt happy with fowarding parameters as is
|
5411
5404
|
return error ? callback(error, undefined) : callback(error, result);
|
5412
5405
|
};
|
@@ -5414,19 +5407,19 @@ const SubNativeModule = hydrate => {
|
|
5414
5407
|
try {
|
5415
5408
|
// this is what we want to be done separately for each network
|
5416
5409
|
// this will update the DB so minimetadata will be available when it's used, veeeeery far down the tree of subscribeChainBalances
|
5417
|
-
await getMiniMetadata(chaindataProvider$1, chainConnector$1, networkId, moduleType$2, signal);
|
5410
|
+
await getMiniMetadata(chaindataProvider$1, chainConnector$1, networkId, moduleType$2, controller.signal);
|
5418
5411
|
} catch (err) {
|
5419
|
-
if (!signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5412
|
+
if (!controller.signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5420
5413
|
return () => {};
|
5421
5414
|
}
|
5422
|
-
if (signal.aborted) return () => {};
|
5415
|
+
if (controller.signal.aborted) return () => {};
|
5423
5416
|
return subscribeChainBalances(networkId, {
|
5424
5417
|
addressesByToken: addressesByTokenByNetwork[networkId] ?? {},
|
5425
5418
|
initialBalances: initialBalancesByNetwork[networkId] ?? []
|
5426
5419
|
}, safeCallback);
|
5427
5420
|
}));
|
5428
5421
|
return () => {
|
5429
|
-
abort();
|
5422
|
+
controller.abort();
|
5430
5423
|
unsubsribeFns.then(fns => fns.forEach(unsubscribe => unsubscribe()));
|
5431
5424
|
};
|
5432
5425
|
},
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
var dexie = require('dexie');
|
4
4
|
var anylogger = require('anylogger');
|
5
|
+
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
6
|
var tokenRates = require('@talismn/token-rates');
|
6
7
|
var util = require('@talismn/util');
|
7
8
|
var BigNumber = require('bignumber.js');
|
8
9
|
var util$1 = require('@polkadot/util');
|
9
10
|
var utilCrypto = require('@polkadot/util-crypto');
|
10
11
|
var pako = require('pako');
|
11
|
-
var chaindataProvider = require('@talismn/chaindata-provider');
|
12
12
|
var viem = require('viem');
|
13
13
|
var isEqual = require('lodash/isEqual');
|
14
14
|
var txwrapperCore = require('@substrate/txwrapper-core');
|
@@ -126,7 +126,7 @@ class EvmTokenFetcher {
|
|
126
126
|
|
127
127
|
var pkg = {
|
128
128
|
name: "@talismn/balances",
|
129
|
-
version: "0.0.0-pr2043-
|
129
|
+
version: "0.0.0-pr2043-20250619091841"};
|
130
130
|
|
131
131
|
var log = anylogger__default.default(pkg.name);
|
132
132
|
|
@@ -410,13 +410,13 @@ class Balance {
|
|
410
410
|
return this.#storage.networkId;
|
411
411
|
}
|
412
412
|
get network() {
|
413
|
-
return this.#db?.networks
|
413
|
+
return this.#db?.networks?.[this.networkId] || null;
|
414
414
|
}
|
415
415
|
get tokenId() {
|
416
416
|
return this.#storage.tokenId;
|
417
417
|
}
|
418
418
|
get token() {
|
419
|
-
return this.#db?.tokens
|
419
|
+
return this.#db?.tokens?.[this.tokenId] || null;
|
420
420
|
}
|
421
421
|
get decimals() {
|
422
422
|
return this.token?.decimals || null;
|
@@ -432,8 +432,8 @@ class Balance {
|
|
432
432
|
if (this.isSource("evm-uniswapv2") && this.token?.type === "evm-uniswapv2" // &&
|
433
433
|
//this.evmNetworkId
|
434
434
|
) {
|
435
|
-
const tokenId0 = evmErc20TokenId(this.networkId, this.token.tokenAddress0);
|
436
|
-
const tokenId1 = evmErc20TokenId(this.networkId, this.token.tokenAddress1);
|
435
|
+
const tokenId0 = chaindataProvider.evmErc20TokenId(this.networkId, this.token.tokenAddress0);
|
436
|
+
const tokenId1 = chaindataProvider.evmErc20TokenId(this.networkId, this.token.tokenAddress1);
|
437
437
|
const decimals = this.token.decimals;
|
438
438
|
const decimals0 = this.token.decimals0;
|
439
439
|
const decimals1 = this.token.decimals1;
|
@@ -866,10 +866,6 @@ const filterMirrorTokens = (balance, i, balances) => {
|
|
866
866
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
867
867
|
};
|
868
868
|
|
869
|
-
// TODO: Move this into a common module which can then be imported both here and into EvmErc20Module
|
870
|
-
// We can't import this directly from EvmErc20Module because then we'd have a circular dependency
|
871
|
-
const evmErc20TokenId = (chainId, tokenContractAddress) => `${chainId}-evm-erc20-${tokenContractAddress}`.toLowerCase();
|
872
|
-
|
873
869
|
/**
|
874
870
|
* `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
|
875
871
|
*
|
@@ -5401,12 +5397,9 @@ const SubNativeModule = hydrate => {
|
|
5401
5397
|
return acc;
|
5402
5398
|
}, {});
|
5403
5399
|
const initialBalancesByNetwork = lodash.groupBy(initialBalances ?? [], "networkId");
|
5404
|
-
const
|
5405
|
-
abort,
|
5406
|
-
signal
|
5407
|
-
} = new AbortController();
|
5400
|
+
const controller = new AbortController();
|
5408
5401
|
const safeCallback = (error, result) => {
|
5409
|
-
if (signal.aborted) return;
|
5402
|
+
if (controller.signal.aborted) return;
|
5410
5403
|
// typescript isnt happy with fowarding parameters as is
|
5411
5404
|
return error ? callback(error, undefined) : callback(error, result);
|
5412
5405
|
};
|
@@ -5414,19 +5407,19 @@ const SubNativeModule = hydrate => {
|
|
5414
5407
|
try {
|
5415
5408
|
// this is what we want to be done separately for each network
|
5416
5409
|
// this will update the DB so minimetadata will be available when it's used, veeeeery far down the tree of subscribeChainBalances
|
5417
|
-
await getMiniMetadata(chaindataProvider$1, chainConnector$1, networkId, moduleType$2, signal);
|
5410
|
+
await getMiniMetadata(chaindataProvider$1, chainConnector$1, networkId, moduleType$2, controller.signal);
|
5418
5411
|
} catch (err) {
|
5419
|
-
if (!signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5412
|
+
if (!controller.signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5420
5413
|
return () => {};
|
5421
5414
|
}
|
5422
|
-
if (signal.aborted) return () => {};
|
5415
|
+
if (controller.signal.aborted) return () => {};
|
5423
5416
|
return subscribeChainBalances(networkId, {
|
5424
5417
|
addressesByToken: addressesByTokenByNetwork[networkId] ?? {},
|
5425
5418
|
initialBalances: initialBalancesByNetwork[networkId] ?? []
|
5426
5419
|
}, safeCallback);
|
5427
5420
|
}));
|
5428
5421
|
return () => {
|
5429
|
-
abort();
|
5422
|
+
controller.abort();
|
5430
5423
|
unsubsribeFns.then(fns => fns.forEach(unsubscribe => unsubscribe()));
|
5431
5424
|
};
|
5432
5425
|
},
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { Dexie, liveQuery } from 'dexie';
|
2
2
|
import anylogger from 'anylogger';
|
3
|
+
import { evmErc20TokenId, EvmErc20TokenSchema, evmNativeTokenId, evmUniswapV2TokenId, githubTokenLogoUrl, parseSubAssetTokenId, subAssetTokenId, parseSubForeignAssetTokenId, subForeignAssetTokenId, parseSubNativeTokenId, subNativeTokenId, subPsp22TokenId, parseSubTokensTokenId, subTokensTokenId } from '@talismn/chaindata-provider';
|
3
4
|
import { newTokenRates } from '@talismn/token-rates';
|
4
5
|
import { isBigInt, BigMath, planckToTokens, isArrayOf, isTruthy, isEthereumAddress, hasOwnProperty, decodeAnyAddress, isNotNil, blake2Concat, firstThenDebounce, Deferred } from '@talismn/util';
|
5
6
|
import BigNumber from 'bignumber.js';
|
6
7
|
import { u8aToHex, assert, stringCamelCase, u8aConcatStrict, u8aConcat, arrayChunk, u8aToString, hexToNumber, hexToU8a } from '@polkadot/util';
|
7
8
|
import { xxhashAsU8a, blake2AsU8a } from '@polkadot/util-crypto';
|
8
9
|
import pako from 'pako';
|
9
|
-
import { evmErc20TokenId as evmErc20TokenId$1, EvmErc20TokenSchema, evmNativeTokenId, evmUniswapV2TokenId, githubTokenLogoUrl, parseSubAssetTokenId, subAssetTokenId, parseSubForeignAssetTokenId, subForeignAssetTokenId, parseSubNativeTokenId, subNativeTokenId, subPsp22TokenId, parseSubTokensTokenId, subTokensTokenId } from '@talismn/chaindata-provider';
|
10
10
|
import { parseAbi, isHex, hexToBigInt } from 'viem';
|
11
11
|
import isEqual from 'lodash/isEqual';
|
12
12
|
import { defineMethod } from '@substrate/txwrapper-core';
|
@@ -111,7 +111,7 @@ class EvmTokenFetcher {
|
|
111
111
|
|
112
112
|
var pkg = {
|
113
113
|
name: "@talismn/balances",
|
114
|
-
version: "0.0.0-pr2043-
|
114
|
+
version: "0.0.0-pr2043-20250619091841"};
|
115
115
|
|
116
116
|
var log = anylogger(pkg.name);
|
117
117
|
|
@@ -395,13 +395,13 @@ class Balance {
|
|
395
395
|
return this.#storage.networkId;
|
396
396
|
}
|
397
397
|
get network() {
|
398
|
-
return this.#db?.networks
|
398
|
+
return this.#db?.networks?.[this.networkId] || null;
|
399
399
|
}
|
400
400
|
get tokenId() {
|
401
401
|
return this.#storage.tokenId;
|
402
402
|
}
|
403
403
|
get token() {
|
404
|
-
return this.#db?.tokens
|
404
|
+
return this.#db?.tokens?.[this.tokenId] || null;
|
405
405
|
}
|
406
406
|
get decimals() {
|
407
407
|
return this.token?.decimals || null;
|
@@ -851,10 +851,6 @@ const filterMirrorTokens = (balance, i, balances) => {
|
|
851
851
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
852
852
|
};
|
853
853
|
|
854
|
-
// TODO: Move this into a common module which can then be imported both here and into EvmErc20Module
|
855
|
-
// We can't import this directly from EvmErc20Module because then we'd have a circular dependency
|
856
|
-
const evmErc20TokenId = (chainId, tokenContractAddress) => `${chainId}-evm-erc20-${tokenContractAddress}`.toLowerCase();
|
857
|
-
|
858
854
|
/**
|
859
855
|
* `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
|
860
856
|
*
|
@@ -1316,7 +1312,7 @@ const EvmErc20Module = hydrate => {
|
|
1316
1312
|
const symbol = tokenConfig?.symbol ?? contractSymbol ?? "ETH";
|
1317
1313
|
const decimals = typeof tokenConfig?.decimals === "number" ? tokenConfig.decimals : typeof contractDecimals === "number" ? contractDecimals : 18;
|
1318
1314
|
if (!symbol || typeof decimals !== "number") continue;
|
1319
|
-
const id = evmErc20TokenId
|
1315
|
+
const id = evmErc20TokenId(chainId, contractAddress);
|
1320
1316
|
const token = {
|
1321
1317
|
id,
|
1322
1318
|
type: "evm-erc20",
|
@@ -5386,12 +5382,9 @@ const SubNativeModule = hydrate => {
|
|
5386
5382
|
return acc;
|
5387
5383
|
}, {});
|
5388
5384
|
const initialBalancesByNetwork = groupBy$1(initialBalances ?? [], "networkId");
|
5389
|
-
const
|
5390
|
-
abort,
|
5391
|
-
signal
|
5392
|
-
} = new AbortController();
|
5385
|
+
const controller = new AbortController();
|
5393
5386
|
const safeCallback = (error, result) => {
|
5394
|
-
if (signal.aborted) return;
|
5387
|
+
if (controller.signal.aborted) return;
|
5395
5388
|
// typescript isnt happy with fowarding parameters as is
|
5396
5389
|
return error ? callback(error, undefined) : callback(error, result);
|
5397
5390
|
};
|
@@ -5399,19 +5392,19 @@ const SubNativeModule = hydrate => {
|
|
5399
5392
|
try {
|
5400
5393
|
// this is what we want to be done separately for each network
|
5401
5394
|
// this will update the DB so minimetadata will be available when it's used, veeeeery far down the tree of subscribeChainBalances
|
5402
|
-
await getMiniMetadata(chaindataProvider, chainConnector, networkId, moduleType$2, signal);
|
5395
|
+
await getMiniMetadata(chaindataProvider, chainConnector, networkId, moduleType$2, controller.signal);
|
5403
5396
|
} catch (err) {
|
5404
|
-
if (!signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5397
|
+
if (!controller.signal.aborted) log.warn("Failed to get native token miniMetadata for network", networkId, err);
|
5405
5398
|
return () => {};
|
5406
5399
|
}
|
5407
|
-
if (signal.aborted) return () => {};
|
5400
|
+
if (controller.signal.aborted) return () => {};
|
5408
5401
|
return subscribeChainBalances(networkId, {
|
5409
5402
|
addressesByToken: addressesByTokenByNetwork[networkId] ?? {},
|
5410
5403
|
initialBalances: initialBalancesByNetwork[networkId] ?? []
|
5411
5404
|
}, safeCallback);
|
5412
5405
|
}));
|
5413
5406
|
return () => {
|
5414
|
-
abort();
|
5407
|
+
controller.abort();
|
5415
5408
|
unsubsribeFns.then(fns => fns.forEach(unsubscribe => unsubscribe()));
|
5416
5409
|
};
|
5417
5410
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.0.0-pr2043-
|
3
|
+
"version": "0.0.0-pr2043-20250619091841",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -35,12 +35,12 @@
|
|
35
35
|
"scale-ts": "^1.6.1",
|
36
36
|
"viem": "^2.27.3",
|
37
37
|
"zod": "^3.25.62",
|
38
|
-
"@talismn/chain-connector": "0.0.0-pr2043-
|
39
|
-
"@talismn/chain-connector-evm": "0.0.0-pr2043-
|
40
|
-
"@talismn/
|
38
|
+
"@talismn/chain-connector": "0.0.0-pr2043-20250619091841",
|
39
|
+
"@talismn/chain-connector-evm": "0.0.0-pr2043-20250619091841",
|
40
|
+
"@talismn/sapi": "0.0.0-pr2043-20250619091841",
|
41
|
+
"@talismn/chaindata-provider": "0.0.0-pr2043-20250619091841",
|
41
42
|
"@talismn/scale": "0.1.2",
|
42
|
-
"@talismn/token-rates": "0.0.0-pr2043-
|
43
|
-
"@talismn/sapi": "0.0.0-pr2043-20250619052729",
|
43
|
+
"@talismn/token-rates": "0.0.0-pr2043-20250619091841",
|
44
44
|
"@talismn/util": "0.4.2"
|
45
45
|
},
|
46
46
|
"devDependencies": {
|