aftermath-ts-sdk 3.2.0 → 3.3.0-dev.3728026

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/dist/index.js CHANGED
@@ -23419,30 +23419,18 @@ var init_walletApi = __esm({
23419
23419
  // TODO: return prices here as well and sort ?
23420
23420
  this.fetchAllCoinBalances = async (inputs) => {
23421
23421
  const { walletAddress } = inputs;
23422
- const allBalances = [];
23422
+ const coinsToBalance = {};
23423
23423
  let cursor;
23424
23424
  do {
23425
23425
  const page = await this.api.client.listBalances({
23426
23426
  owner: walletAddress,
23427
23427
  cursor
23428
23428
  });
23429
- allBalances.push(...page.balances);
23430
- if (page.balances.length === 0 || !page.hasNextPage || !page.cursor) {
23431
- break;
23429
+ for (const balance of page.balances) {
23430
+ coinsToBalance[Helpers.addLeadingZeroesToType(balance.coinType)] = BigInt(balance.balance);
23432
23431
  }
23433
- cursor = page.cursor;
23434
- } while (true);
23435
- const coinsToBalance = allBalances.reduce(
23436
- (acc, balance) => {
23437
- return {
23438
- ...acc,
23439
- [Helpers.addLeadingZeroesToType(balance.coinType)]: BigInt(
23440
- balance.balance
23441
- )
23442
- };
23443
- },
23444
- {}
23445
- );
23432
+ cursor = page.balances.length > 0 && page.hasNextPage && page.cursor ? page.cursor : void 0;
23433
+ } while (cursor !== void 0);
23446
23434
  return coinsToBalance;
23447
23435
  };
23448
23436
  // =========================================================================