@talismn/balances 0.0.0-pr723-20230421072626 → 0.0.0-pr725-20230425085346

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.
package/CHANGELOG.md CHANGED
@@ -1,25 +1,23 @@
1
1
  # @talismn/balances
2
2
 
3
- ## 0.0.0-pr723-20230421072626
3
+ ## 0.0.0-pr725-20230425085346
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - fb8ee962: feat: proxy dapp websocket requests to talisman wallet backend when available
8
8
  - f7aca48b: eslint rules
9
9
  - 01bf239b: feat: crowdloan and nom pool balances
10
- - 35c57c65: fix: removed some explicit `any`s
11
10
  - 01bf239b: fix: packages publishing with incorrect interdependency versions
12
11
  - Updated dependencies [fb8ee962]
13
12
  - Updated dependencies [c898da98]
14
13
  - Updated dependencies [f7aca48b]
15
14
  - Updated dependencies [01bf239b]
16
- - Updated dependencies [35c57c65]
17
15
  - Updated dependencies [01bf239b]
18
- - @talismn/chain-connector@0.0.0-pr723-20230421072626
19
- - @talismn/chain-connector-evm@0.0.0-pr723-20230421072626
20
- - @talismn/chaindata-provider@0.0.0-pr723-20230421072626
21
- - @talismn/token-rates@0.0.0-pr723-20230421072626
22
- - @talismn/util@0.0.0-pr723-20230421072626
16
+ - @talismn/chain-connector@0.0.0-pr725-20230425085346
17
+ - @talismn/chain-connector-evm@0.0.0-pr725-20230425085346
18
+ - @talismn/chaindata-provider@0.0.0-pr725-20230425085346
19
+ - @talismn/token-rates@0.0.0-pr725-20230425085346
20
+ - @talismn/util@0.0.0-pr725-20230425085346
23
21
 
24
22
  ## 0.4.0
25
23
 
@@ -1,7 +1,7 @@
1
1
  import type { Registry } from "@polkadot/types-codec/types";
2
2
  import { ChainConnector } from "@talismn/chain-connector";
3
- import { Chain, ChainId } from "@talismn/chaindata-provider";
4
- import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, DefaultTransferParams, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType, ExtendableTransferParams, NewBalanceModule } from "./BalanceModule";
3
+ import { ChainId } from "@talismn/chaindata-provider";
4
+ import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, DefaultTransferParams, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType, ExtendableTransferParams } from "./BalanceModule";
5
5
  import { AddressesByToken, Balance, BalanceJson, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
6
6
  /**
7
7
  * Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
@@ -13,37 +13,6 @@ export type GetOrCreateTypeRegistry = (chainId: ChainId, metadataRpc?: `0x${stri
13
13
  export declare const createTypeRegistryCache: () => {
14
14
  getOrCreateTypeRegistry: GetOrCreateTypeRegistry;
15
15
  };
16
- export type AnyBalanceModule = BalanceModule<any, any, any, any, any>;
17
- export type AnyNewBalanceModule = NewBalanceModule<any, any, any, any, any>;
18
- /**
19
- * The following `Infer*` collection of generic types can be used when you want to
20
- * extract one of the generic type arguments from an existing BalanceModule.
21
- *
22
- * For example, you might want to write a function which can accept any BalanceModule
23
- * as an input, and then return the specific TokenType for that module:
24
- * function getTokens<T extends AnyBalanceModule>(module: T): InferTokenType<T>
25
- *
26
- * Or for another example, you might want a function which can take any BalanceModule `type`
27
- * string as input, and then return some data associated with that module with the correct type:
28
- * function getChainMeta<T extends AnyBalanceModule>(type: InferModuleType<T>): InferChainMeta<T> | undefined
29
- */
30
- type InferBalanceModuleTypes<T extends AnyNewBalanceModule> = T extends NewBalanceModule<infer TModuleType, infer TTokenType, infer TChainMeta, infer TModuleConfig, infer TTransferParams> ? {
31
- TModuleType: TModuleType;
32
- TTokenType: TTokenType;
33
- TChainMeta: TChainMeta;
34
- TModuleConfig: TModuleConfig;
35
- TTransferParams: TTransferParams;
36
- } : never;
37
- export type InferModuleType<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TModuleType"];
38
- export type InferTokenType<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TTokenType"];
39
- export type InferChainMeta<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TChainMeta"];
40
- export type InferModuleConfig<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TModuleConfig"];
41
- export type InferTransferParams<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TTransferParams"];
42
- /**
43
- * Given a `moduleType` and a `chain` from a chaindataProvider, this function will find the chainMeta
44
- * associated with the given balanceModule for the given chain.
45
- */
46
- export declare const findChainMeta: <TBalanceModule extends AnyNewBalanceModule>(moduleType: InferModuleType<TBalanceModule>, chain: Chain) => InferChainMeta<TBalanceModule> | undefined;
47
16
  export declare const filterMirrorTokens: (balance: Balance, i: number, balances: Balance[]) => boolean;
48
17
  export declare const getValidSubscriptionIds: () => Set<string>;
49
18
  export declare const createSubscriptionId: () => string;
@@ -83,4 +52,3 @@ export declare class RpcStateQueryHelper<T> {
83
52
  subscribe(callback: SubscriptionCallback<T[]>, timeout?: number | false, subscribeMethod?: string, responseMethod?: string, unsubscribeMethod?: string): Promise<UnsubscribeFn>;
84
53
  fetch(method?: string): Promise<T[]>;
85
54
  }
86
- export {};
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr723-20230421072626",
72
+ version: "0.0.0-pr725-20230425085346",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "UNLICENSED",
@@ -135,11 +135,6 @@ var packageJson = {
135
135
 
136
136
  var log = anylogger__default["default"](packageJson.name);
137
137
 
138
- /**
139
- * Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
140
- * This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
141
- */
142
-
143
138
  async function balances(balanceModule, addressesByToken, callback) {
144
139
  // subscription request
145
140
  if (callback !== undefined) return await balanceModule.subscribeBalances(addressesByToken, callback);
@@ -171,31 +166,6 @@ const createTypeRegistryCache = () => {
171
166
  getOrCreateTypeRegistry
172
167
  };
173
168
  };
174
-
175
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
-
177
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
178
-
179
- /**
180
- * The following `Infer*` collection of generic types can be used when you want to
181
- * extract one of the generic type arguments from an existing BalanceModule.
182
- *
183
- * For example, you might want to write a function which can accept any BalanceModule
184
- * as an input, and then return the specific TokenType for that module:
185
- * function getTokens<T extends AnyBalanceModule>(module: T): InferTokenType<T>
186
- *
187
- * Or for another example, you might want a function which can take any BalanceModule `type`
188
- * string as input, and then return some data associated with that module with the correct type:
189
- * function getChainMeta<T extends AnyBalanceModule>(type: InferModuleType<T>): InferChainMeta<T> | undefined
190
- */
191
-
192
- /**
193
- * Given a `moduleType` and a `chain` from a chaindataProvider, this function will find the chainMeta
194
- * associated with the given balanceModule for the given chain.
195
- */
196
- const findChainMeta = (moduleType, chain) => {
197
- return (chain.balanceMetadata ?? []).find(meta => meta.moduleType === moduleType)?.metadata;
198
- };
199
169
  const filterMirrorTokens = (balance, i, balances) => {
200
170
  // TODO: implement a mirrorOf property, which should be set from chaindata
201
171
  const mirrorOf = balance.token?.mirrorOf;
@@ -398,36 +368,7 @@ class RpcStateQueryHelper {
398
368
  }
399
369
  }
400
370
 
401
- /**
402
- * `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
403
- *
404
- * It is the same list, but with any invalid `BalanceType` definitions filtered out.
405
- */
406
-
407
- /**
408
- * The `BalanceJson` sum type, which is a union of all of the possible `BalanceTypes`.
409
- *
410
- * Each variant comes from a plugin in use by the consuming app.
411
- *
412
- * For example, in an app with the `substrate-native`, `evm-native`, `substrate-orml` and `evm-erc20` plugins:
413
- *
414
- * type BalanceJson = SubNativeBalance | EvmNativeBalance | SubOrmlBalance | EvmErc20Balance
415
- *
416
- * If `BalanceTypes` is empty then `BalanceJson` will fall back to the common `IBalance` interface, which every balance must implement.
417
- */
418
-
419
- /** A collection of `BalanceJson` objects */
420
-
421
371
  const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
422
-
423
- /** `IBalance` is a common interface which all balance types must implement. */
424
-
425
- /** An unlabelled amount of a balance */
426
-
427
- /** A labelled amount of a balance */
428
-
429
- /** A labelled locked amount of a balance */
430
-
431
372
  function excludeFromTransferableAmount(locks) {
432
373
  if (typeof locks === "string") return BigInt(locks);
433
374
  if (!Array.isArray(locks)) locks = [locks];
@@ -455,7 +396,7 @@ function includeInTotalExtraAmount(extra) {
455
396
  */
456
397
 
457
398
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
458
- /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
399
+
459
400
  /**
460
401
  * A collection of balances.
461
402
  */
@@ -967,6 +908,5 @@ exports.deriveStatuses = deriveStatuses;
967
908
  exports.excludeFromFeePayableLocks = excludeFromFeePayableLocks;
968
909
  exports.excludeFromTransferableAmount = excludeFromTransferableAmount;
969
910
  exports.filterMirrorTokens = filterMirrorTokens;
970
- exports.findChainMeta = findChainMeta;
971
911
  exports.getValidSubscriptionIds = getValidSubscriptionIds;
972
912
  exports.includeInTotalExtraAmount = includeInTotalExtraAmount;
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr723-20230421072626",
72
+ version: "0.0.0-pr725-20230425085346",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "UNLICENSED",
@@ -135,11 +135,6 @@ var packageJson = {
135
135
 
136
136
  var log = anylogger__default["default"](packageJson.name);
137
137
 
138
- /**
139
- * Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
140
- * This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
141
- */
142
-
143
138
  async function balances(balanceModule, addressesByToken, callback) {
144
139
  // subscription request
145
140
  if (callback !== undefined) return await balanceModule.subscribeBalances(addressesByToken, callback);
@@ -171,31 +166,6 @@ const createTypeRegistryCache = () => {
171
166
  getOrCreateTypeRegistry
172
167
  };
173
168
  };
174
-
175
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
-
177
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
178
-
179
- /**
180
- * The following `Infer*` collection of generic types can be used when you want to
181
- * extract one of the generic type arguments from an existing BalanceModule.
182
- *
183
- * For example, you might want to write a function which can accept any BalanceModule
184
- * as an input, and then return the specific TokenType for that module:
185
- * function getTokens<T extends AnyBalanceModule>(module: T): InferTokenType<T>
186
- *
187
- * Or for another example, you might want a function which can take any BalanceModule `type`
188
- * string as input, and then return some data associated with that module with the correct type:
189
- * function getChainMeta<T extends AnyBalanceModule>(type: InferModuleType<T>): InferChainMeta<T> | undefined
190
- */
191
-
192
- /**
193
- * Given a `moduleType` and a `chain` from a chaindataProvider, this function will find the chainMeta
194
- * associated with the given balanceModule for the given chain.
195
- */
196
- const findChainMeta = (moduleType, chain) => {
197
- return (chain.balanceMetadata ?? []).find(meta => meta.moduleType === moduleType)?.metadata;
198
- };
199
169
  const filterMirrorTokens = (balance, i, balances) => {
200
170
  // TODO: implement a mirrorOf property, which should be set from chaindata
201
171
  const mirrorOf = balance.token?.mirrorOf;
@@ -398,36 +368,7 @@ class RpcStateQueryHelper {
398
368
  }
399
369
  }
400
370
 
401
- /**
402
- * `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
403
- *
404
- * It is the same list, but with any invalid `BalanceType` definitions filtered out.
405
- */
406
-
407
- /**
408
- * The `BalanceJson` sum type, which is a union of all of the possible `BalanceTypes`.
409
- *
410
- * Each variant comes from a plugin in use by the consuming app.
411
- *
412
- * For example, in an app with the `substrate-native`, `evm-native`, `substrate-orml` and `evm-erc20` plugins:
413
- *
414
- * type BalanceJson = SubNativeBalance | EvmNativeBalance | SubOrmlBalance | EvmErc20Balance
415
- *
416
- * If `BalanceTypes` is empty then `BalanceJson` will fall back to the common `IBalance` interface, which every balance must implement.
417
- */
418
-
419
- /** A collection of `BalanceJson` objects */
420
-
421
371
  const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
422
-
423
- /** `IBalance` is a common interface which all balance types must implement. */
424
-
425
- /** An unlabelled amount of a balance */
426
-
427
- /** A labelled amount of a balance */
428
-
429
- /** A labelled locked amount of a balance */
430
-
431
372
  function excludeFromTransferableAmount(locks) {
432
373
  if (typeof locks === "string") return BigInt(locks);
433
374
  if (!Array.isArray(locks)) locks = [locks];
@@ -455,7 +396,7 @@ function includeInTotalExtraAmount(extra) {
455
396
  */
456
397
 
457
398
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
458
- /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
399
+
459
400
  /**
460
401
  * A collection of balances.
461
402
  */
@@ -967,6 +908,5 @@ exports.deriveStatuses = deriveStatuses;
967
908
  exports.excludeFromFeePayableLocks = excludeFromFeePayableLocks;
968
909
  exports.excludeFromTransferableAmount = excludeFromTransferableAmount;
969
910
  exports.filterMirrorTokens = filterMirrorTokens;
970
- exports.findChainMeta = findChainMeta;
971
911
  exports.getValidSubscriptionIds = getValidSubscriptionIds;
972
912
  exports.includeInTotalExtraAmount = includeInTotalExtraAmount;
@@ -60,7 +60,7 @@ const db = new TalismanBalancesDatabase();
60
60
 
61
61
  var packageJson = {
62
62
  name: "@talismn/balances",
63
- version: "0.0.0-pr723-20230421072626",
63
+ version: "0.0.0-pr725-20230425085346",
64
64
  author: "Talisman",
65
65
  homepage: "https://talisman.xyz",
66
66
  license: "UNLICENSED",
@@ -126,11 +126,6 @@ var packageJson = {
126
126
 
127
127
  var log = anylogger(packageJson.name);
128
128
 
129
- /**
130
- * Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
131
- * This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
132
- */
133
-
134
129
  async function balances(balanceModule, addressesByToken, callback) {
135
130
  // subscription request
136
131
  if (callback !== undefined) return await balanceModule.subscribeBalances(addressesByToken, callback);
@@ -162,31 +157,6 @@ const createTypeRegistryCache = () => {
162
157
  getOrCreateTypeRegistry
163
158
  };
164
159
  };
165
-
166
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
-
168
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
169
-
170
- /**
171
- * The following `Infer*` collection of generic types can be used when you want to
172
- * extract one of the generic type arguments from an existing BalanceModule.
173
- *
174
- * For example, you might want to write a function which can accept any BalanceModule
175
- * as an input, and then return the specific TokenType for that module:
176
- * function getTokens<T extends AnyBalanceModule>(module: T): InferTokenType<T>
177
- *
178
- * Or for another example, you might want a function which can take any BalanceModule `type`
179
- * string as input, and then return some data associated with that module with the correct type:
180
- * function getChainMeta<T extends AnyBalanceModule>(type: InferModuleType<T>): InferChainMeta<T> | undefined
181
- */
182
-
183
- /**
184
- * Given a `moduleType` and a `chain` from a chaindataProvider, this function will find the chainMeta
185
- * associated with the given balanceModule for the given chain.
186
- */
187
- const findChainMeta = (moduleType, chain) => {
188
- return (chain.balanceMetadata ?? []).find(meta => meta.moduleType === moduleType)?.metadata;
189
- };
190
160
  const filterMirrorTokens = (balance, i, balances) => {
191
161
  // TODO: implement a mirrorOf property, which should be set from chaindata
192
162
  const mirrorOf = balance.token?.mirrorOf;
@@ -389,36 +359,7 @@ class RpcStateQueryHelper {
389
359
  }
390
360
  }
391
361
 
392
- /**
393
- * `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
394
- *
395
- * It is the same list, but with any invalid `BalanceType` definitions filtered out.
396
- */
397
-
398
- /**
399
- * The `BalanceJson` sum type, which is a union of all of the possible `BalanceTypes`.
400
- *
401
- * Each variant comes from a plugin in use by the consuming app.
402
- *
403
- * For example, in an app with the `substrate-native`, `evm-native`, `substrate-orml` and `evm-erc20` plugins:
404
- *
405
- * type BalanceJson = SubNativeBalance | EvmNativeBalance | SubOrmlBalance | EvmErc20Balance
406
- *
407
- * If `BalanceTypes` is empty then `BalanceJson` will fall back to the common `IBalance` interface, which every balance must implement.
408
- */
409
-
410
- /** A collection of `BalanceJson` objects */
411
-
412
362
  const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
413
-
414
- /** `IBalance` is a common interface which all balance types must implement. */
415
-
416
- /** An unlabelled amount of a balance */
417
-
418
- /** A labelled amount of a balance */
419
-
420
- /** A labelled locked amount of a balance */
421
-
422
363
  function excludeFromTransferableAmount(locks) {
423
364
  if (typeof locks === "string") return BigInt(locks);
424
365
  if (!Array.isArray(locks)) locks = [locks];
@@ -446,7 +387,7 @@ function includeInTotalExtraAmount(extra) {
446
387
  */
447
388
 
448
389
  /** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
449
- /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
390
+
450
391
  /**
451
392
  * A collection of balances.
452
393
  */
@@ -938,4 +879,4 @@ class SumBalancesFormatter {
938
879
  }
939
880
  }
940
881
 
941
- export { Balance, BalanceFormatter, BalanceStatusLive, Balances, DefaultBalanceModule, FiatSumBalancesFormatter, PlanckSumBalancesFormatter, RpcStateQueryHelper, StorageHelper, SumBalancesFormatter, TalismanBalancesDatabase, balances, createSubscriptionId, createTypeRegistryCache, db, deleteSubscriptionId, deriveStatuses, excludeFromFeePayableLocks, excludeFromTransferableAmount, filterMirrorTokens, findChainMeta, getValidSubscriptionIds, includeInTotalExtraAmount };
882
+ export { Balance, BalanceFormatter, BalanceStatusLive, Balances, DefaultBalanceModule, FiatSumBalancesFormatter, PlanckSumBalancesFormatter, RpcStateQueryHelper, StorageHelper, SumBalancesFormatter, TalismanBalancesDatabase, balances, createSubscriptionId, createTypeRegistryCache, db, deleteSubscriptionId, deriveStatuses, excludeFromFeePayableLocks, excludeFromTransferableAmount, filterMirrorTokens, getValidSubscriptionIds, includeInTotalExtraAmount };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr723-20230421072626",
3
+ "version": "0.0.0-pr725-20230425085346",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -27,18 +27,18 @@
27
27
  "clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
28
28
  },
29
29
  "dependencies": {
30
- "@talismn/chain-connector": "0.0.0-pr723-20230421072626",
31
- "@talismn/chain-connector-evm": "0.0.0-pr723-20230421072626",
32
- "@talismn/chaindata-provider": "0.0.0-pr723-20230421072626",
33
- "@talismn/token-rates": "0.0.0-pr723-20230421072626",
34
- "@talismn/util": "0.0.0-pr723-20230421072626",
30
+ "@talismn/chain-connector": "0.0.0-pr725-20230425085346",
31
+ "@talismn/chain-connector-evm": "0.0.0-pr725-20230425085346",
32
+ "@talismn/chaindata-provider": "0.0.0-pr725-20230425085346",
33
+ "@talismn/token-rates": "0.0.0-pr725-20230425085346",
34
+ "@talismn/util": "0.0.0-pr725-20230425085346",
35
35
  "anylogger": "^1.0.11",
36
36
  "dexie": "^3.2.3",
37
37
  "lodash": "4.17.21"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@polkadot/types": "^10.1.4",
41
- "@talismn/eslint-config": "0.0.0-pr723-20230421072626",
41
+ "@talismn/eslint-config": "0.0.0-pr725-20230425085346",
42
42
  "@talismn/tsconfig": "0.0.2",
43
43
  "@types/jest": "^27.5.1",
44
44
  "@types/lodash": "^4.14.180",