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

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,7 +1746,8 @@ 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
1753
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
@@ -2214,7 +2215,6 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2214
2215
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2215
2216
  isValid: z__default.default.literal(true),
2216
2217
  ...chaindataProvider.EvmUniswapV2TokenSchema.pick({
2217
- id: true,
2218
2218
  symbol: true,
2219
2219
  decimals: true,
2220
2220
  name: true,
@@ -2224,7 +2224,7 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2224
2224
  decimals1: true,
2225
2225
  symbol0: true,
2226
2226
  symbol1: true
2227
- })
2227
+ }).shape
2228
2228
  }), z__default.default.strictObject({
2229
2229
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2230
2230
  isValid: z__default.default.literal(false)
@@ -2239,7 +2239,7 @@ const fetchTokens$6 = async ({
2239
2239
  for (const tokenConfig of tokens) {
2240
2240
  const tokenId = chaindataProvider.evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2241
2241
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2242
- if (cached?.isValid) {
2242
+ if (!cached) {
2243
2243
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2244
2244
  if (!client) {
2245
2245
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2290,7 +2290,8 @@ const fetchTokens$6 = async ({
2290
2290
  platform: PLATFORM$6,
2291
2291
  networkId
2292
2292
  };
2293
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
2293
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2294
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
2294
2295
  const parsed = chaindataProvider.EvmUniswapV2TokenSchema.safeParse(token);
2295
2296
  if (!parsed.success) {
2296
2297
  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,7 +1746,8 @@ 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
1753
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
@@ -2214,7 +2215,6 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2214
2215
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2215
2216
  isValid: z__default.default.literal(true),
2216
2217
  ...chaindataProvider.EvmUniswapV2TokenSchema.pick({
2217
- id: true,
2218
2218
  symbol: true,
2219
2219
  decimals: true,
2220
2220
  name: true,
@@ -2224,7 +2224,7 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
2224
2224
  decimals1: true,
2225
2225
  symbol0: true,
2226
2226
  symbol1: true
2227
- })
2227
+ }).shape
2228
2228
  }), z__default.default.strictObject({
2229
2229
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
2230
2230
  isValid: z__default.default.literal(false)
@@ -2239,7 +2239,7 @@ const fetchTokens$6 = async ({
2239
2239
  for (const tokenConfig of tokens) {
2240
2240
  const tokenId = chaindataProvider.evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2241
2241
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2242
- if (cached?.isValid) {
2242
+ if (!cached) {
2243
2243
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2244
2244
  if (!client) {
2245
2245
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2290,7 +2290,8 @@ const fetchTokens$6 = async ({
2290
2290
  platform: PLATFORM$6,
2291
2291
  networkId
2292
2292
  };
2293
- const token = lodash.assign(base, cache[tokenId], tokenConfig);
2293
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2294
+ const token = lodash.assign(base, cached2?.isValid ? lodash.omit(cached2, ["isValid"]) : {}, tokenConfig);
2294
2295
  const parsed = chaindataProvider.EvmUniswapV2TokenSchema.safeParse(token);
2295
2296
  if (!parsed.success) {
2296
2297
  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,7 +1733,8 @@ 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
1740
  log.warn("Ignoring token with invalid EvmErc20TokenSchema", token);
@@ -2201,7 +2202,6 @@ const TokenCacheSchema = z.discriminatedUnion("isValid", [z.strictObject({
2201
2202
  id: EvmUniswapV2TokenSchema.shape.id,
2202
2203
  isValid: z.literal(true),
2203
2204
  ...EvmUniswapV2TokenSchema.pick({
2204
- id: true,
2205
2205
  symbol: true,
2206
2206
  decimals: true,
2207
2207
  name: true,
@@ -2211,7 +2211,7 @@ const TokenCacheSchema = z.discriminatedUnion("isValid", [z.strictObject({
2211
2211
  decimals1: true,
2212
2212
  symbol0: true,
2213
2213
  symbol1: true
2214
- })
2214
+ }).shape
2215
2215
  }), z.strictObject({
2216
2216
  id: EvmUniswapV2TokenSchema.shape.id,
2217
2217
  isValid: z.literal(false)
@@ -2226,7 +2226,7 @@ const fetchTokens$6 = async ({
2226
2226
  for (const tokenConfig of tokens) {
2227
2227
  const tokenId = evmUniswapV2TokenId(networkId, tokenConfig.contractAddress);
2228
2228
  const cached = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2229
- if (cached?.isValid) {
2229
+ if (!cached) {
2230
2230
  const client = await connector.getPublicClientForEvmNetwork(networkId);
2231
2231
  if (!client) {
2232
2232
  log.warn(`No client found for network ${networkId} while fetching EVM ERC20 tokens`);
@@ -2277,7 +2277,8 @@ const fetchTokens$6 = async ({
2277
2277
  platform: PLATFORM$6,
2278
2278
  networkId
2279
2279
  };
2280
- const token = assign(base, cache[tokenId], tokenConfig);
2280
+ const cached2 = cache[tokenId] && TokenCacheSchema.safeParse(cache[tokenId]).data;
2281
+ const token = assign(base, cached2?.isValid ? omit(cached2, ["isValid"]) : {}, tokenConfig);
2281
2282
  const parsed = EvmUniswapV2TokenSchema.safeParse(token);
2282
2283
  if (!parsed.success) {
2283
2284
  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-20250707110010",
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-20250707110010",
39
+ "@talismn/chain-connector-evm": "0.0.0-pr2075-20250707110010",
40
+ "@talismn/chaindata-provider": "0.0.0-pr2075-20250707110010",
41
+ "@talismn/scale": "0.0.0-pr2075-20250707110010",
42
+ "@talismn/sapi": "0.0.0-pr2075-20250707110010",
43
+ "@talismn/util": "0.0.0-pr2075-20250707110010",
44
+ "@talismn/token-rates": "0.0.0-pr2075-20250707110010"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@polkadot/api-contract": "16.1.2",