@skip-go/client 1.3.0 → 1.3.2

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 (148) hide show
  1. package/dist/cjs/api/getAssets.cjs +16 -0
  2. package/dist/cjs/api/getAssetsBetweenChains.cjs +12 -0
  3. package/dist/cjs/api/getBridges.cjs +12 -0
  4. package/dist/cjs/api/getChains.cjs +12 -0
  5. package/dist/cjs/api/getVenues.cjs +12 -0
  6. package/dist/cjs/api/postAssetsFromSource.cjs +13 -0
  7. package/dist/cjs/api/postBalances.cjs +12 -0
  8. package/dist/cjs/api/postIbcOriginAssets.cjs +12 -0
  9. package/dist/cjs/api/postMessages.cjs +12 -0
  10. package/dist/cjs/api/postMessagesDirect.cjs +12 -0
  11. package/dist/cjs/api/postRecommendAssets.cjs +12 -0
  12. package/dist/cjs/api/postRoute.cjs +12 -0
  13. package/dist/cjs/api/postSubmit.cjs +12 -0
  14. package/dist/cjs/api/postSubmitTransaction.cjs +12 -0
  15. package/dist/cjs/api/postTrackTransaction.cjs +12 -0
  16. package/dist/cjs/api/postTransactionStatus.cjs +12 -0
  17. package/dist/cjs/chunk-4R6OCWRR.cjs +1346 -0
  18. package/dist/cjs/chunk-5FR25GF5.cjs +209 -0
  19. package/dist/cjs/chunk-AHRSARNR.cjs +38 -0
  20. package/dist/cjs/chunk-CWUD7UGL.cjs +13 -0
  21. package/dist/cjs/chunk-D2W4UBJB.cjs +136 -0
  22. package/dist/cjs/chunk-DUJSZRFD.cjs +1445 -0
  23. package/dist/cjs/chunk-EINQFLWN.cjs +12 -0
  24. package/dist/cjs/chunk-EQBTNGJJ.cjs +11 -0
  25. package/dist/cjs/chunk-F3EB2AQG.cjs +28 -0
  26. package/dist/cjs/chunk-G3G6PBIF.cjs +47 -0
  27. package/dist/cjs/chunk-HDKNPB2J.cjs +182 -0
  28. package/dist/cjs/chunk-IDDRJJO5.cjs +567 -0
  29. package/dist/cjs/chunk-KMDNP6DN.cjs +24 -0
  30. package/dist/cjs/chunk-KZOSEIWH.cjs +10 -0
  31. package/dist/cjs/chunk-MGYSCMET.cjs +273 -0
  32. package/dist/cjs/chunk-N3LR7KTI.cjs +304 -0
  33. package/dist/cjs/chunk-NQR3EPN2.cjs +12 -0
  34. package/dist/cjs/chunk-OA5PE7TW.cjs +18 -0
  35. package/dist/cjs/chunk-PFCGKAXF.cjs +15 -0
  36. package/dist/cjs/chunk-PG7RVHOU.cjs +12 -0
  37. package/dist/cjs/chunk-RFBDXALX.cjs +12 -0
  38. package/dist/cjs/chunk-SIY2K7TT.cjs +13 -0
  39. package/dist/cjs/chunk-SLZCWA4K.cjs +2234 -0
  40. package/dist/cjs/chunk-T5LPU5A2.cjs +188 -0
  41. package/dist/cjs/chunk-TCQMGBFL.cjs +38 -0
  42. package/dist/cjs/chunk-TFL5E5A6.cjs +12 -0
  43. package/dist/cjs/chunk-TWPLCFOH.cjs +16 -0
  44. package/dist/cjs/chunk-W2DPDT3Y.cjs +22 -0
  45. package/dist/cjs/chunk-WE7KICKO.cjs +95 -0
  46. package/dist/cjs/chunk-WMXUOVHN.cjs +3642 -0
  47. package/dist/cjs/index.cjs +402 -0
  48. package/dist/cjs/public-functions/executeRoute.cjs +28 -0
  49. package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +15 -0
  50. package/dist/cjs/public-functions/getEvmGasAmountForMessage.cjs +11 -0
  51. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +15 -0
  52. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +17 -0
  53. package/dist/cjs/public-functions/getSigningStargateClient.cjs +14 -0
  54. package/dist/cjs/public-functions/setApiOptions.cjs +12 -0
  55. package/dist/cjs/public-functions/setClientOptions.cjs +14 -0
  56. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +18 -0
  57. package/dist/cjs/public-functions/waitForTransaction.cjs +14 -0
  58. package/dist/{api → esm/api}/getAssets.d.ts +1 -1
  59. package/dist/{api → esm/api}/getAssets.js +1 -1
  60. package/dist/{api → esm/api}/getAssetsBetweenChains.d.ts +1 -1
  61. package/dist/{api → esm/api}/getAssetsBetweenChains.js +1 -1
  62. package/dist/{api → esm/api}/getBridges.d.ts +1 -1
  63. package/dist/{api → esm/api}/getBridges.js +1 -1
  64. package/dist/{api → esm/api}/getChains.d.ts +1 -1
  65. package/dist/{api → esm/api}/getChains.js +1 -1
  66. package/dist/{api → esm/api}/getVenues.js +1 -1
  67. package/dist/{api → esm/api}/postAssetsFromSource.d.ts +1 -1
  68. package/dist/{api → esm/api}/postAssetsFromSource.js +1 -1
  69. package/dist/{api → esm/api}/postBalances.d.ts +2 -2
  70. package/dist/{api → esm/api}/postBalances.js +1 -1
  71. package/dist/{api → esm/api}/postIbcOriginAssets.js +1 -1
  72. package/dist/{api → esm/api}/postMessages.d.ts +2 -2
  73. package/dist/{api → esm/api}/postMessages.js +1 -1
  74. package/dist/{api → esm/api}/postMessagesDirect.d.ts +2 -2
  75. package/dist/{api → esm/api}/postMessagesDirect.js +1 -1
  76. package/dist/{api → esm/api}/postRecommendAssets.d.ts +1 -1
  77. package/dist/{api → esm/api}/postRecommendAssets.js +1 -1
  78. package/dist/{api → esm/api}/postRoute.d.ts +3 -3
  79. package/dist/{api → esm/api}/postRoute.js +1 -1
  80. package/dist/{api → esm/api}/postSubmit.d.ts +2 -2
  81. package/dist/{api → esm/api}/postSubmit.js +1 -1
  82. package/dist/{api → esm/api}/postSubmitTransaction.js +1 -1
  83. package/dist/{api → esm/api}/postTrackTransaction.d.ts +2 -2
  84. package/dist/{api → esm/api}/postTrackTransaction.js +1 -1
  85. package/dist/{api → esm/api}/postTransactionStatus.d.ts +2 -2
  86. package/dist/{api → esm/api}/postTransactionStatus.js +1 -1
  87. package/dist/{callbacks-DK2GxU0a.d.ts → esm/callbacks-DGLv2hr0.d.ts} +6 -1
  88. package/dist/{chunk-HIJ6YOTK.js → esm/chunk-HAGMHUOI.js} +20 -4
  89. package/dist/{chunk-KYLULQOS.js → esm/chunk-OQDBWVET.js} +1 -0
  90. package/dist/{client-types-DuWWc2_J.d.ts → esm/client-types-CSzTHcG9.d.ts} +1 -1
  91. package/dist/{generateApi-DvFEIUee.d.ts → esm/generateApi-Bfli9ipj.d.ts} +1 -1
  92. package/dist/{index.d.ts → esm/index.d.ts} +19 -6
  93. package/dist/{index.js → esm/index.js} +3 -2
  94. package/dist/{public-functions → esm/public-functions}/executeRoute.d.ts +4 -4
  95. package/dist/{public-functions → esm/public-functions}/executeRoute.js +2 -2
  96. package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.d.ts +1 -1
  97. package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.d.ts +2 -2
  98. package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.js +1 -1
  99. package/dist/{public-functions → esm/public-functions}/getFeeInfoForChain.d.ts +1 -1
  100. package/dist/{public-functions → esm/public-functions}/getFeeInfoForChain.js +1 -1
  101. package/dist/{public-functions → esm/public-functions}/getRecommendedGasPrice.js +1 -1
  102. package/dist/{public-functions → esm/public-functions}/getSigningStargateClient.js +1 -1
  103. package/dist/{public-functions → esm/public-functions}/setApiOptions.d.ts +1 -1
  104. package/dist/{public-functions → esm/public-functions}/setApiOptions.js +1 -1
  105. package/dist/{public-functions → esm/public-functions}/setClientOptions.d.ts +3 -3
  106. package/dist/{public-functions → esm/public-functions}/setClientOptions.js +1 -1
  107. package/dist/{public-functions → esm/public-functions}/validateCosmosGasBalance.d.ts +4 -4
  108. package/dist/{public-functions → esm/public-functions}/validateCosmosGasBalance.js +1 -1
  109. package/dist/{public-functions → esm/public-functions}/waitForTransaction.d.ts +3 -3
  110. package/dist/{public-functions → esm/public-functions}/waitForTransaction.js +1 -1
  111. package/dist/{setClientOptions-B27lt_6h.d.ts → esm/setClientOptions-RMgGQ1KD.d.ts} +1 -1
  112. package/dist/{swaggerTypes-BrC-ZYnx.d.ts → esm/swaggerTypes-BIYUp1AO.d.ts} +14 -1
  113. package/package.json +19 -7
  114. /package/dist/{api → esm/api}/getVenues.d.ts +0 -0
  115. /package/dist/{api → esm/api}/postIbcOriginAssets.d.ts +0 -0
  116. /package/dist/{api → esm/api}/postSubmitTransaction.d.ts +0 -0
  117. /package/dist/{apiState-DwZhwVul.d.ts → esm/apiState-DwZhwVul.d.ts} +0 -0
  118. /package/dist/{chunk-2R5COFPS.js → esm/chunk-2R5COFPS.js} +0 -0
  119. /package/dist/{chunk-43P4WRGN.js → esm/chunk-43P4WRGN.js} +0 -0
  120. /package/dist/{chunk-4DI7G6TH.js → esm/chunk-4DI7G6TH.js} +0 -0
  121. /package/dist/{chunk-6ULKULTX.js → esm/chunk-6ULKULTX.js} +0 -0
  122. /package/dist/{chunk-6UMMVC2P.js → esm/chunk-6UMMVC2P.js} +0 -0
  123. /package/dist/{chunk-7ZG7HNNC.js → esm/chunk-7ZG7HNNC.js} +0 -0
  124. /package/dist/{chunk-C6NHVJ3R.js → esm/chunk-C6NHVJ3R.js} +0 -0
  125. /package/dist/{chunk-CGZ5DA2T.js → esm/chunk-CGZ5DA2T.js} +0 -0
  126. /package/dist/{chunk-ERPZHRBM.js → esm/chunk-ERPZHRBM.js} +0 -0
  127. /package/dist/{chunk-F65QOYUA.js → esm/chunk-F65QOYUA.js} +0 -0
  128. /package/dist/{chunk-GOD6ESBZ.js → esm/chunk-GOD6ESBZ.js} +0 -0
  129. /package/dist/{chunk-GV2QOWB4.js → esm/chunk-GV2QOWB4.js} +0 -0
  130. /package/dist/{chunk-HS2D6FKN.js → esm/chunk-HS2D6FKN.js} +0 -0
  131. /package/dist/{chunk-I4AMZAHH.js → esm/chunk-I4AMZAHH.js} +0 -0
  132. /package/dist/{chunk-MAOMQHG5.js → esm/chunk-MAOMQHG5.js} +0 -0
  133. /package/dist/{chunk-NZVZH6OA.js → esm/chunk-NZVZH6OA.js} +0 -0
  134. /package/dist/{chunk-PIQZD2VE.js → esm/chunk-PIQZD2VE.js} +0 -0
  135. /package/dist/{chunk-QPJEHGY7.js → esm/chunk-QPJEHGY7.js} +0 -0
  136. /package/dist/{chunk-SS5LQKBL.js → esm/chunk-SS5LQKBL.js} +0 -0
  137. /package/dist/{chunk-SWYON2RG.js → esm/chunk-SWYON2RG.js} +0 -0
  138. /package/dist/{chunk-TD63P2AG.js → esm/chunk-TD63P2AG.js} +0 -0
  139. /package/dist/{chunk-TV2XPAIF.js → esm/chunk-TV2XPAIF.js} +0 -0
  140. /package/dist/{chunk-UZKIIX6A.js → esm/chunk-UZKIIX6A.js} +0 -0
  141. /package/dist/{chunk-VQ5SIQWU.js → esm/chunk-VQ5SIQWU.js} +0 -0
  142. /package/dist/{chunk-VUOOTNLG.js → esm/chunk-VUOOTNLG.js} +0 -0
  143. /package/dist/{chunk-YLMQS52U.js → esm/chunk-YLMQS52U.js} +0 -0
  144. /package/dist/{chunk-YYXOIRHZ.js → esm/chunk-YYXOIRHZ.js} +0 -0
  145. /package/dist/{chunk-ZTDLGX7X.js → esm/chunk-ZTDLGX7X.js} +0 -0
  146. /package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.js +0 -0
  147. /package/dist/{public-functions → esm/public-functions}/getRecommendedGasPrice.d.ts +0 -0
  148. /package/dist/{public-functions → esm/public-functions}/getSigningStargateClient.d.ts +0 -0
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var chunk5FR25GF5_cjs = require('./chunk-5FR25GF5.cjs');
4
+
5
+ // src/api/postSubmitTransaction.ts
6
+ var submitTransaction = chunk5FR25GF5_cjs.api({
7
+ methodName: "submit",
8
+ method: "post",
9
+ path: "v2/tx/submit"
10
+ });
11
+
12
+ exports.submitTransaction = submitTransaction;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var chunk5FR25GF5_cjs = require('./chunk-5FR25GF5.cjs');
4
+
5
+ // src/api/getAssetsBetweenChains.ts
6
+ var assetsBetweenChains = chunk5FR25GF5_cjs.api({
7
+ methodName: "fungibleAssetsBetweenChainsCreate",
8
+ path: "v2/fungible/assets_between_chains"
9
+ });
10
+
11
+ exports.assetsBetweenChains = assetsBetweenChains;
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var viem = require('viem');
4
+
5
+ // src/public-functions/getEvmGasAmountForMessage.ts
6
+ async function getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount) {
7
+ const { to, data, value } = tx;
8
+ if (!signer.account) throw new Error("estimateGasForEvmTx: No account found");
9
+ const extendedSigner = signer.extend(viem.publicActions);
10
+ const fee = await extendedSigner.estimateFeesPerGas();
11
+ try {
12
+ const gasAmount = await extendedSigner.estimateGas({
13
+ account: signer.account,
14
+ to,
15
+ data: `0x${data}`,
16
+ value: value === "" ? void 0 : BigInt(value ?? "")
17
+ });
18
+ return gasAmount * fee.maxFeePerGas;
19
+ } catch (error) {
20
+ const fallbackGasAmount = await getFallbackGasAmount?.(tx.chainId ?? "", "evm" /* Evm */);
21
+ if (fallbackGasAmount) {
22
+ return BigInt(fallbackGasAmount) * fee.maxFeePerGas;
23
+ }
24
+ throw error;
25
+ }
26
+ }
27
+
28
+ exports.getEVMGasAmountForMessage = getEVMGasAmountForMessage;
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var chunk5FR25GF5_cjs = require('./chunk-5FR25GF5.cjs');
4
+
5
+ // src/public-functions/setApiOptions.ts
6
+ var setApiOptions = (options = {}) => {
7
+ chunk5FR25GF5_cjs.ApiState.client = chunk5FR25GF5_cjs.createRequestClient({
8
+ apiUrl: options.apiUrl || "https://api.skip.build",
9
+ apiKey: options.apiKey,
10
+ apiHeaders: options.apiHeaders
11
+ });
12
+ chunk5FR25GF5_cjs.ApiState.setClientInitialized();
13
+ if (options.chainIdsToAffiliates) {
14
+ chunk5FR25GF5_cjs.ApiState.cumulativeAffiliateFeeBPS = validateChainIdsToAffiliates(options.chainIdsToAffiliates);
15
+ chunk5FR25GF5_cjs.ApiState.chainIdsToAffiliates = options.chainIdsToAffiliates;
16
+ }
17
+ return chunk5FR25GF5_cjs.ApiState.clientInitialized;
18
+ };
19
+ function validateChainIdsToAffiliates(chainIdsToAffiliates) {
20
+ const affiliatesArray = Object.values(chainIdsToAffiliates).map((chain) => chain.affiliates).filter((a) => a !== void 0);
21
+ const firstAffiliateBasisPointsFee = affiliatesArray[0]?.reduce((acc, affiliate) => {
22
+ if (!affiliate.basisPointsFee) {
23
+ throw new Error("basisPointFee must exist in each affiliate");
24
+ }
25
+ return acc + parseInt(affiliate.basisPointsFee, 10);
26
+ }, 0);
27
+ const allBasisPointsAreEqual = affiliatesArray.every((affiliate) => {
28
+ const totalBasisPointsFee = affiliate.reduce((acc, affiliate2) => {
29
+ if (!affiliate2.basisPointsFee) {
30
+ throw new Error("basisPointFee must exist in each affiliate");
31
+ }
32
+ if (!affiliate2.address) {
33
+ throw new Error("address to receive fee must exist in each affiliate");
34
+ }
35
+ return acc + parseInt(affiliate2?.basisPointsFee, 10);
36
+ }, 0);
37
+ return totalBasisPointsFee === firstAffiliateBasisPointsFee;
38
+ });
39
+ if (!allBasisPointsAreEqual) {
40
+ throw new Error(
41
+ "basisPointFee does not add up to the same number for each chain in chainIdsToAffiliates"
42
+ );
43
+ }
44
+ return firstAffiliateBasisPointsFee?.toFixed(0);
45
+ }
46
+
47
+ exports.setApiOptions = setApiOptions;
@@ -0,0 +1,182 @@
1
+ 'use strict';
2
+
3
+ var chunkN3LR7KTI_cjs = require('./chunk-N3LR7KTI.cjs');
4
+ var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
5
+ var chunkMGYSCMET_cjs = require('./chunk-MGYSCMET.cjs');
6
+ var chunkD2W4UBJB_cjs = require('./chunk-D2W4UBJB.cjs');
7
+ var stargate = require('@cosmjs/stargate');
8
+ var math = require('@cosmjs/math');
9
+
10
+ var validateCosmosGasBalance = async ({
11
+ chainId,
12
+ signerAddress,
13
+ messages,
14
+ getFallbackGasAmount,
15
+ getOfflineSigner,
16
+ txIndex,
17
+ simulate,
18
+ getCosmosPriorityFeeDenom
19
+ }) => {
20
+ const skipAssets = (await chunkD2W4UBJB_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
21
+ const skipChains = await chunkD2W4UBJB_cjs.ClientState.getSkipChains();
22
+ const prioFeeDenom = await getCosmosPriorityFeeDenom?.(chainId);
23
+ const chain = skipChains?.find((c) => c.chainId === chainId);
24
+ if (!chain) {
25
+ throw new Error(`failed to find chain id '${chainId}'`);
26
+ }
27
+ const { feeAssets } = chain;
28
+ if (!feeAssets) {
29
+ throw new Error(`failed to find fee assets for chain id '${chainId}'`);
30
+ }
31
+ const estimatedGasAmount = await (async () => {
32
+ try {
33
+ if (!simulate) throw new Error("simulate");
34
+ if (txIndex !== 0 && chainId === "noble-1") {
35
+ return "0";
36
+ }
37
+ const { stargateClient } = await chunkMGYSCMET_cjs.getSigningStargateClient({
38
+ chainId,
39
+ getOfflineSigner
40
+ });
41
+ const estimatedGas = await chunkN3LR7KTI_cjs.getCosmosGasAmountForMessage(
42
+ stargateClient,
43
+ signerAddress,
44
+ chainId,
45
+ messages
46
+ );
47
+ return estimatedGas;
48
+ } catch (e) {
49
+ const error = e;
50
+ if (error.message === "simulate" && !getFallbackGasAmount) {
51
+ throw new Error(`unable to get gas amount for ${chainId}'s message(s)`);
52
+ }
53
+ if (getFallbackGasAmount) {
54
+ const fallbackGasAmount = await getFallbackGasAmount(
55
+ chainId,
56
+ "cosmos" /* Cosmos */
57
+ );
58
+ if (!fallbackGasAmount) {
59
+ throw new Error(`unable to estimate gas for message(s) ${messages}`);
60
+ }
61
+ return String(fallbackGasAmount);
62
+ }
63
+ throw error;
64
+ }
65
+ })();
66
+ const fees = feeAssets.map((asset) => {
67
+ const gasPrice = (() => {
68
+ if (!asset?.gasPrice) return void 0;
69
+ let price = asset.gasPrice.average;
70
+ if (price === "") {
71
+ price = asset.gasPrice.high;
72
+ }
73
+ if (price === "") {
74
+ price = asset.gasPrice.low;
75
+ }
76
+ if (!price) return;
77
+ return new stargate.GasPrice(
78
+ math.Decimal.fromUserInput(chunk4R6OCWRR_cjs.BigNumber(price).toFixed(), 18),
79
+ asset?.denom ?? ""
80
+ );
81
+ })();
82
+ if (!gasPrice) {
83
+ return null;
84
+ }
85
+ if (chainId === "noble-1") {
86
+ if (asset.denom.toLowerCase() === "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0".toLowerCase()) {
87
+ const fee2 = stargate.calculateFee(2e6, gasPrice);
88
+ return fee2;
89
+ }
90
+ const fee = stargate.calculateFee(2e5, gasPrice);
91
+ return fee;
92
+ }
93
+ return stargate.calculateFee(Math.ceil(parseFloat(estimatedGasAmount)), gasPrice);
94
+ });
95
+ const feeBalance = await chunkD2W4UBJB_cjs.balances({
96
+ chains: {
97
+ [chainId]: {
98
+ address: signerAddress,
99
+ denoms: feeAssets.map((asset) => asset.denom ?? "")
100
+ }
101
+ }
102
+ });
103
+ const validatedAssets = feeAssets.map((asset, index) => {
104
+ const chainAsset = skipAssets?.find((x) => x.denom === asset.denom);
105
+ const symbol = chainAsset?.recommendedSymbol?.toUpperCase();
106
+ const decimal = Number(chainAsset?.decimals);
107
+ if (!chainAsset) {
108
+ return {
109
+ error: `(${chain?.prettyName}) Unable to find asset for ${asset.denom}`
110
+ };
111
+ }
112
+ if (isNaN(decimal))
113
+ return {
114
+ error: `(${chain?.prettyName}) Unable to find decimal for ${symbol}`
115
+ };
116
+ const fee = fees[index];
117
+ if (!fee) {
118
+ return {
119
+ error: `(${chain?.prettyName}) Unable to calculate fee for ${symbol}`,
120
+ asset
121
+ };
122
+ }
123
+ if (txIndex !== 0 && chainId === "noble-1") {
124
+ return {
125
+ error: null,
126
+ asset,
127
+ fee
128
+ };
129
+ }
130
+ let balance = feeBalance?.chains?.[chainId]?.denoms?.[asset?.denom ?? ""];
131
+ if (!balance) {
132
+ balance = {
133
+ amount: "0",
134
+ formattedAmount: "0"
135
+ };
136
+ }
137
+ if (!fee.amount[0]?.amount) {
138
+ return {
139
+ error: `(${chain?.prettyName}) Unable to get fee for ${symbol}`,
140
+ asset
141
+ };
142
+ }
143
+ if (parseInt(balance?.amount ?? "") < parseInt(fee.amount[0]?.amount)) {
144
+ const userAmount = new chunk4R6OCWRR_cjs.BigNumber(parseFloat(balance?.amount ?? "")).shiftedBy(-decimal).toFixed(decimal);
145
+ const feeAmount = new chunk4R6OCWRR_cjs.BigNumber(parseFloat(fee.amount[0]?.amount)).shiftedBy(-decimal).toFixed(decimal);
146
+ return {
147
+ error: `Insufficient balance for gas on ${chain?.prettyName}. Need ${feeAmount} ${symbol} but only have ${userAmount} ${symbol}.`,
148
+ asset
149
+ };
150
+ }
151
+ return {
152
+ error: null,
153
+ asset,
154
+ fee
155
+ };
156
+ });
157
+ if (prioFeeDenom) {
158
+ const availableAssets = validatedAssets.filter(
159
+ (res) => res?.error === null
160
+ );
161
+ const prioFeeAsset = availableAssets.find(
162
+ (res) => res?.asset?.denom === prioFeeDenom
163
+ );
164
+ if (prioFeeAsset) {
165
+ return prioFeeAsset;
166
+ }
167
+ }
168
+ const feeUsed = validatedAssets.find((res) => res?.error === null);
169
+ if (!feeUsed) {
170
+ if (validatedAssets.length > 1) {
171
+ throw new Error(
172
+ validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${chain.prettyName}.`
173
+ );
174
+ }
175
+ throw new Error(
176
+ validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${chain.prettyName}.`
177
+ );
178
+ }
179
+ return feeUsed;
180
+ };
181
+
182
+ exports.validateCosmosGasBalance = validateCosmosGasBalance;