@skip-go/client 1.4.0 → 1.5.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 (71) hide show
  1. package/dist/cjs/{chunk-IDEJORRT.cjs → chunk-23YF4LFI.cjs} +30 -0
  2. package/dist/cjs/{chunk-Q43XCBMX.cjs → chunk-5CB6SPCX.cjs} +4 -4
  3. package/dist/cjs/{chunk-ZKBSNSHQ.cjs → chunk-EZGHN6ZL.cjs} +120 -116
  4. package/dist/cjs/{chunk-7MC3BVQN.cjs → chunk-KHJQE3DI.cjs} +133 -35
  5. package/dist/cjs/chunk-KSJ5QYMR.cjs +185 -0
  6. package/dist/cjs/chunk-N5V3YW5K.cjs +55 -0
  7. package/dist/cjs/chunk-NDSHB4I6.cjs +214 -0
  8. package/dist/cjs/{chunk-ZAATXQBG.cjs → chunk-QZ2BGX6O.cjs} +2 -2
  9. package/dist/cjs/{chunk-6LA66667.cjs → chunk-RVXCF6AL.cjs} +3 -3
  10. package/dist/cjs/{chunk-46VB6RQK.cjs → chunk-V3FWWJG2.cjs} +10 -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/api/getAssets.d.ts +1 -1
  21. package/dist/esm/api/getAssetsBetweenChains.d.ts +1 -1
  22. package/dist/esm/api/getBridges.d.ts +3 -3
  23. package/dist/esm/api/getChains.d.ts +1 -1
  24. package/dist/esm/api/postAssetsFromSource.d.ts +10 -1
  25. package/dist/esm/api/postBalances.d.ts +2 -2
  26. package/dist/esm/api/postMessages.d.ts +2 -2
  27. package/dist/esm/api/postMessagesDirect.d.ts +3 -1
  28. package/dist/esm/api/postRecommendAssets.d.ts +1 -1
  29. package/dist/esm/api/postRoute.d.ts +4 -2
  30. package/dist/esm/api/postSubmitTransaction.d.ts +2 -2
  31. package/dist/esm/api/postTrackTransaction.d.ts +2 -2
  32. package/dist/esm/api/postTransactionStatus.d.ts +2 -2
  33. package/dist/esm/{callbacks-B3kjKg0v.d.ts → callbacks-DCqqd0D9.d.ts} +22 -69
  34. package/dist/esm/{chunk-CIAOTO3M.js → chunk-2DD5F6PK.js} +1 -1
  35. package/dist/esm/{chunk-4RLJWCQR.js → chunk-3J5IMMMB.js} +1 -1
  36. package/dist/esm/chunk-562J5DCB.js +53 -0
  37. package/dist/esm/{chunk-KYDY7QRT.js → chunk-BZDVQMHK.js} +1 -1
  38. package/dist/esm/chunk-FVQFGEL2.js +212 -0
  39. package/dist/esm/chunk-RHGDUD76.js +180 -0
  40. package/dist/esm/{chunk-GHNH5QC3.js → chunk-VZGOU6MB.js} +9 -2
  41. package/dist/esm/{chunk-BAJFQZDT.js → chunk-W5EGS2G4.js} +99 -96
  42. package/dist/esm/{chunk-REWUSU53.js → chunk-WBZVMPPV.js} +30 -0
  43. package/dist/esm/{chunk-RQ7DXNSS.js → chunk-XYYXRVFN.js} +133 -35
  44. package/dist/esm/client-types-BSZasIDd.d.ts +114 -0
  45. package/dist/esm/{generateApi-C_xgtxrO.d.ts → generateApi-CwM4Ca30.d.ts} +1 -1
  46. package/dist/esm/index.d.ts +216 -6
  47. package/dist/esm/index.js +12 -10
  48. package/dist/esm/public-functions/executeMultipleRoutes.d.ts +60 -0
  49. package/dist/esm/public-functions/executeMultipleRoutes.js +20 -0
  50. package/dist/esm/public-functions/executeRoute.d.ts +5 -5
  51. package/dist/esm/public-functions/executeRoute.js +7 -6
  52. package/dist/esm/public-functions/getCosmosGasAmountForMessage.d.ts +1 -1
  53. package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +5 -2
  54. package/dist/esm/public-functions/getFeeInfoForChain.d.ts +1 -1
  55. package/dist/esm/public-functions/getFeeInfoForChain.js +2 -2
  56. package/dist/esm/public-functions/getRecommendedGasPrice.js +3 -3
  57. package/dist/esm/public-functions/getSigningStargateClient.js +2 -2
  58. package/dist/esm/public-functions/setApiOptions.d.ts +1 -1
  59. package/dist/esm/public-functions/setClientOptions.d.ts +5 -3
  60. package/dist/esm/public-functions/setClientOptions.js +1 -1
  61. package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +5 -5
  62. package/dist/esm/public-functions/subscribeToRouteStatus.js +1 -1
  63. package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +7 -6
  64. package/dist/esm/public-functions/validateCosmosGasBalance.js +4 -4
  65. package/dist/esm/public-functions/waitForTransaction.d.ts +5 -5
  66. package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-0DYCj_A5.d.ts} +1 -1
  67. package/dist/esm/{swaggerTypes-DDwqIjap.d.ts → swaggerTypes-Bh6hu5Q-.d.ts} +220 -196
  68. package/package.json +1 -1
  69. package/dist/cjs/chunk-VIG2BHYJ.cjs +0 -185
  70. package/dist/esm/chunk-3J6O2PVK.js +0 -180
  71. package/dist/esm/client-types-B7Fin0mq.d.ts +0 -61
@@ -1,6 +1,6 @@
1
1
  import { getCosmosGasAmountForMessage } from './chunk-KNXMSLOB.js';
2
2
  import { BigNumber } from './chunk-VQ5SIQWU.js';
3
- import { getSigningStargateClient } from './chunk-KYDY7QRT.js';
3
+ import { getSigningStargateClient } from './chunk-BZDVQMHK.js';
4
4
  import { ClientState, balances } from './chunk-ZOUYAZU6.js';
5
5
  import { GasPrice, calculateFee } from '@cosmjs/stargate';
6
6
  import { Decimal } from '@cosmjs/math';
@@ -13,7 +13,8 @@ var validateCosmosGasBalance = async ({
13
13
  getOfflineSigner,
14
14
  txIndex,
15
15
  simulate,
16
- getCosmosPriorityFeeDenom
16
+ getCosmosPriorityFeeDenom,
17
+ isMultiRoutes
17
18
  }) => {
18
19
  const skipAssets = (await ClientState.getSkipAssets({ chainId }))?.[chainId];
19
20
  const skipChains = await ClientState.getSkipChains();
@@ -81,6 +82,12 @@ var validateCosmosGasBalance = async ({
81
82
  return null;
82
83
  }
83
84
  if (chainId === "noble-1") {
85
+ if (isMultiRoutes && txIndex === 0) {
86
+ return calculateFee(
87
+ Math.ceil(parseFloat(estimatedGasAmount)),
88
+ gasPrice
89
+ );
90
+ }
84
91
  if (asset.denom.toLowerCase() === "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0".toLowerCase()) {
85
92
  const fee2 = calculateFee(2e6, gasPrice);
86
93
  return fee2;
@@ -1,18 +1,15 @@
1
- import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-RQ7DXNSS.js';
2
- import { validateCosmosGasBalance } from './chunk-GHNH5QC3.js';
1
+ import { updateRouteDetails } from './chunk-XYYXRVFN.js';
2
+ import { validateCosmosGasBalance } from './chunk-VZGOU6MB.js';
3
3
  import { getEncodeObjectFromCosmosMessage } from './chunk-KNXMSLOB.js';
4
4
  import { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
5
5
  import { BigNumber } from './chunk-VQ5SIQWU.js';
6
6
  import { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
7
- import { getRpcEndpointForChain, accountParser, getSigningStargateClient } from './chunk-KYDY7QRT.js';
8
- import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-3J6O2PVK.js';
9
- import { messages } from './chunk-AND7HVIU.js';
7
+ import { getRpcEndpointForChain, accountParser, getSigningStargateClient } from './chunk-BZDVQMHK.js';
8
+ import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-RHGDUD76.js';
10
9
  import { submitTransaction } from './chunk-JQ4F4WBG.js';
11
10
  import { venues } from './chunk-52PEBJRQ.js';
12
11
  import { ClientState, balances } from './chunk-ZOUYAZU6.js';
13
- import { ApiState, toCamel, wait } from './chunk-A6KSECAH.js';
14
- import { PublicKey, Transaction, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
15
- import { bech32m, bech32 } from 'bech32';
12
+ import { toCamel, wait } from './chunk-A6KSECAH.js';
16
13
  import { StargateClient } from '@cosmjs/stargate';
17
14
  import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
18
15
  import { isOfflineDirectSigner, makeAuthInfoBytes, makeSignDoc, encodePubkey } from '@cosmjs/proto-signing';
@@ -23,6 +20,8 @@ import { Any } from 'cosmjs-types/google/protobuf/any.js';
23
20
  import { Int53 } from '@cosmjs/math';
24
21
  import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing.js';
25
22
  import { isAddress, publicActions, maxUint256, formatUnits } from 'viem';
23
+ import { Transaction, PublicKey, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
24
+ import { bech32m, bech32 } from 'bech32';
26
25
 
27
26
  // src/private-functions/getRestEndpointForChain.ts
28
27
  var getRestEndpointForChain = async (chainId) => {
@@ -172,11 +171,11 @@ var signCosmosMessageDirect = async (options) => {
172
171
  if (!accountFromSigner) {
173
172
  throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
174
173
  }
175
- const messages2 = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
174
+ const messages = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
176
175
  const txBodyEncodeObject = {
177
176
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
178
177
  value: {
179
- messages: messages2
178
+ messages
180
179
  }
181
180
  };
182
181
  const txBodyBytes = ClientState.registry.encode(txBodyEncodeObject);
@@ -207,26 +206,40 @@ var signCosmosMessageAmino = async (options) => {
207
206
  signerData: { accountNumber, sequence, chainId: signerChainId }
208
207
  } = options;
209
208
  const accounts = await signer.getAccounts();
210
- const accountFromSigner = accounts.find((account) => account.address === signerAddress);
209
+ const accountFromSigner = accounts.find(
210
+ (account) => account.address === signerAddress
211
+ );
211
212
  if (!accountFromSigner) {
212
- throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
213
+ throw new Error(
214
+ "signCosmosMessageAmino: failed to retrieve account from signer"
215
+ );
213
216
  }
214
- const messages2 = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
217
+ const messages = cosmosMsgs.map(
218
+ (cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg)
219
+ );
215
220
  const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
216
- const msgs = messages2.map((msg) => ClientState.aminoTypes.toAmino(msg));
217
- console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
218
- const signDoc = makeSignDoc$1(msgs, fee, signerChainId, "", accountNumber, sequence);
221
+ const msgs = messages.map((msg) => ClientState.aminoTypes.toAmino(msg));
222
+ const signDoc = makeSignDoc$1(
223
+ msgs,
224
+ fee,
225
+ signerChainId,
226
+ "",
227
+ accountNumber,
228
+ sequence
229
+ );
219
230
  const { signature, signed } = await signer.signAmino(signerAddress, signDoc);
220
231
  const signedTxBody = {
221
232
  messages: signed.msgs.map((msg) => ClientState.aminoTypes.fromAmino(msg)),
222
233
  memo: signed.memo
223
234
  };
224
- signedTxBody.messages[0].value.memo = messages2[0].value.memo;
235
+ signedTxBody.messages[0].value.memo = messages[0].value.memo;
225
236
  const signedTxBodyEncodeObject = {
226
237
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
227
238
  value: signedTxBody
228
239
  };
229
- const signedTxBodyBytes = ClientState.registry.encode(signedTxBodyEncodeObject);
240
+ const signedTxBodyBytes = ClientState.registry.encode(
241
+ signedTxBodyEncodeObject
242
+ );
230
243
  const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber();
231
244
  const signedSequence = Int53.fromString(signed.sequence).toNumber();
232
245
  const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
@@ -257,7 +270,7 @@ var signCosmosTransaction = async ({
257
270
  throw new Error("executeCosmosTransaction error: tx is undefined");
258
271
  }
259
272
  const chainId = tx.cosmosTx?.chainId;
260
- const messages2 = tx.cosmosTx?.msgs;
273
+ const messages = tx.cosmosTx?.msgs;
261
274
  const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
262
275
  const gasArray = ClientState.validateGasResults;
263
276
  const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
@@ -271,7 +284,7 @@ var signCosmosTransaction = async ({
271
284
  if (chainId === void 0) {
272
285
  throw new Error("no chainId found for tx");
273
286
  }
274
- if (messages2 === void 0) {
287
+ if (messages === void 0) {
275
288
  throw new Error("no messages found for tx");
276
289
  }
277
290
  const { signer } = await getSigningStargateClient({
@@ -300,7 +313,7 @@ var signCosmosTransaction = async ({
300
313
  const commonRawTxBody = {
301
314
  signerAddress: currentUserAddress,
302
315
  chainId,
303
- cosmosMsgs: messages2,
316
+ cosmosMsgs: messages,
304
317
  fee,
305
318
  signerData: {
306
319
  accountNumber,
@@ -876,7 +889,8 @@ var validateEvmGasBalance = async ({
876
889
  signer,
877
890
  tx,
878
891
  getFallbackGasAmount,
879
- useUnlimitedApproval
892
+ useUnlimitedApproval,
893
+ bypassApprovalCheck
880
894
  }) => {
881
895
  const chainId = tx?.chainId ?? "";
882
896
  const skipAssets = (await ClientState.getSkipAssets({ chainId }))?.[chainId];
@@ -901,7 +915,7 @@ var validateEvmGasBalance = async ({
901
915
  )?.[1];
902
916
  const gasBalance = nativeGasBalance || zeroAddressGasBalance;
903
917
  const { requiredErc20Approvals } = tx;
904
- if (requiredErc20Approvals) {
918
+ if (!bypassApprovalCheck && requiredErc20Approvals) {
905
919
  try {
906
920
  await validateEvmTokenApproval({
907
921
  requiredErc20Approvals,
@@ -1038,10 +1052,10 @@ var validateGasBalances = async ({
1038
1052
  simulate,
1039
1053
  disabledChainIds,
1040
1054
  enabledChainIds,
1041
- useUnlimitedApproval,
1042
1055
  getCosmosPriorityFeeDenom,
1043
1056
  routeId,
1044
- options
1057
+ options,
1058
+ isMultiRoutes
1045
1059
  }) => {
1046
1060
  const validateResult = await Promise.all(
1047
1061
  txs.map(async (tx, i) => {
@@ -1069,7 +1083,8 @@ var validateGasBalances = async ({
1069
1083
  getOfflineSigner: getCosmosSigner,
1070
1084
  txIndex: i,
1071
1085
  simulate,
1072
- getCosmosPriorityFeeDenom
1086
+ getCosmosPriorityFeeDenom,
1087
+ isMultiRoutes
1073
1088
  });
1074
1089
  return res;
1075
1090
  } catch (e) {
@@ -1101,7 +1116,8 @@ var validateGasBalances = async ({
1101
1116
  tx: tx.evmTx,
1102
1117
  signer,
1103
1118
  getFallbackGasAmount,
1104
- useUnlimitedApproval
1119
+ useUnlimitedApproval: options?.useUnlimitedApproval,
1120
+ bypassApprovalCheck: options?.bypassApprovalCheck
1105
1121
  });
1106
1122
  return res;
1107
1123
  } catch (e) {
@@ -1193,7 +1209,8 @@ var executeTransactions = async (options) => {
1193
1209
  onValidateGasBalance,
1194
1210
  trackTxPollingOptions,
1195
1211
  batchSignTxs = true,
1196
- routeId
1212
+ routeId,
1213
+ isMultiRoutes
1197
1214
  } = options;
1198
1215
  if (txs === void 0) {
1199
1216
  throw new Error(
@@ -1203,11 +1220,11 @@ var executeTransactions = async (options) => {
1203
1220
  const chainIds = getChainIdsFromTxs(txs);
1204
1221
  const transactionDetails = txs.map((tx) => {
1205
1222
  if ("cosmosTx" in tx) {
1206
- return { chainId: tx.cosmosTx?.chainId };
1223
+ return { chainId: tx.cosmosTx?.chainId, chainType: "cosmos" /* Cosmos */ };
1207
1224
  } else if ("evmTx" in tx) {
1208
- return { chainId: tx.evmTx?.chainId };
1225
+ return { chainId: tx.evmTx?.chainId, chainType: "evm" /* Evm */ };
1209
1226
  } else if ("svmTx" in tx) {
1210
- return { chainId: tx.svmTx?.chainId };
1227
+ return { chainId: tx.svmTx?.chainId, chainType: "svm" /* Svm */ };
1211
1228
  } else {
1212
1229
  throw new Error("executeRoute error: invalid message type");
1213
1230
  }
@@ -1232,7 +1249,8 @@ var executeTransactions = async (options) => {
1232
1249
  disabledChainIds: validateChainIds,
1233
1250
  getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
1234
1251
  options,
1235
- routeId
1252
+ routeId,
1253
+ isMultiRoutes
1236
1254
  });
1237
1255
  const validateEnabledChainIds = async (chainId) => {
1238
1256
  await validateGasBalances({
@@ -1245,7 +1263,8 @@ var executeTransactions = async (options) => {
1245
1263
  enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
1246
1264
  getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
1247
1265
  options,
1248
- routeId
1266
+ routeId,
1267
+ isMultiRoutes
1249
1268
  });
1250
1269
  };
1251
1270
  let signedTxs = [];
@@ -1259,11 +1278,16 @@ var executeTransactions = async (options) => {
1259
1278
  await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
1260
1279
  const isAllowedToBatchSignTxsUpfront = await (async () => {
1261
1280
  try {
1262
- const currentUserAddress = options.userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
1281
+ const currentUserAddress = options.userAddresses.find(
1282
+ (x) => x.chainId === tx.cosmosTx?.chainId
1283
+ )?.address;
1263
1284
  if (!currentUserAddress) {
1264
1285
  return false;
1265
1286
  }
1266
- const { accountNumber } = await getAccountNumberAndSequence(currentUserAddress, tx.cosmosTx?.chainId);
1287
+ const { accountNumber } = await getAccountNumberAndSequence(
1288
+ currentUserAddress,
1289
+ tx.cosmosTx?.chainId
1290
+ );
1267
1291
  if (accountNumber) {
1268
1292
  return true;
1269
1293
  }
@@ -1290,7 +1314,12 @@ var executeTransactions = async (options) => {
1290
1314
  }
1291
1315
  if ("svmTx" in tx) {
1292
1316
  await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
1293
- const signedTx = await signSvmTransaction({ tx, options, index: i, routeId });
1317
+ const signedTx = await signSvmTransaction({
1318
+ tx,
1319
+ options,
1320
+ index: i,
1321
+ routeId
1322
+ });
1294
1323
  if (!signedTx) {
1295
1324
  throw new Error(`executeRoute error: signedTx is undefined`);
1296
1325
  }
@@ -1331,7 +1360,12 @@ var executeTransactions = async (options) => {
1331
1360
  });
1332
1361
  } else if ("evmTx" in tx) {
1333
1362
  await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
1334
- const txResponse = await executeEvmTransaction(tx, options, index, routeId);
1363
+ const txResponse = await executeEvmTransaction(
1364
+ tx,
1365
+ options,
1366
+ index,
1367
+ routeId
1368
+ );
1335
1369
  txResult = {
1336
1370
  chainId: tx?.evmTx?.chainId ?? "",
1337
1371
  txHash: txResponse.transactionHash
@@ -1346,12 +1380,10 @@ var executeTransactions = async (options) => {
1346
1380
  await onTransactionBroadcast?.({ ...txResult });
1347
1381
  return txResult;
1348
1382
  };
1349
- await executeAndSubscribeToRouteStatus({
1383
+ return {
1350
1384
  transactionDetails,
1351
- executeTransaction,
1352
- routeId,
1353
- options
1354
- });
1385
+ executeTransaction
1386
+ };
1355
1387
  };
1356
1388
  var EVM_GAS_AMOUNT = 15e4;
1357
1389
  var COSMOS_GAS_AMOUNT = {
@@ -1376,59 +1408,6 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
1376
1408
  }
1377
1409
  return defaultGasAmount;
1378
1410
  };
1379
- var executeRoute = async (options) => {
1380
- const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
1381
- const { id: routeId } = updateRouteDetails({
1382
- status: "unconfirmed",
1383
- options
1384
- });
1385
- let addressList = [];
1386
- userAddresses.forEach((userAddress, index) => {
1387
- const requiredChainAddress = route.requiredChainAddresses[index];
1388
- if (requiredChainAddress === userAddress?.chainId) {
1389
- addressList.push(userAddress.address);
1390
- }
1391
- });
1392
- if (addressList.length !== route.requiredChainAddresses.length) {
1393
- addressList = userAddresses.map((x) => x.address);
1394
- }
1395
- const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
1396
- if (!validLength) {
1397
- throw new Error("executeRoute error: invalid address list");
1398
- }
1399
- const isUserAddressesValid = await validateUserAddresses(userAddresses);
1400
- if (!isUserAddressesValid) {
1401
- throw new Error("executeRoute error: invalid user addresses");
1402
- }
1403
- const response = await messages({
1404
- timeoutSeconds,
1405
- amountIn: route?.amountIn,
1406
- amountOut: route.estimatedAmountOut || "0",
1407
- sourceAssetChainId: route?.sourceAssetChainId,
1408
- sourceAssetDenom: route?.sourceAssetDenom,
1409
- destAssetChainId: route?.destAssetChainId,
1410
- destAssetDenom: route?.destAssetDenom,
1411
- operations: route?.operations,
1412
- addressList,
1413
- slippageTolerancePercent: options.slippageTolerancePercent || "1",
1414
- chainIdsToAffiliates: ApiState.chainIdsToAffiliates,
1415
- postRouteHandler: options.postRouteHandler,
1416
- feePayerAddress: options.svmFeePayer?.address
1417
- });
1418
- if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
1419
- const firstTx = response?.txs?.[0];
1420
- if (firstTx && "cosmosTx" in firstTx) {
1421
- firstTx.cosmosTx?.msgs?.unshift(beforeMsg);
1422
- }
1423
- }
1424
- if (afterMsg && (response?.txs?.length ?? 0) > 0) {
1425
- const lastTx = response?.txs?.[response.txs.length - 1];
1426
- if (lastTx && "cosmosTx" in lastTx) {
1427
- lastTx.cosmosTx?.msgs?.push(afterMsg);
1428
- }
1429
- }
1430
- await executeTransactions({ ...options, routeId, txs: response?.txs });
1431
- };
1432
1411
  var validateUserAddresses = async (userAddresses) => {
1433
1412
  const chains2 = await ClientState.getSkipChains();
1434
1413
  const validations = userAddresses.map((userAddress) => {
@@ -1468,5 +1447,29 @@ var validateUserAddresses = async (userAddresses) => {
1468
1447
  });
1469
1448
  return validations.every((validation) => validation);
1470
1449
  };
1450
+ var createValidAddressList = async ({
1451
+ userAddresses,
1452
+ route
1453
+ }) => {
1454
+ let addressList = [];
1455
+ userAddresses.forEach((userAddress, index) => {
1456
+ const requiredChainAddress = route.requiredChainAddresses[index];
1457
+ if (requiredChainAddress === userAddress?.chainId) {
1458
+ addressList.push(userAddress.address);
1459
+ }
1460
+ });
1461
+ if (addressList.length !== route.requiredChainAddresses.length) {
1462
+ addressList = userAddresses.map((x) => x.address);
1463
+ }
1464
+ const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
1465
+ if (!validLength) {
1466
+ throw new Error("createValidAddressList error: invalid address list");
1467
+ }
1468
+ const isUserAddressesValid = await validateUserAddresses(userAddresses);
1469
+ if (!isUserAddressesValid) {
1470
+ throw new Error("createValidAddressList error: invalid user addresses");
1471
+ }
1472
+ return addressList;
1473
+ };
1471
1474
 
1472
- export { executeRoute };
1475
+ export { createValidAddressList, executeTransactions };
@@ -2200,6 +2200,34 @@ var evmosAminoConverters = {
2200
2200
  ...AminoConverter5
2201
2201
  };
2202
2202
  var evmosProtoRegistry = [...registry2, ...registry3, ...registry4, ...registry5];
2203
+
2204
+ // src/codegen/initia/move/v1/tx.amino.ts
2205
+ var AminoConverter6 = {
2206
+ "/initia.move.v1.MsgExecute": {
2207
+ aminoType: "/initia.move.v1.MsgExecute",
2208
+ toAmino: MsgExecute.toAmino,
2209
+ fromAmino: MsgExecute.fromAmino
2210
+ }
2211
+ };
2212
+
2213
+ // src/codegen/initia/client.ts
2214
+ var initiaAminoConverters = {
2215
+ ...AminoConverter6
2216
+ };
2217
+
2218
+ // src/codegen/opinit/ophost/v1/tx.amino.ts
2219
+ var AminoConverter7 = {
2220
+ "/opinit.ophost.v1.MsgInitiateTokenDeposit": {
2221
+ aminoType: "ophost/MsgInitiateTokenDeposit",
2222
+ toAmino: MsgInitiateTokenDeposit.toAmino,
2223
+ fromAmino: MsgInitiateTokenDeposit.fromAmino
2224
+ }
2225
+ };
2226
+
2227
+ // src/codegen/opinit/client.ts
2228
+ var opinitAminoConverters = {
2229
+ ...AminoConverter7
2230
+ };
2203
2231
  var setClientOptions = (options = {}) => {
2204
2232
  ApiState.client = createRequestClient({
2205
2233
  apiUrl: options.apiUrl || "https://api.skip.build",
@@ -2212,6 +2240,8 @@ var setClientOptions = (options = {}) => {
2212
2240
  ...createWasmAminoConverters(),
2213
2241
  ...circleAminoConverters,
2214
2242
  ...evmosAminoConverters,
2243
+ ...initiaAminoConverters,
2244
+ ...opinitAminoConverters,
2215
2245
  ...options.aminoTypes ?? {}
2216
2246
  });
2217
2247
  ClientState.registry = new Registry([