@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.cjs +17 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/xchains/sui/SuiXService.ts +20 -10
|
@@ -22,14 +22,10 @@ export class SuiXService extends XService {
|
|
|
22
22
|
|
|
23
23
|
// getBalance is not used because getBalances uses getAllBalances which returns all balances
|
|
24
24
|
|
|
25
|
-
async getBalances(address: string | undefined, xTokens: XToken[]) {
|
|
25
|
+
async getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>> {
|
|
26
26
|
if (!address) return {};
|
|
27
|
-
|
|
28
27
|
try {
|
|
29
|
-
const
|
|
30
|
-
owner: address,
|
|
31
|
-
});
|
|
32
|
-
const tokenMap = xTokens.reduce((map, xToken) => {
|
|
28
|
+
const balancePromises = xTokens.map(async xToken => {
|
|
33
29
|
let coinType = isNativeToken(xToken) ? '0x2::sui::SUI' : xToken.address;
|
|
34
30
|
|
|
35
31
|
// TODO: hard coded for getting legacy bnUSD balance
|
|
@@ -41,11 +37,25 @@ export class SuiXService extends XService {
|
|
|
41
37
|
'0x3917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR';
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
const balance =
|
|
40
|
+
const balance = await this.suiClient.getBalance({
|
|
41
|
+
owner: address,
|
|
42
|
+
coinType: coinType,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
address: xToken.address,
|
|
47
|
+
balance: balance ? BigInt(balance.totalBalance) : undefined,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const results = await Promise.all(balancePromises);
|
|
52
|
+
|
|
53
|
+
const tokenMap: Record<string, bigint> = {};
|
|
54
|
+
results.forEach(result => {
|
|
55
|
+
if (result.balance !== undefined) {
|
|
56
|
+
tokenMap[result.address] = result.balance;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
49
59
|
|
|
50
60
|
return tokenMap;
|
|
51
61
|
} catch (e) {
|