@talismn/balances 0.0.0-pr2075-20250707104634 → 0.0.0-pr2075-20250707140747

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.
@@ -1691,7 +1691,7 @@ const TokenCacheSchema$1 = z__default.default.discriminatedUnion("isValid", [z__
1691
1691
  symbol: true,
1692
1692
  decimals: true,
1693
1693
  name: true
1694
- })
1694
+ }).shape
1695
1695
  }), z__default.default.strictObject({
1696
1696
  id: chaindataProvider.EvmErc20TokenSchema.shape.id,
1697
1697
  isValid: z__default.default.literal(false)
@@ -1706,7 +1706,7 @@ const fetchTokens$8 = async ({
1706
1706
  for (const tokenConfig of tokens) {
1707
1707
  const tokenId = chaindataProvider.evmErc20TokenId(networkId, tokenConfig.contractAddress);
1708
1708
  const cached = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1709
- if (cached?.isValid) {
1709
+ if (!cached) {
1710
1710
  const client = await connector.getPublicClientForEvmNetwork(networkId);
1711
1711
  if (!client) {
1712
1712
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -1746,10 +1746,16 @@ const fetchTokens$8 = async ({
1746
1746
  platform: PLATFORM$8,
1747
1747
  networkId
1748
1748
  };
1749
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
1749
+ const cached2 = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1750
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
1750
1751
  const parsed = chaindataProvider.EvmErc20TokenSchema.safeParse(token);
1751
1752
  if (!parsed.success) {
1752
- log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
1753
+ log.warn("Ignoring token with invalid EvmErc20TokenSchema", {
1754
+ token,
1755
+ base,
1756
+ cached: cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {},
1757
+ tokenConfig
1758
+ });
1753
1759
  continue;
1754
1760
  }
1755
1761
  result.push(parsed.data);
@@ -2214,7 +2220,6 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2214
2220
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2215
2221
  isValid: z__default.default.literal(true),
2216
2222
  ...chaindataProvider.EvmUniswapV2TokenSchema.pick({
2217
- id: true,
2218
2223
  symbol: true,
2219
2224
  decimals: true,
2220
2225
  name: true,
@@ -2224,7 +2229,7 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2224
2229
  decimals1: true,
2225
2230
  symbol0: true,
2226
2231
  symbol1: true
2227
- })
2232
+ }).shape
2228
2233
  }), z__default.default.strictObject({
2229
2234
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2230
2235
  isValid: z__default.default.literal(false)
@@ -2239,7 +2244,7 @@ const fetchTokens$6 = async ({
2239
2244
  for (const tokenConfig of tokens) {
2240
2245
  const tokenId = chaindataProvider.evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2241
2246
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2242
- if (cached?.isValid) {
2247
+ if (!cached) {
2243
2248
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2244
2249
  if (!client) {
2245
2250
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2290,7 +2295,8 @@ const fetchTokens$6 = async ({
2290
2295
  platform: PLATFORM$6,
2291
2296
  networkId
2292
2297
  };
2293
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
2298
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2299
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
2294
2300
  const parsed = chaindataProvider.EvmUniswapV2TokenSchema.safeParse(token);
2295
2301
  if (!parsed.success) {
2296
2302
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
@@ -1691,7 +1691,7 @@ const TokenCacheSchema$1 = z__default.default.discriminatedUnion("isValid", [z__
1691
1691
  symbol: true,
1692
1692
  decimals: true,
1693
1693
  name: true
1694
- })
1694
+ }).shape
1695
1695
  }), z__default.default.strictObject({
1696
1696
  id: chaindataProvider.EvmErc20TokenSchema.shape.id,
1697
1697
  isValid: z__default.default.literal(false)
@@ -1706,7 +1706,7 @@ const fetchTokens$8 = async ({
1706
1706
  for (const tokenConfig of tokens) {
1707
1707
  const tokenId = chaindataProvider.evmErc20TokenId(networkId, tokenConfig.contractAddress);
1708
1708
  const cached = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1709
- if (cached?.isValid) {
1709
+ if (!cached) {
1710
1710
  const client = await connector.getPublicClientForEvmNetwork(networkId);
1711
1711
  if (!client) {
1712
1712
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -1746,10 +1746,16 @@ const fetchTokens$8 = async ({
1746
1746
  platform: PLATFORM$8,
1747
1747
  networkId
1748
1748
  };
1749
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
1749
+ const cached2 = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1750
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
1750
1751
  const parsed = chaindataProvider.EvmErc20TokenSchema.safeParse(token);
1751
1752
  if (!parsed.success) {
1752
- log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
1753
+ log.warn("Ignoring token with invalid EvmErc20TokenSchema", {
1754
+ token,
1755
+ base,
1756
+ cached: cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {},
1757
+ tokenConfig
1758
+ });
1753
1759
  continue;
1754
1760
  }
1755
1761
  result.push(parsed.data);
@@ -2214,7 +2220,6 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2214
2220
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2215
2221
  isValid: z__default.default.literal(true),
2216
2222
  ...chaindataProvider.EvmUniswapV2TokenSchema.pick({
2217
- id: true,
2218
2223
  symbol: true,
2219
2224
  decimals: true,
2220
2225
  name: true,
@@ -2224,7 +2229,7 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2224
2229
  decimals1: true,
2225
2230
  symbol0: true,
2226
2231
  symbol1: true
2227
- })
2232
+ }).shape
2228
2233
  }), z__default.default.strictObject({
2229
2234
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2230
2235
  isValid: z__default.default.literal(false)
@@ -2239,7 +2244,7 @@ const fetchTokens$6 = async ({
2239
2244
  for (const tokenConfig of tokens) {
2240
2245
  const tokenId = chaindataProvider.evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2241
2246
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2242
- if (cached?.isValid) {
2247
+ if (!cached) {
2243
2248
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2244
2249
  if (!client) {
2245
2250
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2290,7 +2295,8 @@ const fetchTokens$6 = async ({
2290
2295
  platform: PLATFORM$6,
2291
2296
  networkId
2292
2297
  };
2293
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
2298
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2299
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
2294
2300
  const parsed = chaindataProvider.EvmUniswapV2TokenSchema.safeParse(token);
2295
2301
  if (!parsed.success) {
2296
2302
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
@@ -9,7 +9,7 @@ import { u8aToHex, assert, stringCamelCase, u8aConcatStrict, u8aToString, hexToN
9
9
  import { xxhashAsU8a } from '@polkadot/util-crypto';
10
10
  import pako from 'pako';
11
11
  import { parseAbi, erc20Abi, getContract, ContractFunctionExecutionError, hexToString, erc20Abi_bytes32, withRetry, encodeFunctionData, isHex, hexToBigInt } from 'viem';
12
- import { assign, isEqual, fromPairs, toPairs, keys, keyBy, uniq, values, groupBy as groupBy$1 } from 'lodash';
12
+ import { assign, omit, isEqual, fromPairs, toPairs, keys, keyBy, uniq, values, groupBy as groupBy$1 } from 'lodash';
13
13
  import z from 'zod/v4';
14
14
  import { Observable, distinctUntilChanged, of, timer, switchMap, from, firstValueFrom, scan, share, map, switchAll, combineLatest, mergeMap, toArray, interval, startWith, exhaustMap, BehaviorSubject, debounceTime, takeUntil, withLatestFrom, concatMap } from 'rxjs';
15
15
  import isEqual$1 from 'lodash/isEqual';
@@ -1678,7 +1678,7 @@ const TokenCacheSchema$1 = z.discriminatedUnion("isValid", [z.strictObject({
1678
1678
  symbol: true,
1679
1679
  decimals: true,
1680
1680
  name: true
1681
- })
1681
+ }).shape
1682
1682
  }), z.strictObject({
1683
1683
  id: EvmErc20TokenSchema.shape.id,
1684
1684
  isValid: z.literal(false)
@@ -1693,7 +1693,7 @@ const fetchTokens$8 = async ({
1693
1693
  for (const tokenConfig of tokens) {
1694
1694
  const tokenId = evmErc20TokenId(networkId, tokenConfig.contractAddress);
1695
1695
  const cached = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1696
- if (cached?.isValid) {
1696
+ if (!cached) {
1697
1697
  const client = await connector.getPublicClientForEvmNetwork(networkId);
1698
1698
  if (!client) {
1699
1699
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -1733,10 +1733,16 @@ const fetchTokens$8 = async ({
1733
1733
  platform: PLATFORM$8,
1734
1734
  networkId
1735
1735
  };
1736
- const token = assign(base, cache[tokenId], tokenConfig);
1736
+ const cached2 = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
1737
+ const token = assign(base, cached2?.isValid ? omit(cached2, ["isValid"]) : {}, tokenConfig);
1737
1738
  const parsed = EvmErc20TokenSchema.safeParse(token);
1738
1739
  if (!parsed.success) {
1739
- log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
1740
+ log.warn("Ignoring token with invalid EvmErc20TokenSchema", {
1741
+ token,
1742
+ base,
1743
+ cached: cached2?.isValid ? omit(cached2, ["isValid"]) : {},
1744
+ tokenConfig
1745
+ });
1740
1746
  continue;
1741
1747
  }
1742
1748
  result.push(parsed.data);
@@ -2201,7 +2207,6 @@ const TokenCacheSchema = z.discriminatedUnion("isValid", [z.strictObject({
2201
2207
  id: EvmUniswapV2TokenSchema.shape.id,
2202
2208
  isValid: z.literal(true),
2203
2209
  ...EvmUniswapV2TokenSchema.pick({
2204
- id: true,
2205
2210
  symbol: true,
2206
2211
  decimals: true,
2207
2212
  name: true,
@@ -2211,7 +2216,7 @@ const TokenCacheSchema = z.discriminatedUnion("isValid", [z.strictObject({
2211
2216
  decimals1: true,
2212
2217
  symbol0: true,
2213
2218
  symbol1: true
2214
- })
2219
+ }).shape
2215
2220
  }), z.strictObject({
2216
2221
  id: EvmUniswapV2TokenSchema.shape.id,
2217
2222
  isValid: z.literal(false)
@@ -2226,7 +2231,7 @@ const fetchTokens$6 = async ({
2226
2231
  for (const tokenConfig of tokens) {
2227
2232
  const tokenId = evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2228
2233
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2229
- if (cached?.isValid) {
2234
+ if (!cached) {
2230
2235
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2231
2236
  if (!client) {
2232
2237
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2277,7 +2282,8 @@ const fetchTokens$6 = async ({
2277
2282
  platform: PLATFORM$6,
2278
2283
  networkId
2279
2284
  };
2280
- const token = assign(base, cache[tokenId], tokenConfig);
2285
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2286
+ const token = assign(base, cached2?.isValid ? omit(cached2, ["isValid"]) : {}, tokenConfig);
2281
2287
  const parsed = EvmUniswapV2TokenSchema.safeParse(token);
2282
2288
  if (!parsed.success) {
2283
2289
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr2075-20250707104634",
3
+ "version": "0.0.0-pr2075-20250707140747",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -35,13 +35,13 @@
35
35
  "scale-ts": "^1.6.1",
36
36
  "viem": "^2.27.3",
37
37
  "zod": "^3.25.62",
38
- "@talismn/chain-connector-evm": "0.0.0-pr2075-20250707104634",
39
- "@talismn/chain-connector": "0.0.0-pr2075-20250707104634",
40
- "@talismn/chaindata-provider": "0.0.0-pr2075-20250707104634",
41
- "@talismn/sapi": "0.0.0-pr2075-20250707104634",
42
- "@talismn/scale": "0.0.0-pr2075-20250707104634",
43
- "@talismn/token-rates": "0.0.0-pr2075-20250707104634",
44
- "@talismn/util": "0.0.0-pr2075-20250707104634"
38
+ "@talismn/chain-connector": "0.0.0-pr2075-20250707140747",
39
+ "@talismn/chain-connector-evm": "0.0.0-pr2075-20250707140747",
40
+ "@talismn/chaindata-provider": "0.0.0-pr2075-20250707140747",
41
+ "@talismn/sapi": "0.0.0-pr2075-20250707140747",
42
+ "@talismn/scale": "0.0.0-pr2075-20250707140747",
43
+ "@talismn/token-rates": "0.0.0-pr2075-20250707140747",
44
+ "@talismn/util": "0.0.0-pr2075-20250707140747"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@polkadot/api-contract": "16.1.2",