@skip-go/client 1.3.0 → 1.3.1

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-CPTNOPWI.cjs +566 -0
  21. package/dist/cjs/chunk-CWUD7UGL.cjs +13 -0
  22. package/dist/cjs/chunk-D2W4UBJB.cjs +136 -0
  23. package/dist/cjs/chunk-DUJSZRFD.cjs +1445 -0
  24. package/dist/cjs/chunk-EINQFLWN.cjs +12 -0
  25. package/dist/cjs/chunk-EQBTNGJJ.cjs +11 -0
  26. package/dist/cjs/chunk-F3EB2AQG.cjs +28 -0
  27. package/dist/cjs/chunk-G3G6PBIF.cjs +47 -0
  28. package/dist/cjs/chunk-HDKNPB2J.cjs +182 -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 +401 -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/{callbacks-DK2GxU0a.d.ts → esm/callbacks-C2lXb0AH.d.ts} +5 -0
  59. package/dist/{chunk-HIJ6YOTK.js → esm/chunk-HAGMHUOI.js} +20 -4
  60. package/dist/{index.d.ts → esm/index.d.ts} +1 -1
  61. package/dist/{index.js → esm/index.js} +1 -1
  62. package/dist/{public-functions → esm/public-functions}/executeRoute.d.ts +1 -1
  63. package/dist/{public-functions → esm/public-functions}/executeRoute.js +1 -1
  64. package/dist/{public-functions → esm/public-functions}/validateCosmosGasBalance.d.ts +1 -1
  65. package/dist/{public-functions → esm/public-functions}/waitForTransaction.d.ts +1 -1
  66. package/package.json +19 -7
  67. package/dist/{api → esm/api}/getAssets.d.ts +0 -0
  68. package/dist/{api → esm/api}/getAssets.js +0 -0
  69. package/dist/{api → esm/api}/getAssetsBetweenChains.d.ts +0 -0
  70. package/dist/{api → esm/api}/getAssetsBetweenChains.js +0 -0
  71. package/dist/{api → esm/api}/getBridges.d.ts +0 -0
  72. package/dist/{api → esm/api}/getBridges.js +0 -0
  73. package/dist/{api → esm/api}/getChains.d.ts +0 -0
  74. package/dist/{api → esm/api}/getChains.js +0 -0
  75. package/dist/{api → esm/api}/getVenues.d.ts +0 -0
  76. package/dist/{api → esm/api}/getVenues.js +0 -0
  77. package/dist/{api → esm/api}/postAssetsFromSource.d.ts +0 -0
  78. package/dist/{api → esm/api}/postAssetsFromSource.js +0 -0
  79. package/dist/{api → esm/api}/postBalances.d.ts +0 -0
  80. package/dist/{api → esm/api}/postBalances.js +0 -0
  81. package/dist/{api → esm/api}/postIbcOriginAssets.d.ts +0 -0
  82. package/dist/{api → esm/api}/postIbcOriginAssets.js +0 -0
  83. package/dist/{api → esm/api}/postMessages.d.ts +0 -0
  84. package/dist/{api → esm/api}/postMessages.js +0 -0
  85. package/dist/{api → esm/api}/postMessagesDirect.d.ts +193 -193
  86. package/dist/{api → esm/api}/postMessagesDirect.js +0 -0
  87. package/dist/{api → esm/api}/postRecommendAssets.d.ts +0 -0
  88. package/dist/{api → esm/api}/postRecommendAssets.js +0 -0
  89. package/dist/{api → esm/api}/postRoute.d.ts +188 -188
  90. /package/dist/{api → esm/api}/postRoute.js +0 -0
  91. /package/dist/{api → esm/api}/postSubmit.d.ts +0 -0
  92. /package/dist/{api → esm/api}/postSubmit.js +0 -0
  93. /package/dist/{api → esm/api}/postSubmitTransaction.d.ts +0 -0
  94. /package/dist/{api → esm/api}/postSubmitTransaction.js +0 -0
  95. /package/dist/{api → esm/api}/postTrackTransaction.d.ts +0 -0
  96. /package/dist/{api → esm/api}/postTrackTransaction.js +0 -0
  97. /package/dist/{api → esm/api}/postTransactionStatus.d.ts +0 -0
  98. /package/dist/{api → esm/api}/postTransactionStatus.js +0 -0
  99. /package/dist/{apiState-DwZhwVul.d.ts → esm/apiState-DwZhwVul.d.ts} +0 -0
  100. /package/dist/{chunk-2R5COFPS.js → esm/chunk-2R5COFPS.js} +0 -0
  101. /package/dist/{chunk-43P4WRGN.js → esm/chunk-43P4WRGN.js} +0 -0
  102. /package/dist/{chunk-4DI7G6TH.js → esm/chunk-4DI7G6TH.js} +0 -0
  103. /package/dist/{chunk-6ULKULTX.js → esm/chunk-6ULKULTX.js} +0 -0
  104. /package/dist/{chunk-6UMMVC2P.js → esm/chunk-6UMMVC2P.js} +0 -0
  105. /package/dist/{chunk-7ZG7HNNC.js → esm/chunk-7ZG7HNNC.js} +0 -0
  106. /package/dist/{chunk-C6NHVJ3R.js → esm/chunk-C6NHVJ3R.js} +0 -0
  107. /package/dist/{chunk-CGZ5DA2T.js → esm/chunk-CGZ5DA2T.js} +0 -0
  108. /package/dist/{chunk-ERPZHRBM.js → esm/chunk-ERPZHRBM.js} +0 -0
  109. /package/dist/{chunk-F65QOYUA.js → esm/chunk-F65QOYUA.js} +0 -0
  110. /package/dist/{chunk-GOD6ESBZ.js → esm/chunk-GOD6ESBZ.js} +0 -0
  111. /package/dist/{chunk-GV2QOWB4.js → esm/chunk-GV2QOWB4.js} +0 -0
  112. /package/dist/{chunk-HS2D6FKN.js → esm/chunk-HS2D6FKN.js} +0 -0
  113. /package/dist/{chunk-I4AMZAHH.js → esm/chunk-I4AMZAHH.js} +0 -0
  114. /package/dist/{chunk-KYLULQOS.js → esm/chunk-KYLULQOS.js} +0 -0
  115. /package/dist/{chunk-MAOMQHG5.js → esm/chunk-MAOMQHG5.js} +0 -0
  116. /package/dist/{chunk-NZVZH6OA.js → esm/chunk-NZVZH6OA.js} +0 -0
  117. /package/dist/{chunk-PIQZD2VE.js → esm/chunk-PIQZD2VE.js} +0 -0
  118. /package/dist/{chunk-QPJEHGY7.js → esm/chunk-QPJEHGY7.js} +0 -0
  119. /package/dist/{chunk-SS5LQKBL.js → esm/chunk-SS5LQKBL.js} +0 -0
  120. /package/dist/{chunk-SWYON2RG.js → esm/chunk-SWYON2RG.js} +0 -0
  121. /package/dist/{chunk-TD63P2AG.js → esm/chunk-TD63P2AG.js} +0 -0
  122. /package/dist/{chunk-TV2XPAIF.js → esm/chunk-TV2XPAIF.js} +0 -0
  123. /package/dist/{chunk-UZKIIX6A.js → esm/chunk-UZKIIX6A.js} +0 -0
  124. /package/dist/{chunk-VQ5SIQWU.js → esm/chunk-VQ5SIQWU.js} +0 -0
  125. /package/dist/{chunk-VUOOTNLG.js → esm/chunk-VUOOTNLG.js} +0 -0
  126. /package/dist/{chunk-YLMQS52U.js → esm/chunk-YLMQS52U.js} +0 -0
  127. /package/dist/{chunk-YYXOIRHZ.js → esm/chunk-YYXOIRHZ.js} +0 -0
  128. /package/dist/{chunk-ZTDLGX7X.js → esm/chunk-ZTDLGX7X.js} +0 -0
  129. /package/dist/{client-types-DuWWc2_J.d.ts → esm/client-types-DuWWc2_J.d.ts} +0 -0
  130. /package/dist/{generateApi-DvFEIUee.d.ts → esm/generateApi-DvFEIUee.d.ts} +0 -0
  131. /package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.d.ts +0 -0
  132. /package/dist/{public-functions → esm/public-functions}/getCosmosGasAmountForMessage.js +0 -0
  133. /package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.d.ts +0 -0
  134. /package/dist/{public-functions → esm/public-functions}/getEvmGasAmountForMessage.js +0 -0
  135. /package/dist/{public-functions → esm/public-functions}/getFeeInfoForChain.d.ts +0 -0
  136. /package/dist/{public-functions → esm/public-functions}/getFeeInfoForChain.js +0 -0
  137. /package/dist/{public-functions → esm/public-functions}/getRecommendedGasPrice.d.ts +0 -0
  138. /package/dist/{public-functions → esm/public-functions}/getRecommendedGasPrice.js +0 -0
  139. /package/dist/{public-functions → esm/public-functions}/getSigningStargateClient.d.ts +0 -0
  140. /package/dist/{public-functions → esm/public-functions}/getSigningStargateClient.js +0 -0
  141. /package/dist/{public-functions → esm/public-functions}/setApiOptions.d.ts +0 -0
  142. /package/dist/{public-functions → esm/public-functions}/setApiOptions.js +0 -0
  143. /package/dist/{public-functions → esm/public-functions}/setClientOptions.d.ts +0 -0
  144. /package/dist/{public-functions → esm/public-functions}/setClientOptions.js +0 -0
  145. /package/dist/{public-functions → esm/public-functions}/validateCosmosGasBalance.js +0 -0
  146. /package/dist/{public-functions → esm/public-functions}/waitForTransaction.js +0 -0
  147. /package/dist/{setClientOptions-B27lt_6h.d.ts → esm/setClientOptions-B27lt_6h.d.ts} +0 -0
  148. /package/dist/{swaggerTypes-BrC-ZYnx.d.ts → esm/swaggerTypes-BrC-ZYnx.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;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
4
+ var chunkWE7KICKO_cjs = require('./chunk-WE7KICKO.cjs');
5
+ var math = require('@cosmjs/math');
6
+ var stargate = require('@cosmjs/stargate');
7
+
8
+ var getRecommendedGasPrice = async (props) => {
9
+ const feeInfo = await chunkWE7KICKO_cjs.getFeeInfoForChain(props);
10
+ if (!feeInfo || !feeInfo.gasPrice) {
11
+ return void 0;
12
+ }
13
+ let price = feeInfo.gasPrice.average;
14
+ if (price === "") {
15
+ price = feeInfo.gasPrice.high;
16
+ }
17
+ if (price === "") {
18
+ price = feeInfo.gasPrice.low;
19
+ }
20
+ if (!price) return;
21
+ return new stargate.GasPrice(math.Decimal.fromUserInput(chunk4R6OCWRR_cjs.BigNumber(price).toFixed(), 18), feeInfo.denom);
22
+ };
23
+
24
+ exports.getRecommendedGasPrice = getRecommendedGasPrice;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ // src/constants/constants.ts
4
+ var DEFAULT_GAS_DENOM_OVERRIDES = {
5
+ "noble-1": "uusdc"
6
+ };
7
+ var GAS_STATION_CHAIN_IDS = ["bbn-test-5", "bbn-1"];
8
+
9
+ exports.DEFAULT_GAS_DENOM_OVERRIDES = DEFAULT_GAS_DENOM_OVERRIDES;
10
+ exports.GAS_STATION_CHAIN_IDS = GAS_STATION_CHAIN_IDS;
@@ -0,0 +1,273 @@
1
+ 'use strict';
2
+
3
+ var chunkT5LPU5A2_cjs = require('./chunk-T5LPU5A2.cjs');
4
+ var chunkD2W4UBJB_cjs = require('./chunk-D2W4UBJB.cjs');
5
+ var stargate = require('@cosmjs/stargate');
6
+ var utils = require('@cosmjs/utils');
7
+ var binary_js = require('cosmjs-types/binary.js');
8
+ var auth_js = require('cosmjs-types/cosmos/auth/v1beta1/auth.js');
9
+ var coin_js = require('cosmjs-types/cosmos/base/v1beta1/coin.js');
10
+ var protoSigning = require('@cosmjs/proto-signing');
11
+ var sdkTs = require('@injectivelabs/sdk-ts');
12
+ var keys_js = require('cosmjs-types/cosmos/crypto/secp256k1/keys.js');
13
+ var amino = require('@cosmjs/amino');
14
+
15
+ var createBaseVestingAccount = () => {
16
+ return {
17
+ // @ts-expect-error
18
+ baseAccount: void 0,
19
+ originalVesting: [],
20
+ delegatedFree: [],
21
+ delegatedVesting: [],
22
+ endTime: BigInt(0)
23
+ };
24
+ };
25
+ var BaseVestingAccount = {
26
+ encode(message, writer = binary_js.BinaryWriter.create()) {
27
+ if (message.baseAccount !== void 0) {
28
+ auth_js.BaseAccount.encode(
29
+ message.baseAccount,
30
+ writer.uint32(10).fork()
31
+ ).ldelim();
32
+ }
33
+ for (const v of message.originalVesting) {
34
+ coin_js.Coin.encode(v, writer.uint32(18).fork()).ldelim();
35
+ }
36
+ for (const v of message.delegatedFree) {
37
+ coin_js.Coin.encode(v, writer.uint32(26).fork()).ldelim();
38
+ }
39
+ for (const v of message.delegatedVesting) {
40
+ coin_js.Coin.encode(v, writer.uint32(34).fork()).ldelim();
41
+ }
42
+ if (message.endTime !== BigInt(0)) {
43
+ writer.uint32(40).int64(message.endTime);
44
+ }
45
+ return writer;
46
+ },
47
+ decode(input, length) {
48
+ const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
49
+ const end = length === void 0 ? reader.len : reader.pos + length;
50
+ const message = createBaseVestingAccount();
51
+ while (reader.pos < end) {
52
+ const tag = reader.uint32();
53
+ switch (tag >>> 3) {
54
+ case 1:
55
+ message.baseAccount = auth_js.BaseAccount.decode(reader, reader.uint32());
56
+ break;
57
+ case 2:
58
+ message.originalVesting.push(coin_js.Coin.decode(reader, reader.uint32()));
59
+ break;
60
+ case 3:
61
+ message.delegatedFree.push(coin_js.Coin.decode(reader, reader.uint32()));
62
+ break;
63
+ case 4:
64
+ message.delegatedVesting.push(coin_js.Coin.decode(reader, reader.uint32()));
65
+ break;
66
+ case 5:
67
+ message.endTime = reader.int64();
68
+ break;
69
+ default:
70
+ reader.skipType(tag & 7);
71
+ break;
72
+ }
73
+ }
74
+ return message;
75
+ }
76
+ };
77
+ function createBasePeriod() {
78
+ return {
79
+ startTime: BigInt(0),
80
+ length: BigInt(0),
81
+ amount: [],
82
+ actionType: 0
83
+ };
84
+ }
85
+ var Period = {
86
+ encode(message, writer = binary_js.BinaryWriter.create()) {
87
+ if (message.startTime !== BigInt(0)) {
88
+ writer.uint32(8).int64(message.startTime);
89
+ }
90
+ if (message.length !== BigInt(0)) {
91
+ writer.uint32(16).int64(message.length);
92
+ }
93
+ for (const v of message.amount) {
94
+ coin_js.Coin.encode(v, writer.uint32(26).fork()).ldelim();
95
+ }
96
+ if (message.actionType !== 0) {
97
+ writer.uint32(32).int32(message.actionType);
98
+ }
99
+ return writer;
100
+ },
101
+ decode(input, length) {
102
+ const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
103
+ const end = length === void 0 ? reader.len : reader.pos + length;
104
+ const message = createBasePeriod();
105
+ while (reader.pos < end) {
106
+ const tag = reader.uint32();
107
+ switch (tag >>> 3) {
108
+ case 1:
109
+ message.startTime = reader.int64();
110
+ break;
111
+ case 2:
112
+ message.length = reader.int64();
113
+ break;
114
+ case 3:
115
+ message.amount.push(coin_js.Coin.decode(reader, reader.uint32()));
116
+ break;
117
+ case 4:
118
+ message.actionType = reader.int32();
119
+ break;
120
+ default:
121
+ reader.skipType(tag & 7);
122
+ break;
123
+ }
124
+ }
125
+ return message;
126
+ }
127
+ };
128
+ function createBaseStridePeriodicVestingAccount() {
129
+ return {
130
+ //eslint-disable-next-line @typescript-eslint/ban-ts-comment
131
+ //@ts-ignore
132
+ baseVestingAccount: void 0,
133
+ vestingPeriods: []
134
+ };
135
+ }
136
+ var StridePeriodicVestingAccount = {
137
+ encode(message, writer = binary_js.BinaryWriter.create()) {
138
+ if (message.baseVestingAccount !== void 0) {
139
+ BaseVestingAccount.encode(
140
+ message.baseVestingAccount,
141
+ writer.uint32(10).fork()
142
+ ).ldelim();
143
+ }
144
+ for (const v of message.vestingPeriods) {
145
+ Period.encode(v, writer.uint32(26).fork()).ldelim();
146
+ }
147
+ return writer;
148
+ },
149
+ decode(input, length) {
150
+ const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
151
+ const end = length === void 0 ? reader.len : reader.pos + length;
152
+ const message = createBaseStridePeriodicVestingAccount();
153
+ while (reader.pos < end) {
154
+ const tag = reader.uint32();
155
+ switch (tag >>> 3) {
156
+ case 1:
157
+ message.baseVestingAccount = BaseVestingAccount.decode(
158
+ reader,
159
+ reader.uint32()
160
+ );
161
+ break;
162
+ case 3:
163
+ message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
164
+ break;
165
+ default:
166
+ reader.skipType(tag & 7);
167
+ break;
168
+ }
169
+ }
170
+ return message;
171
+ }
172
+ };
173
+ var accountParser = (acc) => {
174
+ switch (acc.typeUrl) {
175
+ case "/stride.vesting.StridePeriodicVestingAccount": {
176
+ const baseAccount = StridePeriodicVestingAccount.decode(acc.value).baseVestingAccount?.baseAccount;
177
+ utils.assertDefinedAndNotNull(baseAccount);
178
+ return {
179
+ address: baseAccount.address,
180
+ pubkey: baseAccount.pubKey ? protoSigning.decodePubkey(baseAccount.pubKey) : null,
181
+ accountNumber: Number(baseAccount.accountNumber),
182
+ sequence: Number(baseAccount.sequence)
183
+ };
184
+ }
185
+ case "/injective.types.v1beta1.EthAccount":
186
+ return sdkTs.accountEthParser(
187
+ acc,
188
+ "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
189
+ );
190
+ case "/ethermint.types.v1.EthAccount":
191
+ return sdkTs.accountEthParser(acc, "/ethermint.crypto.v1.ethsecp256k1.PubKey");
192
+ default: {
193
+ if (acc.typeUrl === "/cosmos.auth.v1beta1.BaseAccount") {
194
+ const { address, pubKey, accountNumber, sequence } = auth_js.BaseAccount.decode(
195
+ acc.value
196
+ );
197
+ if (pubKey?.typeUrl === "/initia.crypto.v1beta1.ethsecp256k1.PubKey") {
198
+ const { key } = keys_js.PubKey.decode(pubKey.value);
199
+ const pk = amino.encodeSecp256k1Pubkey(key);
200
+ return {
201
+ address,
202
+ pubkey: pk,
203
+ accountNumber: Number(accountNumber),
204
+ sequence: Number(sequence)
205
+ };
206
+ }
207
+ }
208
+ return stargate.accountFromAny(acc);
209
+ }
210
+ }
211
+ };
212
+
213
+ // src/private-functions/getRpcEndpointForChain.ts
214
+ var getRpcEndpointForChain = async (chainId) => {
215
+ if (chunkD2W4UBJB_cjs.ClientState.endpointOptions.getRpcEndpointForChain) {
216
+ return chunkD2W4UBJB_cjs.ClientState.endpointOptions.getRpcEndpointForChain(chainId);
217
+ }
218
+ if (chunkD2W4UBJB_cjs.ClientState.endpointOptions.endpoints && chunkD2W4UBJB_cjs.ClientState.endpointOptions.endpoints[chainId]) {
219
+ const endpointOptions = chunkD2W4UBJB_cjs.ClientState.endpointOptions.endpoints[chainId];
220
+ if (endpointOptions?.rpc) {
221
+ return endpointOptions.rpc;
222
+ }
223
+ }
224
+ console.warn(
225
+ "Warning: You are using unreliable public endpoints. We strongly recommend overriding them via endpointOptions for use beyond development settings."
226
+ );
227
+ const chain = chunkT5LPU5A2_cjs.chains().find((chain2) => chain2.chain_id === chainId);
228
+ if (!chain) {
229
+ throw new Error(`getRpcEndpointForChain: failed to find chain id '${chainId}' in registry`);
230
+ }
231
+ if (chain.apis?.rpc?.length === 0 || !chain.apis?.rpc) {
232
+ throw new Error(
233
+ `getRpcEndpointForChain error: failed to find RPC endpoint for chain id '${chainId}'`
234
+ );
235
+ }
236
+ const endpoints = chain.apis?.rpc?.map((api) => api.address);
237
+ const endpoint = await chunkT5LPU5A2_cjs.findFirstWorkingEndpoint(endpoints, "rpc");
238
+ if (!endpoint) {
239
+ throw new Error(
240
+ `getRpcEndpointForChain error: failed to find RPC endpoint for chain id '${chainId}'`
241
+ );
242
+ }
243
+ return endpoint;
244
+ };
245
+
246
+ // src/public-functions/getSigningStargateClient.ts
247
+ var getSigningStargateClient = async ({
248
+ chainId,
249
+ getOfflineSigner
250
+ }) => {
251
+ if (!getOfflineSigner) {
252
+ throw new Error("'getCosmosSigner' is not provided or configured in skip router");
253
+ }
254
+ if (!chunkD2W4UBJB_cjs.ClientState.signingStargateClientByChainId?.[chainId]) {
255
+ const [signer, endpoint] = await Promise.all([
256
+ getOfflineSigner(chainId),
257
+ getRpcEndpointForChain(chainId)
258
+ ]);
259
+ chunkD2W4UBJB_cjs.ClientState.signingStargateClientByChainId[chainId] = await stargate.SigningStargateClient.connectWithSigner(endpoint, signer, {
260
+ aminoTypes: chunkD2W4UBJB_cjs.ClientState.aminoTypes,
261
+ registry: chunkD2W4UBJB_cjs.ClientState.registry,
262
+ accountParser
263
+ });
264
+ }
265
+ return {
266
+ stargateClient: chunkD2W4UBJB_cjs.ClientState.signingStargateClientByChainId[chainId],
267
+ signer: await getOfflineSigner(chainId)
268
+ };
269
+ };
270
+
271
+ exports.accountParser = accountParser;
272
+ exports.getRpcEndpointForChain = getRpcEndpointForChain;
273
+ exports.getSigningStargateClient = getSigningStargateClient;