@talismn/balances 0.0.0-pr2075-20250714084622 → 0.0.0-pr2075-20250714100401

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.
@@ -6305,7 +6305,7 @@ class BalancesProvider {
6305
6305
  getNetworkBalances$(networkId, addressesByTokenId) {
6306
6306
  const network$ = this.#chaindataProvider.getNetworkById$(networkId);
6307
6307
  const tokensMapById$ = this.#chaindataProvider.getTokensMapById$();
6308
- const networkBalances$ = rxjs.combineLatest([network$, tokensMapById$]).pipe(rxjs.switchMap(([network, tokensMapById]) => {
6308
+ return rxjs.combineLatest([network$, tokensMapById$]).pipe(rxjs.switchMap(([network, tokensMapById]) => {
6309
6309
  const tokensAndAddresses = lodashEs.toPairs(addressesByTokenId).map(([tokenId, addresses]) => [tokensMapById[tokenId], addresses]);
6310
6310
  return rxjs.combineLatest(BALANCE_MODULES.filter(mod => mod.platform === network?.platform).map(mod => {
6311
6311
  const tokensWithAddresses = tokensAndAddresses.filter(([token]) => token.type === mod.type);
@@ -6328,12 +6328,6 @@ class BalancesProvider {
6328
6328
  balances: results.flatMap(result => result.balances).sort(sortByBalanceId)
6329
6329
  };
6330
6330
  }), rxjs.distinctUntilChanged(lodashEs.isEqual));
6331
-
6332
- // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6333
- return rxjs.defer(() => networkBalances$.pipe(rxjs.startWith({
6334
- status: "initialising",
6335
- balances: this.getStoredBalances(addressesByTokenId)
6336
- })));
6337
6331
  }
6338
6332
  getPolkadotNetworkModuleBalances$(networkId, tokensWithAddresses, mod) {
6339
6333
  return util.getSharedObservable(`BalancesProvider.getPolkadotNetworkModuleBalances$`, {
@@ -6372,7 +6366,9 @@ class BalancesProvider {
6372
6366
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6373
6367
  })), rxjs.tap(results => {
6374
6368
  this.updateStorage$(balanceIds, results);
6375
- }), rxjs.shareReplay({
6369
+ }),
6370
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6371
+ rxjs.shareReplay({
6376
6372
  refCount: true,
6377
6373
  bufferSize: 1
6378
6374
  }), util.keepAlive(0));
@@ -6420,7 +6416,9 @@ class BalancesProvider {
6420
6416
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6421
6417
  })), rxjs.tap(results => {
6422
6418
  this.updateStorage$(balanceIds, results);
6423
- }), rxjs.shareReplay({
6419
+ }),
6420
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6421
+ rxjs.shareReplay({
6424
6422
  refCount: true,
6425
6423
  bufferSize: 1
6426
6424
  }), util.keepAlive(0));
@@ -6305,7 +6305,7 @@ class BalancesProvider {
6305
6305
  getNetworkBalances$(networkId, addressesByTokenId) {
6306
6306
  const network$ = this.#chaindataProvider.getNetworkById$(networkId);
6307
6307
  const tokensMapById$ = this.#chaindataProvider.getTokensMapById$();
6308
- const networkBalances$ = rxjs.combineLatest([network$, tokensMapById$]).pipe(rxjs.switchMap(([network, tokensMapById]) => {
6308
+ return rxjs.combineLatest([network$, tokensMapById$]).pipe(rxjs.switchMap(([network, tokensMapById]) => {
6309
6309
  const tokensAndAddresses = lodashEs.toPairs(addressesByTokenId).map(([tokenId, addresses]) => [tokensMapById[tokenId], addresses]);
6310
6310
  return rxjs.combineLatest(BALANCE_MODULES.filter(mod => mod.platform === network?.platform).map(mod => {
6311
6311
  const tokensWithAddresses = tokensAndAddresses.filter(([token]) => token.type === mod.type);
@@ -6328,12 +6328,6 @@ class BalancesProvider {
6328
6328
  balances: results.flatMap(result => result.balances).sort(sortByBalanceId)
6329
6329
  };
6330
6330
  }), rxjs.distinctUntilChanged(lodashEs.isEqual));
6331
-
6332
- // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6333
- return rxjs.defer(() => networkBalances$.pipe(rxjs.startWith({
6334
- status: "initialising",
6335
- balances: this.getStoredBalances(addressesByTokenId)
6336
- })));
6337
6331
  }
6338
6332
  getPolkadotNetworkModuleBalances$(networkId, tokensWithAddresses, mod) {
6339
6333
  return util.getSharedObservable(`BalancesProvider.getPolkadotNetworkModuleBalances$`, {
@@ -6372,7 +6366,9 @@ class BalancesProvider {
6372
6366
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6373
6367
  })), rxjs.tap(results => {
6374
6368
  this.updateStorage$(balanceIds, results);
6375
- }), rxjs.shareReplay({
6369
+ }),
6370
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6371
+ rxjs.shareReplay({
6376
6372
  refCount: true,
6377
6373
  bufferSize: 1
6378
6374
  }), util.keepAlive(0));
@@ -6420,7 +6416,9 @@ class BalancesProvider {
6420
6416
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6421
6417
  })), rxjs.tap(results => {
6422
6418
  this.updateStorage$(balanceIds, results);
6423
- }), rxjs.shareReplay({
6419
+ }),
6420
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6421
+ rxjs.shareReplay({
6424
6422
  refCount: true,
6425
6423
  bufferSize: 1
6426
6424
  }), util.keepAlive(0));
@@ -6296,7 +6296,7 @@ class BalancesProvider {
6296
6296
  getNetworkBalances$(networkId, addressesByTokenId) {
6297
6297
  const network$ = this.#chaindataProvider.getNetworkById$(networkId);
6298
6298
  const tokensMapById$ = this.#chaindataProvider.getTokensMapById$();
6299
- const networkBalances$ = combineLatest([network$, tokensMapById$]).pipe(switchMap(([network, tokensMapById]) => {
6299
+ return combineLatest([network$, tokensMapById$]).pipe(switchMap(([network, tokensMapById]) => {
6300
6300
  const tokensAndAddresses = toPairs(addressesByTokenId).map(([tokenId, addresses]) => [tokensMapById[tokenId], addresses]);
6301
6301
  return combineLatest(BALANCE_MODULES.filter(mod => mod.platform === network?.platform).map(mod => {
6302
6302
  const tokensWithAddresses = tokensAndAddresses.filter(([token]) => token.type === mod.type);
@@ -6319,12 +6319,6 @@ class BalancesProvider {
6319
6319
  balances: results.flatMap(result => result.balances).sort(sortByBalanceId)
6320
6320
  };
6321
6321
  }), distinctUntilChanged(isEqual));
6322
-
6323
- // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6324
- return defer(() => networkBalances$.pipe(startWith({
6325
- status: "initialising",
6326
- balances: this.getStoredBalances(addressesByTokenId)
6327
- })));
6328
6322
  }
6329
6323
  getPolkadotNetworkModuleBalances$(networkId, tokensWithAddresses, mod) {
6330
6324
  return getSharedObservable(`BalancesProvider.getPolkadotNetworkModuleBalances$`, {
@@ -6363,7 +6357,9 @@ class BalancesProvider {
6363
6357
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6364
6358
  })), tap(results => {
6365
6359
  this.updateStorage$(balanceIds, results);
6366
- }), shareReplay({
6360
+ }),
6361
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6362
+ shareReplay({
6367
6363
  refCount: true,
6368
6364
  bufferSize: 1
6369
6365
  }), keepAlive(0));
@@ -6411,7 +6407,9 @@ class BalancesProvider {
6411
6407
  balances: results.success.filter(b => new Balance(b).total.planck > 0n)
6412
6408
  })), tap(results => {
6413
6409
  this.updateStorage$(balanceIds, results);
6414
- }), shareReplay({
6410
+ }),
6411
+ // shareReplay + keepAlive(0) keep the subscription alive while root observable is being unsubscribed+resubscribed, in case any input change
6412
+ shareReplay({
6415
6413
  refCount: true,
6416
6414
  bufferSize: 1
6417
6415
  }), keepAlive(0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr2075-20250714084622",
3
+ "version": "0.0.0-pr2075-20250714100401",
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": "0.0.0-pr2075-20250714084622",
38
- "@talismn/token-rates": "0.0.0-pr2075-20250714084622",
39
- "@talismn/chaindata-provider": "0.0.0-pr2075-20250714084622",
40
- "@talismn/chain-connector-evm": "0.0.0-pr2075-20250714084622",
41
- "@talismn/sapi": "0.0.0-pr2075-20250714084622",
42
- "@talismn/util": "0.0.0-pr2075-20250714084622",
43
- "@talismn/scale": "0.0.0-pr2075-20250714084622"
37
+ "@talismn/chain-connector": "0.0.0-pr2075-20250714100401",
38
+ "@talismn/chain-connector-evm": "0.0.0-pr2075-20250714100401",
39
+ "@talismn/scale": "0.0.0-pr2075-20250714100401",
40
+ "@talismn/chaindata-provider": "0.0.0-pr2075-20250714100401",
41
+ "@talismn/token-rates": "0.0.0-pr2075-20250714100401",
42
+ "@talismn/sapi": "0.0.0-pr2075-20250714100401",
43
+ "@talismn/util": "0.0.0-pr2075-20250714100401"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@polkadot/api-contract": "16.1.2",