@talismn/balances 0.0.0-pr2075-20250709170044 → 0.0.0-pr2075-20250710034303

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.
@@ -6488,7 +6488,10 @@ class BalancesProvider {
6488
6488
  status: !isStale && results.some(({
6489
6489
  status
6490
6490
  }) => status === "initialising") ? "initialising" : "live",
6491
- balances: results.flatMap(result => result.balances).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6491
+ balances: results.flatMap(result => result.balances.map(b => isStale && b.status !== "live" ? {
6492
+ ...b,
6493
+ status: "stale"
6494
+ } : b)).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6492
6495
  })), rxjs.startWith({
6493
6496
  status: "initialising",
6494
6497
  balances: this.getStoredBalances(addressesByTokenId)
@@ -6530,7 +6533,12 @@ class BalancesProvider {
6530
6533
  const storage = this.#storage.getValue();
6531
6534
  const balances = lodash.assign({}, storage.balances,
6532
6535
  // delete all balances expected in the result set. because if they are not present it means they are empty.
6533
- lodash.fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), lodash.keyBy(results.balances, b => getBalanceId(b)));
6536
+ lodash.fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), lodash.keyBy(
6537
+ // storage balances must have status "cache", because they are used as start value when initialising subsequent subscriptions
6538
+ results.balances.map(b => ({
6539
+ ...b,
6540
+ status: "cache"
6541
+ })), b => getBalanceId(b)));
6534
6542
  this.#storage.next(lodash.assign({}, storage, {
6535
6543
  balances
6536
6544
  }));
@@ -6488,7 +6488,10 @@ class BalancesProvider {
6488
6488
  status: !isStale && results.some(({
6489
6489
  status
6490
6490
  }) => status === "initialising") ? "initialising" : "live",
6491
- balances: results.flatMap(result => result.balances).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6491
+ balances: results.flatMap(result => result.balances.map(b => isStale && b.status !== "live" ? {
6492
+ ...b,
6493
+ status: "stale"
6494
+ } : b)).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6492
6495
  })), rxjs.startWith({
6493
6496
  status: "initialising",
6494
6497
  balances: this.getStoredBalances(addressesByTokenId)
@@ -6530,7 +6533,12 @@ class BalancesProvider {
6530
6533
  const storage = this.#storage.getValue();
6531
6534
  const balances = lodash.assign({}, storage.balances,
6532
6535
  // delete all balances expected in the result set. because if they are not present it means they are empty.
6533
- lodash.fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), lodash.keyBy(results.balances, b => getBalanceId(b)));
6536
+ lodash.fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), lodash.keyBy(
6537
+ // storage balances must have status "cache", because they are used as start value when initialising subsequent subscriptions
6538
+ results.balances.map(b => ({
6539
+ ...b,
6540
+ status: "cache"
6541
+ })), b => getBalanceId(b)));
6534
6542
  this.#storage.next(lodash.assign({}, storage, {
6535
6543
  balances
6536
6544
  }));
@@ -6479,7 +6479,10 @@ class BalancesProvider {
6479
6479
  status: !isStale && results.some(({
6480
6480
  status
6481
6481
  }) => status === "initialising") ? "initialising" : "live",
6482
- balances: results.flatMap(result => result.balances).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6482
+ balances: results.flatMap(result => result.balances.map(b => isStale && b.status !== "live" ? {
6483
+ ...b,
6484
+ status: "stale"
6485
+ } : b)).sort((a, b) => getBalanceId(a).localeCompare(getBalanceId(b)))
6483
6486
  })), startWith({
6484
6487
  status: "initialising",
6485
6488
  balances: this.getStoredBalances(addressesByTokenId)
@@ -6521,7 +6524,12 @@ class BalancesProvider {
6521
6524
  const storage = this.#storage.getValue();
6522
6525
  const balances = assign({}, storage.balances,
6523
6526
  // delete all balances expected in the result set. because if they are not present it means they are empty.
6524
- fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), keyBy(results.balances, b => getBalanceId(b)));
6527
+ fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), keyBy(
6528
+ // storage balances must have status "cache", because they are used as start value when initialising subsequent subscriptions
6529
+ results.balances.map(b => ({
6530
+ ...b,
6531
+ status: "cache"
6532
+ })), b => getBalanceId(b)));
6525
6533
  this.#storage.next(assign({}, storage, {
6526
6534
  balances
6527
6535
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr2075-20250709170044",
3
+ "version": "0.0.0-pr2075-20250710034303",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -34,13 +34,13 @@
34
34
  "scale-ts": "^1.6.1",
35
35
  "viem": "^2.27.3",
36
36
  "zod": "^3.25.62",
37
- "@talismn/chain-connector-evm": "0.0.0-pr2075-20250709170044",
38
- "@talismn/chain-connector": "0.0.0-pr2075-20250709170044",
39
- "@talismn/sapi": "0.0.0-pr2075-20250709170044",
40
- "@talismn/scale": "0.0.0-pr2075-20250709170044",
41
- "@talismn/token-rates": "0.0.0-pr2075-20250709170044",
42
- "@talismn/util": "0.0.0-pr2075-20250709170044",
43
- "@talismn/chaindata-provider": "0.0.0-pr2075-20250709170044"
37
+ "@talismn/chain-connector": "0.0.0-pr2075-20250710034303",
38
+ "@talismn/chain-connector-evm": "0.0.0-pr2075-20250710034303",
39
+ "@talismn/chaindata-provider": "0.0.0-pr2075-20250710034303",
40
+ "@talismn/sapi": "0.0.0-pr2075-20250710034303",
41
+ "@talismn/scale": "0.0.0-pr2075-20250710034303",
42
+ "@talismn/token-rates": "0.0.0-pr2075-20250710034303",
43
+ "@talismn/util": "0.0.0-pr2075-20250710034303"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@polkadot/api-contract": "16.1.2",