@talismn/balances 0.0.0-pr677-20230414044007 → 0.0.0-pr677-20230414073254
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 +6 -6
- package/dist/talismn-balances.cjs.dev.js +10 -10
- package/dist/talismn-balances.cjs.prod.js +10 -10
- package/dist/talismn-balances.esm.js +10 -10
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
-
## 0.0.0-pr677-
|
3
|
+
## 0.0.0-pr677-20230414073254
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
@@ -9,11 +9,11 @@
|
|
9
9
|
- Updated dependencies [fb8ee962]
|
10
10
|
- Updated dependencies [c898da98]
|
11
11
|
- Updated dependencies [7440f96a]
|
12
|
-
- @talismn/chain-connector@0.0.0-pr677-
|
13
|
-
- @talismn/chain-connector-evm@0.0.0-pr677-
|
14
|
-
- @talismn/util@0.0.0-pr677-
|
15
|
-
- @talismn/chaindata-provider@0.0.0-pr677-
|
16
|
-
- @talismn/token-rates@0.0.0-pr677-
|
12
|
+
- @talismn/chain-connector@0.0.0-pr677-20230414073254
|
13
|
+
- @talismn/chain-connector-evm@0.0.0-pr677-20230414073254
|
14
|
+
- @talismn/util@0.0.0-pr677-20230414073254
|
15
|
+
- @talismn/chaindata-provider@0.0.0-pr677-20230414073254
|
16
|
+
- @talismn/token-rates@0.0.0-pr677-20230414073254
|
17
17
|
|
18
18
|
## 0.4.0
|
19
19
|
|
@@ -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-
|
72
|
+
version: "0.0.0-pr677-20230414073254",
|
73
73
|
author: "Talisman",
|
74
74
|
homepage: "https://talisman.xyz",
|
75
75
|
license: "UNLICENSED",
|
@@ -366,7 +366,7 @@ const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
|
|
366
366
|
function excludeFromTransferableAmount(locks) {
|
367
367
|
if (typeof locks === "string") return BigInt(locks);
|
368
368
|
if (!Array.isArray(locks)) locks = [locks];
|
369
|
-
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock),
|
369
|
+
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock), 0n);
|
370
370
|
}
|
371
371
|
function excludeFromFeePayableLocks(locks) {
|
372
372
|
if (typeof locks === "string") return [];
|
@@ -377,9 +377,9 @@ function excludeFromFeePayableLocks(locks) {
|
|
377
377
|
/** A labelled extra amount of a balance */
|
378
378
|
|
379
379
|
function includeInTotalExtraAmount(extra) {
|
380
|
-
if (!extra) return
|
380
|
+
if (!extra) return 0n;
|
381
381
|
if (!Array.isArray(extra)) extra = [extra];
|
382
|
-
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b,
|
382
|
+
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b, 0n);
|
383
383
|
}
|
384
384
|
|
385
385
|
/** Used by plugins to help define their custom `BalanceType` */
|
@@ -668,11 +668,11 @@ class Balance {
|
|
668
668
|
}
|
669
669
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
670
670
|
get free() {
|
671
|
-
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
671
|
+
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.free?.amount || "0"));
|
672
672
|
}
|
673
673
|
/** The reserved balance of this token. Is included in the total. */
|
674
674
|
get reserved() {
|
675
|
-
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
675
|
+
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.reserves?.amount || "0"));
|
676
676
|
}
|
677
677
|
get reserves() {
|
678
678
|
return (Array.isArray(this.#storage.reserves) ? this.#storage.reserves : [this.#storage.reserves]).flatMap(reserve => {
|
@@ -689,7 +689,7 @@ class Balance {
|
|
689
689
|
}
|
690
690
|
/** The frozen balance of this token. Is included in the free amount. */
|
691
691
|
get locked() {
|
692
|
-
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => util.BigMath.max(a, b),
|
692
|
+
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => util.BigMath.max(a, b), 0n) : BigInt(this.#storage.locks?.amount || "0"));
|
693
693
|
}
|
694
694
|
get locks() {
|
695
695
|
return (Array.isArray(this.#storage.locks) ? this.#storage.locks : [this.#storage.locks]).flatMap(lock => {
|
@@ -717,7 +717,7 @@ class Balance {
|
|
717
717
|
const excludeAmount = excludeFromTransferableAmount(this.#storage.locks);
|
718
718
|
|
719
719
|
// subtract the lock from the free amount (but don't go below 0)
|
720
|
-
return this.#format(util.BigMath.max(this.free.planck - excludeAmount,
|
720
|
+
return this.#format(util.BigMath.max(this.free.planck - excludeAmount, 0n));
|
721
721
|
}
|
722
722
|
/** The feePayable balance of this token. Is generally the free amount - the feeFrozen amount. */
|
723
723
|
get feePayable() {
|
@@ -725,10 +725,10 @@ class Balance {
|
|
725
725
|
if (!this.#storage.locks) return this.free;
|
726
726
|
|
727
727
|
// find the largest lock which can't be used to pay tx fees
|
728
|
-
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock),
|
728
|
+
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock), 0n);
|
729
729
|
|
730
730
|
// subtract the lock from the free amount (but don't go below 0)
|
731
|
-
return this.#format(util.BigMath.max(this.free.planck - excludeAmount,
|
731
|
+
return this.#format(util.BigMath.max(this.free.planck - excludeAmount, 0n));
|
732
732
|
}
|
733
733
|
}
|
734
734
|
class 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-
|
72
|
+
version: "0.0.0-pr677-20230414073254",
|
73
73
|
author: "Talisman",
|
74
74
|
homepage: "https://talisman.xyz",
|
75
75
|
license: "UNLICENSED",
|
@@ -366,7 +366,7 @@ const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
|
|
366
366
|
function excludeFromTransferableAmount(locks) {
|
367
367
|
if (typeof locks === "string") return BigInt(locks);
|
368
368
|
if (!Array.isArray(locks)) locks = [locks];
|
369
|
-
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock),
|
369
|
+
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock), 0n);
|
370
370
|
}
|
371
371
|
function excludeFromFeePayableLocks(locks) {
|
372
372
|
if (typeof locks === "string") return [];
|
@@ -377,9 +377,9 @@ function excludeFromFeePayableLocks(locks) {
|
|
377
377
|
/** A labelled extra amount of a balance */
|
378
378
|
|
379
379
|
function includeInTotalExtraAmount(extra) {
|
380
|
-
if (!extra) return
|
380
|
+
if (!extra) return 0n;
|
381
381
|
if (!Array.isArray(extra)) extra = [extra];
|
382
|
-
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b,
|
382
|
+
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b, 0n);
|
383
383
|
}
|
384
384
|
|
385
385
|
/** Used by plugins to help define their custom `BalanceType` */
|
@@ -668,11 +668,11 @@ class Balance {
|
|
668
668
|
}
|
669
669
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
670
670
|
get free() {
|
671
|
-
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
671
|
+
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.free?.amount || "0"));
|
672
672
|
}
|
673
673
|
/** The reserved balance of this token. Is included in the total. */
|
674
674
|
get reserved() {
|
675
|
-
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
675
|
+
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.reserves?.amount || "0"));
|
676
676
|
}
|
677
677
|
get reserves() {
|
678
678
|
return (Array.isArray(this.#storage.reserves) ? this.#storage.reserves : [this.#storage.reserves]).flatMap(reserve => {
|
@@ -689,7 +689,7 @@ class Balance {
|
|
689
689
|
}
|
690
690
|
/** The frozen balance of this token. Is included in the free amount. */
|
691
691
|
get locked() {
|
692
|
-
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => util.BigMath.max(a, b),
|
692
|
+
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => util.BigMath.max(a, b), 0n) : BigInt(this.#storage.locks?.amount || "0"));
|
693
693
|
}
|
694
694
|
get locks() {
|
695
695
|
return (Array.isArray(this.#storage.locks) ? this.#storage.locks : [this.#storage.locks]).flatMap(lock => {
|
@@ -717,7 +717,7 @@ class Balance {
|
|
717
717
|
const excludeAmount = excludeFromTransferableAmount(this.#storage.locks);
|
718
718
|
|
719
719
|
// subtract the lock from the free amount (but don't go below 0)
|
720
|
-
return this.#format(util.BigMath.max(this.free.planck - excludeAmount,
|
720
|
+
return this.#format(util.BigMath.max(this.free.planck - excludeAmount, 0n));
|
721
721
|
}
|
722
722
|
/** The feePayable balance of this token. Is generally the free amount - the feeFrozen amount. */
|
723
723
|
get feePayable() {
|
@@ -725,10 +725,10 @@ class Balance {
|
|
725
725
|
if (!this.#storage.locks) return this.free;
|
726
726
|
|
727
727
|
// find the largest lock which can't be used to pay tx fees
|
728
|
-
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock),
|
728
|
+
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => util.BigMath.max(max, lock), 0n);
|
729
729
|
|
730
730
|
// subtract the lock from the free amount (but don't go below 0)
|
731
|
-
return this.#format(util.BigMath.max(this.free.planck - excludeAmount,
|
731
|
+
return this.#format(util.BigMath.max(this.free.planck - excludeAmount, 0n));
|
732
732
|
}
|
733
733
|
}
|
734
734
|
class BalanceFormatter {
|
@@ -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-
|
63
|
+
version: "0.0.0-pr677-20230414073254",
|
64
64
|
author: "Talisman",
|
65
65
|
homepage: "https://talisman.xyz",
|
66
66
|
license: "UNLICENSED",
|
@@ -357,7 +357,7 @@ const BalanceStatusLive = subscriptionId => `live-${subscriptionId}`;
|
|
357
357
|
function excludeFromTransferableAmount(locks) {
|
358
358
|
if (typeof locks === "string") return BigInt(locks);
|
359
359
|
if (!Array.isArray(locks)) locks = [locks];
|
360
|
-
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => BigMath.max(max, lock),
|
360
|
+
return locks.filter(lock => lock.includeInTransferable !== true).map(lock => BigInt(lock.amount)).reduce((max, lock) => BigMath.max(max, lock), 0n);
|
361
361
|
}
|
362
362
|
function excludeFromFeePayableLocks(locks) {
|
363
363
|
if (typeof locks === "string") return [];
|
@@ -368,9 +368,9 @@ function excludeFromFeePayableLocks(locks) {
|
|
368
368
|
/** A labelled extra amount of a balance */
|
369
369
|
|
370
370
|
function includeInTotalExtraAmount(extra) {
|
371
|
-
if (!extra) return
|
371
|
+
if (!extra) return 0n;
|
372
372
|
if (!Array.isArray(extra)) extra = [extra];
|
373
|
-
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b,
|
373
|
+
return extra.filter(extra => extra.includeInTotal).map(extra => BigInt(extra.amount)).reduce((a, b) => a + b, 0n);
|
374
374
|
}
|
375
375
|
|
376
376
|
/** Used by plugins to help define their custom `BalanceType` */
|
@@ -659,11 +659,11 @@ class Balance {
|
|
659
659
|
}
|
660
660
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
661
661
|
get free() {
|
662
|
-
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
662
|
+
return this.#format(typeof this.#storage.free === "string" ? BigInt(this.#storage.free) : Array.isArray(this.#storage.free) ? this.#storage.free.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.free?.amount || "0"));
|
663
663
|
}
|
664
664
|
/** The reserved balance of this token. Is included in the total. */
|
665
665
|
get reserved() {
|
666
|
-
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b,
|
666
|
+
return this.#format(typeof this.#storage.reserves === "string" ? BigInt(this.#storage.reserves) : Array.isArray(this.#storage.reserves) ? this.#storage.reserves.map(reserve => BigInt(reserve.amount)).reduce((a, b) => a + b, 0n) : BigInt(this.#storage.reserves?.amount || "0"));
|
667
667
|
}
|
668
668
|
get reserves() {
|
669
669
|
return (Array.isArray(this.#storage.reserves) ? this.#storage.reserves : [this.#storage.reserves]).flatMap(reserve => {
|
@@ -680,7 +680,7 @@ class Balance {
|
|
680
680
|
}
|
681
681
|
/** The frozen balance of this token. Is included in the free amount. */
|
682
682
|
get locked() {
|
683
|
-
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => BigMath.max(a, b),
|
683
|
+
return this.#format(typeof this.#storage.locks === "string" ? BigInt(this.#storage.locks) : Array.isArray(this.#storage.locks) ? this.#storage.locks.map(lock => BigInt(lock.amount)).reduce((a, b) => BigMath.max(a, b), 0n) : BigInt(this.#storage.locks?.amount || "0"));
|
684
684
|
}
|
685
685
|
get locks() {
|
686
686
|
return (Array.isArray(this.#storage.locks) ? this.#storage.locks : [this.#storage.locks]).flatMap(lock => {
|
@@ -708,7 +708,7 @@ class Balance {
|
|
708
708
|
const excludeAmount = excludeFromTransferableAmount(this.#storage.locks);
|
709
709
|
|
710
710
|
// subtract the lock from the free amount (but don't go below 0)
|
711
|
-
return this.#format(BigMath.max(this.free.planck - excludeAmount,
|
711
|
+
return this.#format(BigMath.max(this.free.planck - excludeAmount, 0n));
|
712
712
|
}
|
713
713
|
/** The feePayable balance of this token. Is generally the free amount - the feeFrozen amount. */
|
714
714
|
get feePayable() {
|
@@ -716,10 +716,10 @@ class Balance {
|
|
716
716
|
if (!this.#storage.locks) return this.free;
|
717
717
|
|
718
718
|
// find the largest lock which can't be used to pay tx fees
|
719
|
-
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => BigMath.max(max, lock),
|
719
|
+
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks).map(lock => BigInt(lock.amount)).reduce((max, lock) => BigMath.max(max, lock), 0n);
|
720
720
|
|
721
721
|
// subtract the lock from the free amount (but don't go below 0)
|
722
|
-
return this.#format(BigMath.max(this.free.planck - excludeAmount,
|
722
|
+
return this.#format(BigMath.max(this.free.planck - excludeAmount, 0n));
|
723
723
|
}
|
724
724
|
}
|
725
725
|
class BalanceFormatter {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.0.0-pr677-
|
3
|
+
"version": "0.0.0-pr677-20230414073254",
|
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-
|
31
|
-
"@talismn/chain-connector-evm": "^0.0.0-pr677-
|
32
|
-
"@talismn/chaindata-provider": "^0.0.0-pr677-
|
33
|
-
"@talismn/token-rates": "^0.0.0-pr677-
|
34
|
-
"@talismn/util": "^0.0.0-pr677-
|
30
|
+
"@talismn/chain-connector": "^0.0.0-pr677-20230414073254",
|
31
|
+
"@talismn/chain-connector-evm": "^0.0.0-pr677-20230414073254",
|
32
|
+
"@talismn/chaindata-provider": "^0.0.0-pr677-20230414073254",
|
33
|
+
"@talismn/token-rates": "^0.0.0-pr677-20230414073254",
|
34
|
+
"@talismn/util": "^0.0.0-pr677-20230414073254",
|
35
35
|
"anylogger": "^1.0.11",
|
36
36
|
"dexie": "^3.2.3",
|
37
37
|
"lodash": "4.17.21"
|