@talismn/balances 0.0.0-pr2075-20250710071608 → 0.0.0-pr2075-20250710091134

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 (64) hide show
  1. package/dist/declarations/src/BalancesProvider.d.ts +1 -0
  2. package/dist/declarations/src/getMiniMetadatas/index.d.ts +1 -1
  3. package/dist/declarations/src/modules/evm-erc20/fetchBalances.d.ts +1 -1
  4. package/dist/declarations/src/modules/evm-erc20/fetchTokens.d.ts +1 -1
  5. package/dist/declarations/src/modules/evm-erc20/getMiniMetadata.d.ts +1 -1
  6. package/dist/declarations/src/modules/evm-erc20/getTransferCallData.d.ts +1 -1
  7. package/dist/declarations/src/modules/evm-erc20/module.d.ts +1 -1
  8. package/dist/declarations/src/modules/evm-erc20/subscribeBalances.d.ts +1 -1
  9. package/dist/declarations/src/modules/evm-native/fetchBalances.d.ts +1 -1
  10. package/dist/declarations/src/modules/evm-native/fetchTokens.d.ts +1 -1
  11. package/dist/declarations/src/modules/evm-native/getMiniMetadata.d.ts +1 -1
  12. package/dist/declarations/src/modules/evm-native/getTransferCallData.d.ts +1 -1
  13. package/dist/declarations/src/modules/evm-native/module.d.ts +1 -1
  14. package/dist/declarations/src/modules/evm-native/subscribeBalances.d.ts +1 -1
  15. package/dist/declarations/src/modules/evm-uniswapv2/fetchBalances.d.ts +1 -1
  16. package/dist/declarations/src/modules/evm-uniswapv2/fetchTokens.d.ts +1 -1
  17. package/dist/declarations/src/modules/evm-uniswapv2/getMiniMetadata.d.ts +1 -1
  18. package/dist/declarations/src/modules/evm-uniswapv2/getTransferCallData.d.ts +1 -1
  19. package/dist/declarations/src/modules/evm-uniswapv2/module.d.ts +1 -1
  20. package/dist/declarations/src/modules/evm-uniswapv2/subscribeBalances.d.ts +1 -1
  21. package/dist/declarations/src/modules/index.d.ts +10 -10
  22. package/dist/declarations/src/modules/shared/types.d.ts +2 -2
  23. package/dist/declarations/src/modules/substrate-assets/fetchBalances.d.ts +1 -1
  24. package/dist/declarations/src/modules/substrate-assets/fetchTokens.d.ts +1 -1
  25. package/dist/declarations/src/modules/substrate-assets/getMiniMetadata.d.ts +1 -1
  26. package/dist/declarations/src/modules/substrate-assets/getTransferCallData.d.ts +1 -1
  27. package/dist/declarations/src/modules/substrate-assets/module.d.ts +1 -1
  28. package/dist/declarations/src/modules/substrate-assets/subscribeBalances.d.ts +1 -1
  29. package/dist/declarations/src/modules/substrate-foreignassets/fetchBalances.d.ts +1 -1
  30. package/dist/declarations/src/modules/substrate-foreignassets/fetchTokens.d.ts +1 -1
  31. package/dist/declarations/src/modules/substrate-foreignassets/getMiniMetadata.d.ts +1 -1
  32. package/dist/declarations/src/modules/substrate-foreignassets/getTransferCallData.d.ts +1 -1
  33. package/dist/declarations/src/modules/substrate-foreignassets/module.d.ts +1 -1
  34. package/dist/declarations/src/modules/substrate-foreignassets/subscribeBalances.d.ts +1 -1
  35. package/dist/declarations/src/modules/substrate-hydration/fetchBalances.d.ts +1 -1
  36. package/dist/declarations/src/modules/substrate-hydration/fetchTokens.d.ts +1 -1
  37. package/dist/declarations/src/modules/substrate-hydration/getMiniMetadata.d.ts +1 -1
  38. package/dist/declarations/src/modules/substrate-hydration/getTransferCallData.d.ts +1 -1
  39. package/dist/declarations/src/modules/substrate-hydration/module.d.ts +1 -1
  40. package/dist/declarations/src/modules/substrate-hydration/subscribeBalances.d.ts +1 -1
  41. package/dist/declarations/src/modules/substrate-native/fetchBalances.d.ts +1 -1
  42. package/dist/declarations/src/modules/substrate-native/fetchTokens.d.ts +1 -1
  43. package/dist/declarations/src/modules/substrate-native/getMiniMetadata.d.ts +1 -1
  44. package/dist/declarations/src/modules/substrate-native/getTransferCallData.d.ts +1 -1
  45. package/dist/declarations/src/modules/substrate-native/module.d.ts +1 -1
  46. package/dist/declarations/src/modules/substrate-native/subscribeBalances.d.ts +1 -1
  47. package/dist/declarations/src/modules/substrate-psp22/fetchBalances.d.ts +1 -1
  48. package/dist/declarations/src/modules/substrate-psp22/fetchTokens.d.ts +1 -1
  49. package/dist/declarations/src/modules/substrate-psp22/getMiniMetadata.d.ts +1 -1
  50. package/dist/declarations/src/modules/substrate-psp22/getTransferCallData.d.ts +1 -1
  51. package/dist/declarations/src/modules/substrate-psp22/module.d.ts +1 -1
  52. package/dist/declarations/src/modules/substrate-psp22/subscribeBalances.d.ts +1 -1
  53. package/dist/declarations/src/modules/substrate-tokens/fetchBalances.d.ts +1 -1
  54. package/dist/declarations/src/modules/substrate-tokens/fetchTokens.d.ts +1 -1
  55. package/dist/declarations/src/modules/substrate-tokens/getMiniMetadata.d.ts +1 -1
  56. package/dist/declarations/src/modules/substrate-tokens/getTransferCallData.d.ts +1 -1
  57. package/dist/declarations/src/modules/substrate-tokens/module.d.ts +1 -1
  58. package/dist/declarations/src/modules/substrate-tokens/subscribeBalances.d.ts +1 -1
  59. package/dist/declarations/src/{modules → types}/IBalanceModule.d.ts +16 -26
  60. package/dist/declarations/src/types/index.d.ts +1 -0
  61. package/dist/talismn-balances.cjs.dev.js +53 -52
  62. package/dist/talismn-balances.cjs.prod.js +53 -52
  63. package/dist/talismn-balances.esm.js +56 -55
  64. package/package.json +8 -8
@@ -15,6 +15,7 @@ export declare class BalancesProvider {
15
15
  #private;
16
16
  constructor(chaindataProvider: ChaindataProvider, chainConnectors: ChainConnectors, storage?: BalancesStorage);
17
17
  get storage$(): Observable<BalancesStorage>;
18
+ private get storedMiniMetadataMapById$();
18
19
  getBalances$(addressesByTokenId: Record<TokenId, Address[]>): Observable<BalancesResult>;
19
20
  fetchBalances(addressesByTokenId: Record<TokenId, Address[]>): Promise<IBalance[]>;
20
21
  private getNetworkBalances$;
@@ -2,4 +2,4 @@ import { ChainConnector } from "@talismn/chain-connector";
2
2
  import { ChaindataProvider, DotNetworkId } from "@talismn/chaindata-provider";
3
3
  import { MiniMetadata } from "../types";
4
4
  export { getSpecVersion } from "./getSpecVersion";
5
- export declare const getMiniMetadatas: (chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, networkId: DotNetworkId, specVersion?: number, signal?: AbortSignal) => Promise<MiniMetadata[]>;
5
+ export declare const getMiniMetadatas: (chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, networkId: DotNetworkId, specVersion?: number) => Promise<MiniMetadata[]>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const EvmErc20BalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const EvmNativeBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const EvmUniswapV2BalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,4 +1,4 @@
1
- export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule<"substrate-native", {
1
+ export declare const BALANCE_MODULES: (import("../types/IBalanceModule").IBalanceModule<"substrate-native", {
2
2
  symbol?: string | undefined;
3
3
  networkId?: string | undefined;
4
4
  isDefault?: boolean | undefined;
@@ -16,7 +16,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
16
16
  existentialDeposit?: string | undefined;
17
17
  nominationPoolsPalletId?: string | undefined;
18
18
  hasSubtensorPallet?: boolean | undefined;
19
- }> | import("./IBalanceModule").IBalanceModule<"substrate-assets", {
19
+ }> | import("../types/IBalanceModule").IBalanceModule<"substrate-assets", {
20
20
  assetId: string;
21
21
  symbol?: string | undefined;
22
22
  networkId?: string | undefined;
@@ -27,7 +27,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
27
27
  coingeckoId?: string | undefined;
28
28
  noDiscovery?: boolean | undefined;
29
29
  mirrorOf?: string | undefined;
30
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"substrate-hydration", {
30
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-hydration", {
31
31
  onChainId: number;
32
32
  symbol?: string | undefined;
33
33
  networkId?: string | undefined;
@@ -38,7 +38,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
38
38
  coingeckoId?: string | undefined;
39
39
  noDiscovery?: boolean | undefined;
40
40
  mirrorOf?: string | undefined;
41
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"substrate-foreignassets", {
41
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-foreignassets", {
42
42
  onChainId: string;
43
43
  symbol?: string | undefined;
44
44
  networkId?: string | undefined;
@@ -49,7 +49,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
49
49
  coingeckoId?: string | undefined;
50
50
  noDiscovery?: boolean | undefined;
51
51
  mirrorOf?: string | undefined;
52
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"substrate-psp22", {
52
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-psp22", {
53
53
  contractAddress: string;
54
54
  symbol?: string | undefined;
55
55
  networkId?: string | undefined;
@@ -60,7 +60,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
60
60
  coingeckoId?: string | undefined;
61
61
  noDiscovery?: boolean | undefined;
62
62
  mirrorOf?: string | undefined;
63
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"substrate-tokens", {
63
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-tokens", {
64
64
  symbol: string;
65
65
  decimals: number;
66
66
  existentialDeposit: string;
@@ -76,7 +76,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
76
76
  palletId?: string | undefined;
77
77
  }, {
78
78
  palletId: string;
79
- }> | import("./IBalanceModule").IBalanceModule<"evm-erc20", {
79
+ }> | import("../types/IBalanceModule").IBalanceModule<"evm-erc20", {
80
80
  contractAddress: `0x${string}`;
81
81
  symbol?: string | undefined;
82
82
  networkId?: string | undefined;
@@ -87,7 +87,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
87
87
  coingeckoId?: string | undefined;
88
88
  noDiscovery?: boolean | undefined;
89
89
  mirrorOf?: string | undefined;
90
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"evm-uniswapv2", {
90
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"evm-uniswapv2", {
91
91
  contractAddress: `0x${string}`;
92
92
  symbol?: string | undefined;
93
93
  networkId?: string | undefined;
@@ -98,7 +98,7 @@ export declare const BALANCE_MODULES: (import("./IBalanceModule").IBalanceModule
98
98
  coingeckoId?: string | undefined;
99
99
  noDiscovery?: boolean | undefined;
100
100
  mirrorOf?: string | undefined;
101
- }, unknown, unknown> | import("./IBalanceModule").IBalanceModule<"evm-native", {
101
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"evm-native", {
102
102
  symbol?: string | undefined;
103
103
  networkId?: string | undefined;
104
104
  isDefault?: boolean | undefined;
@@ -120,4 +120,4 @@ export * from "./substrate-hydration";
120
120
  export * from "./substrate-psp22";
121
121
  export * from "./substrate-tokens";
122
122
  export * from "./abis";
123
- export * from "./IBalanceModule";
123
+ export * from "../types/IBalanceModule";
@@ -1,7 +1,7 @@
1
1
  import { TokenOfType, TokenType } from "@talismn/chaindata-provider";
2
- import { PlatformOf, TokensWithAddresses } from "../IBalanceModule";
2
+ import { TokenPlatform, TokensWithAddresses } from "../../types/IBalanceModule";
3
3
  export type BalanceDef<T extends TokenType = TokenType> = {
4
4
  token: TokenOfType<T>;
5
- address: PlatformOf<T> extends "ethereum" ? `0x${string}` : string;
5
+ address: TokenPlatform<T> extends "ethereum" ? `0x${string}` : string;
6
6
  };
7
7
  export declare const getBalanceDefs: <T extends TokenType = TokenType>(addressesByToken: TokensWithAddresses) => BalanceDef<T>[];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const SubAssetsBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const SubForeignAssetsBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const SubHydrationBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["fetchBalances"];
@@ -1,5 +1,5 @@
1
1
  import { ChainConnector } from "@talismn/chain-connector";
2
- import { IBalanceModule } from "../IBalanceModule";
2
+ import { IBalanceModule } from "../../types/IBalanceModule";
3
3
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
4
4
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["fetchTokens"];
5
5
  export declare const getChainProperties: (connector: ChainConnector, networkId: string) => Promise<{
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const SubNativeBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const SubPsp22BalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["fetchBalances"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, TokenConfig } from "./config";
3
3
  export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["getMiniMetadata"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig>["getTransferCallData"];
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const SubTokensBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>;
@@ -1,3 +1,3 @@
1
- import { IBalanceModule } from "../IBalanceModule";
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
2
  import { MiniMetadataExtra, MODULE_TYPE, ModuleConfig, TokenConfig } from "./config";
3
3
  export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE, TokenConfig, ModuleConfig, MiniMetadataExtra>["subscribeBalances"];
@@ -2,19 +2,9 @@ import type { ChainConnector } from "@talismn/chain-connector";
2
2
  import type { ChainConnectorEvm } from "@talismn/chain-connector-evm";
3
3
  import { DotNetworkId, EthNetworkId, Token, TokenId, TokenOfType, TokenType } from "@talismn/chaindata-provider";
4
4
  import { Observable } from "rxjs";
5
- import type { Address, IBalance, MiniMetadata } from "../types";
6
- /**
7
- * Changes:
8
- * - each method is standalone
9
- * - decoupled from chaindataProvider (which uses indexedDB so cant be used in node)
10
- * - all methods are network specific: this way they can return without waiting on other networks, while still being able to group multiple fetchs in one query
11
- * - connector is passed as a parameter on every method that needs one, so that an evm module doesnt need a substrate connector, and also to allow using a module without connector
12
- * - miniMetadatas are be fully typed
13
- * - TokenConfig would be made much simpler
14
- * - the logic about what data to fetch and cache (ex: erc20 symbols/decimals) would be here, where it belongs
15
- */
16
- export type PlatformOf<T extends TokenType> = TokenOfType<T>["platform"];
17
- export type ConnectorOf<P extends PlatformOf<TokenType>> = P extends "ethereum" ? ChainConnectorEvm : P extends "polkadot" ? ChainConnector : never;
5
+ import type { Address, IBalance, MiniMetadata } from ".";
6
+ export type TokenPlatform<T extends TokenType> = TokenOfType<T>["platform"];
7
+ export type PlatformConnector<P extends TokenPlatform<TokenType>> = P extends "ethereum" ? ChainConnectorEvm : P extends "polkadot" ? ChainConnector : never;
18
8
  type DotTransferCallData = {
19
9
  address: string;
20
10
  method: `0x${string}`;
@@ -26,7 +16,7 @@ type EthTransferCallData = {
26
16
  value?: string;
27
17
  };
28
18
  export type BalanceTransferType = "keep-alive" | "all" | "allow-death";
29
- type CallDataOf<P extends PlatformOf<TokenType>> = P extends "ethereum" ? EthTransferCallData : P extends "polkadot" ? DotTransferCallData : never;
19
+ type CallDataOf<P extends TokenPlatform<TokenType>> = P extends "ethereum" ? EthTransferCallData : P extends "polkadot" ? DotTransferCallData : never;
30
20
  export type TokensWithAddresses = Array<[Token, Address[]]>;
31
21
  export type FetchBalanceErrors = Array<{
32
22
  tokenId: TokenId;
@@ -39,46 +29,46 @@ export type FetchBalanceResults = {
39
29
  };
40
30
  export interface IBalanceModule<Type extends TokenType, TokenConfig = unknown, ModuleConfig = unknown, MiniMetadataExtra = unknown> {
41
31
  type: Type;
42
- platform: PlatformOf<Type>;
43
- getMiniMetadata: (arg: PlatformOf<Type> extends "polkadot" ? {
32
+ platform: TokenPlatform<Type>;
33
+ getMiniMetadata: (arg: TokenPlatform<Type> extends "polkadot" ? {
44
34
  networkId: string;
45
35
  specVersion: number;
46
36
  metadataRpc: `0x${string}`;
47
37
  config?: ModuleConfig;
48
- } : never) => PlatformOf<Type> extends "polkadot" ? MiniMetadata<MiniMetadataExtra> : never;
49
- fetchTokens: (arg: PlatformOf<Type> extends "polkadot" ? {
38
+ } : never) => TokenPlatform<Type> extends "polkadot" ? MiniMetadata<MiniMetadataExtra> : never;
39
+ fetchTokens: (arg: TokenPlatform<Type> extends "polkadot" ? {
50
40
  networkId: DotNetworkId;
51
41
  tokens: TokenConfig[];
52
42
  connector: ChainConnector;
53
43
  miniMetadata: MiniMetadata<MiniMetadataExtra>;
54
44
  cache: Record<TokenId, unknown>;
55
- } : PlatformOf<Type> extends "ethereum" ? {
45
+ } : TokenPlatform<Type> extends "ethereum" ? {
56
46
  networkId: EthNetworkId;
57
47
  tokens: TokenConfig[];
58
48
  connector: ChainConnectorEvm;
59
49
  cache: Record<TokenId, unknown>;
60
50
  } : never) => Promise<TokenOfType<Type>[]>;
61
- fetchBalances: (arg: PlatformOf<Type> extends "polkadot" ? {
51
+ fetchBalances: (arg: TokenPlatform<Type> extends "polkadot" ? {
62
52
  networkId: DotNetworkId;
63
53
  tokensWithAddresses: TokensWithAddresses;
64
54
  connector: ChainConnector;
65
55
  miniMetadata: MiniMetadata<MiniMetadataExtra>;
66
- } : PlatformOf<Type> extends "ethereum" ? {
56
+ } : TokenPlatform<Type> extends "ethereum" ? {
67
57
  networkId: EthNetworkId;
68
58
  tokensWithAddresses: TokensWithAddresses;
69
59
  connector: ChainConnectorEvm;
70
60
  } : never) => Promise<FetchBalanceResults>;
71
- subscribeBalances: (arg: PlatformOf<Type> extends "polkadot" ? {
61
+ subscribeBalances: (arg: TokenPlatform<Type> extends "polkadot" ? {
72
62
  networkId: DotNetworkId;
73
63
  tokensWithAddresses: TokensWithAddresses;
74
64
  connector: ChainConnector;
75
65
  miniMetadata: MiniMetadata<MiniMetadataExtra>;
76
- } : PlatformOf<Type> extends "ethereum" ? {
66
+ } : TokenPlatform<Type> extends "ethereum" ? {
77
67
  networkId: EthNetworkId;
78
68
  tokensWithAddresses: TokensWithAddresses;
79
69
  connector: ChainConnectorEvm;
80
70
  } : never) => Observable<FetchBalanceResults>;
81
- getTransferCallData: (arg: PlatformOf<Type> extends "polkadot" ? {
71
+ getTransferCallData: (arg: TokenPlatform<Type> extends "polkadot" ? {
82
72
  from: string;
83
73
  to: string;
84
74
  value: string;
@@ -87,11 +77,11 @@ export interface IBalanceModule<Type extends TokenType, TokenConfig = unknown, M
87
77
  type: BalanceTransferType;
88
78
  connector: ChainConnector;
89
79
  config?: ModuleConfig;
90
- } : PlatformOf<Type> extends "ethereum" ? {
80
+ } : TokenPlatform<Type> extends "ethereum" ? {
91
81
  from: string;
92
82
  to: string;
93
83
  value: string;
94
84
  token: Token;
95
- } : never) => CallDataOf<PlatformOf<Type>> | Promise<CallDataOf<PlatformOf<Type>>>;
85
+ } : never) => CallDataOf<TokenPlatform<Type>> | Promise<CallDataOf<TokenPlatform<Type>>>;
96
86
  }
97
87
  export {};
@@ -4,3 +4,4 @@ export * from "./balancetypes";
4
4
  export * from "./minimetadatas";
5
5
  export * from "./subscriptions";
6
6
  export * from "./chainConnectors";
7
+ export * from "./IBalanceModule";
@@ -2570,7 +2570,7 @@ const deriveMiniMetadataId = ({
2570
2570
  source,
2571
2571
  chainId,
2572
2572
  specVersion
2573
- }) => scale.toHex(scale.Twox64Concat(new TextEncoder().encode(`${source}${chainId}${specVersion}${chaindataProvider.MINIMETADATA_VERSION}`))).slice(-64);
2573
+ }) => scale.toHex(scale.Twox128(new TextEncoder().encode(`${source}${chainId}${specVersion}${chaindataProvider.MINIMETADATA_VERSION}`))).slice(-32);
2574
2574
 
2575
2575
  const getMiniMetadata$5 = ({
2576
2576
  networkId,
@@ -3572,11 +3572,11 @@ const fetchStakeInfoByAddress = async (connector, networkId, miniMetadata, addre
3572
3572
 
3573
3573
  // assume dynamic info doesnt change over the course of a browser session
3574
3574
  const dynamicInfoCache = new Map();
3575
- const getCacheKey = (networkId, netuid) => `${networkId}:${netuid}`;
3575
+ const getCacheKey$1 = (networkId, netuid) => `${networkId}:${netuid}`;
3576
3576
  const fetchDynamicInfoByNetuid = async (connector, networkId, miniMetadata, uniqueNetuids) => {
3577
3577
  const fetchInfo = async netuid => {
3578
3578
  if (netuid === SUBTENSOR_ROOT_NETUID) return null;
3579
- const cacheKey = getCacheKey(networkId, netuid);
3579
+ const cacheKey = getCacheKey$1(networkId, netuid);
3580
3580
  if (!dynamicInfoCache.has(cacheKey)) {
3581
3581
  await viem.withRetry(async () => {
3582
3582
  const result = await fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "SubnetInfoRuntimeApi", "get_dynamic_info", [netuid]);
@@ -6192,31 +6192,27 @@ const getSpecVersion = async (chainConnector, networkId) => {
6192
6192
  }
6193
6193
  };
6194
6194
 
6195
- // share requests as all modules will call this at once
6195
+ const getCacheKey = (networkId, specVersion) => `${networkId}:${specVersion}`;
6196
6196
  const CACHE = new Map();
6197
6197
 
6198
6198
  // ensures we dont fetch miniMetadatas on more than 4 chains at once
6199
6199
  const POOL = new PQueue__default.default({
6200
6200
  concurrency: 4
6201
6201
  });
6202
- const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion, signal) => {
6203
- if (CACHE.has(networkId)) return CACHE.get(networkId);
6204
- if (!signal) log.warn("[miniMetadata] getMiniMetadatas called without signal, this may hang the updates", new Error("No signal provided") // this will show the stack trace so the culprit can fix it
6205
- );
6202
+ const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion) => {
6206
6203
  if (specVersion === undefined) specVersion = await getSpecVersion(chainConnector, networkId);
6207
- const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion), {
6208
- signal
6209
- });
6210
- CACHE.set(networkId, pResult);
6204
+ const cacheKey = getCacheKey(networkId, specVersion);
6205
+ const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion));
6206
+
6207
+ // keep the results in cache (unless call fails) as observables call this function a lot of times
6208
+ CACHE.set(cacheKey, pResult);
6211
6209
  try {
6212
6210
  return await pResult;
6213
6211
  } catch (cause) {
6214
- if (util.isAbortError(cause)) throw cause;
6212
+ CACHE.delete(cacheKey);
6215
6213
  throw new Error(`Failed to fetch metadataRpc for network ${networkId}`, {
6216
6214
  cause
6217
6215
  });
6218
- } finally {
6219
- CACHE.delete(networkId);
6220
6216
  }
6221
6217
  };
6222
6218
  const fetchMiniMetadatas = async (chainConnector, chaindataProvider, chainId, specVersion, signal) => {
@@ -6264,6 +6260,9 @@ class BalancesProvider {
6264
6260
  miniMetadatas: lodashEs.values(miniMetadatas).filter(util.isNotNil)
6265
6261
  })));
6266
6262
  }
6263
+ get storedMiniMetadataMapById$() {
6264
+ return this.#storage.pipe(rxjs.map(storage => lodashEs.keyBy(storage.miniMetadatas, m => m.id)), rxjs.distinctUntilChanged(lodashEs.isEqual), rxjs.shareReplay(1));
6265
+ }
6267
6266
 
6268
6267
  // this is the only public method
6269
6268
  getBalances$(addressesByTokenId) {
@@ -6393,46 +6392,48 @@ class BalancesProvider {
6393
6392
  return this.#chaindataProvider.getNetworkById$(networkId).pipe(rxjs.switchMap(network => chaindataProvider.isNetworkDot(network) && this.#chainConnectors.substrate ? rxjs.from(getSpecVersion(this.#chainConnectors.substrate, networkId)).pipe(rxjs.switchMap(specVersion => this.getMiniMetadatas$(networkId, specVersion))) : rxjs.of([])));
6394
6393
  }
6395
6394
  getMiniMetadatas$(networkId, specVersion) {
6396
- return new rxjs.Observable(subscriber => {
6397
- const controller = new AbortController();
6398
- const subscription = rxjs.combineLatest({
6399
- defaultMiniMetadatas: this.getDefaultMiniMetadatas$(networkId, specVersion),
6400
- storedMiniMetadatas: this.getStoredMiniMetadatas$(networkId, specVersion)
6401
- }).pipe(rxjs.switchMap(({
6402
- storedMiniMetadatas,
6403
- defaultMiniMetadatas
6404
- }) => {
6405
- if (defaultMiniMetadatas.length) return rxjs.of(defaultMiniMetadatas);
6406
- if (storedMiniMetadatas.length) return rxjs.of(storedMiniMetadatas);
6407
- if (!this.#chainConnectors.substrate) return rxjs.of([]);
6408
- return rxjs.from(
6409
- // fetch them from the chain
6410
- getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion, controller.signal)).pipe(
6411
- // and persist in storage for later reuse
6412
- rxjs.tap(newMiniMetadatas => {
6413
- if (!newMiniMetadatas.length) return;
6414
- const storage = this.#storage.getValue();
6415
- const miniMetadatas = lodashEs.assign(
6416
- // keep minimetadatas of other networks
6417
- lodashEs.keyBy(lodashEs.values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6418
- // add the ones for our network
6419
- lodashEs.keyBy(newMiniMetadatas, m => m.id));
6420
- this.#storage.next(lodashEs.assign({}, storage, {
6421
- miniMetadatas
6422
- }));
6395
+ const miniMetadataIds = BALANCE_MODULES.filter(mod => mod.platform === "polkadot").map(mod => deriveMiniMetadataId({
6396
+ chainId: networkId,
6397
+ specVersion,
6398
+ source: mod.type
6399
+ }));
6400
+ return rxjs.combineLatest({
6401
+ defaultMiniMetadatas: this.getDefaultMiniMetadatas$(miniMetadataIds),
6402
+ storedMiniMetadatas: this.getStoredMiniMetadatas$(miniMetadataIds)
6403
+ }).pipe(rxjs.switchMap(({
6404
+ storedMiniMetadatas,
6405
+ defaultMiniMetadatas
6406
+ }) => {
6407
+ if (defaultMiniMetadatas) return rxjs.of(defaultMiniMetadatas);
6408
+ if (storedMiniMetadatas) return rxjs.of(storedMiniMetadatas);
6409
+ if (!this.#chainConnectors.substrate) return rxjs.of([]);
6410
+ return rxjs.from(getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion)).pipe(
6411
+ // and persist in storage for later reuse
6412
+ rxjs.tap(newMiniMetadatas => {
6413
+ if (!newMiniMetadatas.length) return;
6414
+ const storage = this.#storage.getValue();
6415
+ const miniMetadatas = lodashEs.assign(
6416
+ // keep minimetadatas of other networks
6417
+ lodashEs.keyBy(lodashEs.values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6418
+ // add the ones for our network
6419
+ lodashEs.keyBy(newMiniMetadatas, m => m.id));
6420
+ this.#storage.next(lodashEs.assign({}, storage, {
6421
+ miniMetadatas
6423
6422
  }));
6424
- })).subscribe(subscriber);
6425
- return () => {
6426
- subscription.unsubscribe();
6427
- controller.abort();
6428
- };
6429
- });
6423
+ }));
6424
+ }));
6430
6425
  }
6431
- getStoredMiniMetadatas$(networkId, specVersion) {
6432
- return this.storage$.pipe(rxjs.map(storage => storage.miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === chaindataProvider.MINIMETADATA_VERSION)), rxjs.distinctUntilChanged(lodashEs.isEqual));
6426
+ getStoredMiniMetadatas$(miniMetadataIds) {
6427
+ return this.storedMiniMetadataMapById$.pipe(rxjs.map(mapById => {
6428
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6429
+ return miniMetadatas.length && miniMetadatas.every(util.isTruthy) ? miniMetadatas : null;
6430
+ }));
6433
6431
  }
6434
- getDefaultMiniMetadatas$(networkId, specVersion) {
6435
- return this.#chaindataProvider.miniMetadatas$.pipe(rxjs.map(miniMetadatas => miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === chaindataProvider.MINIMETADATA_VERSION)), rxjs.distinctUntilChanged(lodashEs.isEqual));
6432
+ getDefaultMiniMetadatas$(miniMetadataIds) {
6433
+ return this.#chaindataProvider.miniMetadatasMapById$.pipe(rxjs.map(mapById => {
6434
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6435
+ return miniMetadatas.length && miniMetadatas.every(util.isTruthy) ? miniMetadatas : null;
6436
+ }));
6436
6437
  }
6437
6438
  getStoredBalances(addressesByToken) {
6438
6439
  const balanceDefs = lodashEs.toPairs(addressesByToken).flatMap(([tokenId, addresses]) => addresses.map(address => [tokenId, address]));
@@ -2570,7 +2570,7 @@ const deriveMiniMetadataId = ({
2570
2570
  source,
2571
2571
  chainId,
2572
2572
  specVersion
2573
- }) => scale.toHex(scale.Twox64Concat(new TextEncoder().encode(`${source}${chainId}${specVersion}${chaindataProvider.MINIMETADATA_VERSION}`))).slice(-64);
2573
+ }) => scale.toHex(scale.Twox128(new TextEncoder().encode(`${source}${chainId}${specVersion}${chaindataProvider.MINIMETADATA_VERSION}`))).slice(-32);
2574
2574
 
2575
2575
  const getMiniMetadata$5 = ({
2576
2576
  networkId,
@@ -3572,11 +3572,11 @@ const fetchStakeInfoByAddress = async (connector, networkId, miniMetadata, addre
3572
3572
 
3573
3573
  // assume dynamic info doesnt change over the course of a browser session
3574
3574
  const dynamicInfoCache = new Map();
3575
- const getCacheKey = (networkId, netuid) => `${networkId}:${netuid}`;
3575
+ const getCacheKey$1 = (networkId, netuid) => `${networkId}:${netuid}`;
3576
3576
  const fetchDynamicInfoByNetuid = async (connector, networkId, miniMetadata, uniqueNetuids) => {
3577
3577
  const fetchInfo = async netuid => {
3578
3578
  if (netuid === SUBTENSOR_ROOT_NETUID) return null;
3579
- const cacheKey = getCacheKey(networkId, netuid);
3579
+ const cacheKey = getCacheKey$1(networkId, netuid);
3580
3580
  if (!dynamicInfoCache.has(cacheKey)) {
3581
3581
  await viem.withRetry(async () => {
3582
3582
  const result = await fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "SubnetInfoRuntimeApi", "get_dynamic_info", [netuid]);
@@ -6192,31 +6192,27 @@ const getSpecVersion = async (chainConnector, networkId) => {
6192
6192
  }
6193
6193
  };
6194
6194
 
6195
- // share requests as all modules will call this at once
6195
+ const getCacheKey = (networkId, specVersion) => `${networkId}:${specVersion}`;
6196
6196
  const CACHE = new Map();
6197
6197
 
6198
6198
  // ensures we dont fetch miniMetadatas on more than 4 chains at once
6199
6199
  const POOL = new PQueue__default.default({
6200
6200
  concurrency: 4
6201
6201
  });
6202
- const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion, signal) => {
6203
- if (CACHE.has(networkId)) return CACHE.get(networkId);
6204
- if (!signal) log.warn("[miniMetadata] getMiniMetadatas called without signal, this may hang the updates", new Error("No signal provided") // this will show the stack trace so the culprit can fix it
6205
- );
6202
+ const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion) => {
6206
6203
  if (specVersion === undefined) specVersion = await getSpecVersion(chainConnector, networkId);
6207
- const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion), {
6208
- signal
6209
- });
6210
- CACHE.set(networkId, pResult);
6204
+ const cacheKey = getCacheKey(networkId, specVersion);
6205
+ const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion));
6206
+
6207
+ // keep the results in cache (unless call fails) as observables call this function a lot of times
6208
+ CACHE.set(cacheKey, pResult);
6211
6209
  try {
6212
6210
  return await pResult;
6213
6211
  } catch (cause) {
6214
- if (util.isAbortError(cause)) throw cause;
6212
+ CACHE.delete(cacheKey);
6215
6213
  throw new Error(`Failed to fetch metadataRpc for network ${networkId}`, {
6216
6214
  cause
6217
6215
  });
6218
- } finally {
6219
- CACHE.delete(networkId);
6220
6216
  }
6221
6217
  };
6222
6218
  const fetchMiniMetadatas = async (chainConnector, chaindataProvider, chainId, specVersion, signal) => {
@@ -6264,6 +6260,9 @@ class BalancesProvider {
6264
6260
  miniMetadatas: lodashEs.values(miniMetadatas).filter(util.isNotNil)
6265
6261
  })));
6266
6262
  }
6263
+ get storedMiniMetadataMapById$() {
6264
+ return this.#storage.pipe(rxjs.map(storage => lodashEs.keyBy(storage.miniMetadatas, m => m.id)), rxjs.distinctUntilChanged(lodashEs.isEqual), rxjs.shareReplay(1));
6265
+ }
6267
6266
 
6268
6267
  // this is the only public method
6269
6268
  getBalances$(addressesByTokenId) {
@@ -6393,46 +6392,48 @@ class BalancesProvider {
6393
6392
  return this.#chaindataProvider.getNetworkById$(networkId).pipe(rxjs.switchMap(network => chaindataProvider.isNetworkDot(network) && this.#chainConnectors.substrate ? rxjs.from(getSpecVersion(this.#chainConnectors.substrate, networkId)).pipe(rxjs.switchMap(specVersion => this.getMiniMetadatas$(networkId, specVersion))) : rxjs.of([])));
6394
6393
  }
6395
6394
  getMiniMetadatas$(networkId, specVersion) {
6396
- return new rxjs.Observable(subscriber => {
6397
- const controller = new AbortController();
6398
- const subscription = rxjs.combineLatest({
6399
- defaultMiniMetadatas: this.getDefaultMiniMetadatas$(networkId, specVersion),
6400
- storedMiniMetadatas: this.getStoredMiniMetadatas$(networkId, specVersion)
6401
- }).pipe(rxjs.switchMap(({
6402
- storedMiniMetadatas,
6403
- defaultMiniMetadatas
6404
- }) => {
6405
- if (defaultMiniMetadatas.length) return rxjs.of(defaultMiniMetadatas);
6406
- if (storedMiniMetadatas.length) return rxjs.of(storedMiniMetadatas);
6407
- if (!this.#chainConnectors.substrate) return rxjs.of([]);
6408
- return rxjs.from(
6409
- // fetch them from the chain
6410
- getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion, controller.signal)).pipe(
6411
- // and persist in storage for later reuse
6412
- rxjs.tap(newMiniMetadatas => {
6413
- if (!newMiniMetadatas.length) return;
6414
- const storage = this.#storage.getValue();
6415
- const miniMetadatas = lodashEs.assign(
6416
- // keep minimetadatas of other networks
6417
- lodashEs.keyBy(lodashEs.values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6418
- // add the ones for our network
6419
- lodashEs.keyBy(newMiniMetadatas, m => m.id));
6420
- this.#storage.next(lodashEs.assign({}, storage, {
6421
- miniMetadatas
6422
- }));
6395
+ const miniMetadataIds = BALANCE_MODULES.filter(mod => mod.platform === "polkadot").map(mod => deriveMiniMetadataId({
6396
+ chainId: networkId,
6397
+ specVersion,
6398
+ source: mod.type
6399
+ }));
6400
+ return rxjs.combineLatest({
6401
+ defaultMiniMetadatas: this.getDefaultMiniMetadatas$(miniMetadataIds),
6402
+ storedMiniMetadatas: this.getStoredMiniMetadatas$(miniMetadataIds)
6403
+ }).pipe(rxjs.switchMap(({
6404
+ storedMiniMetadatas,
6405
+ defaultMiniMetadatas
6406
+ }) => {
6407
+ if (defaultMiniMetadatas) return rxjs.of(defaultMiniMetadatas);
6408
+ if (storedMiniMetadatas) return rxjs.of(storedMiniMetadatas);
6409
+ if (!this.#chainConnectors.substrate) return rxjs.of([]);
6410
+ return rxjs.from(getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion)).pipe(
6411
+ // and persist in storage for later reuse
6412
+ rxjs.tap(newMiniMetadatas => {
6413
+ if (!newMiniMetadatas.length) return;
6414
+ const storage = this.#storage.getValue();
6415
+ const miniMetadatas = lodashEs.assign(
6416
+ // keep minimetadatas of other networks
6417
+ lodashEs.keyBy(lodashEs.values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6418
+ // add the ones for our network
6419
+ lodashEs.keyBy(newMiniMetadatas, m => m.id));
6420
+ this.#storage.next(lodashEs.assign({}, storage, {
6421
+ miniMetadatas
6423
6422
  }));
6424
- })).subscribe(subscriber);
6425
- return () => {
6426
- subscription.unsubscribe();
6427
- controller.abort();
6428
- };
6429
- });
6423
+ }));
6424
+ }));
6430
6425
  }
6431
- getStoredMiniMetadatas$(networkId, specVersion) {
6432
- return this.storage$.pipe(rxjs.map(storage => storage.miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === chaindataProvider.MINIMETADATA_VERSION)), rxjs.distinctUntilChanged(lodashEs.isEqual));
6426
+ getStoredMiniMetadatas$(miniMetadataIds) {
6427
+ return this.storedMiniMetadataMapById$.pipe(rxjs.map(mapById => {
6428
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6429
+ return miniMetadatas.length && miniMetadatas.every(util.isTruthy) ? miniMetadatas : null;
6430
+ }));
6433
6431
  }
6434
- getDefaultMiniMetadatas$(networkId, specVersion) {
6435
- return this.#chaindataProvider.miniMetadatas$.pipe(rxjs.map(miniMetadatas => miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === chaindataProvider.MINIMETADATA_VERSION)), rxjs.distinctUntilChanged(lodashEs.isEqual));
6432
+ getDefaultMiniMetadatas$(miniMetadataIds) {
6433
+ return this.#chaindataProvider.miniMetadatasMapById$.pipe(rxjs.map(mapById => {
6434
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6435
+ return miniMetadatas.length && miniMetadatas.every(util.isTruthy) ? miniMetadatas : null;
6436
+ }));
6436
6437
  }
6437
6438
  getStoredBalances(addressesByToken) {
6438
6439
  const balanceDefs = lodashEs.toPairs(addressesByToken).flatMap(([tokenId, addresses]) => addresses.map(address => [tokenId, address]));
@@ -1,12 +1,12 @@
1
1
  import { EvmErc20TokenSchema, parseTokenId, parseEvmErc20TokenId, evmErc20TokenId, isTokenOfType, TokenBaseSchema, EvmNativeTokenSchema, evmNativeTokenId, EvmUniswapV2TokenSchema, evmUniswapV2TokenId, SubAssetsTokenSchema, subAssetTokenId, MINIMETADATA_VERSION, SubForeignAssetsTokenSchema, subForeignAssetTokenId, SubHydrationTokenSchema, subHydrationTokenId, SubNativeTokenSchema, subNativeTokenId, SubPsp22TokenSchema, subPsp22TokenId, SubTokensTokenSchema, subTokensTokenId, isNetworkDot } from '@talismn/chaindata-provider';
2
2
  export { MINIMETADATA_VERSION } from '@talismn/chaindata-provider';
3
- import { isEthereumAddress, isNotNil, BigMath, isArrayOf, isBigInt, planckToTokens, isAbortError, getSharedObservable } from '@talismn/util';
3
+ import { isEthereumAddress, isNotNil, BigMath, isArrayOf, isBigInt, planckToTokens, isAbortError, getSharedObservable, isTruthy } from '@talismn/util';
4
4
  import { parseAbi, erc20Abi, getContract, ContractFunctionExecutionError, hexToString, erc20Abi_bytes32, encodeFunctionData, withRetry } from 'viem';
5
5
  import { assign, omit, isEqual, keyBy, keys, uniq, fromPairs, values, toPairs } from 'lodash-es';
6
6
  import z from 'zod/v4';
7
7
  import anylogger from 'anylogger';
8
- import { of, Observable, distinctUntilChanged, map, timer, switchMap, from, firstValueFrom, combineLatest, BehaviorSubject, startWith, filter, tap } from 'rxjs';
9
- import { parseMetadataRpc, toHex, unifyMetadata, decAnyMetadata, getDynamicBuilder, getLookupFn, decodeScale, getStorageKeyPrefix, Twox64Concat, compactMetadata, encodeMetadata, papiParse, papiStringify } from '@talismn/scale';
8
+ import { of, Observable, distinctUntilChanged, map, timer, switchMap, from, firstValueFrom, combineLatest, BehaviorSubject, shareReplay, startWith, filter, tap } from 'rxjs';
9
+ import { parseMetadataRpc, toHex, unifyMetadata, decAnyMetadata, getDynamicBuilder, getLookupFn, decodeScale, getStorageKeyPrefix, Twox128, compactMetadata, encodeMetadata, papiParse, papiStringify } from '@talismn/scale';
10
10
  import { newTokenRates } from '@talismn/token-rates';
11
11
  import BigNumber from 'bignumber.js';
12
12
  import { mergeUint8 } from '@polkadot-api/utils';
@@ -2561,7 +2561,7 @@ const deriveMiniMetadataId = ({
2561
2561
  source,
2562
2562
  chainId,
2563
2563
  specVersion
2564
- }) => toHex(Twox64Concat(new TextEncoder().encode(`${source}${chainId}${specVersion}${MINIMETADATA_VERSION}`))).slice(-64);
2564
+ }) => toHex(Twox128(new TextEncoder().encode(`${source}${chainId}${specVersion}${MINIMETADATA_VERSION}`))).slice(-32);
2565
2565
 
2566
2566
  const getMiniMetadata$5 = ({
2567
2567
  networkId,
@@ -3563,11 +3563,11 @@ const fetchStakeInfoByAddress = async (connector, networkId, miniMetadata, addre
3563
3563
 
3564
3564
  // assume dynamic info doesnt change over the course of a browser session
3565
3565
  const dynamicInfoCache = new Map();
3566
- const getCacheKey = (networkId, netuid) => `${networkId}:${netuid}`;
3566
+ const getCacheKey$1 = (networkId, netuid) => `${networkId}:${netuid}`;
3567
3567
  const fetchDynamicInfoByNetuid = async (connector, networkId, miniMetadata, uniqueNetuids) => {
3568
3568
  const fetchInfo = async netuid => {
3569
3569
  if (netuid === SUBTENSOR_ROOT_NETUID) return null;
3570
- const cacheKey = getCacheKey(networkId, netuid);
3570
+ const cacheKey = getCacheKey$1(networkId, netuid);
3571
3571
  if (!dynamicInfoCache.has(cacheKey)) {
3572
3572
  await withRetry(async () => {
3573
3573
  const result = await fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "SubnetInfoRuntimeApi", "get_dynamic_info", [netuid]);
@@ -6183,31 +6183,27 @@ const getSpecVersion = async (chainConnector, networkId) => {
6183
6183
  }
6184
6184
  };
6185
6185
 
6186
- // share requests as all modules will call this at once
6186
+ const getCacheKey = (networkId, specVersion) => `${networkId}:${specVersion}`;
6187
6187
  const CACHE = new Map();
6188
6188
 
6189
6189
  // ensures we dont fetch miniMetadatas on more than 4 chains at once
6190
6190
  const POOL = new PQueue({
6191
6191
  concurrency: 4
6192
6192
  });
6193
- const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion, signal) => {
6194
- if (CACHE.has(networkId)) return CACHE.get(networkId);
6195
- if (!signal) log.warn("[miniMetadata] getMiniMetadatas called without signal, this may hang the updates", new Error("No signal provided") // this will show the stack trace so the culprit can fix it
6196
- );
6193
+ const getMiniMetadatas = async (chainConnector, chaindataProvider, networkId, specVersion) => {
6197
6194
  if (specVersion === undefined) specVersion = await getSpecVersion(chainConnector, networkId);
6198
- const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion), {
6199
- signal
6200
- });
6201
- CACHE.set(networkId, pResult);
6195
+ const cacheKey = getCacheKey(networkId, specVersion);
6196
+ const pResult = POOL.add(() => fetchMiniMetadatas(chainConnector, chaindataProvider, networkId, specVersion));
6197
+
6198
+ // keep the results in cache (unless call fails) as observables call this function a lot of times
6199
+ CACHE.set(cacheKey, pResult);
6202
6200
  try {
6203
6201
  return await pResult;
6204
6202
  } catch (cause) {
6205
- if (isAbortError(cause)) throw cause;
6203
+ CACHE.delete(cacheKey);
6206
6204
  throw new Error(`Failed to fetch metadataRpc for network ${networkId}`, {
6207
6205
  cause
6208
6206
  });
6209
- } finally {
6210
- CACHE.delete(networkId);
6211
6207
  }
6212
6208
  };
6213
6209
  const fetchMiniMetadatas = async (chainConnector, chaindataProvider, chainId, specVersion, signal) => {
@@ -6255,6 +6251,9 @@ class BalancesProvider {
6255
6251
  miniMetadatas: values(miniMetadatas).filter(isNotNil)
6256
6252
  })));
6257
6253
  }
6254
+ get storedMiniMetadataMapById$() {
6255
+ return this.#storage.pipe(map(storage => keyBy(storage.miniMetadatas, m => m.id)), distinctUntilChanged(isEqual), shareReplay(1));
6256
+ }
6258
6257
 
6259
6258
  // this is the only public method
6260
6259
  getBalances$(addressesByTokenId) {
@@ -6384,46 +6383,48 @@ class BalancesProvider {
6384
6383
  return this.#chaindataProvider.getNetworkById$(networkId).pipe(switchMap(network => isNetworkDot(network) && this.#chainConnectors.substrate ? from(getSpecVersion(this.#chainConnectors.substrate, networkId)).pipe(switchMap(specVersion => this.getMiniMetadatas$(networkId, specVersion))) : of([])));
6385
6384
  }
6386
6385
  getMiniMetadatas$(networkId, specVersion) {
6387
- return new Observable(subscriber => {
6388
- const controller = new AbortController();
6389
- const subscription = combineLatest({
6390
- defaultMiniMetadatas: this.getDefaultMiniMetadatas$(networkId, specVersion),
6391
- storedMiniMetadatas: this.getStoredMiniMetadatas$(networkId, specVersion)
6392
- }).pipe(switchMap(({
6393
- storedMiniMetadatas,
6394
- defaultMiniMetadatas
6395
- }) => {
6396
- if (defaultMiniMetadatas.length) return of(defaultMiniMetadatas);
6397
- if (storedMiniMetadatas.length) return of(storedMiniMetadatas);
6398
- if (!this.#chainConnectors.substrate) return of([]);
6399
- return from(
6400
- // fetch them from the chain
6401
- getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion, controller.signal)).pipe(
6402
- // and persist in storage for later reuse
6403
- tap(newMiniMetadatas => {
6404
- if (!newMiniMetadatas.length) return;
6405
- const storage = this.#storage.getValue();
6406
- const miniMetadatas = assign(
6407
- // keep minimetadatas of other networks
6408
- keyBy(values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6409
- // add the ones for our network
6410
- keyBy(newMiniMetadatas, m => m.id));
6411
- this.#storage.next(assign({}, storage, {
6412
- miniMetadatas
6413
- }));
6386
+ const miniMetadataIds = BALANCE_MODULES.filter(mod => mod.platform === "polkadot").map(mod => deriveMiniMetadataId({
6387
+ chainId: networkId,
6388
+ specVersion,
6389
+ source: mod.type
6390
+ }));
6391
+ return combineLatest({
6392
+ defaultMiniMetadatas: this.getDefaultMiniMetadatas$(miniMetadataIds),
6393
+ storedMiniMetadatas: this.getStoredMiniMetadatas$(miniMetadataIds)
6394
+ }).pipe(switchMap(({
6395
+ storedMiniMetadatas,
6396
+ defaultMiniMetadatas
6397
+ }) => {
6398
+ if (defaultMiniMetadatas) return of(defaultMiniMetadatas);
6399
+ if (storedMiniMetadatas) return of(storedMiniMetadatas);
6400
+ if (!this.#chainConnectors.substrate) return of([]);
6401
+ return from(getMiniMetadatas(this.#chainConnectors.substrate, this.#chaindataProvider, networkId, specVersion)).pipe(
6402
+ // and persist in storage for later reuse
6403
+ tap(newMiniMetadatas => {
6404
+ if (!newMiniMetadatas.length) return;
6405
+ const storage = this.#storage.getValue();
6406
+ const miniMetadatas = assign(
6407
+ // keep minimetadatas of other networks
6408
+ keyBy(values(storage.miniMetadatas).filter(m => m.chainId !== networkId), m => m.id),
6409
+ // add the ones for our network
6410
+ keyBy(newMiniMetadatas, m => m.id));
6411
+ this.#storage.next(assign({}, storage, {
6412
+ miniMetadatas
6414
6413
  }));
6415
- })).subscribe(subscriber);
6416
- return () => {
6417
- subscription.unsubscribe();
6418
- controller.abort();
6419
- };
6420
- });
6414
+ }));
6415
+ }));
6421
6416
  }
6422
- getStoredMiniMetadatas$(networkId, specVersion) {
6423
- return this.storage$.pipe(map(storage => storage.miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === MINIMETADATA_VERSION)), distinctUntilChanged(isEqual));
6417
+ getStoredMiniMetadatas$(miniMetadataIds) {
6418
+ return this.storedMiniMetadataMapById$.pipe(map(mapById => {
6419
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6420
+ return miniMetadatas.length && miniMetadatas.every(isTruthy) ? miniMetadatas : null;
6421
+ }));
6424
6422
  }
6425
- getDefaultMiniMetadatas$(networkId, specVersion) {
6426
- return this.#chaindataProvider.miniMetadatas$.pipe(map(miniMetadatas => miniMetadatas.filter(m => m.chainId === networkId && m.specVersion === specVersion && m.version === MINIMETADATA_VERSION)), distinctUntilChanged(isEqual));
6423
+ getDefaultMiniMetadatas$(miniMetadataIds) {
6424
+ return this.#chaindataProvider.miniMetadatasMapById$.pipe(map(mapById => {
6425
+ const miniMetadatas = miniMetadataIds.map(id => mapById[id]);
6426
+ return miniMetadatas.length && miniMetadatas.every(isTruthy) ? miniMetadatas : null;
6427
+ }));
6427
6428
  }
6428
6429
  getStoredBalances(addressesByToken) {
6429
6430
  const balanceDefs = toPairs(addressesByToken).flatMap(([tokenId, addresses]) => addresses.map(address => [tokenId, address]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr2075-20250710071608",
3
+ "version": "0.0.0-pr2075-20250710091134",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -34,13 +34,13 @@
34
34
  "scale-ts": "^1.6.1",
35
35
  "viem": "^2.27.3",
36
36
  "zod": "^3.25.62",
37
- "@talismn/chain-connector-evm": "0.0.0-pr2075-20250710071608",
38
- "@talismn/chaindata-provider": "0.0.0-pr2075-20250710071608",
39
- "@talismn/chain-connector": "0.0.0-pr2075-20250710071608",
40
- "@talismn/sapi": "0.0.0-pr2075-20250710071608",
41
- "@talismn/scale": "0.0.0-pr2075-20250710071608",
42
- "@talismn/token-rates": "0.0.0-pr2075-20250710071608",
43
- "@talismn/util": "0.0.0-pr2075-20250710071608"
37
+ "@talismn/chain-connector": "0.0.0-pr2075-20250710091134",
38
+ "@talismn/chain-connector-evm": "0.0.0-pr2075-20250710091134",
39
+ "@talismn/chaindata-provider": "0.0.0-pr2075-20250710091134",
40
+ "@talismn/sapi": "0.0.0-pr2075-20250710091134",
41
+ "@talismn/token-rates": "0.0.0-pr2075-20250710091134",
42
+ "@talismn/util": "0.0.0-pr2075-20250710091134",
43
+ "@talismn/scale": "0.0.0-pr2075-20250710091134"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@polkadot/api-contract": "16.1.2",