@sodax/wallet-sdk-react 1.0.0-rc.7 → 1.0.0-rc.8

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.d.cts CHANGED
@@ -258,7 +258,7 @@ declare class SuiXService extends XService {
258
258
  suiAccount: any;
259
259
  private constructor();
260
260
  static getInstance(): SuiXService;
261
- getBalances(address: string | undefined, xTokens: XToken[]): Promise<{}>;
261
+ getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
262
262
  }
263
263
 
264
264
  declare class SuiXConnector extends XConnector {
package/dist/index.d.ts CHANGED
@@ -258,7 +258,7 @@ declare class SuiXService extends XService {
258
258
  suiAccount: any;
259
259
  private constructor();
260
260
  static getInstance(): SuiXService;
261
- getBalances(address: string | undefined, xTokens: XToken[]): Promise<{}>;
261
+ getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>>;
262
262
  }
263
263
 
264
264
  declare class SuiXConnector extends XConnector {
package/dist/index.mjs CHANGED
@@ -711,18 +711,27 @@ var SuiXService = class _SuiXService extends XService {
711
711
  async getBalances(address, xTokens) {
712
712
  if (!address) return {};
713
713
  try {
714
- const allBalances = await this.suiClient.getAllBalances({
715
- owner: address
716
- });
717
- const tokenMap = xTokens.reduce((map, xToken) => {
714
+ const balancePromises = xTokens.map(async (xToken) => {
718
715
  let coinType = isNativeToken(xToken) ? "0x2::sui::SUI" : xToken.address;
719
716
  if (coinType === "0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR") {
720
717
  coinType = "0x3917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR";
721
718
  }
722
- const balance = allBalances.find((b) => b.coinType === coinType);
723
- if (balance) map[xToken.address] = balance.totalBalance;
724
- return map;
725
- }, {});
719
+ const balance = await this.suiClient.getBalance({
720
+ owner: address,
721
+ coinType
722
+ });
723
+ return {
724
+ address: xToken.address,
725
+ balance: balance ? BigInt(balance.totalBalance) : void 0
726
+ };
727
+ });
728
+ const results = await Promise.all(balancePromises);
729
+ const tokenMap = {};
730
+ results.forEach((result) => {
731
+ if (result.balance !== void 0) {
732
+ tokenMap[result.address] = result.balance;
733
+ }
734
+ });
726
735
  return tokenMap;
727
736
  } catch (e) {
728
737
  console.log("error", e);