@talismn/balances 0.0.0-pr2075-20250707152840 → 0.0.0-pr2075-20250708110002

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.
@@ -0,0 +1,23 @@
1
+ import { AnyMiniMetadata, ChaindataProvider, TokenId } from "@talismn/chaindata-provider";
2
+ import { Observable } from "rxjs";
3
+ import { ChainConnectors } from ".";
4
+ import { Address, IBalance } from "./types";
5
+ type BalancesStatus = "initialising" | "live";
6
+ export type BalancesResult = {
7
+ status: BalancesStatus;
8
+ balances: IBalance[];
9
+ };
10
+ export type BalancesStorage = {
11
+ balances: IBalance[];
12
+ miniMetadatas: AnyMiniMetadata[];
13
+ };
14
+ export declare class BalancesProvider {
15
+ #private;
16
+ constructor(chaindataProvider: ChaindataProvider, chainConnectors: ChainConnectors, storage?: BalancesStorage);
17
+ get storage$(): Observable<BalancesStorage>;
18
+ getBalances$(addressesByToken: Record<TokenId, Address[]>): Observable<BalancesResult>;
19
+ private getNetworkBalances$;
20
+ private getNetworkMiniMetadatas$;
21
+ private getStoredBalances;
22
+ }
23
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { ChainConnector } from "@talismn/chain-connector";
2
2
  import { ChaindataProvider, DotNetworkId } from "@talismn/chaindata-provider";
3
3
  import { MiniMetadata } from "../types";
4
- export declare const getMiniMetadatas: (chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, networkId: DotNetworkId, specVersion: number, signal?: AbortSignal) => Promise<MiniMetadata[]>;
4
+ export declare const getMiniMetadatas: (chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, networkId: DotNetworkId, specVersion?: number, signal?: AbortSignal) => Promise<MiniMetadata[]>;
@@ -3,3 +3,4 @@ export * from "./TalismanBalancesDatabase";
3
3
  export * from "./modules";
4
4
  export * from "./types";
5
5
  export * from "./version";
6
+ export * from "./BalancesProvider";
@@ -63,22 +63,22 @@ export interface IBalanceModule<Type extends TokenType, TokenConfig = unknown, M
63
63
  } : never) => Promise<TokenOfType<Type>[]>;
64
64
  fetchBalances: (arg: PlatformOf<Type> extends "polkadot" ? {
65
65
  networkId: DotNetworkId;
66
- addressesByToken: TokensWithAddresses;
66
+ tokensWithAddresses: TokensWithAddresses;
67
67
  connector: ChainConnector;
68
68
  miniMetadata: MiniMetadata<MiniMetadataExtra>;
69
69
  } : PlatformOf<Type> extends "ethereum" ? {
70
70
  networkId: EthNetworkId;
71
- addressesByToken: TokensWithAddresses;
71
+ tokensWithAddresses: TokensWithAddresses;
72
72
  connector: ChainConnectorEvm;
73
73
  } : never) => Promise<FetchBalanceResults>;
74
74
  subscribeBalances: (arg: PlatformOf<Type> extends "polkadot" ? {
75
75
  networkId: DotNetworkId;
76
- addressesByToken: TokensWithAddresses;
76
+ tokensWithAddresses: TokensWithAddresses;
77
77
  connector: ChainConnector;
78
78
  miniMetadata: MiniMetadata<MiniMetadataExtra>;
79
79
  } : PlatformOf<Type> extends "ethereum" ? {
80
80
  networkId: EthNetworkId;
81
- addressesByToken: TokensWithAddresses;
81
+ tokensWithAddresses: TokensWithAddresses;
82
82
  connector: ChainConnectorEvm;
83
83
  } : never) => Observable<FetchBalanceResults>;
84
84
  getTransferCallData: (arg: PlatformOf<Type> extends "polkadot" ? {
@@ -29,7 +29,7 @@ export type BalanceSearchQuery = Partial<NonFunctionProperties<Balance>> | ((bal
29
29
  */
30
30
  export declare class Balances {
31
31
  #private;
32
- constructor(balances: Balances | BalanceJsonList | Balance[] | BalanceJson[] | Balance, hydrate?: HydrateDb);
32
+ constructor(balances: Balances | BalanceJsonList | Balance[] | IBalance[] | BalanceJson[] | Balance, hydrate?: HydrateDb);
33
33
  /**
34
34
  * Calling toJSON on a collection of balances will return the underlying BalanceJsonList.
35
35
  */
@@ -113,13 +113,13 @@ export declare class Balances {
113
113
  */
114
114
  get sum(): SumBalancesFormatter;
115
115
  }
116
- export declare const getBalanceId: (balance: BalanceJson) => string;
116
+ export declare const getBalanceId: (balance: Pick<IBalance, "address" | "tokenId">) => string;
117
117
  /**
118
118
  * An individual balance.
119
119
  */
120
120
  export declare class Balance {
121
121
  #private;
122
- constructor(storage: BalanceJson, hydrate?: HydrateDb);
122
+ constructor(storage: BalanceJson | IBalance, hydrate?: HydrateDb);
123
123
  toJSON: () => BalanceJson;
124
124
  isSource: (source: BalanceSource) => boolean;
125
125
  hydrate: (hydrate?: HydrateDb) => void;
@@ -181,6 +181,7 @@ export declare class Balance {
181
181
  palletId?: string | undefined;
182
182
  } | undefined;
183
183
  "substrate-foreignassets"?: undefined;
184
+ "substrate-hydration"?: any;
184
185
  } | undefined;
185
186
  } | {
186
187
  id: string;