@talismn/balances 0.0.0-pr2043-20250615092436 → 0.0.0-pr2043-20250617092446

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.
@@ -1,4 +1,4 @@
1
- import { ChainList, SimpleEvmNetworkList, TokenList } from "@talismn/chaindata-provider";
1
+ import { NetworkList, TokenList } from "@talismn/chaindata-provider";
2
2
  import { TokenRateCurrency, TokenRates, TokenRatesList } from "@talismn/token-rates";
3
3
  import { NonFunctionProperties } from "@talismn/util";
4
4
  import { Amount, AmountWithLabel, BalanceJson, BalanceJsonList, BalanceStatusTypes, ExtraAmount, IBalance, LockedAmount } from "./balancetypes";
@@ -19,8 +19,7 @@ export type NarrowBalanceType<S extends IBalance, P> = S extends {
19
19
  export type BalanceSource = BalanceJson["source"];
20
20
  /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
21
21
  export type HydrateDb = Partial<{
22
- chains: ChainList;
23
- evmNetworks: SimpleEvmNetworkList;
22
+ networks: NetworkList;
24
23
  tokens: TokenList;
25
24
  tokenRates: TokenRatesList;
26
25
  }>;
@@ -128,148 +127,11 @@ export declare class Balance {
128
127
  get source(): "evm-erc20" | "evm-native" | "evm-uniswapv2" | "substrate-assets" | "substrate-foreignassets" | "substrate-native" | "substrate-psp22" | "substrate-tokens";
129
128
  get status(): import("./balancetypes").BalanceStatus;
130
129
  get address(): string;
131
- get chainId(): string | undefined;
132
- get chain(): import("@talismn/chaindata-provider").Chain | null;
133
- get evmNetworkId(): string | undefined;
134
- get evmNetwork(): import("@talismn/chaindata-provider").SimpleEvmNetwork | null;
135
- get tokenId(): string;
136
- get token(): {
137
- id: string;
138
- decimals: number;
139
- symbol: string;
140
- name: string;
141
- networkId: string;
142
- type: "evm-erc20";
143
- platform: "ethereum";
144
- contractAddress: `0x${string}`;
145
- isTestnet?: boolean | undefined;
146
- isDefault?: boolean | undefined;
147
- logo?: string | undefined;
148
- coingeckoId?: string | undefined;
149
- noDiscovery?: boolean | undefined;
150
- mirrorOf?: string | undefined;
151
- isCustom?: boolean | undefined;
152
- } | {
153
- id: string;
154
- decimals: number;
155
- symbol: string;
156
- name: string;
157
- networkId: string;
158
- type: "evm-native";
159
- platform: "ethereum";
160
- isTestnet?: boolean | undefined;
161
- isDefault?: boolean | undefined;
162
- logo?: string | undefined;
163
- coingeckoId?: string | undefined;
164
- noDiscovery?: boolean | undefined;
165
- mirrorOf?: string | undefined;
166
- } | {
167
- id: string;
168
- decimals: number;
169
- symbol: string;
170
- name: string;
171
- networkId: string;
172
- platform: "ethereum";
173
- contractAddress: `0x${string}`;
174
- type: "evm-uniswapv2";
175
- symbol0: string;
176
- symbol1: string;
177
- decimals0: number;
178
- decimals1: number;
179
- tokenAddress0: `0x${string}`;
180
- tokenAddress1: `0x${string}`;
181
- isTestnet?: boolean | undefined;
182
- isDefault?: boolean | undefined;
183
- logo?: string | undefined;
184
- coingeckoId?: string | undefined;
185
- noDiscovery?: boolean | undefined;
186
- mirrorOf?: string | undefined;
187
- isCustom?: boolean | undefined;
188
- coingeckoId0?: string | undefined;
189
- coingeckoId1?: string | undefined;
190
- } | {
191
- id: string;
192
- decimals: number;
193
- symbol: string;
194
- name: string;
195
- networkId: string;
196
- type: "substrate-assets";
197
- platform: "polkadot";
198
- assetId: string;
199
- existentialDeposit: string;
200
- isTestnet?: boolean | undefined;
201
- isDefault?: boolean | undefined;
202
- logo?: string | undefined;
203
- coingeckoId?: string | undefined;
204
- noDiscovery?: boolean | undefined;
205
- mirrorOf?: string | undefined;
206
- isFrozen?: boolean | undefined;
207
- } | {
208
- id: string;
209
- decimals: number;
210
- symbol: string;
211
- name: string;
212
- networkId: string;
213
- type: "substrate-foreignassets";
214
- platform: "polkadot";
215
- onChainId: string;
216
- existentialDeposit: string;
217
- isTestnet?: boolean | undefined;
218
- isDefault?: boolean | undefined;
219
- logo?: string | undefined;
220
- coingeckoId?: string | undefined;
221
- noDiscovery?: boolean | undefined;
222
- mirrorOf?: string | undefined;
223
- isFrozen?: boolean | undefined;
224
- } | {
225
- id: string;
226
- decimals: number;
227
- symbol: string;
228
- name: string;
229
- networkId: string;
230
- type: "substrate-native";
231
- platform: "polkadot";
232
- existentialDeposit: string;
233
- isTestnet?: boolean | undefined;
234
- isDefault?: boolean | undefined;
235
- logo?: string | undefined;
236
- coingeckoId?: string | undefined;
237
- noDiscovery?: boolean | undefined;
238
- mirrorOf?: string | undefined;
239
- } | {
240
- id: string;
241
- decimals: number;
242
- symbol: string;
243
- name: string;
244
- networkId: string;
245
- type: "substrate-psp22";
246
- platform: "polkadot";
247
- existentialDeposit: string;
248
- contractAddress: string;
249
- isTestnet?: boolean | undefined;
250
- isDefault?: boolean | undefined;
251
- logo?: string | undefined;
252
- coingeckoId?: string | undefined;
253
- noDiscovery?: boolean | undefined;
254
- mirrorOf?: string | undefined;
255
- } | {
256
- id: string;
257
- decimals: number;
258
- symbol: string;
259
- name: string;
260
- networkId: string;
261
- type: "substrate-tokens";
262
- platform: "polkadot";
263
- onChainId: string | number;
264
- existentialDeposit: string;
265
- isTestnet?: boolean | undefined;
266
- isDefault?: boolean | undefined;
267
- logo?: string | undefined;
268
- coingeckoId?: string | undefined;
269
- noDiscovery?: boolean | undefined;
270
- mirrorOf?: string | undefined;
271
- } | null;
272
- get decimals(): number | null;
130
+ get networkId(): NetworkId;
131
+ get network(): any;
132
+ get tokenId(): TokenId;
133
+ get token(): any;
134
+ get decimals(): any;
273
135
  get rates(): TokenRates | null;
274
136
  /**
275
137
  * A general method to get formatted values matching a certain type from this balance.
@@ -1,5 +1,5 @@
1
1
  import { PluginBalanceTypes } from "@talismn/balances/plugins";
2
- import { ChainId, EvmChainId, EvmNetworkId, SubChainId, TokenId } from "@talismn/chaindata-provider";
2
+ import { NetworkId, TokenId } from "@talismn/chaindata-provider";
3
3
  import { Address } from "./addresses";
4
4
  /**
5
5
  * `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
@@ -34,17 +34,7 @@ type IBalanceBase = {
34
34
  address: Address;
35
35
  /** The token this balance is for */
36
36
  tokenId: TokenId;
37
- };
38
- type IBalanceBaseEvm = {
39
- /** WIP, use `chainId` or `evmNetworkId` for now */
40
- multiChainId: EvmChainId;
41
- /** The evm chain this balance is on */
42
- evmNetworkId: EvmNetworkId;
43
- };
44
- type IBalanceBaseSubstrate = {
45
- multiChainId: SubChainId;
46
- /** The substrate chain this balance is on */
47
- chainId: ChainId;
37
+ networkId: NetworkId;
48
38
  };
49
39
  type IBalanceSimpleValues = {
50
40
  /** For balance types with a simple value, this is the value of the balance (eg, evm native token balance) */
@@ -57,9 +47,9 @@ type IBalanceComplexValues = {
57
47
  value?: undefined;
58
48
  };
59
49
  /** `IBalance` is a common interface which all balance types must implement. */
60
- export type IBalance = IBalanceBase & (IBalanceSimpleValues | IBalanceComplexValues) & (IBalanceBaseEvm | IBalanceBaseSubstrate);
61
- export type EvmBalance = IBalanceBase & IBalanceBaseEvm & (IBalanceSimpleValues | IBalanceComplexValues);
62
- export type SubstrateBalance = IBalanceBase & IBalanceBaseSubstrate & (IBalanceSimpleValues | IBalanceComplexValues);
50
+ export type IBalance = IBalanceBase & (IBalanceSimpleValues | IBalanceComplexValues);
51
+ export type EvmBalance = IBalanceBase & (IBalanceSimpleValues | IBalanceComplexValues);
52
+ export type SubstrateBalance = IBalanceBase & (IBalanceSimpleValues | IBalanceComplexValues);
63
53
  /** An unlabelled amount of a balance */
64
54
  export type Amount = string;
65
55
  export type BalanceStatusTypes = "free" | "reserved" | "locked" | "extra" | "crowdloan" | "nompool" | "subtensor";
@@ -101,7 +91,7 @@ export type ExtraAmount<TLabel extends string> = BaseAmountWithLabel<TLabel> & {
101
91
  includeInTotal?: boolean;
102
92
  };
103
93
  /** Used by plugins to help define their custom `BalanceType` */
104
- export type NewBalanceType<TModuleType extends string, TBalanceValueType extends "simple" | "complex", TNetworkType extends "ethereum" | "substrate"> = IBalanceBase & (TBalanceValueType extends "simple" ? IBalanceSimpleValues : IBalanceComplexValues) & (TNetworkType extends "ethereum" ? IBalanceBaseEvm : IBalanceBaseSubstrate) & {
94
+ export type NewBalanceType<TModuleType extends string, TBalanceValueType extends "simple" | "complex"> = IBalanceBase & (TBalanceValueType extends "simple" ? IBalanceSimpleValues : IBalanceComplexValues) & {
105
95
  source: TModuleType;
106
96
  };
107
97
  export {};
@@ -1,6 +1,6 @@
1
1
  import { ChainId } from "@talismn/chaindata-provider";
2
2
  /** For fast db access, you can calculate the primary key for a miniMetadata using this method */
3
- export declare const deriveMiniMetadataId: ({ source, chainId, specName, specVersion, balancesConfig, }: Pick<MiniMetadata, "source" | "chainId" | "specName" | "specVersion" | "balancesConfig">) => string;
3
+ export declare const deriveMiniMetadataId: ({ source, chainId, specVersion, libVersion, }: Pick<MiniMetadata, "source" | "chainId" | "specVersion" | "libVersion">) => string;
4
4
  export type MiniMetadataStatus =
5
5
  /** Metadata is up to date */
6
6
  "good"
@@ -15,19 +15,10 @@ export type MiniMetadata = {
15
15
  source: string;
16
16
  /** The chain this miniMetadata came from */
17
17
  chainId: ChainId;
18
- /** The chain specName which this miniMetadata is valid for */
19
- specName: string;
20
18
  /** The chain specVersion which this miniMetadata is valid for */
21
- specVersion: string;
22
- /** The JSON-encoded chain balancesConfig which this miniMetadata is valid for */
23
- balancesConfig: string;
24
- /** The version of the metadata format e.g. 13, 14, 15, etc */
25
- version: number;
19
+ specVersion: number;
20
+ /** the version of the balances library used to craft the mini metadata */
21
+ libVersion: string;
26
22
  /** The miniMetadata encoded as a hex string */
27
23
  data: `0x${string}` | null;
28
- /**
29
- * Some balance modules need a little bit of extra data in addition to the miniMetadata.
30
- * They can store that data as a JSON-encoded string here.
31
- */
32
- extra: string;
33
24
  };