@skip-go/client 1.3.7 → 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.
- package/dist/cjs/api/getAssets.cjs +4 -4
- package/dist/cjs/api/getAssetsBetweenChains.cjs +3 -3
- package/dist/cjs/api/getBridges.cjs +3 -3
- package/dist/cjs/api/getChains.cjs +3 -3
- package/dist/cjs/api/getVenues.cjs +3 -3
- package/dist/cjs/api/postAssetsFromSource.cjs +4 -4
- package/dist/cjs/api/postBalances.cjs +3 -3
- package/dist/cjs/api/postIbcOriginAssets.cjs +3 -3
- package/dist/cjs/api/postMessages.cjs +3 -3
- package/dist/cjs/api/postMessagesDirect.cjs +3 -3
- package/dist/cjs/api/postRecommendAssets.cjs +3 -3
- package/dist/cjs/api/postRoute.cjs +3 -3
- package/dist/cjs/api/postSubmitTransaction.cjs +3 -3
- package/dist/cjs/api/postTrackTransaction.cjs +3 -3
- package/dist/cjs/api/postTransactionStatus.cjs +3 -3
- package/dist/cjs/{chunk-2EKCOIWV.cjs → chunk-23YF4LFI.cjs} +185 -154
- package/dist/cjs/chunk-3M7YYWGL.cjs +295 -0
- package/dist/cjs/chunk-4YTACAVP.cjs +185 -0
- package/dist/cjs/{chunk-MW3TE7DC.cjs → chunk-5AYPH3ZR.cjs} +2 -2
- package/dist/cjs/{chunk-2CCLIBCC.cjs → chunk-5HDKZVOL.cjs} +2 -2
- package/dist/cjs/{chunk-YYBGBKRE.cjs → chunk-A26H4FVN.cjs} +4 -4
- package/dist/cjs/{chunk-P7CDAHIX.cjs → chunk-AXYRULAI.cjs} +2 -2
- package/dist/cjs/{chunk-E2P5MVX3.cjs → chunk-CUDPMOR6.cjs} +16 -9
- package/dist/cjs/{chunk-WMXUOVHN.cjs → chunk-DWOE6N5S.cjs} +248 -532
- package/dist/cjs/{chunk-7I2KQNIU.cjs → chunk-EJMC4JXF.cjs} +2 -2
- package/dist/cjs/{chunk-HKQ5VION.cjs → chunk-ERGJBZUC.cjs} +5 -1
- package/dist/cjs/{chunk-J5RC6ZU5.cjs → chunk-FNB244QI.cjs} +6 -6
- package/dist/cjs/chunk-GCJO6DZD.cjs +55 -0
- package/dist/cjs/{chunk-OEYY7NXT.cjs → chunk-HHZGD62Y.cjs} +256 -168
- package/dist/cjs/{chunk-DBDB2XWX.cjs → chunk-JBKNEFXB.cjs} +3 -3
- package/dist/cjs/{chunk-AF7EI5BT.cjs → chunk-K4YAPDUE.cjs} +2 -2
- package/dist/cjs/{chunk-MN6HFZJA.cjs → chunk-KM2D7PJL.cjs} +33 -33
- package/dist/cjs/{chunk-XGBCEYWI.cjs → chunk-LHY62HPI.cjs} +2 -2
- package/dist/cjs/{chunk-EXK2GDR5.cjs → chunk-LUVMRHAJ.cjs} +2 -2
- package/dist/cjs/{chunk-QSISUSYP.cjs → chunk-N4UW74AG.cjs} +4 -4
- package/dist/cjs/{chunk-FY56EEFB.cjs → chunk-OZUCMWNE.cjs} +2 -2
- package/dist/cjs/{chunk-2VQ2TNFM.cjs → chunk-QPM7H2YL.cjs} +2 -2
- package/dist/cjs/{chunk-FO25SR66.cjs → chunk-RCGCQD6T.cjs} +6 -6
- package/dist/cjs/chunk-UIQML2XG.cjs +455 -0
- package/dist/cjs/chunk-VF65UG3E.cjs +214 -0
- package/dist/cjs/{chunk-VKVHMUDR.cjs → chunk-W3KF3V57.cjs} +6 -6
- package/dist/cjs/{chunk-YN66ABRQ.cjs → chunk-X22PL5T7.cjs} +126 -16
- package/dist/cjs/{chunk-DCFIIF7G.cjs → chunk-X5AJHZ2J.cjs} +2 -2
- package/dist/cjs/{chunk-MCZ3F457.cjs → chunk-ZBPDDVQ2.cjs} +2 -2
- package/dist/cjs/index.cjs +66 -54
- package/dist/cjs/public-functions/executeMultipleRoutes.cjs +29 -0
- package/dist/cjs/public-functions/executeRoute.cjs +17 -15
- package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +5 -4
- package/dist/cjs/public-functions/getFeeInfoForChain.cjs +5 -5
- package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +6 -6
- package/dist/cjs/public-functions/getSigningStargateClient.cjs +6 -5
- package/dist/cjs/public-functions/setApiOptions.cjs +3 -3
- package/dist/cjs/public-functions/setClientOptions.cjs +6 -5
- package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +26 -0
- package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +9 -8
- package/dist/cjs/public-functions/waitForTransaction.cjs +5 -5
- package/dist/esm/api/getAssets.js +2 -2
- package/dist/esm/api/getAssetsBetweenChains.js +2 -2
- package/dist/esm/api/getBridges.js +2 -2
- package/dist/esm/api/getChains.js +2 -2
- package/dist/esm/api/getVenues.js +2 -2
- package/dist/esm/api/postAssetsFromSource.js +3 -3
- package/dist/esm/api/postBalances.js +2 -2
- package/dist/esm/api/postIbcOriginAssets.js +2 -2
- package/dist/esm/api/postMessages.js +2 -2
- package/dist/esm/api/postMessagesDirect.js +2 -2
- package/dist/esm/api/postRecommendAssets.js +2 -2
- package/dist/esm/api/postRoute.js +2 -2
- package/dist/esm/api/postSubmitTransaction.js +2 -2
- package/dist/esm/api/postTrackTransaction.d.ts +2 -1
- package/dist/esm/api/postTrackTransaction.js +2 -2
- package/dist/esm/api/postTransactionStatus.d.ts +1 -1
- package/dist/esm/api/postTransactionStatus.js +2 -2
- package/dist/esm/callbacks-CvqAtBJq.d.ts +130 -0
- package/dist/esm/{chunk-SJP6W2SK.js → chunk-3XOGEVJL.js} +1 -1
- package/dist/esm/{chunk-JSY7M43P.js → chunk-52PEBJRQ.js} +1 -1
- package/dist/esm/chunk-7RS3YIVC.js +53 -0
- package/dist/esm/{chunk-7ITTEUMR.js → chunk-7X4ERB3R.js} +1 -1
- package/dist/esm/{chunk-LZI7A4JI.js → chunk-A6KSECAH.js} +5 -1
- package/dist/esm/{chunk-7LSTJXAF.js → chunk-AND7HVIU.js} +1 -1
- package/dist/esm/{chunk-MXCJ2M3K.js → chunk-APRMN34M.js} +1 -1
- package/dist/esm/chunk-AZALP3WR.js +212 -0
- package/dist/esm/{chunk-5JZOTYDC.js → chunk-CX5N7ZLJ.js} +1 -1
- package/dist/esm/{chunk-JYUNVL4F.js → chunk-FH2YHZVV.js} +1 -1
- package/dist/esm/chunk-IUYOY23L.js +180 -0
- package/dist/esm/{chunk-IQQDEBLI.js → chunk-JKN4E5VN.js} +11 -4
- package/dist/esm/{chunk-OHV2LZEG.js → chunk-JQ4F4WBG.js} +1 -1
- package/dist/esm/{chunk-5FKIW2ZL.js → chunk-KLGGCB73.js} +2 -2
- package/dist/esm/{chunk-P76IRSIS.js → chunk-KNXMSLOB.js} +2 -2
- package/dist/esm/{chunk-IWXRHEX4.js → chunk-LHNGF5J2.js} +2 -2
- package/dist/esm/{chunk-KJVD5P3Q.js → chunk-MPSXXWKL.js} +109 -3
- package/dist/esm/{chunk-FFFVITWF.js → chunk-MTAS5XMN.js} +219 -132
- package/dist/esm/{chunk-JIADJKRD.js → chunk-OTS5KO43.js} +1 -1
- package/dist/esm/{chunk-CU6W3622.js → chunk-QIS6ILPS.js} +3 -3
- package/dist/esm/chunk-QO2CYYF5.js +278 -0
- package/dist/esm/{chunk-XXTECZG3.js → chunk-S4RO2LHD.js} +1 -1
- package/dist/esm/{chunk-7YN3UVVF.js → chunk-UI3SIFZN.js} +1 -1
- package/dist/esm/{chunk-TD63P2AG.js → chunk-UIDIKXMB.js} +65 -340
- package/dist/esm/chunk-VUXLWWLF.js +450 -0
- package/dist/esm/{chunk-OL7CWCPB.js → chunk-WBZVMPPV.js} +34 -3
- package/dist/esm/{chunk-HT6O3BQ7.js → chunk-Y2YCODZK.js} +1 -1
- package/dist/esm/{chunk-IPHFFTGO.js → chunk-ZI3SYUQH.js} +1 -1
- package/dist/esm/{chunk-2L7PKZDY.js → chunk-ZOUYAZU6.js} +1 -1
- package/dist/esm/client-types-Dk6ypWdO.d.ts +114 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +29 -25
- package/dist/esm/public-functions/executeMultipleRoutes.d.ts +60 -0
- package/dist/esm/public-functions/executeMultipleRoutes.js +20 -0
- package/dist/esm/public-functions/executeRoute.d.ts +7 -76
- package/dist/esm/public-functions/executeRoute.js +16 -14
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +3 -2
- package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +4 -1
- package/dist/esm/public-functions/getFeeInfoForChain.js +4 -4
- package/dist/esm/public-functions/getRecommendedGasPrice.js +5 -5
- package/dist/esm/public-functions/getSigningStargateClient.js +5 -4
- package/dist/esm/public-functions/setApiOptions.js +2 -2
- package/dist/esm/public-functions/setClientOptions.d.ts +4 -2
- package/dist/esm/public-functions/setClientOptions.js +5 -4
- package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +12 -0
- package/dist/esm/public-functions/subscribeToRouteStatus.js +5 -0
- package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +7 -5
- package/dist/esm/public-functions/validateCosmosGasBalance.js +8 -7
- package/dist/esm/public-functions/waitForTransaction.d.ts +6 -2
- package/dist/esm/public-functions/waitForTransaction.js +4 -4
- package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-BD8e7m2x.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/cjs/chunk-7H6XRQAX.cjs +0 -185
- package/dist/esm/callbacks-CuL50GnB.d.ts +0 -38
- package/dist/esm/chunk-U6AH2WOP.js +0 -180
- package/dist/esm/client-types-B7Fin0mq.d.ts +0 -61
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkUIQML2XG_cjs = require('./chunk-UIQML2XG.cjs');
|
|
4
|
+
var chunkCUDPMOR6_cjs = require('./chunk-CUDPMOR6.cjs');
|
|
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
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var chunkHKQ5VION_cjs = require('./chunk-HKQ5VION.cjs');
|
|
16
|
-
var web3_js = require('@solana/web3.js');
|
|
17
|
-
var bech32 = require('bech32');
|
|
9
|
+
var chunkX22PL5T7_cjs = require('./chunk-X22PL5T7.cjs');
|
|
10
|
+
var chunk4YTACAVP_cjs = require('./chunk-4YTACAVP.cjs');
|
|
11
|
+
var chunk5HDKZVOL_cjs = require('./chunk-5HDKZVOL.cjs');
|
|
12
|
+
var chunk5AYPH3ZR_cjs = require('./chunk-5AYPH3ZR.cjs');
|
|
13
|
+
var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
|
|
14
|
+
var chunkERGJBZUC_cjs = require('./chunk-ERGJBZUC.cjs');
|
|
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,19 +22,21 @@ 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) => {
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
30
|
+
if (chunkN4UW74AG_cjs.ClientState.endpointOptions.getRestEndpointForChain) {
|
|
31
|
+
return chunkN4UW74AG_cjs.ClientState.endpointOptions.getRestEndpointForChain(chainId);
|
|
33
32
|
}
|
|
34
|
-
if (
|
|
35
|
-
const endpointOptions =
|
|
33
|
+
if (chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints && chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints[chainId]) {
|
|
34
|
+
const endpointOptions = chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints[chainId];
|
|
36
35
|
if (endpointOptions?.rest) {
|
|
37
36
|
return endpointOptions.rest;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
const chain =
|
|
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
|
|
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
|
|
67
|
-
const client =
|
|
68
|
-
accountParser:
|
|
65
|
+
const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(chainId);
|
|
66
|
+
const client = chunkN4UW74AG_cjs.ClientState.signingStargateClientByChainId[chainId] ?? await stargate.StargateClient.connect(endpoint, {
|
|
67
|
+
accountParser: chunkX22PL5T7_cjs.accountParser
|
|
69
68
|
});
|
|
70
69
|
const account = await client.getAccount(address);
|
|
71
70
|
if (!account) {
|
|
@@ -91,7 +90,7 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
91
90
|
throw new Error(`Failed to fetch account data: ${res.statusText}`);
|
|
92
91
|
}
|
|
93
92
|
const jsonResponse = await res.json();
|
|
94
|
-
const response =
|
|
93
|
+
const response = chunkERGJBZUC_cjs.toCamel(jsonResponse);
|
|
95
94
|
let sequence = 0;
|
|
96
95
|
let accountNumber = 0;
|
|
97
96
|
if (response.account.baseAccount) {
|
|
@@ -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 =
|
|
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 =
|
|
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,14 +173,14 @@ 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
|
|
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
|
|
180
|
+
messages
|
|
182
181
|
}
|
|
183
182
|
};
|
|
184
|
-
const txBodyBytes =
|
|
183
|
+
const txBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(txBodyEncodeObject);
|
|
185
184
|
const gasLimit = math.Int53.fromString(fee.gas).toNumber();
|
|
186
185
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
187
186
|
const authInfoBytes = protoSigning.makeAuthInfoBytes(
|
|
@@ -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(
|
|
211
|
+
const accountFromSigner = accounts.find(
|
|
212
|
+
(account) => account.address === signerAddress
|
|
213
|
+
);
|
|
213
214
|
if (!accountFromSigner) {
|
|
214
|
-
throw new Error(
|
|
215
|
+
throw new Error(
|
|
216
|
+
"signCosmosMessageAmino: failed to retrieve account from signer"
|
|
217
|
+
);
|
|
215
218
|
}
|
|
216
|
-
const
|
|
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 =
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
messages: signed.msgs.map((msg) =>
|
|
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 =
|
|
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 =
|
|
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);
|
|
@@ -251,16 +264,17 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
251
264
|
var signCosmosTransaction = async ({
|
|
252
265
|
tx,
|
|
253
266
|
options,
|
|
254
|
-
index
|
|
267
|
+
index,
|
|
268
|
+
routeId
|
|
255
269
|
}) => {
|
|
256
270
|
const { userAddresses } = options;
|
|
257
271
|
if (tx === void 0) {
|
|
258
272
|
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
259
273
|
}
|
|
260
274
|
const chainId = tx.cosmosTx?.chainId;
|
|
261
|
-
const
|
|
275
|
+
const messages = tx.cosmosTx?.msgs;
|
|
262
276
|
const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
263
|
-
const gasArray =
|
|
277
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
264
278
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
265
279
|
if (typeof gas?.error === "string") {
|
|
266
280
|
throw new Error(gas?.error);
|
|
@@ -272,10 +286,10 @@ var signCosmosTransaction = async ({
|
|
|
272
286
|
if (chainId === void 0) {
|
|
273
287
|
throw new Error("no chainId found for tx");
|
|
274
288
|
}
|
|
275
|
-
if (
|
|
289
|
+
if (messages === void 0) {
|
|
276
290
|
throw new Error("no messages found for tx");
|
|
277
291
|
}
|
|
278
|
-
const { signer } = await
|
|
292
|
+
const { signer } = await chunkX22PL5T7_cjs.getSigningStargateClient({
|
|
279
293
|
chainId,
|
|
280
294
|
getOfflineSigner: options?.getCosmosSigner
|
|
281
295
|
});
|
|
@@ -301,7 +315,7 @@ var signCosmosTransaction = async ({
|
|
|
301
315
|
const commonRawTxBody = {
|
|
302
316
|
signerAddress: currentUserAddress,
|
|
303
317
|
chainId,
|
|
304
|
-
cosmosMsgs:
|
|
318
|
+
cosmosMsgs: messages,
|
|
305
319
|
fee,
|
|
306
320
|
signerData: {
|
|
307
321
|
accountNumber,
|
|
@@ -314,6 +328,11 @@ var signCosmosTransaction = async ({
|
|
|
314
328
|
txIndex: index,
|
|
315
329
|
signerAddress: currentUserAddress
|
|
316
330
|
});
|
|
331
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
332
|
+
status: "signing",
|
|
333
|
+
routeId,
|
|
334
|
+
options
|
|
335
|
+
});
|
|
317
336
|
if (protoSigning.isOfflineDirectSigner(signer)) {
|
|
318
337
|
rawTx = await signCosmosMessageDirect({
|
|
319
338
|
...commonRawTxBody,
|
|
@@ -325,6 +344,11 @@ var signCosmosTransaction = async ({
|
|
|
325
344
|
options?.onTransactionSigned?.({
|
|
326
345
|
chainId
|
|
327
346
|
});
|
|
347
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
348
|
+
status: "pending",
|
|
349
|
+
routeId,
|
|
350
|
+
options
|
|
351
|
+
});
|
|
328
352
|
const txBytes = tx_js.TxRaw.encode(rawTx).finish();
|
|
329
353
|
const rawTxBase64 = Buffer.from(txBytes).toString("base64");
|
|
330
354
|
return rawTxBase64;
|
|
@@ -334,7 +358,8 @@ var signCosmosTransaction = async ({
|
|
|
334
358
|
var executeCosmosTransaction = async ({
|
|
335
359
|
tx,
|
|
336
360
|
options,
|
|
337
|
-
index
|
|
361
|
+
index,
|
|
362
|
+
routeId
|
|
338
363
|
}) => {
|
|
339
364
|
if (tx === void 0) {
|
|
340
365
|
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
@@ -342,10 +367,11 @@ var executeCosmosTransaction = async ({
|
|
|
342
367
|
const rawTxBase64 = await signCosmosTransaction({
|
|
343
368
|
tx,
|
|
344
369
|
options,
|
|
345
|
-
index
|
|
370
|
+
index,
|
|
371
|
+
routeId
|
|
346
372
|
});
|
|
347
373
|
const chainId = tx.cosmosTx?.chainId;
|
|
348
|
-
const txResponse = await
|
|
374
|
+
const txResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
349
375
|
chainId,
|
|
350
376
|
tx: rawTxBase64
|
|
351
377
|
});
|
|
@@ -557,8 +583,8 @@ var erc20ABI = /* @__PURE__ */ createAbi([
|
|
|
557
583
|
]);
|
|
558
584
|
|
|
559
585
|
// src/private-functions/evm/executeEvmTransaction.ts
|
|
560
|
-
var executeEvmTransaction = async (message, options, index) => {
|
|
561
|
-
const gasArray =
|
|
586
|
+
var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
587
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
562
588
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
563
589
|
if (typeof gas?.error === "string") {
|
|
564
590
|
throw new Error(gas?.error);
|
|
@@ -604,6 +630,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
604
630
|
status: "pending",
|
|
605
631
|
allowance: requiredApproval
|
|
606
632
|
});
|
|
633
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
634
|
+
status: "allowance",
|
|
635
|
+
routeId,
|
|
636
|
+
options
|
|
637
|
+
});
|
|
607
638
|
const txHash2 = await extendedSigner.writeContract({
|
|
608
639
|
account: evmSigner.account,
|
|
609
640
|
address: requiredApproval.tokenContract,
|
|
@@ -633,6 +664,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
633
664
|
signerAddress: evmSigner.account.address,
|
|
634
665
|
txIndex: index
|
|
635
666
|
});
|
|
667
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
668
|
+
status: "signing",
|
|
669
|
+
routeId,
|
|
670
|
+
options
|
|
671
|
+
});
|
|
636
672
|
const txHash = await extendedSigner.sendTransaction({
|
|
637
673
|
account: evmSigner.account,
|
|
638
674
|
to: evmTx.to,
|
|
@@ -640,6 +676,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
640
676
|
chain: evmSigner.chain,
|
|
641
677
|
value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
|
|
642
678
|
});
|
|
679
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
680
|
+
status: "pending",
|
|
681
|
+
routeId,
|
|
682
|
+
options
|
|
683
|
+
});
|
|
643
684
|
onTransactionSigned?.({
|
|
644
685
|
chainId: evmTx.chainId
|
|
645
686
|
});
|
|
@@ -651,9 +692,10 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
651
692
|
var signSvmTransaction = async ({
|
|
652
693
|
tx,
|
|
653
694
|
options,
|
|
654
|
-
index
|
|
695
|
+
index,
|
|
696
|
+
routeId
|
|
655
697
|
}) => {
|
|
656
|
-
const gasArray =
|
|
698
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
657
699
|
if (tx === void 0) {
|
|
658
700
|
throw new Error("executeSvmTransaction error: tx is undefined");
|
|
659
701
|
}
|
|
@@ -690,26 +732,36 @@ var signSvmTransaction = async ({
|
|
|
690
732
|
signerAddress: signer.publicKey?.toBase58(),
|
|
691
733
|
txIndex: index
|
|
692
734
|
});
|
|
735
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
736
|
+
status: "signing",
|
|
737
|
+
routeId,
|
|
738
|
+
options
|
|
739
|
+
});
|
|
693
740
|
const signedTx = await signer.signTransaction(transaction);
|
|
694
741
|
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
742
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
743
|
+
status: "pending",
|
|
744
|
+
routeId,
|
|
745
|
+
options
|
|
746
|
+
});
|
|
695
747
|
const serializedTx = signedTx.serialize();
|
|
696
748
|
return serializedTx;
|
|
697
749
|
};
|
|
698
750
|
|
|
699
751
|
// src/private-functions/svm/executeSvmTransaction.ts
|
|
700
|
-
var executeSvmTransaction = async (tx, options, index) => {
|
|
752
|
+
var executeSvmTransaction = async (tx, options, index, routeId) => {
|
|
701
753
|
const svmTx = tx?.svmTx;
|
|
702
754
|
if (!svmTx?.chainId) {
|
|
703
755
|
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
704
756
|
}
|
|
705
|
-
const signedTx = await signSvmTransaction({ tx, options, index });
|
|
757
|
+
const signedTx = await signSvmTransaction({ tx, options, index, routeId });
|
|
706
758
|
if (!signedTx) {
|
|
707
759
|
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
708
760
|
}
|
|
709
|
-
const endpoint = await
|
|
761
|
+
const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(svmTx.chainId);
|
|
710
762
|
const connection = new web3_js.Connection(endpoint);
|
|
711
763
|
let signature;
|
|
712
|
-
const submitTxResponse = await
|
|
764
|
+
const submitTxResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
713
765
|
chainId: svmTx.chainId,
|
|
714
766
|
tx: signedTx.toString("base64")
|
|
715
767
|
});
|
|
@@ -737,13 +789,13 @@ var executeSvmTransaction = async (tx, options, index) => {
|
|
|
737
789
|
};
|
|
738
790
|
}
|
|
739
791
|
if (getStatusCount > 12) {
|
|
740
|
-
await
|
|
792
|
+
await chunkERGJBZUC_cjs.wait(3e3);
|
|
741
793
|
throw new Error(
|
|
742
794
|
`executeSvmTransaction error: waiting finalized status timed out for ${signature}`
|
|
743
795
|
);
|
|
744
796
|
}
|
|
745
797
|
getStatusCount++;
|
|
746
|
-
await
|
|
798
|
+
await chunkERGJBZUC_cjs.wait(3e3);
|
|
747
799
|
} catch (error) {
|
|
748
800
|
errorCount++;
|
|
749
801
|
if (errorCount > 12) {
|
|
@@ -777,7 +829,7 @@ var validateEvmTokenApproval = async ({
|
|
|
777
829
|
const fee = await extendedSigner.estimateFeesPerGas();
|
|
778
830
|
const allowanceGasFee = BigInt(fee.maxFeePerGas) * BigInt(1e5);
|
|
779
831
|
if (!gasBalance) {
|
|
780
|
-
const chainAssets = (await
|
|
832
|
+
const chainAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
781
833
|
const nativeAsset = chainAssets?.find((x) => x.denom.includes("-native"));
|
|
782
834
|
const zeroAddressAsset = chainAssets?.find(
|
|
783
835
|
(x) => x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
@@ -794,7 +846,7 @@ var validateEvmTokenApproval = async ({
|
|
|
794
846
|
);
|
|
795
847
|
}
|
|
796
848
|
if (chunk4R6OCWRR_cjs.BigNumber(gasBalance.amount).lt(Number(allowanceGasFee))) {
|
|
797
|
-
const chainAssets = (await
|
|
849
|
+
const chainAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
798
850
|
const asset = chainAssets?.find(
|
|
799
851
|
(x) => x.denom.includes("-native") || x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
800
852
|
);
|
|
@@ -839,11 +891,12 @@ var validateEvmGasBalance = async ({
|
|
|
839
891
|
signer,
|
|
840
892
|
tx,
|
|
841
893
|
getFallbackGasAmount,
|
|
842
|
-
useUnlimitedApproval
|
|
894
|
+
useUnlimitedApproval,
|
|
895
|
+
bypassApprovalCheck
|
|
843
896
|
}) => {
|
|
844
897
|
const chainId = tx?.chainId ?? "";
|
|
845
|
-
const skipAssets = (await
|
|
846
|
-
const skipChains = await
|
|
898
|
+
const skipAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
|
|
899
|
+
const skipChains = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
|
|
847
900
|
const chain = skipChains?.find?.((chain2) => chain2.chainId === chainId);
|
|
848
901
|
if (!chain) {
|
|
849
902
|
throw new Error(`failed to find chain for chainId: '${chainId}'`);
|
|
@@ -851,7 +904,7 @@ var validateEvmGasBalance = async ({
|
|
|
851
904
|
if (!signer.account?.address) {
|
|
852
905
|
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
853
906
|
}
|
|
854
|
-
const skipBalances = (await
|
|
907
|
+
const skipBalances = (await chunkN4UW74AG_cjs.balances({
|
|
855
908
|
chains: {
|
|
856
909
|
[tx?.chainId ?? ""]: {
|
|
857
910
|
address: signer.account?.address
|
|
@@ -864,7 +917,7 @@ var validateEvmGasBalance = async ({
|
|
|
864
917
|
)?.[1];
|
|
865
918
|
const gasBalance = nativeGasBalance || zeroAddressGasBalance;
|
|
866
919
|
const { requiredErc20Approvals } = tx;
|
|
867
|
-
if (requiredErc20Approvals) {
|
|
920
|
+
if (!bypassApprovalCheck && requiredErc20Approvals) {
|
|
868
921
|
try {
|
|
869
922
|
await validateEvmTokenApproval({
|
|
870
923
|
requiredErc20Approvals,
|
|
@@ -937,7 +990,7 @@ var validateSvmGasBalance = async ({
|
|
|
937
990
|
fee: null
|
|
938
991
|
};
|
|
939
992
|
}
|
|
940
|
-
const endpoint = await
|
|
993
|
+
const endpoint = await chunkX22PL5T7_cjs.getRpcEndpointForChain(tx.chainId ?? "");
|
|
941
994
|
const connection = new web3_js.Connection(endpoint);
|
|
942
995
|
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
943
996
|
if (!tx.tx) {
|
|
@@ -1001,8 +1054,10 @@ var validateGasBalances = async ({
|
|
|
1001
1054
|
simulate,
|
|
1002
1055
|
disabledChainIds,
|
|
1003
1056
|
enabledChainIds,
|
|
1004
|
-
|
|
1005
|
-
|
|
1057
|
+
getCosmosPriorityFeeDenom,
|
|
1058
|
+
routeId,
|
|
1059
|
+
options,
|
|
1060
|
+
isMultiRoutes
|
|
1006
1061
|
}) => {
|
|
1007
1062
|
const validateResult = await Promise.all(
|
|
1008
1063
|
txs.map(async (tx, i) => {
|
|
@@ -1013,11 +1068,16 @@ var validateGasBalances = async ({
|
|
|
1013
1068
|
onValidateGasBalance?.({
|
|
1014
1069
|
status: "pending"
|
|
1015
1070
|
});
|
|
1071
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
1072
|
+
status: "validating",
|
|
1073
|
+
routeId,
|
|
1074
|
+
options
|
|
1075
|
+
});
|
|
1016
1076
|
if (!tx?.cosmosTx?.msgs) {
|
|
1017
1077
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1018
1078
|
}
|
|
1019
1079
|
try {
|
|
1020
|
-
const res = await
|
|
1080
|
+
const res = await chunkCUDPMOR6_cjs.validateCosmosGasBalance({
|
|
1021
1081
|
chainId: tx.cosmosTx.chainId ?? "",
|
|
1022
1082
|
signerAddress: tx.cosmosTx.signerAddress ?? "",
|
|
1023
1083
|
messages: tx.cosmosTx.msgs,
|
|
@@ -1025,7 +1085,8 @@ var validateGasBalances = async ({
|
|
|
1025
1085
|
getOfflineSigner: getCosmosSigner,
|
|
1026
1086
|
txIndex: i,
|
|
1027
1087
|
simulate,
|
|
1028
|
-
getCosmosPriorityFeeDenom
|
|
1088
|
+
getCosmosPriorityFeeDenom,
|
|
1089
|
+
isMultiRoutes
|
|
1029
1090
|
});
|
|
1030
1091
|
return res;
|
|
1031
1092
|
} catch (e) {
|
|
@@ -1041,6 +1102,11 @@ var validateGasBalances = async ({
|
|
|
1041
1102
|
onValidateGasBalance?.({
|
|
1042
1103
|
status: "pending"
|
|
1043
1104
|
});
|
|
1105
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
1106
|
+
status: "validating",
|
|
1107
|
+
routeId,
|
|
1108
|
+
options
|
|
1109
|
+
});
|
|
1044
1110
|
const signer = await getEvmSigner?.(tx?.evmTx?.chainId ?? "");
|
|
1045
1111
|
if (!signer) {
|
|
1046
1112
|
throw new Error(
|
|
@@ -1052,7 +1118,8 @@ var validateGasBalances = async ({
|
|
|
1052
1118
|
tx: tx.evmTx,
|
|
1053
1119
|
signer,
|
|
1054
1120
|
getFallbackGasAmount,
|
|
1055
|
-
useUnlimitedApproval
|
|
1121
|
+
useUnlimitedApproval: options?.useUnlimitedApproval,
|
|
1122
|
+
bypassApprovalCheck: options?.bypassApprovalCheck
|
|
1056
1123
|
});
|
|
1057
1124
|
return res;
|
|
1058
1125
|
} catch (e) {
|
|
@@ -1068,6 +1135,11 @@ var validateGasBalances = async ({
|
|
|
1068
1135
|
onValidateGasBalance?.({
|
|
1069
1136
|
status: "pending"
|
|
1070
1137
|
});
|
|
1138
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
1139
|
+
status: "validating",
|
|
1140
|
+
routeId,
|
|
1141
|
+
options
|
|
1142
|
+
});
|
|
1071
1143
|
try {
|
|
1072
1144
|
const res = await validateSvmGasBalance({
|
|
1073
1145
|
tx: tx.svmTx,
|
|
@@ -1093,13 +1165,37 @@ var validateGasBalances = async ({
|
|
|
1093
1165
|
onValidateGasBalance?.({
|
|
1094
1166
|
status: "error"
|
|
1095
1167
|
});
|
|
1096
|
-
|
|
1168
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = validateResult;
|
|
1097
1169
|
throw new Error(`${txError.error}`);
|
|
1098
1170
|
}
|
|
1099
1171
|
onValidateGasBalance?.({
|
|
1100
1172
|
status: "completed"
|
|
1101
1173
|
});
|
|
1102
|
-
|
|
1174
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = validateResult;
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
// src/private-functions/getChainIdsFromTxs.ts
|
|
1178
|
+
var getChainIdsFromTxs = (txs) => {
|
|
1179
|
+
return txs.map((tx) => {
|
|
1180
|
+
if ("cosmosTx" in tx) {
|
|
1181
|
+
return {
|
|
1182
|
+
chainType: "cosmos" /* Cosmos */,
|
|
1183
|
+
chainId: tx.cosmosTx?.chainId
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
if ("svmTx" in tx) {
|
|
1187
|
+
return {
|
|
1188
|
+
chainType: "svm" /* Svm */,
|
|
1189
|
+
chainId: tx.svmTx?.chainId
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
if ("evmTx" in tx) {
|
|
1193
|
+
return {
|
|
1194
|
+
chainType: "evm" /* Evm */,
|
|
1195
|
+
chainId: tx.evmTx?.chainId
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1103
1199
|
};
|
|
1104
1200
|
|
|
1105
1201
|
// src/private-functions/executeTransactions.ts
|
|
@@ -1107,7 +1203,6 @@ var executeTransactions = async (options) => {
|
|
|
1107
1203
|
const {
|
|
1108
1204
|
txs,
|
|
1109
1205
|
onTransactionBroadcast,
|
|
1110
|
-
onTransactionCompleted,
|
|
1111
1206
|
simulate = true,
|
|
1112
1207
|
batchSimulate = true,
|
|
1113
1208
|
getFallbackGasAmount = getDefaultFallbackGasAmount,
|
|
@@ -1115,37 +1210,36 @@ var executeTransactions = async (options) => {
|
|
|
1115
1210
|
getEvmSigner,
|
|
1116
1211
|
onValidateGasBalance,
|
|
1117
1212
|
trackTxPollingOptions,
|
|
1118
|
-
batchSignTxs = true
|
|
1213
|
+
batchSignTxs = true,
|
|
1214
|
+
routeId,
|
|
1215
|
+
isMultiRoutes
|
|
1119
1216
|
} = options;
|
|
1120
1217
|
if (txs === void 0) {
|
|
1121
1218
|
throw new Error(
|
|
1122
1219
|
"executeTransactions error: txs is undefined in executeTransactions"
|
|
1123
1220
|
);
|
|
1124
1221
|
}
|
|
1125
|
-
const chainIds = txs
|
|
1222
|
+
const chainIds = getChainIdsFromTxs(txs);
|
|
1223
|
+
const transactionDetails = txs.map((tx) => {
|
|
1126
1224
|
if ("cosmosTx" in tx) {
|
|
1127
|
-
return {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
chainType: "svm",
|
|
1135
|
-
chainId: tx.svmTx?.chainId
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
if ("evmTx" in tx) {
|
|
1139
|
-
return {
|
|
1140
|
-
chainType: "evm",
|
|
1141
|
-
chainId: tx.evmTx?.chainId
|
|
1142
|
-
};
|
|
1225
|
+
return { chainId: tx.cosmosTx?.chainId, chainType: "cosmos" /* Cosmos */ };
|
|
1226
|
+
} else if ("evmTx" in tx) {
|
|
1227
|
+
return { chainId: tx.evmTx?.chainId, chainType: "evm" /* Evm */ };
|
|
1228
|
+
} else if ("svmTx" in tx) {
|
|
1229
|
+
return { chainId: tx.svmTx?.chainId, chainType: "svm" /* Svm */ };
|
|
1230
|
+
} else {
|
|
1231
|
+
throw new Error("executeRoute error: invalid message type");
|
|
1143
1232
|
}
|
|
1144
1233
|
});
|
|
1234
|
+
chunkUIQML2XG_cjs.updateRouteDetails({
|
|
1235
|
+
transactionDetails,
|
|
1236
|
+
routeId,
|
|
1237
|
+
options
|
|
1238
|
+
});
|
|
1145
1239
|
const isGasStationSourceEVM = chainIds.find((item, i, array) => {
|
|
1146
|
-
return chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm"
|
|
1240
|
+
return chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm" /* Evm */;
|
|
1147
1241
|
});
|
|
1148
|
-
|
|
1242
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = void 0;
|
|
1149
1243
|
const validateChainIds = !batchSimulate ? chainIds.map((x) => x?.chainId ?? "") : isGasStationSourceEVM ? chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS : [];
|
|
1150
1244
|
await validateGasBalances({
|
|
1151
1245
|
txs,
|
|
@@ -1155,7 +1249,10 @@ var executeTransactions = async (options) => {
|
|
|
1155
1249
|
onValidateGasBalance,
|
|
1156
1250
|
simulate,
|
|
1157
1251
|
disabledChainIds: validateChainIds,
|
|
1158
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1252
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1253
|
+
options,
|
|
1254
|
+
routeId,
|
|
1255
|
+
isMultiRoutes
|
|
1159
1256
|
});
|
|
1160
1257
|
const validateEnabledChainIds = async (chainId) => {
|
|
1161
1258
|
await validateGasBalances({
|
|
@@ -1166,7 +1263,10 @@ var executeTransactions = async (options) => {
|
|
|
1166
1263
|
onValidateGasBalance,
|
|
1167
1264
|
simulate,
|
|
1168
1265
|
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
|
|
1169
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1266
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1267
|
+
options,
|
|
1268
|
+
routeId,
|
|
1269
|
+
isMultiRoutes
|
|
1170
1270
|
});
|
|
1171
1271
|
};
|
|
1172
1272
|
let signedTxs = [];
|
|
@@ -1180,11 +1280,16 @@ var executeTransactions = async (options) => {
|
|
|
1180
1280
|
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1181
1281
|
const isAllowedToBatchSignTxsUpfront = await (async () => {
|
|
1182
1282
|
try {
|
|
1183
|
-
const currentUserAddress = options.userAddresses.find(
|
|
1283
|
+
const currentUserAddress = options.userAddresses.find(
|
|
1284
|
+
(x) => x.chainId === tx.cosmosTx?.chainId
|
|
1285
|
+
)?.address;
|
|
1184
1286
|
if (!currentUserAddress) {
|
|
1185
1287
|
return false;
|
|
1186
1288
|
}
|
|
1187
|
-
const { accountNumber } = await getAccountNumberAndSequence(
|
|
1289
|
+
const { accountNumber } = await getAccountNumberAndSequence(
|
|
1290
|
+
currentUserAddress,
|
|
1291
|
+
tx.cosmosTx?.chainId
|
|
1292
|
+
);
|
|
1188
1293
|
if (accountNumber) {
|
|
1189
1294
|
return true;
|
|
1190
1295
|
}
|
|
@@ -1199,7 +1304,8 @@ var executeTransactions = async (options) => {
|
|
|
1199
1304
|
const signedTx = await signCosmosTransaction({
|
|
1200
1305
|
tx,
|
|
1201
1306
|
options,
|
|
1202
|
-
index: i
|
|
1307
|
+
index: i,
|
|
1308
|
+
routeId
|
|
1203
1309
|
});
|
|
1204
1310
|
signedTxs.push({
|
|
1205
1311
|
index: i,
|
|
@@ -1210,7 +1316,12 @@ var executeTransactions = async (options) => {
|
|
|
1210
1316
|
}
|
|
1211
1317
|
if ("svmTx" in tx) {
|
|
1212
1318
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1213
|
-
const signedTx = await signSvmTransaction({
|
|
1319
|
+
const signedTx = await signSvmTransaction({
|
|
1320
|
+
tx,
|
|
1321
|
+
options,
|
|
1322
|
+
index: i,
|
|
1323
|
+
routeId
|
|
1324
|
+
});
|
|
1214
1325
|
if (!signedTx) {
|
|
1215
1326
|
throw new Error(`executeRoute error: signedTx is undefined`);
|
|
1216
1327
|
}
|
|
@@ -1223,15 +1334,15 @@ var executeTransactions = async (options) => {
|
|
|
1223
1334
|
}
|
|
1224
1335
|
}
|
|
1225
1336
|
}
|
|
1226
|
-
|
|
1227
|
-
const tx = txs[
|
|
1337
|
+
const executeTransaction = async (index) => {
|
|
1338
|
+
const tx = txs[index];
|
|
1228
1339
|
if (!tx) {
|
|
1229
|
-
throw new Error(`executeRoute error: invalid message at index ${
|
|
1340
|
+
throw new Error(`executeRoute error: invalid message at index ${index}`);
|
|
1230
1341
|
}
|
|
1231
1342
|
let txResult;
|
|
1232
|
-
const txSigned = signedTxs.find((item) => item.index ===
|
|
1343
|
+
const txSigned = signedTxs.find((item) => item.index === index);
|
|
1233
1344
|
if (txSigned) {
|
|
1234
|
-
const txResponse = await
|
|
1345
|
+
const txResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
1235
1346
|
chainId: txSigned.chainId,
|
|
1236
1347
|
tx: txSigned.tx
|
|
1237
1348
|
});
|
|
@@ -1246,34 +1357,35 @@ var executeTransactions = async (options) => {
|
|
|
1246
1357
|
txResult = await executeCosmosTransaction({
|
|
1247
1358
|
tx,
|
|
1248
1359
|
options,
|
|
1249
|
-
index
|
|
1360
|
+
index,
|
|
1361
|
+
routeId
|
|
1250
1362
|
});
|
|
1251
1363
|
} else if ("evmTx" in tx) {
|
|
1252
1364
|
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1253
|
-
const txResponse = await executeEvmTransaction(
|
|
1365
|
+
const txResponse = await executeEvmTransaction(
|
|
1366
|
+
tx,
|
|
1367
|
+
options,
|
|
1368
|
+
index,
|
|
1369
|
+
routeId
|
|
1370
|
+
);
|
|
1254
1371
|
txResult = {
|
|
1255
1372
|
chainId: tx?.evmTx?.chainId ?? "",
|
|
1256
1373
|
txHash: txResponse.transactionHash
|
|
1257
1374
|
};
|
|
1258
1375
|
} else if ("svmTx" in tx) {
|
|
1259
1376
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1260
|
-
txResult = await executeSvmTransaction(tx, options,
|
|
1377
|
+
txResult = await executeSvmTransaction(tx, options, index, routeId);
|
|
1261
1378
|
} else {
|
|
1262
1379
|
throw new Error("executeRoute error: invalid message type");
|
|
1263
1380
|
}
|
|
1264
1381
|
}
|
|
1265
1382
|
await onTransactionBroadcast?.({ ...txResult });
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
chainId: txResult.chainId,
|
|
1273
|
-
txHash: txResult.txHash,
|
|
1274
|
-
status: txStatusResponse
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1383
|
+
return txResult;
|
|
1384
|
+
};
|
|
1385
|
+
return {
|
|
1386
|
+
transactionDetails,
|
|
1387
|
+
executeTransaction
|
|
1388
|
+
};
|
|
1277
1389
|
};
|
|
1278
1390
|
var EVM_GAS_AMOUNT = 15e4;
|
|
1279
1391
|
var COSMOS_GAS_AMOUNT = {
|
|
@@ -1286,7 +1398,7 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1286
1398
|
return EVM_GAS_AMOUNT;
|
|
1287
1399
|
}
|
|
1288
1400
|
if (chainType !== "cosmos" /* Cosmos */) return void 0;
|
|
1289
|
-
const venuesResult = await
|
|
1401
|
+
const venuesResult = await chunk5AYPH3ZR_cjs.venues();
|
|
1290
1402
|
const isSwapChain = venuesResult?.some(
|
|
1291
1403
|
(venue) => venue.chainId === chainId
|
|
1292
1404
|
) ?? false;
|
|
@@ -1298,57 +1410,8 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1298
1410
|
}
|
|
1299
1411
|
return defaultGasAmount;
|
|
1300
1412
|
};
|
|
1301
|
-
var executeRoute = async (options) => {
|
|
1302
|
-
const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
|
|
1303
|
-
let addressList = [];
|
|
1304
|
-
userAddresses.forEach((userAddress, index) => {
|
|
1305
|
-
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
1306
|
-
if (requiredChainAddress === userAddress?.chainId) {
|
|
1307
|
-
addressList.push(userAddress.address);
|
|
1308
|
-
}
|
|
1309
|
-
});
|
|
1310
|
-
if (addressList.length !== route.requiredChainAddresses.length) {
|
|
1311
|
-
addressList = userAddresses.map((x) => x.address);
|
|
1312
|
-
}
|
|
1313
|
-
const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
|
|
1314
|
-
if (!validLength) {
|
|
1315
|
-
throw new Error("executeRoute error: invalid address list");
|
|
1316
|
-
}
|
|
1317
|
-
const isUserAddressesValid = await validateUserAddresses(userAddresses);
|
|
1318
|
-
if (!isUserAddressesValid) {
|
|
1319
|
-
throw new Error("executeRoute error: invalid user addresses");
|
|
1320
|
-
}
|
|
1321
|
-
const response = await chunkFY56EEFB_cjs.messages({
|
|
1322
|
-
timeoutSeconds,
|
|
1323
|
-
amountIn: route?.amountIn,
|
|
1324
|
-
amountOut: route.estimatedAmountOut || "0",
|
|
1325
|
-
sourceAssetChainId: route?.sourceAssetChainId,
|
|
1326
|
-
sourceAssetDenom: route?.sourceAssetDenom,
|
|
1327
|
-
destAssetChainId: route?.destAssetChainId,
|
|
1328
|
-
destAssetDenom: route?.destAssetDenom,
|
|
1329
|
-
operations: route?.operations,
|
|
1330
|
-
addressList,
|
|
1331
|
-
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
1332
|
-
chainIdsToAffiliates: chunkHKQ5VION_cjs.ApiState.chainIdsToAffiliates,
|
|
1333
|
-
postRouteHandler: options.postRouteHandler,
|
|
1334
|
-
feePayerAddress: options.svmFeePayer?.address
|
|
1335
|
-
});
|
|
1336
|
-
if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1337
|
-
const firstTx = response?.txs?.[0];
|
|
1338
|
-
if (firstTx && "cosmosTx" in firstTx) {
|
|
1339
|
-
firstTx.cosmosTx?.msgs?.unshift(beforeMsg);
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
if (afterMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1343
|
-
const lastTx = response?.txs?.[response.txs.length - 1];
|
|
1344
|
-
if (lastTx && "cosmosTx" in lastTx) {
|
|
1345
|
-
lastTx.cosmosTx?.msgs?.push(afterMsg);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
await executeTransactions({ ...options, txs: response?.txs });
|
|
1349
|
-
};
|
|
1350
1413
|
var validateUserAddresses = async (userAddresses) => {
|
|
1351
|
-
const chains2 = await
|
|
1414
|
+
const chains2 = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
|
|
1352
1415
|
const validations = userAddresses.map((userAddress) => {
|
|
1353
1416
|
const chain = chains2.find((chain2) => chain2.chainId === userAddress.chainId);
|
|
1354
1417
|
switch (chain?.chainType) {
|
|
@@ -1386,5 +1449,30 @@ var validateUserAddresses = async (userAddresses) => {
|
|
|
1386
1449
|
});
|
|
1387
1450
|
return validations.every((validation) => validation);
|
|
1388
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
|
+
};
|
|
1389
1476
|
|
|
1390
|
-
exports.
|
|
1477
|
+
exports.createValidAddressList = createValidAddressList;
|
|
1478
|
+
exports.executeTransactions = executeTransactions;
|