@talismn/balances 0.0.0-pr643-20230322031130 → 0.0.0-pr645-20230322061321
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 +16 -15
- package/dist/talismn-balances.cjs.dev.js +14 -30
- package/dist/talismn-balances.cjs.prod.js +14 -30
- package/dist/talismn-balances.esm.js +14 -30
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
-
## 0.0.0-
|
4
|
-
|
5
|
-
### Patch Changes
|
6
|
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
- Updated dependencies [
|
11
|
-
- Updated dependencies [
|
12
|
-
- Updated dependencies [
|
13
|
-
|
14
|
-
- @talismn/
|
15
|
-
- @talismn/
|
16
|
-
- @talismn/
|
17
|
-
- @talismn/
|
3
|
+
## 0.0.0-pr645-20230322061321
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 3068bd60: feat: stale balances and exponential rpc backoff
|
8
|
+
- 6643a4e4: fix: tokenRates in @talismn/balances-react
|
9
|
+
- 6643a4e4: fix: ported useDbCache related perf fixes to @talismn/balances-react
|
10
|
+
- Updated dependencies [3068bd60]
|
11
|
+
- Updated dependencies [6643a4e4]
|
12
|
+
- Updated dependencies [79f6ccf6]
|
13
|
+
- Updated dependencies [c24dc1fb]
|
14
|
+
- @talismn/chain-connector@0.0.0-pr645-20230322061321
|
15
|
+
- @talismn/util@0.0.0-pr645-20230322061321
|
16
|
+
- @talismn/token-rates@0.0.0-pr645-20230322061321
|
17
|
+
- @talismn/chaindata-provider@0.0.0-pr645-20230322061321
|
18
|
+
- @talismn/chain-connector-evm@0.0.0-pr645-20230322061321
|
18
19
|
|
19
20
|
## 0.3.3
|
20
21
|
|
@@ -67,7 +67,7 @@ const db = new TalismanBalancesDatabase();
|
|
67
67
|
|
68
68
|
var packageJson = {
|
69
69
|
name: "@talismn/balances",
|
70
|
-
version: "0.0.0-
|
70
|
+
version: "0.0.0-pr645-20230322061321",
|
71
71
|
author: "Talisman",
|
72
72
|
homepage: "https://talisman.xyz",
|
73
73
|
license: "UNLICENSED",
|
@@ -86,7 +86,7 @@ var packageJson = {
|
|
86
86
|
"/plugins"
|
87
87
|
],
|
88
88
|
engines: {
|
89
|
-
node: ">=
|
89
|
+
node: ">=18"
|
90
90
|
},
|
91
91
|
scripts: {
|
92
92
|
test: "jest",
|
@@ -157,9 +157,8 @@ const createTypeRegistryCache = () => {
|
|
157
157
|
};
|
158
158
|
};
|
159
159
|
const filterMirrorTokens = (balance, i, balances) => {
|
160
|
-
var _balance$token;
|
161
160
|
// TODO: implement a mirrorOf property, which should be set from chaindata
|
162
|
-
const mirrorOf =
|
161
|
+
const mirrorOf = balance.token?.mirrorOf;
|
163
162
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
164
163
|
};
|
165
164
|
|
@@ -195,8 +194,7 @@ class StorageHelper {
|
|
195
194
|
}
|
196
195
|
}
|
197
196
|
get stateKey() {
|
198
|
-
|
199
|
-
return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
|
197
|
+
return this.#storageKey?.toHex();
|
200
198
|
}
|
201
199
|
get module() {
|
202
200
|
return this.#module;
|
@@ -421,10 +419,7 @@ class Balances {
|
|
421
419
|
* @returns A sorted array of the balances in this collection.
|
422
420
|
*/
|
423
421
|
get sorted() {
|
424
|
-
return [...this].sort((a, b) =>
|
425
|
-
var _ref, _ref2;
|
426
|
-
return (((_ref = a.chain || a.evmNetwork) === null || _ref === void 0 ? void 0 : _ref.sortIndex) ?? Number.MAX_SAFE_INTEGER) - (((_ref2 = b.chain || b.evmNetwork) === null || _ref2 === void 0 ? void 0 : _ref2.sortIndex) ?? Number.MAX_SAFE_INTEGER);
|
427
|
-
});
|
422
|
+
return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER));
|
428
423
|
}
|
429
424
|
|
430
425
|
/**
|
@@ -488,10 +483,7 @@ class Balance {
|
|
488
483
|
hydrate = hydrate => {
|
489
484
|
if (hydrate !== undefined) this.#db = hydrate;
|
490
485
|
};
|
491
|
-
#format = balance =>
|
492
|
-
var _this$db;
|
493
|
-
return new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, ((_this$db = this.#db) === null || _this$db === void 0 ? void 0 : _this$db.tokenRates) && this.#db.tokenRates[this.tokenId]);
|
494
|
-
};
|
486
|
+
#format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
|
495
487
|
|
496
488
|
//
|
497
489
|
// Accessors
|
@@ -521,32 +513,27 @@ class Balance {
|
|
521
513
|
return this.#storage.chainId;
|
522
514
|
}
|
523
515
|
get chain() {
|
524
|
-
|
525
|
-
return ((_this$db2 = this.#db) === null || _this$db2 === void 0 ? void 0 : _this$db2.chains) && this.chainId && ((_this$db3 = this.#db) === null || _this$db3 === void 0 ? void 0 : _this$db3.chains[this.chainId]) || null;
|
516
|
+
return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
|
526
517
|
}
|
527
518
|
get evmNetworkId() {
|
528
519
|
return this.#storage.evmNetworkId;
|
529
520
|
}
|
530
521
|
get evmNetwork() {
|
531
|
-
var _this$db4, _this$db5;
|
532
522
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
533
|
-
return
|
523
|
+
return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
|
534
524
|
}
|
535
525
|
get tokenId() {
|
536
526
|
return this.#storage.tokenId;
|
537
527
|
}
|
538
528
|
get token() {
|
539
|
-
var _this$db6, _this$db7;
|
540
529
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
541
|
-
return
|
530
|
+
return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
|
542
531
|
}
|
543
532
|
get decimals() {
|
544
|
-
|
545
|
-
return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
|
533
|
+
return this.token?.decimals || null;
|
546
534
|
}
|
547
535
|
get rates() {
|
548
|
-
|
549
|
-
return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
|
536
|
+
return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
|
550
537
|
}
|
551
538
|
|
552
539
|
/**
|
@@ -560,18 +547,15 @@ class Balance {
|
|
560
547
|
}
|
561
548
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
562
549
|
get free() {
|
563
|
-
|
564
|
-
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, BigInt("0")) : BigInt(((_this$storage$free = this.#storage.free) === null || _this$storage$free === void 0 ? void 0 : _this$storage$free.amount) || "0"));
|
550
|
+
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, BigInt("0")) : BigInt(this.#storage.free?.amount || "0"));
|
565
551
|
}
|
566
552
|
/** The reserved balance of this token. Is included in the total. */
|
567
553
|
get reserved() {
|
568
|
-
|
569
|
-
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, BigInt("0")) : BigInt(((_this$storage$reserve = this.#storage.reserves) === null || _this$storage$reserve === void 0 ? void 0 : _this$storage$reserve.amount) || "0"));
|
554
|
+
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, BigInt("0")) : BigInt(this.#storage.reserves?.amount || "0"));
|
570
555
|
}
|
571
556
|
/** The frozen balance of this token. Is included in the free amount. */
|
572
557
|
get locked() {
|
573
|
-
|
574
|
-
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), BigInt("0")) : BigInt(((_this$storage$locks = this.#storage.locks) === null || _this$storage$locks === void 0 ? void 0 : _this$storage$locks.amount) || "0"));
|
558
|
+
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), BigInt("0")) : BigInt(this.#storage.locks?.amount || "0"));
|
575
559
|
}
|
576
560
|
/** @depreacted - use balance.locked */
|
577
561
|
get frozen() {
|
@@ -67,7 +67,7 @@ const db = new TalismanBalancesDatabase();
|
|
67
67
|
|
68
68
|
var packageJson = {
|
69
69
|
name: "@talismn/balances",
|
70
|
-
version: "0.0.0-
|
70
|
+
version: "0.0.0-pr645-20230322061321",
|
71
71
|
author: "Talisman",
|
72
72
|
homepage: "https://talisman.xyz",
|
73
73
|
license: "UNLICENSED",
|
@@ -86,7 +86,7 @@ var packageJson = {
|
|
86
86
|
"/plugins"
|
87
87
|
],
|
88
88
|
engines: {
|
89
|
-
node: ">=
|
89
|
+
node: ">=18"
|
90
90
|
},
|
91
91
|
scripts: {
|
92
92
|
test: "jest",
|
@@ -157,9 +157,8 @@ const createTypeRegistryCache = () => {
|
|
157
157
|
};
|
158
158
|
};
|
159
159
|
const filterMirrorTokens = (balance, i, balances) => {
|
160
|
-
var _balance$token;
|
161
160
|
// TODO: implement a mirrorOf property, which should be set from chaindata
|
162
|
-
const mirrorOf =
|
161
|
+
const mirrorOf = balance.token?.mirrorOf;
|
163
162
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
164
163
|
};
|
165
164
|
|
@@ -195,8 +194,7 @@ class StorageHelper {
|
|
195
194
|
}
|
196
195
|
}
|
197
196
|
get stateKey() {
|
198
|
-
|
199
|
-
return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
|
197
|
+
return this.#storageKey?.toHex();
|
200
198
|
}
|
201
199
|
get module() {
|
202
200
|
return this.#module;
|
@@ -421,10 +419,7 @@ class Balances {
|
|
421
419
|
* @returns A sorted array of the balances in this collection.
|
422
420
|
*/
|
423
421
|
get sorted() {
|
424
|
-
return [...this].sort((a, b) =>
|
425
|
-
var _ref, _ref2;
|
426
|
-
return (((_ref = a.chain || a.evmNetwork) === null || _ref === void 0 ? void 0 : _ref.sortIndex) ?? Number.MAX_SAFE_INTEGER) - (((_ref2 = b.chain || b.evmNetwork) === null || _ref2 === void 0 ? void 0 : _ref2.sortIndex) ?? Number.MAX_SAFE_INTEGER);
|
427
|
-
});
|
422
|
+
return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER));
|
428
423
|
}
|
429
424
|
|
430
425
|
/**
|
@@ -488,10 +483,7 @@ class Balance {
|
|
488
483
|
hydrate = hydrate => {
|
489
484
|
if (hydrate !== undefined) this.#db = hydrate;
|
490
485
|
};
|
491
|
-
#format = balance =>
|
492
|
-
var _this$db;
|
493
|
-
return new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, ((_this$db = this.#db) === null || _this$db === void 0 ? void 0 : _this$db.tokenRates) && this.#db.tokenRates[this.tokenId]);
|
494
|
-
};
|
486
|
+
#format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
|
495
487
|
|
496
488
|
//
|
497
489
|
// Accessors
|
@@ -521,32 +513,27 @@ class Balance {
|
|
521
513
|
return this.#storage.chainId;
|
522
514
|
}
|
523
515
|
get chain() {
|
524
|
-
|
525
|
-
return ((_this$db2 = this.#db) === null || _this$db2 === void 0 ? void 0 : _this$db2.chains) && this.chainId && ((_this$db3 = this.#db) === null || _this$db3 === void 0 ? void 0 : _this$db3.chains[this.chainId]) || null;
|
516
|
+
return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
|
526
517
|
}
|
527
518
|
get evmNetworkId() {
|
528
519
|
return this.#storage.evmNetworkId;
|
529
520
|
}
|
530
521
|
get evmNetwork() {
|
531
|
-
var _this$db4, _this$db5;
|
532
522
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
533
|
-
return
|
523
|
+
return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
|
534
524
|
}
|
535
525
|
get tokenId() {
|
536
526
|
return this.#storage.tokenId;
|
537
527
|
}
|
538
528
|
get token() {
|
539
|
-
var _this$db6, _this$db7;
|
540
529
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
541
|
-
return
|
530
|
+
return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
|
542
531
|
}
|
543
532
|
get decimals() {
|
544
|
-
|
545
|
-
return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
|
533
|
+
return this.token?.decimals || null;
|
546
534
|
}
|
547
535
|
get rates() {
|
548
|
-
|
549
|
-
return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
|
536
|
+
return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
|
550
537
|
}
|
551
538
|
|
552
539
|
/**
|
@@ -560,18 +547,15 @@ class Balance {
|
|
560
547
|
}
|
561
548
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
562
549
|
get free() {
|
563
|
-
|
564
|
-
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, BigInt("0")) : BigInt(((_this$storage$free = this.#storage.free) === null || _this$storage$free === void 0 ? void 0 : _this$storage$free.amount) || "0"));
|
550
|
+
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, BigInt("0")) : BigInt(this.#storage.free?.amount || "0"));
|
565
551
|
}
|
566
552
|
/** The reserved balance of this token. Is included in the total. */
|
567
553
|
get reserved() {
|
568
|
-
|
569
|
-
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, BigInt("0")) : BigInt(((_this$storage$reserve = this.#storage.reserves) === null || _this$storage$reserve === void 0 ? void 0 : _this$storage$reserve.amount) || "0"));
|
554
|
+
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, BigInt("0")) : BigInt(this.#storage.reserves?.amount || "0"));
|
570
555
|
}
|
571
556
|
/** The frozen balance of this token. Is included in the free amount. */
|
572
557
|
get locked() {
|
573
|
-
|
574
|
-
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), BigInt("0")) : BigInt(((_this$storage$locks = this.#storage.locks) === null || _this$storage$locks === void 0 ? void 0 : _this$storage$locks.amount) || "0"));
|
558
|
+
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), BigInt("0")) : BigInt(this.#storage.locks?.amount || "0"));
|
575
559
|
}
|
576
560
|
/** @depreacted - use balance.locked */
|
577
561
|
get frozen() {
|
@@ -59,7 +59,7 @@ const db = new TalismanBalancesDatabase();
|
|
59
59
|
|
60
60
|
var packageJson = {
|
61
61
|
name: "@talismn/balances",
|
62
|
-
version: "0.0.0-
|
62
|
+
version: "0.0.0-pr645-20230322061321",
|
63
63
|
author: "Talisman",
|
64
64
|
homepage: "https://talisman.xyz",
|
65
65
|
license: "UNLICENSED",
|
@@ -78,7 +78,7 @@ var packageJson = {
|
|
78
78
|
"/plugins"
|
79
79
|
],
|
80
80
|
engines: {
|
81
|
-
node: ">=
|
81
|
+
node: ">=18"
|
82
82
|
},
|
83
83
|
scripts: {
|
84
84
|
test: "jest",
|
@@ -149,9 +149,8 @@ const createTypeRegistryCache = () => {
|
|
149
149
|
};
|
150
150
|
};
|
151
151
|
const filterMirrorTokens = (balance, i, balances) => {
|
152
|
-
var _balance$token;
|
153
152
|
// TODO: implement a mirrorOf property, which should be set from chaindata
|
154
|
-
const mirrorOf =
|
153
|
+
const mirrorOf = balance.token?.mirrorOf;
|
155
154
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
156
155
|
};
|
157
156
|
|
@@ -187,8 +186,7 @@ class StorageHelper {
|
|
187
186
|
}
|
188
187
|
}
|
189
188
|
get stateKey() {
|
190
|
-
|
191
|
-
return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
|
189
|
+
return this.#storageKey?.toHex();
|
192
190
|
}
|
193
191
|
get module() {
|
194
192
|
return this.#module;
|
@@ -413,10 +411,7 @@ class Balances {
|
|
413
411
|
* @returns A sorted array of the balances in this collection.
|
414
412
|
*/
|
415
413
|
get sorted() {
|
416
|
-
return [...this].sort((a, b) =>
|
417
|
-
var _ref, _ref2;
|
418
|
-
return (((_ref = a.chain || a.evmNetwork) === null || _ref === void 0 ? void 0 : _ref.sortIndex) ?? Number.MAX_SAFE_INTEGER) - (((_ref2 = b.chain || b.evmNetwork) === null || _ref2 === void 0 ? void 0 : _ref2.sortIndex) ?? Number.MAX_SAFE_INTEGER);
|
419
|
-
});
|
414
|
+
return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex ?? Number.MAX_SAFE_INTEGER));
|
420
415
|
}
|
421
416
|
|
422
417
|
/**
|
@@ -480,10 +475,7 @@ class Balance {
|
|
480
475
|
hydrate = hydrate => {
|
481
476
|
if (hydrate !== undefined) this.#db = hydrate;
|
482
477
|
};
|
483
|
-
#format = balance =>
|
484
|
-
var _this$db;
|
485
|
-
return new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, ((_this$db = this.#db) === null || _this$db === void 0 ? void 0 : _this$db.tokenRates) && this.#db.tokenRates[this.tokenId]);
|
486
|
-
};
|
478
|
+
#format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
|
487
479
|
|
488
480
|
//
|
489
481
|
// Accessors
|
@@ -513,32 +505,27 @@ class Balance {
|
|
513
505
|
return this.#storage.chainId;
|
514
506
|
}
|
515
507
|
get chain() {
|
516
|
-
|
517
|
-
return ((_this$db2 = this.#db) === null || _this$db2 === void 0 ? void 0 : _this$db2.chains) && this.chainId && ((_this$db3 = this.#db) === null || _this$db3 === void 0 ? void 0 : _this$db3.chains[this.chainId]) || null;
|
508
|
+
return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
|
518
509
|
}
|
519
510
|
get evmNetworkId() {
|
520
511
|
return this.#storage.evmNetworkId;
|
521
512
|
}
|
522
513
|
get evmNetwork() {
|
523
|
-
var _this$db4, _this$db5;
|
524
514
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
525
|
-
return
|
515
|
+
return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
|
526
516
|
}
|
527
517
|
get tokenId() {
|
528
518
|
return this.#storage.tokenId;
|
529
519
|
}
|
530
520
|
get token() {
|
531
|
-
var _this$db6, _this$db7;
|
532
521
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
533
|
-
return
|
522
|
+
return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
|
534
523
|
}
|
535
524
|
get decimals() {
|
536
|
-
|
537
|
-
return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
|
525
|
+
return this.token?.decimals || null;
|
538
526
|
}
|
539
527
|
get rates() {
|
540
|
-
|
541
|
-
return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
|
528
|
+
return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
|
542
529
|
}
|
543
530
|
|
544
531
|
/**
|
@@ -552,18 +539,15 @@ class Balance {
|
|
552
539
|
}
|
553
540
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
554
541
|
get free() {
|
555
|
-
|
556
|
-
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, BigInt("0")) : BigInt(((_this$storage$free = this.#storage.free) === null || _this$storage$free === void 0 ? void 0 : _this$storage$free.amount) || "0"));
|
542
|
+
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, BigInt("0")) : BigInt(this.#storage.free?.amount || "0"));
|
557
543
|
}
|
558
544
|
/** The reserved balance of this token. Is included in the total. */
|
559
545
|
get reserved() {
|
560
|
-
|
561
|
-
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, BigInt("0")) : BigInt(((_this$storage$reserve = this.#storage.reserves) === null || _this$storage$reserve === void 0 ? void 0 : _this$storage$reserve.amount) || "0"));
|
546
|
+
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, BigInt("0")) : BigInt(this.#storage.reserves?.amount || "0"));
|
562
547
|
}
|
563
548
|
/** The frozen balance of this token. Is included in the free amount. */
|
564
549
|
get locked() {
|
565
|
-
|
566
|
-
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), BigInt("0")) : BigInt(((_this$storage$locks = this.#storage.locks) === null || _this$storage$locks === void 0 ? void 0 : _this$storage$locks.amount) || "0"));
|
550
|
+
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), BigInt("0")) : BigInt(this.#storage.locks?.amount || "0"));
|
567
551
|
}
|
568
552
|
/** @depreacted - use balance.locked */
|
569
553
|
get frozen() {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-pr645-20230322061321",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"/plugins"
|
20
20
|
],
|
21
21
|
"engines": {
|
22
|
-
"node": ">=
|
22
|
+
"node": ">=18"
|
23
23
|
},
|
24
24
|
"scripts": {
|
25
25
|
"test": "jest",
|
@@ -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-
|
31
|
-
"@talismn/chain-connector-evm": "^0.0.0-
|
32
|
-
"@talismn/chaindata-provider": "^0.0.0-
|
33
|
-
"@talismn/token-rates": "^0.0.0-
|
34
|
-
"@talismn/util": "^0.0.0-
|
30
|
+
"@talismn/chain-connector": "^0.0.0-pr645-20230322061321",
|
31
|
+
"@talismn/chain-connector-evm": "^0.0.0-pr645-20230322061321",
|
32
|
+
"@talismn/chaindata-provider": "^0.0.0-pr645-20230322061321",
|
33
|
+
"@talismn/token-rates": "^0.0.0-pr645-20230322061321",
|
34
|
+
"@talismn/util": "^0.0.0-pr645-20230322061321",
|
35
35
|
"anylogger": "^1.0.11",
|
36
36
|
"dexie": "^3.2.3"
|
37
37
|
},
|