@talismn/balances 0.0.0-pr2120-20250805013559 → 0.0.0-pr2125-20250805020704

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.
@@ -8,6 +8,10 @@ type FormattedAmount<GenericAmount extends AmountWithLabel<TLabel>, TLabel exten
8
8
  export declare function excludeFromTransferableAmount(locks: Amount | FormattedAmount<LockedAmount<string>, string> | Array<FormattedAmount<LockedAmount<string>, string>>): bigint;
9
9
  export declare function excludeFromFeePayableLocks(locks: Amount | LockedAmount<string> | Array<LockedAmount<string>>): Array<LockedAmount<string>>;
10
10
  export declare function includeInTotalExtraAmount(extra?: FormattedAmount<ExtraAmount<string>, string> | Array<FormattedAmount<ExtraAmount<string>, string>>): bigint;
11
+ /**
12
+ * Have the importing library define its Token and BalanceJson enums (as a sum type of all plugins) and pass them into some
13
+ * internal global typescript context, which is then picked up on by this module.
14
+ */
11
15
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
12
16
  export type NarrowBalanceType<S extends IBalance, P> = S extends {
13
17
  source: P;
@@ -142,7 +146,7 @@ export declare class Balance {
142
146
  chainName: string;
143
147
  specName: string;
144
148
  specVersion: number;
145
- account: "*25519" | "secp256k1";
149
+ account: "secp256k1" | "*25519";
146
150
  prefix: number;
147
151
  rpcs: string[];
148
152
  topology: {
@@ -201,14 +205,17 @@ export declare class Balance {
201
205
  themeColor?: string | undefined;
202
206
  substrateChainId?: string | undefined;
203
207
  preserveGasEstimate?: boolean | undefined;
204
- feeType?: "eip-1559" | "legacy" | undefined;
208
+ feeType?: "legacy" | "eip-1559" | undefined;
205
209
  l2FeeType?: {
206
210
  type: "op-stack";
207
211
  } | {
208
212
  type: "scroll";
209
213
  l1GasPriceOracle: `0x${string}`;
210
214
  } | undefined;
211
- contracts?: Partial<Record<"Erc20Aggregator" | "Multicall3", `0x${string}`>> | undefined;
215
+ contracts?: {
216
+ Erc20Aggregator?: `0x${string}` | undefined;
217
+ Multicall3?: `0x${string}` | undefined;
218
+ } | undefined;
212
219
  balancesConfig?: {
213
220
  "evm-native"?: undefined;
214
221
  "evm-erc20"?: undefined;
@@ -351,7 +358,7 @@ export declare class Balance {
351
358
  type: "substrate-hydration";
352
359
  platform: "polkadot";
353
360
  onChainId: number;
354
- assetType: "Token" | "External" | "Erc20";
361
+ assetType: "Token" | "Erc20" | "External";
355
362
  isSufficient: boolean;
356
363
  existentialDeposit: string;
357
364
  isDefault?: boolean | undefined;
@@ -68,4 +68,8 @@ export type ExtraAmount<TLabel extends string> = BaseAmountWithLabel<TLabel> & {
68
68
  /** If set to true, this extra amount will be included in the calculation of the total amount of this balance. */
69
69
  includeInTotal?: boolean;
70
70
  };
71
+ /** Used by plugins to help define their custom `BalanceType` */
72
+ export type NewBalanceType<TModuleType extends string, TBalanceValueType extends "simple" | "complex"> = IBalanceBase & (TBalanceValueType extends "simple" ? IBalanceSimpleValues : IBalanceComplexValues) & {
73
+ source: TModuleType;
74
+ };
71
75
  export {};
@@ -1852,6 +1852,11 @@ function includeInTotalExtraAmount(extra) {
1852
1852
  return extra.filter(extra => extra.includeInTotal).map(extra => extra.amount.planck).reduce((a, b) => a + b, 0n);
1853
1853
  }
1854
1854
 
1855
+ /**
1856
+ * Have the importing library define its Token and BalanceJson enums (as a sum type of all plugins) and pass them into some
1857
+ * internal global typescript context, which is then picked up on by this module.
1858
+ */
1859
+
1855
1860
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
1856
1861
 
1857
1862
  /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
@@ -2588,6 +2593,8 @@ const getValueId = amount => {
2588
2593
 
2589
2594
  /** A labelled extra amount of a balance */
2590
2595
 
2596
+ /** Used by plugins to help define their custom `BalanceType` */
2597
+
2591
2598
  /** For fast db access, you can calculate the primary key for a miniMetadata using this method */
2592
2599
  const deriveMiniMetadataId = ({
2593
2600
  source,
@@ -1852,6 +1852,11 @@ function includeInTotalExtraAmount(extra) {
1852
1852
  return extra.filter(extra => extra.includeInTotal).map(extra => extra.amount.planck).reduce((a, b) => a + b, 0n);
1853
1853
  }
1854
1854
 
1855
+ /**
1856
+ * Have the importing library define its Token and BalanceJson enums (as a sum type of all plugins) and pass them into some
1857
+ * internal global typescript context, which is then picked up on by this module.
1858
+ */
1859
+
1855
1860
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
1856
1861
 
1857
1862
  /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
@@ -2588,6 +2593,8 @@ const getValueId = amount => {
2588
2593
 
2589
2594
  /** A labelled extra amount of a balance */
2590
2595
 
2596
+ /** Used by plugins to help define their custom `BalanceType` */
2597
+
2591
2598
  /** For fast db access, you can calculate the primary key for a miniMetadata using this method */
2592
2599
  const deriveMiniMetadataId = ({
2593
2600
  source,
@@ -1843,6 +1843,11 @@ function includeInTotalExtraAmount(extra) {
1843
1843
  return extra.filter(extra => extra.includeInTotal).map(extra => extra.amount.planck).reduce((a, b) => a + b, 0n);
1844
1844
  }
1845
1845
 
1846
+ /**
1847
+ * Have the importing library define its Token and BalanceJson enums (as a sum type of all plugins) and pass them into some
1848
+ * internal global typescript context, which is then picked up on by this module.
1849
+ */
1850
+
1846
1851
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
1847
1852
 
1848
1853
  /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
@@ -2579,6 +2584,8 @@ const getValueId = amount => {
2579
2584
 
2580
2585
  /** A labelled extra amount of a balance */
2581
2586
 
2587
+ /** Used by plugins to help define their custom `BalanceType` */
2588
+
2582
2589
  /** For fast db access, you can calculate the primary key for a miniMetadata using this method */
2583
2590
  const deriveMiniMetadataId = ({
2584
2591
  source,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr2120-20250805013559",
3
+ "version": "0.0.0-pr2125-20250805020704",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -33,14 +33,14 @@
33
33
  "rxjs": "^7.8.1",
34
34
  "scale-ts": "^1.6.1",
35
35
  "viem": "^2.27.3",
36
- "zod": "^3.25.62",
37
- "@talismn/chain-connector": "0.0.0-pr2120-20250805013559",
36
+ "zod": "^3.25.76",
37
+ "@talismn/chain-connector": "0.0.0-pr2125-20250805020704",
38
+ "@talismn/chain-connector-evm": "0.0.0-pr2125-20250805020704",
39
+ "@talismn/chaindata-provider": "0.0.0-pr2125-20250805020704",
38
40
  "@talismn/sapi": "0.0.8",
39
41
  "@talismn/scale": "0.2.0",
40
- "@talismn/chaindata-provider": "0.0.0-pr2120-20250805013559",
41
- "@talismn/chain-connector-evm": "0.0.0-pr2120-20250805013559",
42
- "@talismn/token-rates": "0.0.0-pr2120-20250805013559",
43
- "@talismn/util": "0.0.0-pr2120-20250805013559"
42
+ "@talismn/token-rates": "0.0.0-pr2125-20250805020704",
43
+ "@talismn/util": "0.5.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@polkadot/api-contract": "16.1.2",