@swapkit/toolboxes 4.3.7 → 4.3.9
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/src/evm/index.cjs +2 -2
- package/dist/src/evm/index.cjs.map +7 -7
- package/dist/src/evm/index.js +2 -2
- package/dist/src/evm/index.js.map +7 -7
- package/dist/src/index.cjs +3 -3
- package/dist/src/index.cjs.map +12 -12
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +12 -12
- package/dist/src/near/index.cjs +2 -2
- package/dist/src/near/index.cjs.map +3 -3
- package/dist/src/near/index.js +2 -2
- package/dist/src/near/index.js.map +3 -3
- package/dist/src/radix/index.cjs +2 -2
- package/dist/src/radix/index.cjs.map +3 -3
- package/dist/src/radix/index.js +2 -2
- package/dist/src/radix/index.js.map +3 -3
- package/dist/src/solana/index.cjs +2 -2
- package/dist/src/solana/index.cjs.map +3 -3
- package/dist/src/solana/index.js +2 -2
- package/dist/src/solana/index.js.map +3 -3
- package/dist/src/substrate/index.cjs +2 -2
- package/dist/src/substrate/index.cjs.map +3 -3
- package/dist/src/substrate/index.js +2 -2
- package/dist/src/substrate/index.js.map +3 -3
- package/dist/src/sui/index.cjs +2 -2
- package/dist/src/sui/index.cjs.map +3 -3
- package/dist/src/sui/index.js +2 -2
- package/dist/src/sui/index.js.map +3 -3
- package/dist/src/ton/index.cjs +2 -2
- package/dist/src/ton/index.cjs.map +3 -3
- package/dist/src/ton/index.js +2 -2
- package/dist/src/ton/index.js.map +3 -3
- package/dist/src/utxo/index.cjs +3 -3
- package/dist/src/utxo/index.cjs.map +3 -3
- package/dist/src/utxo/index.js +3 -3
- package/dist/src/utxo/index.js.map +3 -3
- package/dist/types/evm/helpers.d.ts +1 -1
- package/dist/types/evm/helpers.d.ts.map +1 -1
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +2 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
- package/dist/types/evm/toolbox/evm.d.ts +38 -38
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
- package/dist/types/evm/toolbox/op.d.ts +2 -14
- package/dist/types/evm/toolbox/op.d.ts.map +1 -1
- package/dist/types/radix/index.d.ts.map +1 -1
- package/dist/types/solana/toolbox.d.ts.map +1 -1
- package/dist/types/sui/toolbox.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cosmos/__tests__/toolbox.test.ts +8 -4
- package/src/evm/helpers.ts +7 -9
- package/src/evm/toolbox/baseEVMToolbox.ts +4 -1
- package/src/evm/toolbox/evm.ts +2 -3
- package/src/evm/toolbox/op.ts +1 -21
- package/src/radix/index.ts +7 -1
- package/src/solana/toolbox.ts +2 -8
- package/src/substrate/balance.ts +2 -2
- package/src/sui/__tests__/toolbox.test.ts +9 -5
- package/src/sui/toolbox.ts +4 -3
- package/src/ton/__tests__/toolbox.test.ts +9 -5
- package/src/ton/toolbox.ts +2 -2
- package/src/utils.ts +8 -1
package/src/substrate/balance.ts
CHANGED
|
@@ -29,7 +29,7 @@ export async function getSubstrateBalance(
|
|
|
29
29
|
} catch (error) {
|
|
30
30
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
31
31
|
console.error(`Error fetching substrate balance: ${errorMessage}`);
|
|
32
|
-
return [];
|
|
32
|
+
return [gasAsset.set(0)];
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -66,7 +66,7 @@ export async function getChainflipBalance(
|
|
|
66
66
|
} catch (error) {
|
|
67
67
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
68
68
|
console.error(`Error fetching chainflip balance: ${errorMessage}`);
|
|
69
|
-
return [];
|
|
69
|
+
return [gasAsset.set(0)];
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -42,11 +42,15 @@ describe("Sui Toolbox", () => {
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
test(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
test(
|
|
46
|
+
"should fetch balance for known address",
|
|
47
|
+
async () => {
|
|
48
|
+
const balances = await context.toolbox.getBalance(KNOWN_SUI_ADDRESS);
|
|
49
|
+
expect(balances[0]?.chain).toBe(Chain.Sui);
|
|
50
|
+
expect(balances[0]?.symbol).toBe("SUI");
|
|
51
|
+
},
|
|
52
|
+
{ retry: 3, timeout: 10000 },
|
|
53
|
+
);
|
|
50
54
|
|
|
51
55
|
test("should estimate transaction fee", async () => {
|
|
52
56
|
const fee = await context.toolbox.estimateTransactionFee();
|
package/src/sui/toolbox.ts
CHANGED
|
@@ -40,10 +40,11 @@ export async function getSuiToolbox({ provider: providerParam, ...signerParams }
|
|
|
40
40
|
throw new SwapKitError("toolbox_sui_address_required" as any);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const { baseDecimal: fromBaseDecimal, chain } = getChainConfig(Chain.Sui);
|
|
44
|
+
|
|
43
45
|
try {
|
|
44
46
|
const suiClient = await getSuiClient();
|
|
45
47
|
const { totalBalance } = await suiClient.getBalance({ owner: addressToQuery });
|
|
46
|
-
const { baseDecimal: fromBaseDecimal, chain } = getChainConfig(Chain.Sui);
|
|
47
48
|
|
|
48
49
|
const suiBalances = [AssetValue.from({ chain, fromBaseDecimal, value: totalBalance })];
|
|
49
50
|
|
|
@@ -60,8 +61,8 @@ export async function getSuiToolbox({ provider: providerParam, ...signerParams }
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
return suiBalances;
|
|
63
|
-
} catch
|
|
64
|
-
|
|
64
|
+
} catch {
|
|
65
|
+
return [AssetValue.from({ chain })];
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -39,11 +39,15 @@ describe("TON Toolbox", () => {
|
|
|
39
39
|
expect(context.toolbox.validateAddress(address)).toBe(true);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
test(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
test(
|
|
43
|
+
"should fetch balance for known address",
|
|
44
|
+
async () => {
|
|
45
|
+
const balances = await context.toolbox.getBalance(KNOWN_TON_ADDRESS);
|
|
46
|
+
expect(balances[0]?.chain).toBe(Chain.Ton);
|
|
47
|
+
expect(balances[0]?.symbol).toBe("TON");
|
|
48
|
+
},
|
|
49
|
+
{ retry: 3, timeout: 10000 },
|
|
50
|
+
);
|
|
47
51
|
|
|
48
52
|
test("should estimate transaction fee", async () => {
|
|
49
53
|
const fee = await context.toolbox.estimateTransactionFee();
|
package/src/ton/toolbox.ts
CHANGED
|
@@ -52,8 +52,8 @@ export async function getTONToolbox(toolboxParams: TONToolboxParams = {}) {
|
|
|
52
52
|
try {
|
|
53
53
|
const balance = await client.getBalance(Address.parse(address));
|
|
54
54
|
return [AssetValue.from({ chain: Chain.Ton, value: SwapKitNumber.fromBigInt(balance, baseDecimal) })];
|
|
55
|
-
} catch
|
|
56
|
-
|
|
55
|
+
} catch {
|
|
56
|
+
return [AssetValue.from({ chain: Chain.Ton })];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
package/src/utils.ts
CHANGED
|
@@ -20,8 +20,15 @@ export function getBalance<T extends Chain>(chain: T) {
|
|
|
20
20
|
return async function getBalance(address: string, scamFilter = true) {
|
|
21
21
|
const balances = await SwapKitApi.getChainBalance({ address, chain, scamFilter });
|
|
22
22
|
const { baseDecimal } = getChainConfig(chain);
|
|
23
|
-
|
|
23
|
+
const assetValues = balances.map(({ identifier, value, decimal }) => {
|
|
24
24
|
return new AssetValue({ decimal: decimal || baseDecimal, identifier, value });
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
const hasNativeAsset = assetValues.some((asset) => asset.isGasAsset);
|
|
28
|
+
if (!hasNativeAsset) {
|
|
29
|
+
return [AssetValue.from({ chain }), ...assetValues];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return assetValues;
|
|
26
33
|
};
|
|
27
34
|
}
|