@skip-go/client 1.4.0 → 1.5.0

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 (53) hide show
  1. package/dist/cjs/{chunk-IDEJORRT.cjs → chunk-23YF4LFI.cjs} +30 -0
  2. package/dist/cjs/chunk-4YTACAVP.cjs +185 -0
  3. package/dist/cjs/{chunk-46VB6RQK.cjs → chunk-CUDPMOR6.cjs} +10 -3
  4. package/dist/cjs/chunk-GCJO6DZD.cjs +55 -0
  5. package/dist/cjs/{chunk-ZKBSNSHQ.cjs → chunk-HHZGD62Y.cjs} +120 -116
  6. package/dist/cjs/{chunk-ZAATXQBG.cjs → chunk-K4YAPDUE.cjs} +2 -2
  7. package/dist/cjs/{chunk-7MC3BVQN.cjs → chunk-UIQML2XG.cjs} +113 -28
  8. package/dist/cjs/chunk-VF65UG3E.cjs +214 -0
  9. package/dist/cjs/{chunk-Q43XCBMX.cjs → chunk-W3KF3V57.cjs} +4 -4
  10. package/dist/cjs/{chunk-6LA66667.cjs → chunk-X22PL5T7.cjs} +3 -3
  11. package/dist/cjs/index.cjs +26 -20
  12. package/dist/cjs/public-functions/executeMultipleRoutes.cjs +29 -0
  13. package/dist/cjs/public-functions/executeRoute.cjs +8 -7
  14. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +3 -3
  15. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +4 -4
  16. package/dist/cjs/public-functions/getSigningStargateClient.cjs +3 -3
  17. package/dist/cjs/public-functions/setClientOptions.cjs +2 -2
  18. package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +5 -5
  19. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +5 -5
  20. package/dist/esm/{callbacks-B3kjKg0v.d.ts → callbacks-CvqAtBJq.d.ts} +19 -64
  21. package/dist/esm/chunk-7RS3YIVC.js +53 -0
  22. package/dist/esm/chunk-AZALP3WR.js +212 -0
  23. package/dist/esm/{chunk-CIAOTO3M.js → chunk-CX5N7ZLJ.js} +1 -1
  24. package/dist/esm/chunk-IUYOY23L.js +180 -0
  25. package/dist/esm/{chunk-GHNH5QC3.js → chunk-JKN4E5VN.js} +9 -2
  26. package/dist/esm/{chunk-4RLJWCQR.js → chunk-KLGGCB73.js} +1 -1
  27. package/dist/esm/{chunk-KYDY7QRT.js → chunk-MPSXXWKL.js} +1 -1
  28. package/dist/esm/{chunk-BAJFQZDT.js → chunk-MTAS5XMN.js} +99 -96
  29. package/dist/esm/{chunk-RQ7DXNSS.js → chunk-VUXLWWLF.js} +113 -28
  30. package/dist/esm/{chunk-REWUSU53.js → chunk-WBZVMPPV.js} +30 -0
  31. package/dist/esm/client-types-Dk6ypWdO.d.ts +114 -0
  32. package/dist/esm/index.d.ts +4 -3
  33. package/dist/esm/index.js +12 -10
  34. package/dist/esm/public-functions/executeMultipleRoutes.d.ts +60 -0
  35. package/dist/esm/public-functions/executeMultipleRoutes.js +20 -0
  36. package/dist/esm/public-functions/executeRoute.d.ts +3 -3
  37. package/dist/esm/public-functions/executeRoute.js +7 -6
  38. package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +4 -1
  39. package/dist/esm/public-functions/getFeeInfoForChain.js +2 -2
  40. package/dist/esm/public-functions/getRecommendedGasPrice.js +3 -3
  41. package/dist/esm/public-functions/getSigningStargateClient.js +2 -2
  42. package/dist/esm/public-functions/setClientOptions.d.ts +4 -2
  43. package/dist/esm/public-functions/setClientOptions.js +1 -1
  44. package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +3 -3
  45. package/dist/esm/public-functions/subscribeToRouteStatus.js +1 -1
  46. package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +5 -4
  47. package/dist/esm/public-functions/validateCosmosGasBalance.js +4 -4
  48. package/dist/esm/public-functions/waitForTransaction.d.ts +3 -3
  49. package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-BD8e7m2x.d.ts} +1 -1
  50. package/package.json +1 -1
  51. package/dist/cjs/chunk-VIG2BHYJ.cjs +0 -185
  52. package/dist/esm/chunk-3J6O2PVK.js +0 -180
  53. package/dist/esm/client-types-B7Fin0mq.d.ts +0 -61
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkKM2D7PJL_cjs = require('./chunk-KM2D7PJL.cjs');
4
4
  var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
5
- var chunk6LA66667_cjs = require('./chunk-6LA66667.cjs');
5
+ var chunkX22PL5T7_cjs = require('./chunk-X22PL5T7.cjs');
6
6
  var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
7
7
  var stargate = require('@cosmjs/stargate');
8
8
  var math = require('@cosmjs/math');
@@ -15,7 +15,8 @@ var validateCosmosGasBalance = async ({
15
15
  getOfflineSigner,
16
16
  txIndex,
17
17
  simulate,
18
- getCosmosPriorityFeeDenom
18
+ getCosmosPriorityFeeDenom,
19
+ isMultiRoutes
19
20
  }) => {
20
21
  const skipAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
21
22
  const skipChains = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
@@ -34,7 +35,7 @@ var validateCosmosGasBalance = async ({
34
35
  if (txIndex !== 0 && chainId === "noble-1") {
35
36
  return "0";
36
37
  }
37
- const { stargateClient } = await chunk6LA66667_cjs.getSigningStargateClient({
38
+ const { stargateClient } = await chunkX22PL5T7_cjs.getSigningStargateClient({
38
39
  chainId,
39
40
  getOfflineSigner
40
41
  });
@@ -83,6 +84,12 @@ var validateCosmosGasBalance = async ({
83
84
  return null;
84
85
  }
85
86
  if (chainId === "noble-1") {
87
+ if (isMultiRoutes && txIndex === 0) {
88
+ return stargate.calculateFee(
89
+ Math.ceil(parseFloat(estimatedGasAmount)),
90
+ gasPrice
91
+ );
92
+ }
86
93
  if (asset.denom.toLowerCase() === "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0".toLowerCase()) {
87
94
  const fee2 = stargate.calculateFee(2e6, gasPrice);
88
95
  return fee2;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var chunkHHZGD62Y_cjs = require('./chunk-HHZGD62Y.cjs');
4
+ var chunkUIQML2XG_cjs = require('./chunk-UIQML2XG.cjs');
5
+ var chunkOZUCMWNE_cjs = require('./chunk-OZUCMWNE.cjs');
6
+ var chunkERGJBZUC_cjs = require('./chunk-ERGJBZUC.cjs');
7
+
8
+ // src/public-functions/executeRoute.ts
9
+ var executeRoute = async (options) => {
10
+ const { route, userAddresses, appendCosmosMsgs, timeoutSeconds } = options;
11
+ const { id: routeId } = chunkUIQML2XG_cjs.updateRouteDetails({
12
+ status: "unconfirmed",
13
+ options
14
+ });
15
+ const addressList = await chunkHHZGD62Y_cjs.createValidAddressList({
16
+ userAddresses,
17
+ route
18
+ });
19
+ const response = await chunkOZUCMWNE_cjs.messages({
20
+ timeoutSeconds,
21
+ amountIn: route?.amountIn,
22
+ amountOut: route.estimatedAmountOut || "0",
23
+ sourceAssetChainId: route?.sourceAssetChainId,
24
+ sourceAssetDenom: route?.sourceAssetDenom,
25
+ destAssetChainId: route?.destAssetChainId,
26
+ destAssetDenom: route?.destAssetDenom,
27
+ operations: route?.operations,
28
+ addressList,
29
+ slippageTolerancePercent: options.slippageTolerancePercent || "1",
30
+ chainIdsToAffiliates: chunkERGJBZUC_cjs.ApiState.chainIdsToAffiliates,
31
+ postRouteHandler: options.postRouteHandler,
32
+ feePayerAddress: options.svmFeePayer?.address
33
+ });
34
+ if (appendCosmosMsgs) {
35
+ Object.entries(appendCosmosMsgs).forEach(([chainId, msgs]) => {
36
+ const txIndex = response?.txs?.findIndex(
37
+ (tx2) => "cosmosTx" in tx2 && tx2.cosmosTx.chainId === chainId
38
+ );
39
+ if (txIndex === void 0 || txIndex === -1) return;
40
+ const tx = response?.txs?.[txIndex];
41
+ if (tx && "cosmosTx" in tx) {
42
+ tx.cosmosTx.msgs?.unshift(...msgs);
43
+ }
44
+ });
45
+ }
46
+ const { transactionDetails, executeTransaction } = await chunkHHZGD62Y_cjs.executeTransactions({ ...options, routeId, txs: response?.txs });
47
+ await chunkUIQML2XG_cjs.executeAndSubscribeToRouteStatus({
48
+ transactionDetails,
49
+ executeTransaction,
50
+ routeId,
51
+ options
52
+ });
53
+ };
54
+
55
+ exports.executeRoute = executeRoute;
@@ -1,20 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk7MC3BVQN_cjs = require('./chunk-7MC3BVQN.cjs');
4
- var chunk46VB6RQK_cjs = require('./chunk-46VB6RQK.cjs');
3
+ var chunkUIQML2XG_cjs = require('./chunk-UIQML2XG.cjs');
4
+ var chunkCUDPMOR6_cjs = require('./chunk-CUDPMOR6.cjs');
5
5
  var chunkKM2D7PJL_cjs = require('./chunk-KM2D7PJL.cjs');
6
6
  var chunkF3EB2AQG_cjs = require('./chunk-F3EB2AQG.cjs');
7
7
  var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
8
8
  var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
9
- var chunk6LA66667_cjs = require('./chunk-6LA66667.cjs');
10
- var chunkVIG2BHYJ_cjs = require('./chunk-VIG2BHYJ.cjs');
11
- var chunkOZUCMWNE_cjs = require('./chunk-OZUCMWNE.cjs');
9
+ var chunkX22PL5T7_cjs = require('./chunk-X22PL5T7.cjs');
10
+ var chunk4YTACAVP_cjs = require('./chunk-4YTACAVP.cjs');
12
11
  var chunk5HDKZVOL_cjs = require('./chunk-5HDKZVOL.cjs');
13
12
  var chunk5AYPH3ZR_cjs = require('./chunk-5AYPH3ZR.cjs');
14
13
  var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
15
14
  var chunkERGJBZUC_cjs = require('./chunk-ERGJBZUC.cjs');
16
- var web3_js = require('@solana/web3.js');
17
- var bech32 = require('bech32');
18
15
  var stargate = require('@cosmjs/stargate');
19
16
  var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
20
17
  var protoSigning = require('@cosmjs/proto-signing');
@@ -25,6 +22,8 @@ var any_js = require('cosmjs-types/google/protobuf/any.js');
25
22
  var math = require('@cosmjs/math');
26
23
  var signing_js = require('cosmjs-types/cosmos/tx/signing/v1beta1/signing.js');
27
24
  var viem = require('viem');
25
+ var web3_js = require('@solana/web3.js');
26
+ var bech32 = require('bech32');
28
27
 
29
28
  // src/private-functions/getRestEndpointForChain.ts
30
29
  var getRestEndpointForChain = async (chainId) => {
@@ -37,7 +36,7 @@ var getRestEndpointForChain = async (chainId) => {
37
36
  return endpointOptions.rest;
38
37
  }
39
38
  }
40
- const chain = chunkVIG2BHYJ_cjs.chains().find((chain2) => chain2.chainId === chainId);
39
+ const chain = chunk4YTACAVP_cjs.chains().find((chain2) => chain2.chainId === chainId);
41
40
  if (!chain) {
42
41
  throw new Error(
43
42
  `getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
@@ -49,7 +48,7 @@ var getRestEndpointForChain = async (chainId) => {
49
48
  );
50
49
  }
51
50
  const endpoints = chain.apis?.rest?.map((api) => api.address);
52
- const endpoint = await chunkVIG2BHYJ_cjs.findFirstWorkingEndpoint(endpoints, "rest");
51
+ const endpoint = await chunk4YTACAVP_cjs.findFirstWorkingEndpoint(endpoints, "rest");
53
52
  if (!endpoint) {
54
53
  throw new Error(
55
54
  `getRestEndpointForChain error: failed to find REST endpoint for chain id '${chainId}'`
@@ -63,9 +62,9 @@ var getAccountNumberAndSequence = async (address, chainId) => {
63
62
  if (chainId.includes("dymension")) {
64
63
  return getAccountNumberAndSequenceFromDymension(address, chainId);
65
64
  }
66
- const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(chainId);
65
+ const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(chainId);
67
66
  const client = chunkN4UW74AG_cjs.ClientState.signingStargateClientByChainId[chainId] ?? await stargate.StargateClient.connect(endpoint, {
68
- accountParser: chunk6LA66667_cjs.accountParser
67
+ accountParser: chunkX22PL5T7_cjs.accountParser
69
68
  });
70
69
  const account = await client.getAccount(address);
71
70
  if (!account) {
@@ -126,7 +125,7 @@ function encodeEthSecp256k1Pubkey(pubkey) {
126
125
 
127
126
  // src/proto-signing/pubkey.ts
128
127
  function makePubkeyAnyFromAccount(account, chainId) {
129
- const isEthermint = chunkVIG2BHYJ_cjs.getIsEthermint(chainId);
128
+ const isEthermint = chunk4YTACAVP_cjs.getIsEthermint(chainId);
130
129
  const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) : amino.encodeSecp256k1Pubkey(account.pubkey);
131
130
  const pubkeyAny = encodePubkeyToAny(pubkey, chainId, isEthermint);
132
131
  return pubkeyAny;
@@ -147,7 +146,7 @@ function encodePubkeyToAny(pubkey, chainId, isEthermint) {
147
146
  value: Uint8Array.from(keys_js.PubKey.encode(pubkeyProto).finish())
148
147
  });
149
148
  } else {
150
- const isInitia = chunkVIG2BHYJ_cjs.getIsInitia(chainId);
149
+ const isInitia = chunk4YTACAVP_cjs.getIsInitia(chainId);
151
150
  const pubkeyProto = keys_js.PubKey.fromPartial({
152
151
  key: encoding.fromBase64(pubkey.value)
153
152
  });
@@ -174,11 +173,11 @@ var signCosmosMessageDirect = async (options) => {
174
173
  if (!accountFromSigner) {
175
174
  throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
176
175
  }
177
- const messages2 = cosmosMsgs.map((cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
176
+ const messages = cosmosMsgs.map((cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
178
177
  const txBodyEncodeObject = {
179
178
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
180
179
  value: {
181
- messages: messages2
180
+ messages
182
181
  }
183
182
  };
184
183
  const txBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(txBodyEncodeObject);
@@ -209,26 +208,40 @@ var signCosmosMessageAmino = async (options) => {
209
208
  signerData: { accountNumber, sequence, chainId: signerChainId }
210
209
  } = options;
211
210
  const accounts = await signer.getAccounts();
212
- const accountFromSigner = accounts.find((account) => account.address === signerAddress);
211
+ const accountFromSigner = accounts.find(
212
+ (account) => account.address === signerAddress
213
+ );
213
214
  if (!accountFromSigner) {
214
- throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
215
+ throw new Error(
216
+ "signCosmosMessageAmino: failed to retrieve account from signer"
217
+ );
215
218
  }
216
- const messages2 = cosmosMsgs.map((cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
219
+ const messages = cosmosMsgs.map(
220
+ (cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg)
221
+ );
217
222
  const signMode = signing_js.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
218
- const msgs = messages2.map((msg) => chunkN4UW74AG_cjs.ClientState.aminoTypes.toAmino(msg));
219
- console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
220
- const signDoc = amino.makeSignDoc(msgs, fee, signerChainId, "", accountNumber, sequence);
223
+ const msgs = messages.map((msg) => chunkN4UW74AG_cjs.ClientState.aminoTypes.toAmino(msg));
224
+ const signDoc = amino.makeSignDoc(
225
+ msgs,
226
+ fee,
227
+ signerChainId,
228
+ "",
229
+ accountNumber,
230
+ sequence
231
+ );
221
232
  const { signature, signed } = await signer.signAmino(signerAddress, signDoc);
222
233
  const signedTxBody = {
223
234
  messages: signed.msgs.map((msg) => chunkN4UW74AG_cjs.ClientState.aminoTypes.fromAmino(msg)),
224
235
  memo: signed.memo
225
236
  };
226
- signedTxBody.messages[0].value.memo = messages2[0].value.memo;
237
+ signedTxBody.messages[0].value.memo = messages[0].value.memo;
227
238
  const signedTxBodyEncodeObject = {
228
239
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
229
240
  value: signedTxBody
230
241
  };
231
- const signedTxBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(signedTxBodyEncodeObject);
242
+ const signedTxBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(
243
+ signedTxBodyEncodeObject
244
+ );
232
245
  const signedGasLimit = math.Int53.fromString(signed.fee.gas).toNumber();
233
246
  const signedSequence = math.Int53.fromString(signed.sequence).toNumber();
234
247
  const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
@@ -259,7 +272,7 @@ var signCosmosTransaction = async ({
259
272
  throw new Error("executeCosmosTransaction error: tx is undefined");
260
273
  }
261
274
  const chainId = tx.cosmosTx?.chainId;
262
- const messages2 = tx.cosmosTx?.msgs;
275
+ const messages = tx.cosmosTx?.msgs;
263
276
  const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
264
277
  const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
265
278
  const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
@@ -273,10 +286,10 @@ var signCosmosTransaction = async ({
273
286
  if (chainId === void 0) {
274
287
  throw new Error("no chainId found for tx");
275
288
  }
276
- if (messages2 === void 0) {
289
+ if (messages === void 0) {
277
290
  throw new Error("no messages found for tx");
278
291
  }
279
- const { signer } = await chunk6LA66667_cjs.getSigningStargateClient({
292
+ const { signer } = await chunkX22PL5T7_cjs.getSigningStargateClient({
280
293
  chainId,
281
294
  getOfflineSigner: options?.getCosmosSigner
282
295
  });
@@ -302,7 +315,7 @@ var signCosmosTransaction = async ({
302
315
  const commonRawTxBody = {
303
316
  signerAddress: currentUserAddress,
304
317
  chainId,
305
- cosmosMsgs: messages2,
318
+ cosmosMsgs: messages,
306
319
  fee,
307
320
  signerData: {
308
321
  accountNumber,
@@ -315,7 +328,7 @@ var signCosmosTransaction = async ({
315
328
  txIndex: index,
316
329
  signerAddress: currentUserAddress
317
330
  });
318
- chunk7MC3BVQN_cjs.updateRouteDetails({
331
+ chunkUIQML2XG_cjs.updateRouteDetails({
319
332
  status: "signing",
320
333
  routeId,
321
334
  options
@@ -331,7 +344,7 @@ var signCosmosTransaction = async ({
331
344
  options?.onTransactionSigned?.({
332
345
  chainId
333
346
  });
334
- chunk7MC3BVQN_cjs.updateRouteDetails({
347
+ chunkUIQML2XG_cjs.updateRouteDetails({
335
348
  status: "pending",
336
349
  routeId,
337
350
  options
@@ -617,7 +630,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
617
630
  status: "pending",
618
631
  allowance: requiredApproval
619
632
  });
620
- chunk7MC3BVQN_cjs.updateRouteDetails({
633
+ chunkUIQML2XG_cjs.updateRouteDetails({
621
634
  status: "allowance",
622
635
  routeId,
623
636
  options
@@ -651,7 +664,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
651
664
  signerAddress: evmSigner.account.address,
652
665
  txIndex: index
653
666
  });
654
- chunk7MC3BVQN_cjs.updateRouteDetails({
667
+ chunkUIQML2XG_cjs.updateRouteDetails({
655
668
  status: "signing",
656
669
  routeId,
657
670
  options
@@ -663,7 +676,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
663
676
  chain: evmSigner.chain,
664
677
  value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
665
678
  });
666
- chunk7MC3BVQN_cjs.updateRouteDetails({
679
+ chunkUIQML2XG_cjs.updateRouteDetails({
667
680
  status: "pending",
668
681
  routeId,
669
682
  options
@@ -719,14 +732,14 @@ var signSvmTransaction = async ({
719
732
  signerAddress: signer.publicKey?.toBase58(),
720
733
  txIndex: index
721
734
  });
722
- chunk7MC3BVQN_cjs.updateRouteDetails({
735
+ chunkUIQML2XG_cjs.updateRouteDetails({
723
736
  status: "signing",
724
737
  routeId,
725
738
  options
726
739
  });
727
740
  const signedTx = await signer.signTransaction(transaction);
728
741
  options?.onTransactionSigned?.({ chainId: svmTx.chainId });
729
- chunk7MC3BVQN_cjs.updateRouteDetails({
742
+ chunkUIQML2XG_cjs.updateRouteDetails({
730
743
  status: "pending",
731
744
  routeId,
732
745
  options
@@ -745,7 +758,7 @@ var executeSvmTransaction = async (tx, options, index, routeId) => {
745
758
  if (!signedTx) {
746
759
  throw new Error("executeSvmTransaction error: signedTx is undefined");
747
760
  }
748
- const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(svmTx.chainId);
761
+ const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(svmTx.chainId);
749
762
  const connection = new web3_js.Connection(endpoint);
750
763
  let signature;
751
764
  const submitTxResponse = await chunk5HDKZVOL_cjs.submitTransaction({
@@ -878,7 +891,8 @@ var validateEvmGasBalance = async ({
878
891
  signer,
879
892
  tx,
880
893
  getFallbackGasAmount,
881
- useUnlimitedApproval
894
+ useUnlimitedApproval,
895
+ bypassApprovalCheck
882
896
  }) => {
883
897
  const chainId = tx?.chainId ?? "";
884
898
  const skipAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
@@ -903,7 +917,7 @@ var validateEvmGasBalance = async ({
903
917
  )?.[1];
904
918
  const gasBalance = nativeGasBalance || zeroAddressGasBalance;
905
919
  const { requiredErc20Approvals } = tx;
906
- if (requiredErc20Approvals) {
920
+ if (!bypassApprovalCheck && requiredErc20Approvals) {
907
921
  try {
908
922
  await validateEvmTokenApproval({
909
923
  requiredErc20Approvals,
@@ -976,7 +990,7 @@ var validateSvmGasBalance = async ({
976
990
  fee: null
977
991
  };
978
992
  }
979
- const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(tx.chainId ?? "");
993
+ const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(tx.chainId ?? "");
980
994
  const connection = new web3_js.Connection(endpoint);
981
995
  if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
982
996
  if (!tx.tx) {
@@ -1040,10 +1054,10 @@ var validateGasBalances = async ({
1040
1054
  simulate,
1041
1055
  disabledChainIds,
1042
1056
  enabledChainIds,
1043
- useUnlimitedApproval,
1044
1057
  getCosmosPriorityFeeDenom,
1045
1058
  routeId,
1046
- options
1059
+ options,
1060
+ isMultiRoutes
1047
1061
  }) => {
1048
1062
  const validateResult = await Promise.all(
1049
1063
  txs.map(async (tx, i) => {
@@ -1054,7 +1068,7 @@ var validateGasBalances = async ({
1054
1068
  onValidateGasBalance?.({
1055
1069
  status: "pending"
1056
1070
  });
1057
- chunk7MC3BVQN_cjs.updateRouteDetails({
1071
+ chunkUIQML2XG_cjs.updateRouteDetails({
1058
1072
  status: "validating",
1059
1073
  routeId,
1060
1074
  options
@@ -1063,7 +1077,7 @@ var validateGasBalances = async ({
1063
1077
  throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
1064
1078
  }
1065
1079
  try {
1066
- const res = await chunk46VB6RQK_cjs.validateCosmosGasBalance({
1080
+ const res = await chunkCUDPMOR6_cjs.validateCosmosGasBalance({
1067
1081
  chainId: tx.cosmosTx.chainId ?? "",
1068
1082
  signerAddress: tx.cosmosTx.signerAddress ?? "",
1069
1083
  messages: tx.cosmosTx.msgs,
@@ -1071,7 +1085,8 @@ var validateGasBalances = async ({
1071
1085
  getOfflineSigner: getCosmosSigner,
1072
1086
  txIndex: i,
1073
1087
  simulate,
1074
- getCosmosPriorityFeeDenom
1088
+ getCosmosPriorityFeeDenom,
1089
+ isMultiRoutes
1075
1090
  });
1076
1091
  return res;
1077
1092
  } catch (e) {
@@ -1087,7 +1102,7 @@ var validateGasBalances = async ({
1087
1102
  onValidateGasBalance?.({
1088
1103
  status: "pending"
1089
1104
  });
1090
- chunk7MC3BVQN_cjs.updateRouteDetails({
1105
+ chunkUIQML2XG_cjs.updateRouteDetails({
1091
1106
  status: "validating",
1092
1107
  routeId,
1093
1108
  options
@@ -1103,7 +1118,8 @@ var validateGasBalances = async ({
1103
1118
  tx: tx.evmTx,
1104
1119
  signer,
1105
1120
  getFallbackGasAmount,
1106
- useUnlimitedApproval
1121
+ useUnlimitedApproval: options?.useUnlimitedApproval,
1122
+ bypassApprovalCheck: options?.bypassApprovalCheck
1107
1123
  });
1108
1124
  return res;
1109
1125
  } catch (e) {
@@ -1119,7 +1135,7 @@ var validateGasBalances = async ({
1119
1135
  onValidateGasBalance?.({
1120
1136
  status: "pending"
1121
1137
  });
1122
- chunk7MC3BVQN_cjs.updateRouteDetails({
1138
+ chunkUIQML2XG_cjs.updateRouteDetails({
1123
1139
  status: "validating",
1124
1140
  routeId,
1125
1141
  options
@@ -1195,7 +1211,8 @@ var executeTransactions = async (options) => {
1195
1211
  onValidateGasBalance,
1196
1212
  trackTxPollingOptions,
1197
1213
  batchSignTxs = true,
1198
- routeId
1214
+ routeId,
1215
+ isMultiRoutes
1199
1216
  } = options;
1200
1217
  if (txs === void 0) {
1201
1218
  throw new Error(
@@ -1205,16 +1222,16 @@ var executeTransactions = async (options) => {
1205
1222
  const chainIds = getChainIdsFromTxs(txs);
1206
1223
  const transactionDetails = txs.map((tx) => {
1207
1224
  if ("cosmosTx" in tx) {
1208
- return { chainId: tx.cosmosTx?.chainId };
1225
+ return { chainId: tx.cosmosTx?.chainId, chainType: "cosmos" /* Cosmos */ };
1209
1226
  } else if ("evmTx" in tx) {
1210
- return { chainId: tx.evmTx?.chainId };
1227
+ return { chainId: tx.evmTx?.chainId, chainType: "evm" /* Evm */ };
1211
1228
  } else if ("svmTx" in tx) {
1212
- return { chainId: tx.svmTx?.chainId };
1229
+ return { chainId: tx.svmTx?.chainId, chainType: "svm" /* Svm */ };
1213
1230
  } else {
1214
1231
  throw new Error("executeRoute error: invalid message type");
1215
1232
  }
1216
1233
  });
1217
- chunk7MC3BVQN_cjs.updateRouteDetails({
1234
+ chunkUIQML2XG_cjs.updateRouteDetails({
1218
1235
  transactionDetails,
1219
1236
  routeId,
1220
1237
  options
@@ -1234,7 +1251,8 @@ var executeTransactions = async (options) => {
1234
1251
  disabledChainIds: validateChainIds,
1235
1252
  getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
1236
1253
  options,
1237
- routeId
1254
+ routeId,
1255
+ isMultiRoutes
1238
1256
  });
1239
1257
  const validateEnabledChainIds = async (chainId) => {
1240
1258
  await validateGasBalances({
@@ -1247,7 +1265,8 @@ var executeTransactions = async (options) => {
1247
1265
  enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
1248
1266
  getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
1249
1267
  options,
1250
- routeId
1268
+ routeId,
1269
+ isMultiRoutes
1251
1270
  });
1252
1271
  };
1253
1272
  let signedTxs = [];
@@ -1261,11 +1280,16 @@ var executeTransactions = async (options) => {
1261
1280
  await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
1262
1281
  const isAllowedToBatchSignTxsUpfront = await (async () => {
1263
1282
  try {
1264
- const currentUserAddress = options.userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
1283
+ const currentUserAddress = options.userAddresses.find(
1284
+ (x) => x.chainId === tx.cosmosTx?.chainId
1285
+ )?.address;
1265
1286
  if (!currentUserAddress) {
1266
1287
  return false;
1267
1288
  }
1268
- const { accountNumber } = await getAccountNumberAndSequence(currentUserAddress, tx.cosmosTx?.chainId);
1289
+ const { accountNumber } = await getAccountNumberAndSequence(
1290
+ currentUserAddress,
1291
+ tx.cosmosTx?.chainId
1292
+ );
1269
1293
  if (accountNumber) {
1270
1294
  return true;
1271
1295
  }
@@ -1292,7 +1316,12 @@ var executeTransactions = async (options) => {
1292
1316
  }
1293
1317
  if ("svmTx" in tx) {
1294
1318
  await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
1295
- const signedTx = await signSvmTransaction({ tx, options, index: i, routeId });
1319
+ const signedTx = await signSvmTransaction({
1320
+ tx,
1321
+ options,
1322
+ index: i,
1323
+ routeId
1324
+ });
1296
1325
  if (!signedTx) {
1297
1326
  throw new Error(`executeRoute error: signedTx is undefined`);
1298
1327
  }
@@ -1333,7 +1362,12 @@ var executeTransactions = async (options) => {
1333
1362
  });
1334
1363
  } else if ("evmTx" in tx) {
1335
1364
  await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
1336
- const txResponse = await executeEvmTransaction(tx, options, index, routeId);
1365
+ const txResponse = await executeEvmTransaction(
1366
+ tx,
1367
+ options,
1368
+ index,
1369
+ routeId
1370
+ );
1337
1371
  txResult = {
1338
1372
  chainId: tx?.evmTx?.chainId ?? "",
1339
1373
  txHash: txResponse.transactionHash
@@ -1348,12 +1382,10 @@ var executeTransactions = async (options) => {
1348
1382
  await onTransactionBroadcast?.({ ...txResult });
1349
1383
  return txResult;
1350
1384
  };
1351
- await chunk7MC3BVQN_cjs.executeAndSubscribeToRouteStatus({
1385
+ return {
1352
1386
  transactionDetails,
1353
- executeTransaction,
1354
- routeId,
1355
- options
1356
- });
1387
+ executeTransaction
1388
+ };
1357
1389
  };
1358
1390
  var EVM_GAS_AMOUNT = 15e4;
1359
1391
  var COSMOS_GAS_AMOUNT = {
@@ -1378,59 +1410,6 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
1378
1410
  }
1379
1411
  return defaultGasAmount;
1380
1412
  };
1381
- var executeRoute = async (options) => {
1382
- const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
1383
- const { id: routeId } = chunk7MC3BVQN_cjs.updateRouteDetails({
1384
- status: "unconfirmed",
1385
- options
1386
- });
1387
- let addressList = [];
1388
- userAddresses.forEach((userAddress, index) => {
1389
- const requiredChainAddress = route.requiredChainAddresses[index];
1390
- if (requiredChainAddress === userAddress?.chainId) {
1391
- addressList.push(userAddress.address);
1392
- }
1393
- });
1394
- if (addressList.length !== route.requiredChainAddresses.length) {
1395
- addressList = userAddresses.map((x) => x.address);
1396
- }
1397
- const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
1398
- if (!validLength) {
1399
- throw new Error("executeRoute error: invalid address list");
1400
- }
1401
- const isUserAddressesValid = await validateUserAddresses(userAddresses);
1402
- if (!isUserAddressesValid) {
1403
- throw new Error("executeRoute error: invalid user addresses");
1404
- }
1405
- const response = await chunkOZUCMWNE_cjs.messages({
1406
- timeoutSeconds,
1407
- amountIn: route?.amountIn,
1408
- amountOut: route.estimatedAmountOut || "0",
1409
- sourceAssetChainId: route?.sourceAssetChainId,
1410
- sourceAssetDenom: route?.sourceAssetDenom,
1411
- destAssetChainId: route?.destAssetChainId,
1412
- destAssetDenom: route?.destAssetDenom,
1413
- operations: route?.operations,
1414
- addressList,
1415
- slippageTolerancePercent: options.slippageTolerancePercent || "1",
1416
- chainIdsToAffiliates: chunkERGJBZUC_cjs.ApiState.chainIdsToAffiliates,
1417
- postRouteHandler: options.postRouteHandler,
1418
- feePayerAddress: options.svmFeePayer?.address
1419
- });
1420
- if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
1421
- const firstTx = response?.txs?.[0];
1422
- if (firstTx && "cosmosTx" in firstTx) {
1423
- firstTx.cosmosTx?.msgs?.unshift(beforeMsg);
1424
- }
1425
- }
1426
- if (afterMsg && (response?.txs?.length ?? 0) > 0) {
1427
- const lastTx = response?.txs?.[response.txs.length - 1];
1428
- if (lastTx && "cosmosTx" in lastTx) {
1429
- lastTx.cosmosTx?.msgs?.push(afterMsg);
1430
- }
1431
- }
1432
- await executeTransactions({ ...options, routeId, txs: response?.txs });
1433
- };
1434
1413
  var validateUserAddresses = async (userAddresses) => {
1435
1414
  const chains2 = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
1436
1415
  const validations = userAddresses.map((userAddress) => {
@@ -1470,5 +1449,30 @@ var validateUserAddresses = async (userAddresses) => {
1470
1449
  });
1471
1450
  return validations.every((validation) => validation);
1472
1451
  };
1452
+ var createValidAddressList = async ({
1453
+ userAddresses,
1454
+ route
1455
+ }) => {
1456
+ let addressList = [];
1457
+ userAddresses.forEach((userAddress, index) => {
1458
+ const requiredChainAddress = route.requiredChainAddresses[index];
1459
+ if (requiredChainAddress === userAddress?.chainId) {
1460
+ addressList.push(userAddress.address);
1461
+ }
1462
+ });
1463
+ if (addressList.length !== route.requiredChainAddresses.length) {
1464
+ addressList = userAddresses.map((x) => x.address);
1465
+ }
1466
+ const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
1467
+ if (!validLength) {
1468
+ throw new Error("createValidAddressList error: invalid address list");
1469
+ }
1470
+ const isUserAddressesValid = await validateUserAddresses(userAddresses);
1471
+ if (!isUserAddressesValid) {
1472
+ throw new Error("createValidAddressList error: invalid user addresses");
1473
+ }
1474
+ return addressList;
1475
+ };
1473
1476
 
1474
- exports.executeRoute = executeRoute;
1477
+ exports.createValidAddressList = createValidAddressList;
1478
+ exports.executeTransactions = executeTransactions;
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
4
- var chunkQ43XCBMX_cjs = require('./chunk-Q43XCBMX.cjs');
4
+ var chunkW3KF3V57_cjs = require('./chunk-W3KF3V57.cjs');
5
5
  var math = require('@cosmjs/math');
6
6
  var stargate = require('@cosmjs/stargate');
7
7
 
8
8
  var getRecommendedGasPrice = async (props) => {
9
- const feeInfo = await chunkQ43XCBMX_cjs.getFeeInfoForChain(props);
9
+ const feeInfo = await chunkW3KF3V57_cjs.getFeeInfoForChain(props);
10
10
  if (!feeInfo || !feeInfo.gasPrice) {
11
11
  return void 0;
12
12
  }