@talismn/balances 0.0.0-pr677-20230418034508 → 0.0.0-pr677-20230418051607

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,21 +1,21 @@
1
1
  # @talismn/balances
2
2
 
3
- ## 0.0.0-pr677-20230418034508
3
+ ## 0.0.0-pr677-20230418051607
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - fb8ee962: feat: proxy dapp websocket requests to talisman wallet backend when available
8
- - 6b9a99a1: feat: crowdloan and nom pool balances
9
- - 9d24530b: fix: packages publishing with incorrect interdependency versions
8
+ - 31ba6a31: feat: crowdloan and nom pool balances
9
+ - b08460f2: fix: packages publishing with incorrect interdependency versions
10
10
  - Updated dependencies [fb8ee962]
11
11
  - Updated dependencies [c898da98]
12
- - Updated dependencies [6b9a99a1]
13
- - Updated dependencies [9d24530b]
14
- - @talismn/chain-connector@0.0.0-pr677-20230418034508
15
- - @talismn/chain-connector-evm@0.0.0-pr677-20230418034508
16
- - @talismn/util@0.0.0-pr677-20230418034508
17
- - @talismn/chaindata-provider@0.0.0-pr677-20230418034508
18
- - @talismn/token-rates@0.0.0-pr677-20230418034508
12
+ - Updated dependencies [31ba6a31]
13
+ - Updated dependencies [b08460f2]
14
+ - @talismn/chain-connector@0.0.0-pr677-20230418051607
15
+ - @talismn/chain-connector-evm@0.0.0-pr677-20230418051607
16
+ - @talismn/util@0.0.0-pr677-20230418051607
17
+ - @talismn/chaindata-provider@0.0.0-pr677-20230418051607
18
+ - @talismn/token-rates@0.0.0-pr677-20230418051607
19
19
 
20
20
  ## 0.4.0
21
21
 
@@ -61,6 +61,19 @@ export declare class Balances {
61
61
  * @returns All balances which match the query.
62
62
  */
63
63
  find: (query: BalanceSearchQuery | BalanceSearchQuery[]) => Balances;
64
+ /**
65
+ * Filters this collection to exclude token balances where the token has a `mirrorOf` field
66
+ * and another balance exists in this collection for the token specified by the `mirrorOf` field.
67
+ */
68
+ filterMirrorTokens: () => Balances;
69
+ /**
70
+ * Filters this collection to only include balances which are not zero.
71
+ */
72
+ filterNonZero: (type: "total" | "free" | "reserved" | "locked" | "frozen" | "transferable" | "feePayable") => Balances;
73
+ /**
74
+ * Filters this collection to only include balances which are not zero AND have a fiat conversion rate.
75
+ */
76
+ filterNonZeroFiat: (type: "total" | "free" | "reserved" | "locked" | "frozen" | "transferable" | "feePayable", currency: TokenRateCurrency) => Balances;
64
77
  /**
65
78
  * Add some balances to this collection.
66
79
  * Added balances take priority over existing balances.
@@ -148,7 +161,7 @@ export declare class Balance {
148
161
  includeInTransferable?: boolean | undefined;
149
162
  excludeFromFeePayable?: boolean | undefined;
150
163
  }[];
151
- /** @depreacted - use balance.locked */
164
+ /** @deprecated Use balance.locked */
152
165
  get frozen(): BalanceFormatter;
153
166
  /** The transferable balance of this token. Is generally the free amount - the miscFrozen amount. */
154
167
  get transferable(): BalanceFormatter;
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr677-20230418034508",
72
+ version: "0.0.0-pr677-20230418051607",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "UNLICENSED",
@@ -490,6 +490,27 @@ class Balances {
490
490
  return new Balances([...this].filter(filter));
491
491
  };
492
492
 
493
+ /**
494
+ * Filters this collection to exclude token balances where the token has a `mirrorOf` field
495
+ * and another balance exists in this collection for the token specified by the `mirrorOf` field.
496
+ */
497
+ filterMirrorTokens = () => new Balances([...this].filter(filterMirrorTokens));
498
+
499
+ /**
500
+ * Filters this collection to only include balances which are not zero.
501
+ */
502
+ filterNonZero = type => {
503
+ const filter = balance => balance[type].planck > 0n;
504
+ return this.find(filter);
505
+ };
506
+ /**
507
+ * Filters this collection to only include balances which are not zero AND have a fiat conversion rate.
508
+ */
509
+ filterNonZeroFiat = (type, currency) => {
510
+ const filter = balance => (balance[type].fiat(currency) ?? 0) > 0;
511
+ return this.find(filter);
512
+ };
513
+
493
514
  /**
494
515
  * Add some balances to this collection.
495
516
  * Added balances take priority over existing balances.
@@ -704,7 +725,7 @@ class Balance {
704
725
  };
705
726
  });
706
727
  }
707
- /** @depreacted - use balance.locked */
728
+ /** @deprecated Use balance.locked */
708
729
  get frozen() {
709
730
  return this.locked;
710
731
  }
@@ -763,11 +784,11 @@ class FiatSumBalancesFormatter {
763
784
  }
764
785
  #sum = balanceField => {
765
786
  // a function to get a fiat amount from a balance
766
- const fiat = balance => balance[balanceField].fiat(this.#currency) || 0;
787
+ const fiat = balance => balance[balanceField].fiat(this.#currency) ?? 0;
767
788
 
768
789
  // a function to add two amounts
769
790
  const sum = (a, b) => a + b;
770
- return [...this.#balances].filter(filterMirrorTokens).reduce((total, balance) => sum(
791
+ return this.#balances.filterMirrorTokens().each.reduce((total, balance) => sum(
771
792
  // add the total amount...
772
793
  total,
773
794
  // ...to the fiat amount of each balance
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr677-20230418034508",
72
+ version: "0.0.0-pr677-20230418051607",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "UNLICENSED",
@@ -490,6 +490,27 @@ class Balances {
490
490
  return new Balances([...this].filter(filter));
491
491
  };
492
492
 
493
+ /**
494
+ * Filters this collection to exclude token balances where the token has a `mirrorOf` field
495
+ * and another balance exists in this collection for the token specified by the `mirrorOf` field.
496
+ */
497
+ filterMirrorTokens = () => new Balances([...this].filter(filterMirrorTokens));
498
+
499
+ /**
500
+ * Filters this collection to only include balances which are not zero.
501
+ */
502
+ filterNonZero = type => {
503
+ const filter = balance => balance[type].planck > 0n;
504
+ return this.find(filter);
505
+ };
506
+ /**
507
+ * Filters this collection to only include balances which are not zero AND have a fiat conversion rate.
508
+ */
509
+ filterNonZeroFiat = (type, currency) => {
510
+ const filter = balance => (balance[type].fiat(currency) ?? 0) > 0;
511
+ return this.find(filter);
512
+ };
513
+
493
514
  /**
494
515
  * Add some balances to this collection.
495
516
  * Added balances take priority over existing balances.
@@ -704,7 +725,7 @@ class Balance {
704
725
  };
705
726
  });
706
727
  }
707
- /** @depreacted - use balance.locked */
728
+ /** @deprecated Use balance.locked */
708
729
  get frozen() {
709
730
  return this.locked;
710
731
  }
@@ -763,11 +784,11 @@ class FiatSumBalancesFormatter {
763
784
  }
764
785
  #sum = balanceField => {
765
786
  // a function to get a fiat amount from a balance
766
- const fiat = balance => balance[balanceField].fiat(this.#currency) || 0;
787
+ const fiat = balance => balance[balanceField].fiat(this.#currency) ?? 0;
767
788
 
768
789
  // a function to add two amounts
769
790
  const sum = (a, b) => a + b;
770
- return [...this.#balances].filter(filterMirrorTokens).reduce((total, balance) => sum(
791
+ return this.#balances.filterMirrorTokens().each.reduce((total, balance) => sum(
771
792
  // add the total amount...
772
793
  total,
773
794
  // ...to the fiat amount of each balance
@@ -60,7 +60,7 @@ const db = new TalismanBalancesDatabase();
60
60
 
61
61
  var packageJson = {
62
62
  name: "@talismn/balances",
63
- version: "0.0.0-pr677-20230418034508",
63
+ version: "0.0.0-pr677-20230418051607",
64
64
  author: "Talisman",
65
65
  homepage: "https://talisman.xyz",
66
66
  license: "UNLICENSED",
@@ -481,6 +481,27 @@ class Balances {
481
481
  return new Balances([...this].filter(filter));
482
482
  };
483
483
 
484
+ /**
485
+ * Filters this collection to exclude token balances where the token has a `mirrorOf` field
486
+ * and another balance exists in this collection for the token specified by the `mirrorOf` field.
487
+ */
488
+ filterMirrorTokens = () => new Balances([...this].filter(filterMirrorTokens));
489
+
490
+ /**
491
+ * Filters this collection to only include balances which are not zero.
492
+ */
493
+ filterNonZero = type => {
494
+ const filter = balance => balance[type].planck > 0n;
495
+ return this.find(filter);
496
+ };
497
+ /**
498
+ * Filters this collection to only include balances which are not zero AND have a fiat conversion rate.
499
+ */
500
+ filterNonZeroFiat = (type, currency) => {
501
+ const filter = balance => (balance[type].fiat(currency) ?? 0) > 0;
502
+ return this.find(filter);
503
+ };
504
+
484
505
  /**
485
506
  * Add some balances to this collection.
486
507
  * Added balances take priority over existing balances.
@@ -695,7 +716,7 @@ class Balance {
695
716
  };
696
717
  });
697
718
  }
698
- /** @depreacted - use balance.locked */
719
+ /** @deprecated Use balance.locked */
699
720
  get frozen() {
700
721
  return this.locked;
701
722
  }
@@ -754,11 +775,11 @@ class FiatSumBalancesFormatter {
754
775
  }
755
776
  #sum = balanceField => {
756
777
  // a function to get a fiat amount from a balance
757
- const fiat = balance => balance[balanceField].fiat(this.#currency) || 0;
778
+ const fiat = balance => balance[balanceField].fiat(this.#currency) ?? 0;
758
779
 
759
780
  // a function to add two amounts
760
781
  const sum = (a, b) => a + b;
761
- return [...this.#balances].filter(filterMirrorTokens).reduce((total, balance) => sum(
782
+ return this.#balances.filterMirrorTokens().each.reduce((total, balance) => sum(
762
783
  // add the total amount...
763
784
  total,
764
785
  // ...to the fiat amount of each balance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr677-20230418034508",
3
+ "version": "0.0.0-pr677-20230418051607",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -27,11 +27,11 @@
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-pr677-20230418034508",
31
- "@talismn/chain-connector-evm": "0.0.0-pr677-20230418034508",
32
- "@talismn/chaindata-provider": "0.0.0-pr677-20230418034508",
33
- "@talismn/token-rates": "0.0.0-pr677-20230418034508",
34
- "@talismn/util": "0.0.0-pr677-20230418034508",
30
+ "@talismn/chain-connector": "0.0.0-pr677-20230418051607",
31
+ "@talismn/chain-connector-evm": "0.0.0-pr677-20230418051607",
32
+ "@talismn/chaindata-provider": "0.0.0-pr677-20230418051607",
33
+ "@talismn/token-rates": "0.0.0-pr677-20230418051607",
34
+ "@talismn/util": "0.0.0-pr677-20230418051607",
35
35
  "anylogger": "^1.0.11",
36
36
  "dexie": "^3.2.3",
37
37
  "lodash": "4.17.21"