@talismn/balances 0.0.0-pr563-20230221193038 → 0.0.0-pr563-20230221230003

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,10 +1,10 @@
1
1
  # @talismn/balances
2
2
 
3
- ## 0.0.0-pr563-20230221193038
3
+ ## 0.0.0-pr563-20230221230003
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 536eddb: fix: ported useDbCache related perf fixes to @talismn/balances-react
7
+ - 536eddb5: fix: ported useDbCache related perf fixes to @talismn/balances-react
8
8
 
9
9
  ## 0.3.3
10
10
 
@@ -74,7 +74,7 @@ const db = new TalismanBalancesDatabase();
74
74
 
75
75
  var packageJson = {
76
76
  name: "@talismn/balances",
77
- version: "0.0.0-pr563-20230221193038",
77
+ version: "0.0.0-pr563-20230221230003",
78
78
  author: "Talisman",
79
79
  homepage: "https://talisman.xyz",
80
80
  license: "UNLICENSED",
@@ -107,7 +107,7 @@ var packageJson = {
107
107
  "@talismn/token-rates": "workspace:^",
108
108
  "@talismn/util": "workspace:^",
109
109
  anylogger: "^1.0.11",
110
- dexie: "^3.2.3",
110
+ dexie: "^3.2.2",
111
111
  lodash: "^4.17.21",
112
112
  "typescript-memoize": "^1.1.0"
113
113
  },
@@ -148,9 +148,8 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
148
148
  return await balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
149
149
  }
150
150
  const filterMirrorTokens = (balance, i, balances) => {
151
- var _balance$token;
152
151
  // TODO implement a mirrorOf property, which should be set from chaindata
153
- const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
152
+ const mirrorOf = balance.token?.mirrorOf;
154
153
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
155
154
  };
156
155
 
@@ -186,8 +185,7 @@ class StorageHelper {
186
185
  }
187
186
  }
188
187
  get stateKey() {
189
- var _this$storageKey;
190
- return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
188
+ return this.#storageKey?.toHex();
191
189
  }
192
190
  get module() {
193
191
  return this.#module;
@@ -442,10 +440,7 @@ let Balances = (_dec = typescriptMemoize.Memoize(), _dec2 = typescriptMemoize.Me
442
440
  * @returns A sorted array of the balances in this collection.
443
441
  */
444
442
  get sorted() {
445
- return [...this].sort((a, b) => {
446
- var _ref, _ref2;
447
- 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);
448
- });
443
+ return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER));
449
444
  }
450
445
 
451
446
  /**
@@ -510,10 +505,7 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
510
505
  hydrate = hydrate => {
511
506
  if (hydrate !== undefined) this.#db = hydrate;
512
507
  };
513
- #format = balance => {
514
- var _this$db;
515
- 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]);
516
- };
508
+ #format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
517
509
 
518
510
  //
519
511
  // Accessors
@@ -543,32 +535,27 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
543
535
  return this.#storage.chainId;
544
536
  }
545
537
  get chain() {
546
- var _this$db2, _this$db3;
547
- 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;
538
+ return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
548
539
  }
549
540
  get evmNetworkId() {
550
541
  return this.#storage.evmNetworkId;
551
542
  }
552
543
  get evmNetwork() {
553
- var _this$db4, _this$db5;
554
544
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
555
- return ((_this$db4 = this.#db) === null || _this$db4 === void 0 ? void 0 : _this$db4.evmNetworks) && ((_this$db5 = this.#db) === null || _this$db5 === void 0 ? void 0 : _this$db5.evmNetworks[this.evmNetworkId]) || null;
545
+ return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
556
546
  }
557
547
  get tokenId() {
558
548
  return this.#storage.tokenId;
559
549
  }
560
550
  get token() {
561
- var _this$db6, _this$db7;
562
551
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
563
- return ((_this$db6 = this.#db) === null || _this$db6 === void 0 ? void 0 : _this$db6.tokens) && ((_this$db7 = this.#db) === null || _this$db7 === void 0 ? void 0 : _this$db7.tokens[this.tokenId]) || null;
552
+ return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
564
553
  }
565
554
  get decimals() {
566
- var _this$token;
567
- return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
555
+ return this.token?.decimals || null;
568
556
  }
569
557
  get rates() {
570
- var _this$db8;
571
- return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
558
+ return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
572
559
  }
573
560
 
574
561
  /**
@@ -582,18 +569,15 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
582
569
  }
583
570
  /** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
584
571
  get free() {
585
- var _this$storage$free;
586
- 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"));
572
+ 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"));
587
573
  }
588
574
  /** The reserved balance of this token. Is included in the total. */
589
575
  get reserved() {
590
- var _this$storage$reserve;
591
- 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"));
576
+ 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"));
592
577
  }
593
578
  /** The frozen balance of this token. Is included in the free amount. */
594
579
  get locked() {
595
- var _this$storage$locks;
596
- 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"));
580
+ 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"));
597
581
  }
598
582
  /** @depreacted - use balance.locked */
599
583
  get frozen() {
@@ -74,7 +74,7 @@ const db = new TalismanBalancesDatabase();
74
74
 
75
75
  var packageJson = {
76
76
  name: "@talismn/balances",
77
- version: "0.0.0-pr563-20230221193038",
77
+ version: "0.0.0-pr563-20230221230003",
78
78
  author: "Talisman",
79
79
  homepage: "https://talisman.xyz",
80
80
  license: "UNLICENSED",
@@ -107,7 +107,7 @@ var packageJson = {
107
107
  "@talismn/token-rates": "workspace:^",
108
108
  "@talismn/util": "workspace:^",
109
109
  anylogger: "^1.0.11",
110
- dexie: "^3.2.3",
110
+ dexie: "^3.2.2",
111
111
  lodash: "^4.17.21",
112
112
  "typescript-memoize": "^1.1.0"
113
113
  },
@@ -148,9 +148,8 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
148
148
  return await balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
149
149
  }
150
150
  const filterMirrorTokens = (balance, i, balances) => {
151
- var _balance$token;
152
151
  // TODO implement a mirrorOf property, which should be set from chaindata
153
- const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
152
+ const mirrorOf = balance.token?.mirrorOf;
154
153
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
155
154
  };
156
155
 
@@ -186,8 +185,7 @@ class StorageHelper {
186
185
  }
187
186
  }
188
187
  get stateKey() {
189
- var _this$storageKey;
190
- return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
188
+ return this.#storageKey?.toHex();
191
189
  }
192
190
  get module() {
193
191
  return this.#module;
@@ -442,10 +440,7 @@ let Balances = (_dec = typescriptMemoize.Memoize(), _dec2 = typescriptMemoize.Me
442
440
  * @returns A sorted array of the balances in this collection.
443
441
  */
444
442
  get sorted() {
445
- return [...this].sort((a, b) => {
446
- var _ref, _ref2;
447
- 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);
448
- });
443
+ return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER));
449
444
  }
450
445
 
451
446
  /**
@@ -510,10 +505,7 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
510
505
  hydrate = hydrate => {
511
506
  if (hydrate !== undefined) this.#db = hydrate;
512
507
  };
513
- #format = balance => {
514
- var _this$db;
515
- 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]);
516
- };
508
+ #format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
517
509
 
518
510
  //
519
511
  // Accessors
@@ -543,32 +535,27 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
543
535
  return this.#storage.chainId;
544
536
  }
545
537
  get chain() {
546
- var _this$db2, _this$db3;
547
- 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;
538
+ return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
548
539
  }
549
540
  get evmNetworkId() {
550
541
  return this.#storage.evmNetworkId;
551
542
  }
552
543
  get evmNetwork() {
553
- var _this$db4, _this$db5;
554
544
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
555
- return ((_this$db4 = this.#db) === null || _this$db4 === void 0 ? void 0 : _this$db4.evmNetworks) && ((_this$db5 = this.#db) === null || _this$db5 === void 0 ? void 0 : _this$db5.evmNetworks[this.evmNetworkId]) || null;
545
+ return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
556
546
  }
557
547
  get tokenId() {
558
548
  return this.#storage.tokenId;
559
549
  }
560
550
  get token() {
561
- var _this$db6, _this$db7;
562
551
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
563
- return ((_this$db6 = this.#db) === null || _this$db6 === void 0 ? void 0 : _this$db6.tokens) && ((_this$db7 = this.#db) === null || _this$db7 === void 0 ? void 0 : _this$db7.tokens[this.tokenId]) || null;
552
+ return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
564
553
  }
565
554
  get decimals() {
566
- var _this$token;
567
- return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
555
+ return this.token?.decimals || null;
568
556
  }
569
557
  get rates() {
570
- var _this$db8;
571
- return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
558
+ return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
572
559
  }
573
560
 
574
561
  /**
@@ -582,18 +569,15 @@ let Balance = (_dec4 = typescriptMemoize.Memoize(), _dec5 = typescriptMemoize.Me
582
569
  }
583
570
  /** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
584
571
  get free() {
585
- var _this$storage$free;
586
- 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"));
572
+ 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"));
587
573
  }
588
574
  /** The reserved balance of this token. Is included in the total. */
589
575
  get reserved() {
590
- var _this$storage$reserve;
591
- 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"));
576
+ 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"));
592
577
  }
593
578
  /** The frozen balance of this token. Is included in the free amount. */
594
579
  get locked() {
595
- var _this$storage$locks;
596
- 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"));
580
+ 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"));
597
581
  }
598
582
  /** @depreacted - use balance.locked */
599
583
  get frozen() {
@@ -65,7 +65,7 @@ const db = new TalismanBalancesDatabase();
65
65
 
66
66
  var packageJson = {
67
67
  name: "@talismn/balances",
68
- version: "0.0.0-pr563-20230221193038",
68
+ version: "0.0.0-pr563-20230221230003",
69
69
  author: "Talisman",
70
70
  homepage: "https://talisman.xyz",
71
71
  license: "UNLICENSED",
@@ -98,7 +98,7 @@ var packageJson = {
98
98
  "@talismn/token-rates": "workspace:^",
99
99
  "@talismn/util": "workspace:^",
100
100
  anylogger: "^1.0.11",
101
- dexie: "^3.2.3",
101
+ dexie: "^3.2.2",
102
102
  lodash: "^4.17.21",
103
103
  "typescript-memoize": "^1.1.0"
104
104
  },
@@ -139,9 +139,8 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
139
139
  return await balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
140
140
  }
141
141
  const filterMirrorTokens = (balance, i, balances) => {
142
- var _balance$token;
143
142
  // TODO implement a mirrorOf property, which should be set from chaindata
144
- const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
143
+ const mirrorOf = balance.token?.mirrorOf;
145
144
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
146
145
  };
147
146
 
@@ -177,8 +176,7 @@ class StorageHelper {
177
176
  }
178
177
  }
179
178
  get stateKey() {
180
- var _this$storageKey;
181
- return (_this$storageKey = this.#storageKey) === null || _this$storageKey === void 0 ? void 0 : _this$storageKey.toHex();
179
+ return this.#storageKey?.toHex();
182
180
  }
183
181
  get module() {
184
182
  return this.#module;
@@ -433,10 +431,7 @@ let Balances = (_dec = Memoize(), _dec2 = Memoize(), _dec3 = Memoize(), (_class
433
431
  * @returns A sorted array of the balances in this collection.
434
432
  */
435
433
  get sorted() {
436
- return [...this].sort((a, b) => {
437
- var _ref, _ref2;
438
- 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);
439
- });
434
+ return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER) - ((b.chain || b.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER));
440
435
  }
441
436
 
442
437
  /**
@@ -501,10 +496,7 @@ let Balance = (_dec4 = Memoize(), _dec5 = Memoize(), _dec6 = Memoize(), _dec7 =
501
496
  hydrate = hydrate => {
502
497
  if (hydrate !== undefined) this.#db = hydrate;
503
498
  };
504
- #format = balance => {
505
- var _this$db;
506
- 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]);
507
- };
499
+ #format = balance => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
508
500
 
509
501
  //
510
502
  // Accessors
@@ -534,32 +526,27 @@ let Balance = (_dec4 = Memoize(), _dec5 = Memoize(), _dec6 = Memoize(), _dec7 =
534
526
  return this.#storage.chainId;
535
527
  }
536
528
  get chain() {
537
- var _this$db2, _this$db3;
538
- 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;
529
+ return this.#db?.chains && this.chainId && this.#db?.chains[this.chainId] || null;
539
530
  }
540
531
  get evmNetworkId() {
541
532
  return this.#storage.evmNetworkId;
542
533
  }
543
534
  get evmNetwork() {
544
- var _this$db4, _this$db5;
545
535
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
546
- return ((_this$db4 = this.#db) === null || _this$db4 === void 0 ? void 0 : _this$db4.evmNetworks) && ((_this$db5 = this.#db) === null || _this$db5 === void 0 ? void 0 : _this$db5.evmNetworks[this.evmNetworkId]) || null;
536
+ return this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId] || null;
547
537
  }
548
538
  get tokenId() {
549
539
  return this.#storage.tokenId;
550
540
  }
551
541
  get token() {
552
- var _this$db6, _this$db7;
553
542
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
554
- return ((_this$db6 = this.#db) === null || _this$db6 === void 0 ? void 0 : _this$db6.tokens) && ((_this$db7 = this.#db) === null || _this$db7 === void 0 ? void 0 : _this$db7.tokens[this.tokenId]) || null;
543
+ return this.#db?.tokens && this.#db?.tokens[this.tokenId] || null;
555
544
  }
556
545
  get decimals() {
557
- var _this$token;
558
- return ((_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.decimals) || null;
546
+ return this.token?.decimals || null;
559
547
  }
560
548
  get rates() {
561
- var _this$db8;
562
- return ((_this$db8 = this.#db) === null || _this$db8 === void 0 ? void 0 : _this$db8.tokenRates) && this.#db.tokenRates[this.tokenId] || null;
549
+ return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
563
550
  }
564
551
 
565
552
  /**
@@ -573,18 +560,15 @@ let Balance = (_dec4 = Memoize(), _dec5 = Memoize(), _dec6 = Memoize(), _dec7 =
573
560
  }
574
561
  /** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
575
562
  get free() {
576
- var _this$storage$free;
577
- 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"));
563
+ 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"));
578
564
  }
579
565
  /** The reserved balance of this token. Is included in the total. */
580
566
  get reserved() {
581
- var _this$storage$reserve;
582
- 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"));
567
+ 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"));
583
568
  }
584
569
  /** The frozen balance of this token. Is included in the free amount. */
585
570
  get locked() {
586
- var _this$storage$locks;
587
- 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"));
571
+ 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"));
588
572
  }
589
573
  /** @depreacted - use balance.locked */
590
574
  get frozen() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr563-20230221193038",
3
+ "version": "0.0.0-pr563-20230221230003",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -33,7 +33,7 @@
33
33
  "@talismn/token-rates": "^0.1.14",
34
34
  "@talismn/util": "^0.1.7",
35
35
  "anylogger": "^1.0.11",
36
- "dexie": "^3.2.3",
36
+ "dexie": "^3.2.2",
37
37
  "lodash": "^4.17.21",
38
38
  "typescript-memoize": "^1.1.0"
39
39
  },