@swapkit/toolboxes 4.3.6 → 4.3.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.
Files changed (61) hide show
  1. package/dist/src/evm/index.cjs +2 -2
  2. package/dist/src/evm/index.cjs.map +7 -7
  3. package/dist/src/evm/index.js +2 -2
  4. package/dist/src/evm/index.js.map +7 -7
  5. package/dist/src/index.cjs +3 -3
  6. package/dist/src/index.cjs.map +13 -13
  7. package/dist/src/index.js +3 -3
  8. package/dist/src/index.js.map +13 -13
  9. package/dist/src/near/index.cjs +2 -2
  10. package/dist/src/near/index.cjs.map +3 -3
  11. package/dist/src/near/index.js +2 -2
  12. package/dist/src/near/index.js.map +3 -3
  13. package/dist/src/radix/index.cjs +2 -2
  14. package/dist/src/radix/index.cjs.map +3 -3
  15. package/dist/src/radix/index.js +2 -2
  16. package/dist/src/radix/index.js.map +3 -3
  17. package/dist/src/solana/index.cjs +2 -2
  18. package/dist/src/solana/index.cjs.map +3 -3
  19. package/dist/src/solana/index.js +2 -2
  20. package/dist/src/solana/index.js.map +3 -3
  21. package/dist/src/substrate/index.cjs +2 -2
  22. package/dist/src/substrate/index.cjs.map +3 -3
  23. package/dist/src/substrate/index.js +2 -2
  24. package/dist/src/substrate/index.js.map +3 -3
  25. package/dist/src/sui/index.cjs +2 -2
  26. package/dist/src/sui/index.cjs.map +3 -3
  27. package/dist/src/sui/index.js +2 -2
  28. package/dist/src/sui/index.js.map +3 -3
  29. package/dist/src/ton/index.cjs +2 -2
  30. package/dist/src/ton/index.cjs.map +3 -3
  31. package/dist/src/ton/index.js +2 -2
  32. package/dist/src/ton/index.js.map +3 -3
  33. package/dist/src/utxo/index.cjs +3 -3
  34. package/dist/src/utxo/index.cjs.map +4 -4
  35. package/dist/src/utxo/index.js +3 -3
  36. package/dist/src/utxo/index.js.map +4 -4
  37. package/dist/types/evm/helpers.d.ts +1 -1
  38. package/dist/types/evm/helpers.d.ts.map +1 -1
  39. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +2 -0
  40. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
  41. package/dist/types/evm/toolbox/evm.d.ts +38 -38
  42. package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
  43. package/dist/types/evm/toolbox/op.d.ts +2 -14
  44. package/dist/types/evm/toolbox/op.d.ts.map +1 -1
  45. package/dist/types/radix/index.d.ts.map +1 -1
  46. package/dist/types/solana/toolbox.d.ts.map +1 -1
  47. package/dist/types/sui/toolbox.d.ts.map +1 -1
  48. package/dist/types/utils.d.ts.map +1 -1
  49. package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
  50. package/package.json +2 -2
  51. package/src/evm/helpers.ts +7 -9
  52. package/src/evm/toolbox/baseEVMToolbox.ts +4 -1
  53. package/src/evm/toolbox/evm.ts +2 -3
  54. package/src/evm/toolbox/op.ts +1 -21
  55. package/src/radix/index.ts +7 -1
  56. package/src/solana/toolbox.ts +2 -8
  57. package/src/substrate/balance.ts +2 -2
  58. package/src/sui/toolbox.ts +4 -3
  59. package/src/ton/toolbox.ts +2 -2
  60. package/src/utils.ts +8 -1
  61. package/src/utxo/toolbox/zcash.ts +1 -4
@@ -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
 
@@ -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 (error) {
64
- throw new SwapKitError("toolbox_sui_balance_error" as any, { error });
64
+ } catch {
65
+ return [AssetValue.from({ chain })];
65
66
  }
66
67
  }
67
68
 
@@ -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 (error) {
56
- throw new SwapKitError("core_wallet_connection_not_found", { error });
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
- return balances.map(({ identifier, value, decimal }) => {
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
  }
@@ -145,10 +145,7 @@ async function createTransaction(buildTxParams: UTXOBuildTxParams) {
145
145
 
146
146
  const psbt = bitgo.createPsbtForNetwork({ network: getZcashNetwork() }, { version: 455 }) as ZcashPsbt;
147
147
 
148
- // const NU6 = 0xc8e71055;
149
- const NU5 = 0xc2d6d0b4;
150
- // const branchId = tipHeight >= 2726400 ? NU6 : tipHeight >= 1687104 ? NU5 : NU5;
151
- const branchId = NU5;
148
+ const branchId = 0x4dec4df0;
152
149
 
153
150
  const CONSENSUS_BRANCH_ID_KEY = Buffer.concat([Buffer.of(0xfc), Buffer.of(0x05), Buffer.from("BITGO"), Buffer.of(0)]);
154
151