@talismn/balances 0.0.0-pr2041-20250612085325 → 0.0.0-pr2043-20250612121753

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.
Files changed (21) hide show
  1. package/dist/declarations/src/modules/EvmErc20Module.d.ts +3 -10
  2. package/dist/declarations/src/modules/EvmNativeModule.d.ts +2 -11
  3. package/dist/declarations/src/modules/EvmUniswapV2Module.d.ts +4 -12
  4. package/dist/declarations/src/modules/SubstrateAssetsModule.d.ts +1 -4
  5. package/dist/declarations/src/modules/SubstrateForeignAssetsModule.d.ts +1 -4
  6. package/dist/declarations/src/modules/SubstrateNativeModule/index.d.ts +3 -2
  7. package/dist/declarations/src/modules/SubstrateNativeModule/subscribeCrowdloans.d.ts +2 -2
  8. package/dist/declarations/src/modules/SubstrateNativeModule/subscribeNompoolStaking.d.ts +2 -2
  9. package/dist/declarations/src/modules/SubstrateNativeModule/subscribeSubtensorStaking.d.ts +2 -2
  10. package/dist/declarations/src/modules/SubstrateNativeModule/types.d.ts +1 -9
  11. package/dist/declarations/src/modules/SubstrateNativeModule/util/QueryCache.d.ts +2 -2
  12. package/dist/declarations/src/modules/SubstrateNativeModule/util/buildQueries.d.ts +2 -2
  13. package/dist/declarations/src/modules/SubstratePsp22Module.d.ts +1 -4
  14. package/dist/declarations/src/modules/SubstrateTokensModule.d.ts +1 -4
  15. package/dist/declarations/src/modules/index.d.ts +195 -39
  16. package/dist/declarations/src/types/balances.d.ts +118 -63
  17. package/dist/talismn-balances.cjs.dev.js +80 -347
  18. package/dist/talismn-balances.cjs.prod.js +80 -347
  19. package/dist/talismn-balances.esm.js +83 -348
  20. package/package.json +8 -8
  21. package/dist/declarations/src/modules/SubstrateEquilibriumModule.d.ts +0 -39
@@ -1467,7 +1467,7 @@ const erc20Abi = [{
1467
1467
 
1468
1468
  const erc20BalancesAggregatorAbi = viem.parseAbi(["struct AccountToken {address account; address token;}", "function balances(AccountToken[] memory accountTokens) public view returns (uint256[] memory)"]);
1469
1469
 
1470
- const moduleType$8 = "evm-erc20";
1470
+ const moduleType$7 = "evm-erc20";
1471
1471
  const evmErc20TokenId = (chainId, tokenContractAddress) => `${chainId}-evm-erc20-${tokenContractAddress}`.toLowerCase();
1472
1472
  const EvmErc20Module = hydrate => {
1473
1473
  const {
@@ -1492,14 +1492,14 @@ const EvmErc20Module = hydrate => {
1492
1492
  }, {});
1493
1493
  };
1494
1494
  const getModuleTokens = async () => {
1495
- return await chaindataProvider$1.tokensByIdForType(moduleType$8);
1495
+ return await chaindataProvider$1.tokensByIdForType(moduleType$7);
1496
1496
  };
1497
1497
  const getErc20Aggregators = async () => {
1498
1498
  const evmNetworks = await chaindataProvider$1.evmNetworks();
1499
1499
  return Object.fromEntries(evmNetworks.filter(n => n.erc20aggregator).map(n => [n.id, n.erc20aggregator]));
1500
1500
  };
1501
1501
  return {
1502
- ...DefaultBalanceModule(moduleType$8),
1502
+ ...DefaultBalanceModule(moduleType$7),
1503
1503
  /**
1504
1504
  * This method is currently executed on [a squid](https://github.com/TalismanSociety/chaindata-squid/blob/0ee02818bf5caa7362e3f3664e55ef05ec8df078/src/steps/updateEvmNetworksFromGithub.ts#L280-L284).
1505
1505
  * In a future version of the balance libraries, we may build some kind of async scheduling system which will keep the chainmeta for each chain up to date without relying on a squid.
@@ -1523,13 +1523,16 @@ const EvmErc20Module = hydrate => {
1523
1523
  const {
1524
1524
  contractAddress,
1525
1525
  symbol: contractSymbol,
1526
- decimals: contractDecimals
1526
+ decimals: contractDecimals,
1527
+ name: contractName
1527
1528
  } = tokenConfig;
1528
1529
  // TODO : in chaindata's build, filter out all tokens that don't have any of these
1529
1530
  if (!contractAddress || !contractSymbol || contractDecimals === undefined) {
1530
1531
  log.warn("ignoring token on chain %s", chainId, tokenConfig);
1531
1532
  continue;
1532
1533
  }
1534
+
1535
+ // TODO zodify this
1533
1536
  const symbol = tokenConfig?.symbol ?? contractSymbol ?? "ETH";
1534
1537
  const decimals = typeof tokenConfig?.decimals === "number" ? tokenConfig.decimals : typeof contractDecimals === "number" ? contractDecimals : 18;
1535
1538
  if (!symbol || typeof decimals !== "number") continue;
@@ -1537,21 +1540,26 @@ const EvmErc20Module = hydrate => {
1537
1540
  const token = {
1538
1541
  id,
1539
1542
  type: "evm-erc20",
1543
+ platform: "ethereum",
1540
1544
  isTestnet,
1541
1545
  isDefault: tokenConfig.isDefault ?? true,
1542
1546
  symbol,
1543
1547
  decimals,
1548
+ name: contractName ?? symbol,
1544
1549
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
1545
1550
  contractAddress,
1546
- evmNetwork: {
1547
- id: chainId
1548
- }
1551
+ networkId: chainId
1549
1552
  };
1550
1553
  if (tokenConfig?.symbol) token.symbol = tokenConfig?.symbol;
1551
1554
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
1552
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
1553
1555
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
1554
1556
  if (tokenConfig?.noDiscovery) token.noDiscovery = tokenConfig?.noDiscovery;
1557
+ const validation = chaindataProvider.EvmErc20TokenDef.safeParse(token);
1558
+ if (validation.success) {
1559
+ chainTokens[token.id] = token;
1560
+ } else {
1561
+ log.warn("Ignoring invalid token", token.id, validation.error.message, validation.error.issues);
1562
+ }
1555
1563
  chainTokens[token.id] = token;
1556
1564
  }
1557
1565
  return chainTokens;
@@ -1575,7 +1583,7 @@ const EvmErc20Module = hydrate => {
1575
1583
  const ethAddresses = addresses.filter(util.isEthereumAddress);
1576
1584
  if (ethAddresses.length === 0) return null;
1577
1585
  const token = tokens[tokenId];
1578
- const evmNetworkId = token.evmNetwork?.id;
1586
+ const evmNetworkId = token.networkId;
1579
1587
  if (!evmNetworkId) return null;
1580
1588
  return [tokenId, ethAddresses];
1581
1589
  }).filter(x => Boolean(x)));
@@ -1785,7 +1793,7 @@ function groupAddressesByTokenByEvmNetwork$1(addressesByToken, tokens) {
1785
1793
  log.error(`Token ${tokenId} not found`);
1786
1794
  return byChain;
1787
1795
  }
1788
- const chainId = token.evmNetwork?.id;
1796
+ const chainId = token.networkId;
1789
1797
  if (!chainId) {
1790
1798
  log.error(`Token ${tokenId} has no evm network`);
1791
1799
  return byChain;
@@ -1798,7 +1806,7 @@ function groupAddressesByTokenByEvmNetwork$1(addressesByToken, tokens) {
1798
1806
 
1799
1807
  const abiMulticall = viem.parseAbi(["struct Call { address target; bytes callData; }", "struct Call3 { address target; bool allowFailure; bytes callData; }", "struct Call3Value { address target; bool allowFailure; uint256 value; bytes callData; }", "struct Result { bool success; bytes returnData; }", "function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData)", "function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData)", "function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData)", "function blockAndAggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)", "function getBasefee() view returns (uint256 basefee)", "function getBlockHash(uint256 blockNumber) view returns (bytes32 blockHash)", "function getBlockNumber() view returns (uint256 blockNumber)", "function getChainId() view returns (uint256 chainid)", "function getCurrentBlockCoinbase() view returns (address coinbase)", "function getCurrentBlockDifficulty() view returns (uint256 difficulty)", "function getCurrentBlockGasLimit() view returns (uint256 gaslimit)", "function getCurrentBlockTimestamp() view returns (uint256 timestamp)", "function getEthBalance(address addr) view returns (uint256 balance)", "function getLastBlockHash() view returns (bytes32 blockHash)", "function tryAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (Result[] memory returnData)", "function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)"]);
1800
1808
 
1801
- const moduleType$7 = "evm-native";
1809
+ const moduleType$6 = "evm-native";
1802
1810
  const evmNativeTokenId = chainId => `${chainId}-evm-native`.toLowerCase().replace(/ /g, "-");
1803
1811
  const getEvmNetworkIdFromTokenId = tokenId => {
1804
1812
  const evmNetworkId = tokenId.split("-")[0];
@@ -1811,12 +1819,12 @@ const EvmNativeModule = hydrate => {
1811
1819
  chaindataProvider: chaindataProvider$1
1812
1820
  } = hydrate;
1813
1821
  const getModuleTokens = async () => {
1814
- return await chaindataProvider$1.tokensByIdForType(moduleType$7);
1822
+ return await chaindataProvider$1.tokensByIdForType(moduleType$6);
1815
1823
  };
1816
1824
  return {
1817
- ...DefaultBalanceModule(moduleType$7),
1825
+ ...DefaultBalanceModule(moduleType$6),
1818
1826
  get tokens() {
1819
- return chaindataProvider$1.tokensByIdForType(moduleType$7);
1827
+ return chaindataProvider$1.tokensByIdForType(moduleType$6);
1820
1828
  },
1821
1829
  /**
1822
1830
  * This method is currently executed on [a squid](https://github.com/TalismanSociety/chaindata-squid/blob/0ee02818bf5caa7362e3f3664e55ef05ec8df078/src/steps/updateEvmNetworksFromGithub.ts#L280-L284).
@@ -1838,22 +1846,22 @@ const EvmNativeModule = hydrate => {
1838
1846
  } = chainMeta;
1839
1847
  const symbol = moduleConfig?.symbol ?? "ETH";
1840
1848
  const decimals = typeof moduleConfig?.decimals === "number" ? moduleConfig.decimals : 18;
1849
+ const name = moduleConfig?.name ?? symbol;
1841
1850
  const id = evmNativeTokenId(chainId);
1842
1851
  const nativeToken = {
1852
+ platform: "ethereum",
1843
1853
  id,
1844
1854
  type: "evm-native",
1845
1855
  isTestnet,
1846
1856
  isDefault: true,
1847
1857
  symbol,
1848
1858
  decimals,
1859
+ name,
1849
1860
  logo: moduleConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
1850
- evmNetwork: {
1851
- id: chainId
1852
- }
1861
+ networkId: chainId
1853
1862
  };
1854
1863
  if (moduleConfig?.symbol) nativeToken.symbol = moduleConfig?.symbol;
1855
1864
  if (moduleConfig?.coingeckoId) nativeToken.coingeckoId = moduleConfig?.coingeckoId;
1856
- if (moduleConfig?.dcentName) nativeToken.dcentName = moduleConfig?.dcentName;
1857
1865
  if (moduleConfig?.mirrorOf) nativeToken.mirrorOf = moduleConfig?.mirrorOf;
1858
1866
  if (moduleConfig?.noDiscovery) nativeToken.noDiscovery = moduleConfig?.noDiscovery;
1859
1867
  return {
@@ -1873,7 +1881,7 @@ const EvmNativeModule = hydrate => {
1873
1881
  const ethAddresses = addresses.filter(util.isEthereumAddress);
1874
1882
  if (ethAddresses.length === 0) return null;
1875
1883
  const token = tokens[tokenId];
1876
- const evmNetworkId = token.evmNetwork?.id;
1884
+ const evmNetworkId = token.networkId;
1877
1885
  if (!evmNetworkId) return null;
1878
1886
  return [tokenId, ethAddresses];
1879
1887
  }).filter(x => Boolean(x)));
@@ -1965,7 +1973,7 @@ const fetchBalances$2 = async (evmChainConnector, addressesByToken, tokens) => {
1965
1973
  if (!evmChainConnector) throw new Error(`This module requires an evm chain connector`);
1966
1974
  return Promise.all(Object.entries(addressesByToken).map(async ([tokenId, addresses]) => {
1967
1975
  const token = tokens[tokenId];
1968
- const evmNetworkId = token.evmNetwork?.id;
1976
+ const evmNetworkId = token.networkId;
1969
1977
  if (!evmNetworkId) throw new Error(`Token ${token.id} has no evm network`);
1970
1978
  const publicClient = await evmChainConnector.getPublicClientForEvmNetwork(evmNetworkId);
1971
1979
  if (!publicClient) throw new Error(`Could not get rpc provider for evm network ${evmNetworkId}`);
@@ -2034,7 +2042,7 @@ async function getFreeBalances(publicClient, addresses) {
2034
2042
  });
2035
2043
  } catch (err) {
2036
2044
  const errorMessage = util.hasOwnProperty(err, "shortMessage") ? err.shortMessage : util.hasOwnProperty(err, "message") ? err.message : err;
2037
- log.warn(`Failed to get balance from chain ${publicClient.chain?.id} for ${ethAddresses.length} addresses: ${errorMessage}`);
2045
+ log.warn(`Failed to get balance from chain ${publicClient.chain.id} for ${ethAddresses.length} addresses: ${errorMessage}`);
2038
2046
  return ethAddresses.map(() => "error");
2039
2047
  }
2040
2048
  }
@@ -2602,7 +2610,7 @@ const uniswapV2PairAbi = [{
2602
2610
  type: "function"
2603
2611
  }];
2604
2612
 
2605
- const moduleType$6 = "evm-uniswapv2";
2613
+ const moduleType$5 = "evm-uniswapv2";
2606
2614
  const evmUniswapV2TokenId = (chainId, contractAddress) => `${chainId}-evm-uniswapv2-${contractAddress}`.toLowerCase();
2607
2615
  const EvmUniswapV2Module = hydrate => {
2608
2616
  const {
@@ -2612,7 +2620,7 @@ const EvmUniswapV2Module = hydrate => {
2612
2620
  const chainConnector = chainConnectors.evm;
2613
2621
  util$1.assert(chainConnector, "This module requires an evm chain connector");
2614
2622
  return {
2615
- ...DefaultBalanceModule(moduleType$6),
2623
+ ...DefaultBalanceModule(moduleType$5),
2616
2624
  async fetchEvmChainMeta(chainId) {
2617
2625
  const isTestnet = (await chaindataProvider$1.evmNetworkById(chainId))?.isTestnet || false;
2618
2626
  return {
@@ -2635,7 +2643,8 @@ const EvmUniswapV2Module = hydrate => {
2635
2643
  tokenAddress0,
2636
2644
  tokenAddress1,
2637
2645
  coingeckoId0,
2638
- coingeckoId1
2646
+ coingeckoId1,
2647
+ name
2639
2648
  } = tokenConfig;
2640
2649
  if (!contractAddress || decimals === undefined || symbol0 === undefined || decimals0 === undefined || symbol1 === undefined || decimals1 === undefined || tokenAddress0 === undefined || tokenAddress1 === undefined) {
2641
2650
  log.warn("ignoring token on chain %s", chainId, tokenConfig);
@@ -2645,9 +2654,11 @@ const EvmUniswapV2Module = hydrate => {
2645
2654
  const token = {
2646
2655
  id,
2647
2656
  type: "evm-uniswapv2",
2657
+ platform: "ethereum",
2648
2658
  isTestnet,
2649
2659
  isDefault: tokenConfig.isDefault ?? false,
2650
2660
  symbol: `${symbol0 ?? "UNKNOWN"}/${symbol1 ?? "UNKNOWN"}`,
2661
+ name: name ?? `${symbol0 ?? "UNKNOWN"}/${symbol1 ?? "UNKNOWN"}`,
2651
2662
  decimals,
2652
2663
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl("uniswap"),
2653
2664
  symbol0,
@@ -2659,13 +2670,10 @@ const EvmUniswapV2Module = hydrate => {
2659
2670
  tokenAddress1,
2660
2671
  coingeckoId0,
2661
2672
  coingeckoId1,
2662
- evmNetwork: {
2663
- id: chainId
2664
- }
2673
+ networkId: chainId
2665
2674
  };
2666
2675
  if (tokenConfig?.symbol) token.symbol = tokenConfig?.symbol;
2667
2676
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
2668
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
2669
2677
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
2670
2678
  if (tokenConfig?.noDiscovery) token.noDiscovery = tokenConfig?.noDiscovery;
2671
2679
  tokens[token.id] = token;
@@ -2809,7 +2817,7 @@ function groupAddressesByTokenByEvmNetwork(addressesByToken, tokens) {
2809
2817
  log.error(`Token ${tokenId} not found`);
2810
2818
  return byChain;
2811
2819
  }
2812
- const chainId = token.evmNetwork?.id;
2820
+ const chainId = token.networkId;
2813
2821
  if (!chainId) {
2814
2822
  log.error(`Token ${tokenId} has no evm network`);
2815
2823
  return byChain;
@@ -3040,7 +3048,7 @@ const detectTransferMethod = metadataRpc => {
3040
3048
  return hasDeprecatedTransferCall ? "transfer" : "transfer_allow_death";
3041
3049
  };
3042
3050
 
3043
- const getUniqueChainIds = (addressesByToken, tokens) => [...new Set(Object.keys(addressesByToken).map(tokenId => tokens[tokenId]?.chain?.id).flatMap(chainId => chainId ? [chainId] : []))];
3051
+ const getUniqueChainIds = (addressesByToken, tokens) => [...new Set(Object.keys(addressesByToken).map(tokenId => tokens[tokenId]?.networkId).flatMap(chainId => chainId ? [chainId] : []))];
3044
3052
 
3045
3053
  const makeContractCaller = ({
3046
3054
  chainConnector,
@@ -3149,7 +3157,7 @@ const decompress = data => {
3149
3157
  return JSON.parse(decompressed);
3150
3158
  };
3151
3159
 
3152
- const moduleType$5 = "substrate-assets";
3160
+ const moduleType$4 = "substrate-assets";
3153
3161
  const subAssetTokenId = (chainId, assetId, tokenSymbol) => `${chainId}-substrate-assets-${assetId}-${tokenSymbol}`.toLowerCase().replace(/ /g, "-");
3154
3162
  const SubAssetsModule = hydrate => {
3155
3163
  const {
@@ -3159,7 +3167,7 @@ const SubAssetsModule = hydrate => {
3159
3167
  const chainConnector = chainConnectors.substrate;
3160
3168
  util$1.assert(chainConnector, "This module requires a substrate chain connector");
3161
3169
  return {
3162
- ...DefaultBalanceModule(moduleType$5),
3170
+ ...DefaultBalanceModule(moduleType$4),
3163
3171
  async fetchSubstrateChainMeta(chainId, moduleConfig, metadataRpc) {
3164
3172
  const isTestnet = (await chaindataProvider$1.chainById(chainId))?.isTestnet || false;
3165
3173
  if (metadataRpc === undefined) return {
@@ -3210,24 +3218,23 @@ const SubAssetsModule = hydrate => {
3210
3218
  const token = {
3211
3219
  id,
3212
3220
  type: "substrate-assets",
3221
+ platform: "polkadot",
3213
3222
  isTestnet,
3214
3223
  isDefault: tokenConfig?.isDefault ?? true,
3215
3224
  symbol,
3225
+ name: tokenConfig?.name || symbol,
3216
3226
  decimals,
3217
3227
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
3218
3228
  existentialDeposit,
3219
3229
  assetId,
3220
3230
  isFrozen,
3221
- chain: {
3222
- id: chainId
3223
- }
3231
+ networkId: chainId
3224
3232
  };
3225
3233
  if (tokenConfig?.symbol) {
3226
3234
  token.symbol = tokenConfig?.symbol;
3227
3235
  token.id = subAssetTokenId(chainId, assetId, token.symbol);
3228
3236
  }
3229
3237
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
3230
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
3231
3238
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
3232
3239
  tokens[token.id] = token;
3233
3240
  } catch (error) {
@@ -3241,7 +3248,7 @@ const SubAssetsModule = hydrate => {
3241
3248
  async subscribeBalances({
3242
3249
  addressesByToken
3243
3250
  }, callback) {
3244
- const queries = await buildQueries$4(chaindataProvider$1, addressesByToken);
3251
+ const queries = await buildQueries$3(chaindataProvider$1, addressesByToken);
3245
3252
  const unsubscribe = await new RpcStateQueryHelper(chainConnector, queries).subscribe((error, result) => {
3246
3253
  if (error) return callback(error);
3247
3254
  const balances = result?.filter(b => b !== null) ?? [];
@@ -3251,7 +3258,7 @@ const SubAssetsModule = hydrate => {
3251
3258
  },
3252
3259
  async fetchBalances(addressesByToken) {
3253
3260
  util$1.assert(chainConnectors.substrate, "This module requires a substrate chain connector");
3254
- const queries = await buildQueries$4(chaindataProvider$1, addressesByToken);
3261
+ const queries = await buildQueries$3(chaindataProvider$1, addressesByToken);
3255
3262
  const result = await new RpcStateQueryHelper(chainConnectors.substrate, queries).fetch();
3256
3263
  const balances = result?.filter(b => b !== null) ?? [];
3257
3264
  return new Balances(balances);
@@ -3275,7 +3282,7 @@ const SubAssetsModule = hydrate => {
3275
3282
  const token = await chaindataProvider$1.tokenById(tokenId);
3276
3283
  util$1.assert(token, `Token ${tokenId} not found in store`);
3277
3284
  if (token.type !== "substrate-assets") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
3278
- const chainId = token.chain.id;
3285
+ const chainId = token.networkId;
3279
3286
  const chain = await chaindataProvider$1.chainById(chainId);
3280
3287
  util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
3281
3288
  const {
@@ -3321,7 +3328,7 @@ const SubAssetsModule = hydrate => {
3321
3328
  }
3322
3329
  };
3323
3330
  };
3324
- async function buildQueries$4(chaindataProvider, addressesByToken) {
3331
+ async function buildQueries$3(chaindataProvider, addressesByToken) {
3325
3332
  const allChains = await chaindataProvider.chainsById();
3326
3333
  const tokens = await chaindataProvider.tokensById();
3327
3334
  const miniMetadatas = new Map((await db.miniMetadatas.toArray()).map(miniMetadata => [miniMetadata.id, miniMetadata]));
@@ -3346,7 +3353,7 @@ async function buildQueries$4(chaindataProvider, addressesByToken) {
3346
3353
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
3347
3354
  return [];
3348
3355
  }
3349
- const chainId = token.chain?.id;
3356
+ const chainId = token.networkId;
3350
3357
  if (!chainId) {
3351
3358
  log.warn(`Token ${tokenId} has no chain`);
3352
3359
  return [];
@@ -3428,274 +3435,6 @@ const tryEncode = (scaleCoder, ...args) => {
3428
3435
  }
3429
3436
  };
3430
3437
 
3431
- const moduleType$4 = "substrate-equilibrium";
3432
- const subEquilibriumTokenId = (chainId, tokenSymbol) => `${chainId}-substrate-equilibrium-${tokenSymbol}`.toLowerCase().replace(/ /g, "-");
3433
- const SubEquilibriumModule = hydrate => {
3434
- const {
3435
- chainConnectors,
3436
- chaindataProvider: chaindataProvider$1
3437
- } = hydrate;
3438
- const chainConnector = chainConnectors.substrate;
3439
- util$1.assert(chainConnector, "This module requires a substrate chain connector");
3440
- return {
3441
- ...DefaultBalanceModule(moduleType$4),
3442
- async fetchSubstrateChainMeta(chainId, moduleConfig, metadataRpc) {
3443
- const isTestnet = (await chaindataProvider$1.chainById(chainId))?.isTestnet || false;
3444
- if (metadataRpc === undefined) return {
3445
- isTestnet
3446
- };
3447
- if (moduleConfig?.disable !== false) return {
3448
- isTestnet
3449
- }; // default to disabled
3450
-
3451
- const metadataVersion = scale.getMetadataVersion(metadataRpc);
3452
- const metadata = scale.decAnyMetadata(metadataRpc);
3453
- scale.compactMetadata(metadata, [{
3454
- pallet: "EqAssets",
3455
- items: ["Assets"]
3456
- }, {
3457
- pallet: "System",
3458
- items: ["Account"]
3459
- }]);
3460
- const miniMetadata = scale.encodeMetadata(metadata);
3461
- return {
3462
- isTestnet,
3463
- miniMetadata,
3464
- metadataVersion
3465
- };
3466
- },
3467
- async fetchSubstrateChainTokens(chainId, chainMeta, moduleConfig) {
3468
- // default to disabled
3469
- if (moduleConfig?.disable !== false) return {};
3470
- const {
3471
- isTestnet,
3472
- miniMetadata,
3473
- metadataVersion
3474
- } = chainMeta;
3475
- if (miniMetadata === undefined || metadataVersion === undefined) return {};
3476
- if (metadataVersion < 14) return {};
3477
- try {
3478
- const metadata = scale.unifyMetadata(scale.decAnyMetadata(miniMetadata));
3479
- const scaleBuilder = scale.getDynamicBuilder(scale.getLookupFn(metadata));
3480
- const assetsCoder = scaleBuilder.buildStorage("EqAssets", "Assets");
3481
- const stateKey = assetsCoder.keys.enc();
3482
-
3483
- /** NOTE: Just a guideline, the RPC can return whatever it wants */
3484
-
3485
- const assetsResult = await chainConnector.send(chainId, "state_getStorage", [stateKey]).then(result => assetsCoder.value.dec(result) ?? null);
3486
- const tokens = (Array.isArray(assetsResult) ? assetsResult : []).flatMap(asset => {
3487
- if (!asset) return [];
3488
- if (!asset?.id) return [];
3489
- const assetId = asset.id.toString(10);
3490
- const symbol = tokenSymbolFromU64Id(asset.id);
3491
- const id = subEquilibriumTokenId(chainId, symbol);
3492
- const decimals = DEFAULT_DECIMALS$1;
3493
- const tokenConfig = (moduleConfig?.tokens ?? []).find(token => token.assetId === assetId);
3494
- const token = {
3495
- id,
3496
- type: "substrate-equilibrium",
3497
- isTestnet,
3498
- isDefault: tokenConfig?.isDefault ?? true,
3499
- symbol,
3500
- decimals,
3501
- logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
3502
- // TODO: Fetch the ED
3503
- existentialDeposit: "0",
3504
- assetId,
3505
- chain: {
3506
- id: chainId
3507
- }
3508
- };
3509
- if (tokenConfig?.symbol) {
3510
- token.symbol = tokenConfig?.symbol;
3511
- token.id = subEquilibriumTokenId(chainId, token.symbol);
3512
- }
3513
- if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
3514
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
3515
- if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
3516
- return [[token.id, token]];
3517
- });
3518
- return Object.fromEntries(tokens);
3519
- } catch (error) {
3520
- log.error(`Failed to build substrate-equilibrium tokens on ${chainId}`, error?.message ?? error);
3521
- return {};
3522
- }
3523
- },
3524
- // TODO: Don't create empty subscriptions
3525
- async subscribeBalances({
3526
- addressesByToken
3527
- }, callback) {
3528
- const queries = await buildQueries$3(chaindataProvider$1, addressesByToken);
3529
- const unsubscribe = await new RpcStateQueryHelper(chainConnector, queries).subscribe((error, result) => {
3530
- if (error) return callback(error);
3531
- const balances = result?.flatMap(balances => balances) ?? [];
3532
- if (balances.length > 0) callback(null, new Balances(balances));
3533
- });
3534
- return unsubscribe;
3535
- },
3536
- async fetchBalances(addressesByToken) {
3537
- util$1.assert(chainConnectors.substrate, "This module requires a substrate chain connector");
3538
- const queries = await buildQueries$3(chaindataProvider$1, addressesByToken);
3539
- const result = await new RpcStateQueryHelper(chainConnectors.substrate, queries).fetch();
3540
- const balances = result?.flatMap(balances => balances) ?? [];
3541
- return new Balances(balances);
3542
- },
3543
- async transferToken({
3544
- tokenId,
3545
- from,
3546
- to,
3547
- amount,
3548
- registry,
3549
- metadataRpc,
3550
- blockHash,
3551
- blockNumber,
3552
- nonce,
3553
- specVersion,
3554
- transactionVersion,
3555
- tip,
3556
- transferMethod,
3557
- userExtensions
3558
- }) {
3559
- const token = await chaindataProvider$1.tokenById(tokenId);
3560
- util$1.assert(token, `Token ${tokenId} not found in store`);
3561
- if (token.type !== "substrate-equilibrium") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
3562
- const chainId = token.chain.id;
3563
- const chain = await chaindataProvider$1.chainById(chainId);
3564
- util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
3565
- const {
3566
- genesisHash
3567
- } = chain;
3568
- const {
3569
- assetId
3570
- } = token;
3571
- const pallet = "EqBalances";
3572
- const method = transferMethod === "transfer_all" ?
3573
- // the eqBalances pallet has no transfer_all method
3574
- "transfer" : transferMethod === "transfer_keep_alive" ?
3575
- // the eqBalances pallet has no transfer_keep_alive method
3576
- "transfer" : "transfer";
3577
- const args = {
3578
- asset: assetId,
3579
- to,
3580
- value: amount
3581
- };
3582
- const unsigned = txwrapperCore.defineMethod({
3583
- method: {
3584
- pallet: camelCase__default.default(pallet),
3585
- name: camelCase__default.default(method),
3586
- args
3587
- },
3588
- address: from,
3589
- blockHash,
3590
- blockNumber,
3591
- eraPeriod: 64,
3592
- genesisHash,
3593
- metadataRpc,
3594
- nonce,
3595
- specVersion,
3596
- tip: tip ? Number(tip) : 0,
3597
- transactionVersion
3598
- }, {
3599
- metadataRpc,
3600
- registry,
3601
- userExtensions
3602
- });
3603
- return {
3604
- type: "substrate",
3605
- callData: unsigned.method
3606
- };
3607
- }
3608
- };
3609
- };
3610
- async function buildQueries$3(chaindataProvider, addressesByToken) {
3611
- const allChains = await chaindataProvider.chainsById();
3612
- const tokens = await chaindataProvider.tokensById();
3613
- const miniMetadatas = new Map((await db.miniMetadatas.toArray()).map(miniMetadata => [miniMetadata.id, miniMetadata]));
3614
- const uniqueChainIds = getUniqueChainIds(addressesByToken, tokens);
3615
- const chains = Object.fromEntries(uniqueChainIds.map(chainId => [chainId, allChains[chainId]]));
3616
- const chainStorageCoders = buildStorageCoders({
3617
- chainIds: uniqueChainIds,
3618
- chains,
3619
- miniMetadatas,
3620
- moduleType: "substrate-equilibrium",
3621
- coders: {
3622
- storage: ["System", "Account"]
3623
- }
3624
- });
3625
-
3626
- // equilibrium returns all chain tokens for each address in the one query
3627
- // so, we only need to make one query per address, rather than one query per token per address
3628
- const addressesByChain = new Map();
3629
- const tokensByAddress = new Map();
3630
- Object.entries(addressesByToken).map(([tokenId, addresses]) => {
3631
- const token = tokens[tokenId];
3632
- if (!token) return log.warn(`Token ${tokenId} not found`);
3633
- if (token.type !== "substrate-equilibrium") return log.debug(`This module doesn't handle tokens of type ${token.type}`);
3634
- const chainId = token?.chain?.id;
3635
- if (!chainId) return log.warn(`Token ${tokenId} has no chain`);
3636
- const byChain = addressesByChain.get(chainId) ?? new Set();
3637
- addresses.forEach(address => {
3638
- byChain?.add(address);
3639
- tokensByAddress.set(address, (tokensByAddress.get(address) ?? new Set()).add(token));
3640
- });
3641
- addressesByChain.set(chainId, byChain);
3642
- });
3643
- return Array.from(addressesByChain).flatMap(([chainId, addresses]) => {
3644
- const chain = chains[chainId];
3645
- if (!chain) {
3646
- log.warn(`Chain ${chainId} not found`);
3647
- return [];
3648
- }
3649
- return Array.from(addresses).flatMap(address => {
3650
- const scaleCoder = chainStorageCoders.get(chainId)?.storage;
3651
- const stateKey = scale.encodeStateKey(scaleCoder, `Invalid address in ${chainId} storage query ${address}`, address);
3652
- if (!stateKey) return [];
3653
- const decodeResult = change => {
3654
- /** NOTE: This type is only a hint for typescript, the chain can actually return whatever it wants to */
3655
-
3656
- const decoded = scale.decodeScale(scaleCoder, change, `Failed to decode eqBalances on chain ${chainId}`);
3657
- const tokenBalances = Object.fromEntries((decoded?.data?.value?.balance ?? []).map(balance => ({
3658
- id: (balance?.[0] ?? 0n)?.toString?.(),
3659
- free: balance?.[1]?.type === "Positive" ? (balance?.[1]?.value ?? 0n).toString() : balance?.[1]?.type === "Negative" ? ((balance?.[1]?.value ?? 0n) * -1n).toString() : "0"
3660
- })).map(({
3661
- id,
3662
- free
3663
- }) => [id, free]).filter(([id, free]) => id !== undefined && free !== undefined));
3664
- const result = Array.from(tokensByAddress.get(address) ?? []).filter(t => t.chain.id === chainId).map(token => {
3665
- const value = tokenBalances[token.assetId];
3666
- return {
3667
- source: "substrate-equilibrium",
3668
- status: "live",
3669
- address,
3670
- multiChainId: {
3671
- subChainId: chainId
3672
- },
3673
- chainId,
3674
- tokenId: token.id,
3675
- value
3676
- };
3677
- }).filter(b => b !== undefined);
3678
- return result;
3679
- };
3680
- return {
3681
- chainId,
3682
- stateKey,
3683
- decodeResult
3684
- };
3685
- });
3686
- });
3687
- }
3688
- const DEFAULT_DECIMALS$1 = 9;
3689
- const tokenSymbolFromU64Id = u64 => {
3690
- const bytes = [];
3691
- let num = typeof u64 === "number" ? BigInt(u64) : util.isBigInt(u64) ? u64 : u64.toBigInt();
3692
- do {
3693
- bytes.unshift(Number(num % 256n));
3694
- num = num / 256n;
3695
- } while (num > 0);
3696
- return new TextDecoder("utf-8").decode(new Uint8Array(bytes)).toUpperCase();
3697
- };
3698
-
3699
3438
  const moduleType$3 = "substrate-foreignassets";
3700
3439
  const subForeignAssetTokenId = (chainId, tokenSymbol) => `${chainId}-substrate-foreignassets-${tokenSymbol}`.toLowerCase().replace(/ /g, "-");
3701
3440
  const SubForeignAssetsModule = hydrate => {
@@ -3764,24 +3503,23 @@ const SubForeignAssetsModule = hydrate => {
3764
3503
  const token = {
3765
3504
  id,
3766
3505
  type: "substrate-foreignassets",
3506
+ platform: "polkadot",
3767
3507
  isTestnet,
3768
3508
  isDefault: tokenConfig?.isDefault ?? true,
3769
3509
  symbol,
3770
3510
  decimals,
3511
+ name: tokenConfig?.name || symbol,
3771
3512
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
3772
3513
  existentialDeposit,
3773
3514
  onChainId: tokenConfig.onChainId,
3774
3515
  isFrozen,
3775
- chain: {
3776
- id: chainId
3777
- }
3516
+ networkId: chainId
3778
3517
  };
3779
3518
  if (tokenConfig?.symbol) {
3780
3519
  token.symbol = tokenConfig?.symbol;
3781
3520
  token.id = subForeignAssetTokenId(chainId, token.symbol);
3782
3521
  }
3783
3522
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
3784
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
3785
3523
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
3786
3524
  tokens[token.id] = token;
3787
3525
  } catch (error) {
@@ -3820,7 +3558,7 @@ const SubForeignAssetsModule = hydrate => {
3820
3558
  const token = await chaindataProvider$1.tokenById(tokenId);
3821
3559
  util$1.assert(token, `Token ${tokenId} not found in store`);
3822
3560
  if (token.type !== "substrate-foreignassets") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
3823
- const chainId = token.chain.id;
3561
+ const chainId = token.networkId;
3824
3562
  const chain = await chaindataProvider$1.chainById(chainId);
3825
3563
  util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
3826
3564
  const onChainId = (() => {
@@ -3886,7 +3624,7 @@ async function buildQueries$2(chaindataProvider, addressesByToken) {
3886
3624
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
3887
3625
  return [];
3888
3626
  }
3889
- const chainId = token.chain?.id;
3627
+ const chainId = token.networkId;
3890
3628
  if (!chainId) {
3891
3629
  log.warn(`Token ${tokenId} has no chain`);
3892
3630
  return [];
@@ -3995,7 +3733,7 @@ async function subscribeCrowdloans(chaindataProvider, chainConnector, addressesB
3995
3733
  // ignore non-native tokens
3996
3734
  if (token.type !== "substrate-native") return;
3997
3735
  // ignore tokens on chains with no crowdloans pallet
3998
- const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.chain.id]);
3736
+ const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.networkId]);
3999
3737
  return typeof chainMeta?.crowdloanPalletId === "string";
4000
3738
  }).map(([tokenId]) => tokenId);
4001
3739
 
@@ -4028,7 +3766,7 @@ async function subscribeCrowdloans(chaindataProvider, chainConnector, addressesB
4028
3766
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
4029
3767
  continue;
4030
3768
  }
4031
- const chainId = token.chain?.id;
3769
+ const chainId = token.networkId;
4032
3770
  if (!chainId) {
4033
3771
  log.warn(`Token ${tokenId} has no chain`);
4034
3772
  continue;
@@ -4265,7 +4003,7 @@ async function subscribeNompoolStaking(chaindataProvider, chainConnector, addres
4265
4003
  // ignore non-native tokens
4266
4004
  if (token.type !== "substrate-native") return false;
4267
4005
  // ignore tokens on chains with no nompools pallet
4268
- const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.chain.id]);
4006
+ const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.networkId]);
4269
4007
  return typeof chainMeta?.nominationPoolsPalletId === "string";
4270
4008
  }).map(([tokenId]) => tokenId);
4271
4009
 
@@ -4300,7 +4038,7 @@ async function subscribeNompoolStaking(chaindataProvider, chainConnector, addres
4300
4038
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
4301
4039
  continue;
4302
4040
  }
4303
- const chainId = token.chain?.id;
4041
+ const chainId = token.networkId;
4304
4042
  if (!chainId) {
4305
4043
  log.warn(`Token ${tokenId} has no chain`);
4306
4044
  continue;
@@ -4580,7 +4318,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
4580
4318
  // ignore non-native tokens
4581
4319
  if (token.type !== "substrate-native") return false;
4582
4320
  // ignore tokens on chains with no subtensor pallet
4583
- const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.chain.id]);
4321
+ const [chainMeta] = findChainMeta(miniMetadatas, "substrate-native", allChains[token.networkId]);
4584
4322
  return chainMeta?.hasSubtensorPallet === true;
4585
4323
  }).map(([tokenId]) => tokenId);
4586
4324
 
@@ -4603,7 +4341,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
4603
4341
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
4604
4342
  continue;
4605
4343
  }
4606
- const chainId = token.chain?.id;
4344
+ const chainId = token.networkId;
4607
4345
  if (!chainId) {
4608
4346
  log.warn(`Token ${tokenId} has no chain`);
4609
4347
  continue;
@@ -4947,7 +4685,7 @@ async function buildQueries$1(chains, tokens, chainStorageCoders, miniMetadatas,
4947
4685
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
4948
4686
  return outerResult;
4949
4687
  }
4950
- const chainId = token.chain?.id;
4688
+ const chainId = token.networkId;
4951
4689
  if (!chainId) {
4952
4690
  log.warn(`Token ${tokenId} has no chain`);
4953
4691
  return outerResult;
@@ -5288,8 +5026,8 @@ class QueryCache {
5288
5026
  this.metadataSub = commonMetadataObservable.pipe(util.firstThenDebounce(500), detectMiniMetadataChanges(), rxjs.combineLatestWith(this.chaindataProvider.tokensObservable), rxjs.distinctUntilChanged()).subscribe(([miniMetadataChanges, tokens]) => {
5289
5027
  // invalidate cache entries for any chains with new metadata
5290
5028
  const tokensByChainId = tokens.filter(token => token.type === "substrate-native").reduce((result, token) => {
5291
- if (!token.chain?.id) return result;
5292
- result[token.chain.id] ? result[token.chain.id].push(token) : result[token.chain.id] = [token];
5029
+ if (!token.networkId) return result;
5030
+ result[token.networkId] ? result[token.networkId].push(token) : result[token.networkId] = [token];
5293
5031
  return result;
5294
5032
  }, {});
5295
5033
  miniMetadataChanges.forEach(chainId => {
@@ -5508,19 +5246,18 @@ const SubNativeModule = hydrate => {
5508
5246
  const nativeToken = {
5509
5247
  id,
5510
5248
  type: "substrate-native",
5249
+ platform: "polkadot",
5511
5250
  isTestnet,
5512
5251
  isDefault: moduleConfig?.isDefault ?? true,
5513
5252
  symbol: symbol ?? DEFAULT_SYMBOL,
5253
+ name: moduleConfig?.name ?? symbol ?? DEFAULT_SYMBOL,
5514
5254
  decimals: decimals ?? DEFAULT_DECIMALS,
5515
5255
  logo: moduleConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
5516
5256
  existentialDeposit: existentialDeposit ?? "0",
5517
- chain: {
5518
- id: chainId
5519
- }
5257
+ networkId: chainId
5520
5258
  };
5521
5259
  if (moduleConfig?.symbol) nativeToken.symbol = moduleConfig?.symbol;
5522
5260
  if (moduleConfig?.coingeckoId) nativeToken.coingeckoId = moduleConfig?.coingeckoId;
5523
- if (moduleConfig?.dcentName) nativeToken.dcentName = moduleConfig?.dcentName;
5524
5261
  if (moduleConfig?.mirrorOf) nativeToken.mirrorOf = moduleConfig?.mirrorOf;
5525
5262
  return {
5526
5263
  [nativeToken.id]: nativeToken
@@ -5648,7 +5385,7 @@ const SubNativeModule = hydrate => {
5648
5385
  if (error instanceof chainConnector.ChainConnectionError) {
5649
5386
  // coerce ChainConnection errors into SubNativeBalance errors
5650
5387
  const errorChainId = error.chainId;
5651
- Object.entries(await getModuleTokens()).filter(([, token]) => token.chain?.id === errorChainId).forEach(([tokenId]) => {
5388
+ Object.entries(await getModuleTokens()).filter(([, token]) => token.networkId === errorChainId).forEach(([tokenId]) => {
5652
5389
  const wrappedError = new SubNativeBalanceError(tokenId, error.message);
5653
5390
  handleUpdate(wrappedError);
5654
5391
  });
@@ -5713,7 +5450,7 @@ const SubNativeModule = hydrate => {
5713
5450
  const token = await chaindataProvider$1.tokenById(tokenId);
5714
5451
  util$1.assert(token, `Token ${tokenId} not found in store`);
5715
5452
  if (token.type !== "substrate-native") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
5716
- const chainId = token.chain.id;
5453
+ const chainId = token.networkId;
5717
5454
  const chain = await chaindataProvider$1.chainById(chainId);
5718
5455
  util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
5719
5456
  const {
@@ -6962,23 +6699,22 @@ const SubPsp22Module = hydrate => {
6962
6699
  const token = {
6963
6700
  id,
6964
6701
  type: "substrate-psp22",
6702
+ platform: "polkadot",
6965
6703
  isTestnet,
6966
6704
  isDefault: tokenConfig.isDefault ?? true,
6967
6705
  symbol,
6968
6706
  decimals,
6707
+ name: tokenConfig?.name || symbol,
6969
6708
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
6970
6709
  existentialDeposit,
6971
6710
  contractAddress,
6972
- chain: {
6973
- id: chainId
6974
- }
6711
+ networkId: chainId
6975
6712
  };
6976
6713
  if (tokenConfig?.symbol) {
6977
6714
  token.symbol = tokenConfig?.symbol;
6978
6715
  token.id = subPsp22TokenId(chainId, token.symbol);
6979
6716
  }
6980
6717
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
6981
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
6982
6718
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
6983
6719
  tokens[token.id] = token;
6984
6720
  } catch (error) {
@@ -7044,7 +6780,7 @@ const SubPsp22Module = hydrate => {
7044
6780
  const token = await chaindataProvider$1.tokenById(tokenId);
7045
6781
  util$1.assert(token, `Token ${tokenId} not found in store`);
7046
6782
  if (token.type !== "substrate-psp22") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
7047
- const chainId = token.chain.id;
6783
+ const chainId = token.networkId;
7048
6784
  const chain = await chaindataProvider$1.chainById(chainId);
7049
6785
  util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
7050
6786
  const {
@@ -7121,7 +6857,7 @@ const fetchBalances = async (chainConnector, tokens, addressesByToken) => {
7121
6857
  // TODO: Use `decodeOutput` from `./util/decodeOutput`
7122
6858
  const contractCall = makeContractCaller({
7123
6859
  chainConnector,
7124
- chainId: token.chain.id,
6860
+ chainId: token.networkId,
7125
6861
  registry
7126
6862
  });
7127
6863
  if (token.contractAddress === undefined) {
@@ -7139,9 +6875,9 @@ const fetchBalances = async (chainConnector, tokens, addressesByToken) => {
7139
6875
  status: "live",
7140
6876
  address,
7141
6877
  multiChainId: {
7142
- subChainId: token.chain.id
6878
+ subChainId: token.networkId
7143
6879
  },
7144
- chainId: token.chain.id,
6880
+ chainId: token.networkId,
7145
6881
  tokenId,
7146
6882
  value: balance
7147
6883
  };
@@ -7218,23 +6954,22 @@ const SubTokensModule = hydrate => {
7218
6954
  const token = {
7219
6955
  id,
7220
6956
  type: "substrate-tokens",
6957
+ platform: "polkadot",
7221
6958
  isTestnet,
7222
6959
  isDefault: tokenConfig.isDefault ?? true,
7223
6960
  symbol,
7224
6961
  decimals,
6962
+ name: tokenConfig?.name ?? symbol,
7225
6963
  logo: tokenConfig?.logo || chaindataProvider.githubTokenLogoUrl(id),
7226
6964
  existentialDeposit,
7227
6965
  onChainId,
7228
- chain: {
7229
- id: chainId
7230
- }
6966
+ networkId: chainId
7231
6967
  };
7232
6968
  if (tokenConfig?.symbol) {
7233
6969
  token.symbol = tokenConfig?.symbol;
7234
6970
  token.id = subTokensTokenId(chainId, token.onChainId);
7235
6971
  }
7236
6972
  if (tokenConfig?.coingeckoId) token.coingeckoId = tokenConfig?.coingeckoId;
7237
- if (tokenConfig?.dcentName) token.dcentName = tokenConfig?.dcentName;
7238
6973
  if (tokenConfig?.mirrorOf) token.mirrorOf = tokenConfig?.mirrorOf;
7239
6974
  tokens[token.id] = token;
7240
6975
  } catch (error) {
@@ -7273,7 +7008,7 @@ const SubTokensModule = hydrate => {
7273
7008
  const token = await chaindataProvider$1.tokenById(tokenId);
7274
7009
  util$1.assert(token, `Token ${tokenId} not found in store`);
7275
7010
  if (token.type !== "substrate-tokens") throw new Error(`This module doesn't handle tokens of type ${token.type}`);
7276
- const chainId = token.chain.id;
7011
+ const chainId = token.networkId;
7277
7012
  const chain = await chaindataProvider$1.chainById(chainId);
7278
7013
  util$1.assert(chain?.genesisHash, `Chain ${chainId} not found in store`);
7279
7014
  const miniMetadatas = new Map((await db.miniMetadatas.toArray()).map(miniMetadata => [miniMetadata.id, miniMetadata]));
@@ -7405,7 +7140,7 @@ async function buildQueries(chaindataProvider, addressesByToken) {
7405
7140
  log.debug(`This module doesn't handle tokens of type ${token.type}`);
7406
7141
  return [];
7407
7142
  }
7408
- const chainId = token.chain?.id;
7143
+ const chainId = token.networkId;
7409
7144
  if (!chainId) {
7410
7145
  log.warn(`Token ${tokenId} has no chain`);
7411
7146
  return [];
@@ -7471,7 +7206,7 @@ async function buildQueries(chaindataProvider, addressesByToken) {
7471
7206
  });
7472
7207
  }
7473
7208
 
7474
- const defaultBalanceModules = [EvmErc20Module, EvmNativeModule, EvmUniswapV2Module, SubAssetsModule, SubEquilibriumModule, SubForeignAssetsModule, SubNativeModule, SubPsp22Module, SubTokensModule];
7209
+ const defaultBalanceModules = [EvmErc20Module, EvmNativeModule, EvmUniswapV2Module, SubAssetsModule, SubForeignAssetsModule, SubNativeModule, SubPsp22Module, SubTokensModule];
7475
7210
 
7476
7211
  /** Pulls the latest chaindata from https://github.com/TalismanSociety/chaindata */
7477
7212
  const hydrateChaindataAndMiniMetadata = async (chaindataProvider, miniMetadataUpdater) => {
@@ -7518,7 +7253,6 @@ exports.SCALE_FACTOR = SCALE_FACTOR;
7518
7253
  exports.SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = SUBTENSOR_MIN_STAKE_AMOUNT_PLANK;
7519
7254
  exports.SUBTENSOR_ROOT_NETUID = SUBTENSOR_ROOT_NETUID;
7520
7255
  exports.SubAssetsModule = SubAssetsModule;
7521
- exports.SubEquilibriumModule = SubEquilibriumModule;
7522
7256
  exports.SubForeignAssetsModule = SubForeignAssetsModule;
7523
7257
  exports.SubNativeModule = SubNativeModule;
7524
7258
  exports.SubPsp22Module = SubPsp22Module;
@@ -7557,7 +7291,6 @@ exports.hydrateChaindataAndMiniMetadata = hydrateChaindataAndMiniMetadata;
7557
7291
  exports.includeInTotalExtraAmount = includeInTotalExtraAmount;
7558
7292
  exports.makeContractCaller = makeContractCaller;
7559
7293
  exports.subAssetTokenId = subAssetTokenId;
7560
- exports.subEquilibriumTokenId = subEquilibriumTokenId;
7561
7294
  exports.subForeignAssetTokenId = subForeignAssetTokenId;
7562
7295
  exports.subNativeTokenId = subNativeTokenId;
7563
7296
  exports.subPsp22TokenId = subPsp22TokenId;