@talismn/balances 0.0.0-pr563-20230222052739 → 0.0.0-pr577-20230228061431

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