@skip-go/client 1.3.6 → 1.4.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-3M7YYWGL.cjs +295 -0
- package/dist/cjs/{chunk-IE22IVFA.cjs → chunk-46VB6RQK.cjs} +8 -8
- 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-3FYU3BJ7.cjs → chunk-6LA66667.cjs} +126 -16
- package/dist/cjs/chunk-7MC3BVQN.cjs +370 -0
- 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-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-2EKCOIWV.cjs → chunk-IDEJORRT.cjs} +155 -154
- package/dist/cjs/{chunk-DBDB2XWX.cjs → chunk-JBKNEFXB.cjs} +3 -3
- package/dist/cjs/{chunk-N3LR7KTI.cjs → chunk-KM2D7PJL.cjs} +33 -57
- 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-JTB3SPCH.cjs → chunk-Q43XCBMX.cjs} +6 -6
- 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-VIG2BHYJ.cjs +185 -0
- package/dist/cjs/{chunk-DCFIIF7G.cjs → chunk-X5AJHZ2J.cjs} +2 -2
- package/dist/cjs/{chunk-SZ64FWGB.cjs → chunk-ZAATXQBG.cjs} +2 -2
- package/dist/cjs/{chunk-MCZ3F457.cjs → chunk-ZBPDDVQ2.cjs} +2 -2
- package/dist/cjs/{chunk-VGS46RWR.cjs → chunk-ZKBSNSHQ.cjs} +188 -209
- package/dist/cjs/index.cjs +57 -51
- package/dist/cjs/public-functions/executeRoute.cjs +16 -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-B3kjKg0v.d.ts +175 -0
- package/dist/esm/chunk-3J6O2PVK.js +180 -0
- package/dist/esm/{chunk-SJP6W2SK.js → chunk-3XOGEVJL.js} +1 -1
- package/dist/esm/{chunk-ZL6XF5A3.js → chunk-4RLJWCQR.js} +2 -2
- package/dist/esm/{chunk-JSY7M43P.js → chunk-52PEBJRQ.js} +1 -1
- 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-6ZLEWCU2.js → chunk-BAJFQZDT.js} +146 -167
- package/dist/esm/{chunk-5KIWNRW4.js → chunk-CIAOTO3M.js} +1 -1
- package/dist/esm/{chunk-JYUNVL4F.js → chunk-FH2YHZVV.js} +1 -1
- package/dist/esm/{chunk-ADUNNC4O.js → chunk-GHNH5QC3.js} +3 -3
- package/dist/esm/{chunk-OHV2LZEG.js → chunk-JQ4F4WBG.js} +1 -1
- package/dist/esm/{chunk-TV2XPAIF.js → chunk-KNXMSLOB.js} +3 -26
- package/dist/esm/{chunk-YLVFZDR5.js → chunk-KYDY7QRT.js} +109 -3
- package/dist/esm/{chunk-IWXRHEX4.js → chunk-LHNGF5J2.js} +2 -2
- 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-OL7CWCPB.js → chunk-REWUSU53.js} +4 -3
- package/dist/esm/chunk-RQ7DXNSS.js +365 -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-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/index.d.ts +2 -3
- package/dist/esm/index.js +27 -25
- package/dist/esm/public-functions/executeRoute.d.ts +7 -76
- package/dist/esm/public-functions/executeRoute.js +15 -14
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +3 -2
- 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.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 +3 -2
- package/dist/esm/public-functions/validateCosmosGasBalance.js +8 -7
- package/dist/esm/public-functions/waitForTransaction.d.ts +5 -1
- package/dist/esm/public-functions/waitForTransaction.js +4 -4
- package/package.json +3 -3
- package/dist/cjs/chunk-MN763TPC.cjs +0 -187
- package/dist/esm/callbacks-CuL50GnB.d.ts +0 -38
- package/dist/esm/chunk-VBWLUZXT.js +0 -182
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk7MC3BVQN_cjs = require('./chunk-7MC3BVQN.cjs');
|
|
4
|
+
var chunk46VB6RQK_cjs = require('./chunk-46VB6RQK.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
|
|
9
|
+
var chunk6LA66667_cjs = require('./chunk-6LA66667.cjs');
|
|
10
|
+
var chunkVIG2BHYJ_cjs = require('./chunk-VIG2BHYJ.cjs');
|
|
11
|
+
var chunkOZUCMWNE_cjs = require('./chunk-OZUCMWNE.cjs');
|
|
12
|
+
var chunk5HDKZVOL_cjs = require('./chunk-5HDKZVOL.cjs');
|
|
13
|
+
var chunk5AYPH3ZR_cjs = require('./chunk-5AYPH3ZR.cjs');
|
|
14
|
+
var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
|
|
15
|
+
var chunkERGJBZUC_cjs = require('./chunk-ERGJBZUC.cjs');
|
|
16
16
|
var web3_js = require('@solana/web3.js');
|
|
17
17
|
var bech32 = require('bech32');
|
|
18
18
|
var stargate = require('@cosmjs/stargate');
|
|
19
19
|
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
20
20
|
var protoSigning = require('@cosmjs/proto-signing');
|
|
21
|
-
var encoding = require('@cosmjs/encoding');
|
|
22
|
-
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
23
|
-
var utils = require('@injectivelabs/utils');
|
|
24
21
|
var amino = require('@cosmjs/amino');
|
|
22
|
+
var encoding = require('@cosmjs/encoding');
|
|
25
23
|
var keys_js = require('cosmjs-types/cosmos/crypto/secp256k1/keys.js');
|
|
26
24
|
var any_js = require('cosmjs-types/google/protobuf/any.js');
|
|
27
25
|
var math = require('@cosmjs/math');
|
|
@@ -30,16 +28,16 @@ var viem = require('viem');
|
|
|
30
28
|
|
|
31
29
|
// src/private-functions/getRestEndpointForChain.ts
|
|
32
30
|
var getRestEndpointForChain = async (chainId) => {
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
31
|
+
if (chunkN4UW74AG_cjs.ClientState.endpointOptions.getRestEndpointForChain) {
|
|
32
|
+
return chunkN4UW74AG_cjs.ClientState.endpointOptions.getRestEndpointForChain(chainId);
|
|
35
33
|
}
|
|
36
|
-
if (
|
|
37
|
-
const endpointOptions =
|
|
34
|
+
if (chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints && chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints[chainId]) {
|
|
35
|
+
const endpointOptions = chunkN4UW74AG_cjs.ClientState.endpointOptions.endpoints[chainId];
|
|
38
36
|
if (endpointOptions?.rest) {
|
|
39
37
|
return endpointOptions.rest;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
const chain =
|
|
40
|
+
const chain = chunkVIG2BHYJ_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
43
41
|
if (!chain) {
|
|
44
42
|
throw new Error(
|
|
45
43
|
`getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
|
|
@@ -51,7 +49,7 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
const endpoints = chain.apis?.rest?.map((api) => api.address);
|
|
54
|
-
const endpoint = await
|
|
52
|
+
const endpoint = await chunkVIG2BHYJ_cjs.findFirstWorkingEndpoint(endpoints, "rest");
|
|
55
53
|
if (!endpoint) {
|
|
56
54
|
throw new Error(
|
|
57
55
|
`getRestEndpointForChain error: failed to find REST endpoint for chain id '${chainId}'`
|
|
@@ -65,9 +63,9 @@ var getAccountNumberAndSequence = async (address, chainId) => {
|
|
|
65
63
|
if (chainId.includes("dymension")) {
|
|
66
64
|
return getAccountNumberAndSequenceFromDymension(address, chainId);
|
|
67
65
|
}
|
|
68
|
-
const endpoint = await
|
|
69
|
-
const client =
|
|
70
|
-
accountParser:
|
|
66
|
+
const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(chainId);
|
|
67
|
+
const client = chunkN4UW74AG_cjs.ClientState.signingStargateClientByChainId[chainId] ?? await stargate.StargateClient.connect(endpoint, {
|
|
68
|
+
accountParser: chunk6LA66667_cjs.accountParser
|
|
71
69
|
});
|
|
72
70
|
const account = await client.getAccount(address);
|
|
73
71
|
if (!account) {
|
|
@@ -93,7 +91,7 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
93
91
|
throw new Error(`Failed to fetch account data: ${res.statusText}`);
|
|
94
92
|
}
|
|
95
93
|
const jsonResponse = await res.json();
|
|
96
|
-
const response =
|
|
94
|
+
const response = chunkERGJBZUC_cjs.toCamel(jsonResponse);
|
|
97
95
|
let sequence = 0;
|
|
98
96
|
let accountNumber = 0;
|
|
99
97
|
if (response.account.baseAccount) {
|
|
@@ -108,95 +106,6 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
108
106
|
sequence
|
|
109
107
|
};
|
|
110
108
|
};
|
|
111
|
-
function createTransaction({
|
|
112
|
-
chainId,
|
|
113
|
-
message,
|
|
114
|
-
timeoutHeight,
|
|
115
|
-
memo = "",
|
|
116
|
-
fee = utils.DEFAULT_STD_FEE,
|
|
117
|
-
signMode = 1,
|
|
118
|
-
pubKey,
|
|
119
|
-
accountNumber,
|
|
120
|
-
sequence
|
|
121
|
-
}) {
|
|
122
|
-
const signers = {
|
|
123
|
-
pubKey,
|
|
124
|
-
accountNumber,
|
|
125
|
-
sequence
|
|
126
|
-
};
|
|
127
|
-
return sdkTs.createTransactionWithSigners({
|
|
128
|
-
fee,
|
|
129
|
-
memo,
|
|
130
|
-
message,
|
|
131
|
-
signers,
|
|
132
|
-
chainId,
|
|
133
|
-
signMode,
|
|
134
|
-
timeoutHeight
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/private-functions/cosmos/signCosmosMessageDirectEvmos.ts
|
|
139
|
-
var signCosmosMessageDirectEvmos = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
140
|
-
const accounts = await signer.getAccounts();
|
|
141
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
142
|
-
if (!accountFromSigner) {
|
|
143
|
-
throw new Error("signCosmosMessageDirectEvmos: failed to retrieve account from signer");
|
|
144
|
-
}
|
|
145
|
-
const messages2 = cosmosMsgs.map(
|
|
146
|
-
(cosmosMsg) => chunkN3LR7KTI_cjs.getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
147
|
-
);
|
|
148
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
149
|
-
const { signDoc } = createTransaction({
|
|
150
|
-
pubKey: pk,
|
|
151
|
-
chainId,
|
|
152
|
-
message: messages2,
|
|
153
|
-
sequence,
|
|
154
|
-
accountNumber,
|
|
155
|
-
timeoutHeight: 0,
|
|
156
|
-
fee
|
|
157
|
-
});
|
|
158
|
-
const directSignResponse = await signer.signDirect(signerAddress, signDoc);
|
|
159
|
-
return tx_js.TxRaw.fromPartial({
|
|
160
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
161
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
162
|
-
signatures: [encoding.fromBase64(directSignResponse.signature.signature)]
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
166
|
-
const accounts = await signer.getAccounts();
|
|
167
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
168
|
-
if (!accountFromSigner) {
|
|
169
|
-
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
170
|
-
}
|
|
171
|
-
const restEndpoint = await getRestEndpointForChain(chainId);
|
|
172
|
-
const chainRestTendermintApi = new sdkTs.ChainRestTendermintApi(restEndpoint);
|
|
173
|
-
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
174
|
-
const latestHeight = latestBlock.header.height;
|
|
175
|
-
const timeoutHeight = new utils.BigNumberInBase(latestHeight).plus(utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
176
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
177
|
-
const messages2 = cosmosMsgs.map(
|
|
178
|
-
(cosmosMsg) => chunkN3LR7KTI_cjs.getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
179
|
-
);
|
|
180
|
-
const { signDoc } = createTransaction({
|
|
181
|
-
pubKey: pk,
|
|
182
|
-
chainId,
|
|
183
|
-
message: messages2,
|
|
184
|
-
sequence,
|
|
185
|
-
accountNumber,
|
|
186
|
-
timeoutHeight: timeoutHeight.toNumber(),
|
|
187
|
-
fee
|
|
188
|
-
});
|
|
189
|
-
const directSignResponse = await signer.signDirect(
|
|
190
|
-
signerAddress,
|
|
191
|
-
// @ts-expect-error TODO: Fix this
|
|
192
|
-
signDoc
|
|
193
|
-
);
|
|
194
|
-
return tx_js.TxRaw.fromPartial({
|
|
195
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
196
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
197
|
-
signatures: [encoding.fromBase64(directSignResponse.signature.signature)]
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
109
|
var pubkeyType = {
|
|
201
110
|
ethsecp256k1: "ethermint/PubKeyEthSecp256k1",
|
|
202
111
|
...amino.pubkeyType
|
|
@@ -217,7 +126,7 @@ function encodeEthSecp256k1Pubkey(pubkey) {
|
|
|
217
126
|
|
|
218
127
|
// src/proto-signing/pubkey.ts
|
|
219
128
|
function makePubkeyAnyFromAccount(account, chainId) {
|
|
220
|
-
const isEthermint =
|
|
129
|
+
const isEthermint = chunkVIG2BHYJ_cjs.getIsEthermint(chainId);
|
|
221
130
|
const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) : amino.encodeSecp256k1Pubkey(account.pubkey);
|
|
222
131
|
const pubkeyAny = encodePubkeyToAny(pubkey, chainId, isEthermint);
|
|
223
132
|
return pubkeyAny;
|
|
@@ -238,7 +147,7 @@ function encodePubkeyToAny(pubkey, chainId, isEthermint) {
|
|
|
238
147
|
value: Uint8Array.from(keys_js.PubKey.encode(pubkeyProto).finish())
|
|
239
148
|
});
|
|
240
149
|
} else {
|
|
241
|
-
const isInitia =
|
|
150
|
+
const isInitia = chunkVIG2BHYJ_cjs.getIsInitia(chainId);
|
|
242
151
|
const pubkeyProto = keys_js.PubKey.fromPartial({
|
|
243
152
|
key: encoding.fromBase64(pubkey.value)
|
|
244
153
|
});
|
|
@@ -260,33 +169,19 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
260
169
|
fee,
|
|
261
170
|
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
262
171
|
} = options;
|
|
263
|
-
if (chainId.includes("evmos")) {
|
|
264
|
-
return signCosmosMessageDirectEvmos(signerAddress, signer, cosmosMsgs, fee, {
|
|
265
|
-
accountNumber,
|
|
266
|
-
sequence,
|
|
267
|
-
chainId: signerChainId
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (chainId.includes("injective")) {
|
|
271
|
-
return signCosmosMessageDirectInjective(signerAddress, signer, cosmosMsgs, fee, {
|
|
272
|
-
accountNumber,
|
|
273
|
-
sequence,
|
|
274
|
-
chainId: signerChainId
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
172
|
const accounts = await signer.getAccounts();
|
|
278
173
|
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
279
174
|
if (!accountFromSigner) {
|
|
280
175
|
throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
|
|
281
176
|
}
|
|
282
|
-
const messages2 = cosmosMsgs.map((cosmosMsg) =>
|
|
177
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
283
178
|
const txBodyEncodeObject = {
|
|
284
179
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
285
180
|
value: {
|
|
286
181
|
messages: messages2
|
|
287
182
|
}
|
|
288
183
|
};
|
|
289
|
-
const txBodyBytes =
|
|
184
|
+
const txBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(txBodyEncodeObject);
|
|
290
185
|
const gasLimit = math.Int53.fromString(fee.gas).toNumber();
|
|
291
186
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
292
187
|
const authInfoBytes = protoSigning.makeAuthInfoBytes(
|
|
@@ -318,14 +213,14 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
318
213
|
if (!accountFromSigner) {
|
|
319
214
|
throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
|
|
320
215
|
}
|
|
321
|
-
const messages2 = cosmosMsgs.map((cosmosMsg) =>
|
|
216
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => chunkKM2D7PJL_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
322
217
|
const signMode = signing_js.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
323
|
-
const msgs = messages2.map((msg) =>
|
|
218
|
+
const msgs = messages2.map((msg) => chunkN4UW74AG_cjs.ClientState.aminoTypes.toAmino(msg));
|
|
324
219
|
console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
325
220
|
const signDoc = amino.makeSignDoc(msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
326
221
|
const { signature, signed } = await signer.signAmino(signerAddress, signDoc);
|
|
327
222
|
const signedTxBody = {
|
|
328
|
-
messages: signed.msgs.map((msg) =>
|
|
223
|
+
messages: signed.msgs.map((msg) => chunkN4UW74AG_cjs.ClientState.aminoTypes.fromAmino(msg)),
|
|
329
224
|
memo: signed.memo
|
|
330
225
|
};
|
|
331
226
|
signedTxBody.messages[0].value.memo = messages2[0].value.memo;
|
|
@@ -333,7 +228,7 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
333
228
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
334
229
|
value: signedTxBody
|
|
335
230
|
};
|
|
336
|
-
const signedTxBodyBytes =
|
|
231
|
+
const signedTxBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(signedTxBodyEncodeObject);
|
|
337
232
|
const signedGasLimit = math.Int53.fromString(signed.fee.gas).toNumber();
|
|
338
233
|
const signedSequence = math.Int53.fromString(signed.sequence).toNumber();
|
|
339
234
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
@@ -356,7 +251,8 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
356
251
|
var signCosmosTransaction = async ({
|
|
357
252
|
tx,
|
|
358
253
|
options,
|
|
359
|
-
index
|
|
254
|
+
index,
|
|
255
|
+
routeId
|
|
360
256
|
}) => {
|
|
361
257
|
const { userAddresses } = options;
|
|
362
258
|
if (tx === void 0) {
|
|
@@ -365,7 +261,7 @@ var signCosmosTransaction = async ({
|
|
|
365
261
|
const chainId = tx.cosmosTx?.chainId;
|
|
366
262
|
const messages2 = tx.cosmosTx?.msgs;
|
|
367
263
|
const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
368
|
-
const gasArray =
|
|
264
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
369
265
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
370
266
|
if (typeof gas?.error === "string") {
|
|
371
267
|
throw new Error(gas?.error);
|
|
@@ -380,7 +276,7 @@ var signCosmosTransaction = async ({
|
|
|
380
276
|
if (messages2 === void 0) {
|
|
381
277
|
throw new Error("no messages found for tx");
|
|
382
278
|
}
|
|
383
|
-
const { signer } = await
|
|
279
|
+
const { signer } = await chunk6LA66667_cjs.getSigningStargateClient({
|
|
384
280
|
chainId,
|
|
385
281
|
getOfflineSigner: options?.getCosmosSigner
|
|
386
282
|
});
|
|
@@ -419,6 +315,11 @@ var signCosmosTransaction = async ({
|
|
|
419
315
|
txIndex: index,
|
|
420
316
|
signerAddress: currentUserAddress
|
|
421
317
|
});
|
|
318
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
319
|
+
status: "signing",
|
|
320
|
+
routeId,
|
|
321
|
+
options
|
|
322
|
+
});
|
|
422
323
|
if (protoSigning.isOfflineDirectSigner(signer)) {
|
|
423
324
|
rawTx = await signCosmosMessageDirect({
|
|
424
325
|
...commonRawTxBody,
|
|
@@ -430,6 +331,11 @@ var signCosmosTransaction = async ({
|
|
|
430
331
|
options?.onTransactionSigned?.({
|
|
431
332
|
chainId
|
|
432
333
|
});
|
|
334
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
335
|
+
status: "pending",
|
|
336
|
+
routeId,
|
|
337
|
+
options
|
|
338
|
+
});
|
|
433
339
|
const txBytes = tx_js.TxRaw.encode(rawTx).finish();
|
|
434
340
|
const rawTxBase64 = Buffer.from(txBytes).toString("base64");
|
|
435
341
|
return rawTxBase64;
|
|
@@ -439,7 +345,8 @@ var signCosmosTransaction = async ({
|
|
|
439
345
|
var executeCosmosTransaction = async ({
|
|
440
346
|
tx,
|
|
441
347
|
options,
|
|
442
|
-
index
|
|
348
|
+
index,
|
|
349
|
+
routeId
|
|
443
350
|
}) => {
|
|
444
351
|
if (tx === void 0) {
|
|
445
352
|
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
@@ -447,10 +354,11 @@ var executeCosmosTransaction = async ({
|
|
|
447
354
|
const rawTxBase64 = await signCosmosTransaction({
|
|
448
355
|
tx,
|
|
449
356
|
options,
|
|
450
|
-
index
|
|
357
|
+
index,
|
|
358
|
+
routeId
|
|
451
359
|
});
|
|
452
360
|
const chainId = tx.cosmosTx?.chainId;
|
|
453
|
-
const txResponse = await
|
|
361
|
+
const txResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
454
362
|
chainId,
|
|
455
363
|
tx: rawTxBase64
|
|
456
364
|
});
|
|
@@ -662,8 +570,8 @@ var erc20ABI = /* @__PURE__ */ createAbi([
|
|
|
662
570
|
]);
|
|
663
571
|
|
|
664
572
|
// src/private-functions/evm/executeEvmTransaction.ts
|
|
665
|
-
var executeEvmTransaction = async (message, options, index) => {
|
|
666
|
-
const gasArray =
|
|
573
|
+
var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
574
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
667
575
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
668
576
|
if (typeof gas?.error === "string") {
|
|
669
577
|
throw new Error(gas?.error);
|
|
@@ -709,6 +617,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
709
617
|
status: "pending",
|
|
710
618
|
allowance: requiredApproval
|
|
711
619
|
});
|
|
620
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
621
|
+
status: "allowance",
|
|
622
|
+
routeId,
|
|
623
|
+
options
|
|
624
|
+
});
|
|
712
625
|
const txHash2 = await extendedSigner.writeContract({
|
|
713
626
|
account: evmSigner.account,
|
|
714
627
|
address: requiredApproval.tokenContract,
|
|
@@ -738,6 +651,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
738
651
|
signerAddress: evmSigner.account.address,
|
|
739
652
|
txIndex: index
|
|
740
653
|
});
|
|
654
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
655
|
+
status: "signing",
|
|
656
|
+
routeId,
|
|
657
|
+
options
|
|
658
|
+
});
|
|
741
659
|
const txHash = await extendedSigner.sendTransaction({
|
|
742
660
|
account: evmSigner.account,
|
|
743
661
|
to: evmTx.to,
|
|
@@ -745,6 +663,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
745
663
|
chain: evmSigner.chain,
|
|
746
664
|
value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
|
|
747
665
|
});
|
|
666
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
667
|
+
status: "pending",
|
|
668
|
+
routeId,
|
|
669
|
+
options
|
|
670
|
+
});
|
|
748
671
|
onTransactionSigned?.({
|
|
749
672
|
chainId: evmTx.chainId
|
|
750
673
|
});
|
|
@@ -756,9 +679,10 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
756
679
|
var signSvmTransaction = async ({
|
|
757
680
|
tx,
|
|
758
681
|
options,
|
|
759
|
-
index
|
|
682
|
+
index,
|
|
683
|
+
routeId
|
|
760
684
|
}) => {
|
|
761
|
-
const gasArray =
|
|
685
|
+
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
762
686
|
if (tx === void 0) {
|
|
763
687
|
throw new Error("executeSvmTransaction error: tx is undefined");
|
|
764
688
|
}
|
|
@@ -795,26 +719,36 @@ var signSvmTransaction = async ({
|
|
|
795
719
|
signerAddress: signer.publicKey?.toBase58(),
|
|
796
720
|
txIndex: index
|
|
797
721
|
});
|
|
722
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
723
|
+
status: "signing",
|
|
724
|
+
routeId,
|
|
725
|
+
options
|
|
726
|
+
});
|
|
798
727
|
const signedTx = await signer.signTransaction(transaction);
|
|
799
728
|
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
729
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
730
|
+
status: "pending",
|
|
731
|
+
routeId,
|
|
732
|
+
options
|
|
733
|
+
});
|
|
800
734
|
const serializedTx = signedTx.serialize();
|
|
801
735
|
return serializedTx;
|
|
802
736
|
};
|
|
803
737
|
|
|
804
738
|
// src/private-functions/svm/executeSvmTransaction.ts
|
|
805
|
-
var executeSvmTransaction = async (tx, options, index) => {
|
|
739
|
+
var executeSvmTransaction = async (tx, options, index, routeId) => {
|
|
806
740
|
const svmTx = tx?.svmTx;
|
|
807
741
|
if (!svmTx?.chainId) {
|
|
808
742
|
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
809
743
|
}
|
|
810
|
-
const signedTx = await signSvmTransaction({ tx, options, index });
|
|
744
|
+
const signedTx = await signSvmTransaction({ tx, options, index, routeId });
|
|
811
745
|
if (!signedTx) {
|
|
812
746
|
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
813
747
|
}
|
|
814
|
-
const endpoint = await
|
|
748
|
+
const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(svmTx.chainId);
|
|
815
749
|
const connection = new web3_js.Connection(endpoint);
|
|
816
750
|
let signature;
|
|
817
|
-
const submitTxResponse = await
|
|
751
|
+
const submitTxResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
818
752
|
chainId: svmTx.chainId,
|
|
819
753
|
tx: signedTx.toString("base64")
|
|
820
754
|
});
|
|
@@ -842,13 +776,13 @@ var executeSvmTransaction = async (tx, options, index) => {
|
|
|
842
776
|
};
|
|
843
777
|
}
|
|
844
778
|
if (getStatusCount > 12) {
|
|
845
|
-
await
|
|
779
|
+
await chunkERGJBZUC_cjs.wait(3e3);
|
|
846
780
|
throw new Error(
|
|
847
781
|
`executeSvmTransaction error: waiting finalized status timed out for ${signature}`
|
|
848
782
|
);
|
|
849
783
|
}
|
|
850
784
|
getStatusCount++;
|
|
851
|
-
await
|
|
785
|
+
await chunkERGJBZUC_cjs.wait(3e3);
|
|
852
786
|
} catch (error) {
|
|
853
787
|
errorCount++;
|
|
854
788
|
if (errorCount > 12) {
|
|
@@ -882,7 +816,7 @@ var validateEvmTokenApproval = async ({
|
|
|
882
816
|
const fee = await extendedSigner.estimateFeesPerGas();
|
|
883
817
|
const allowanceGasFee = BigInt(fee.maxFeePerGas) * BigInt(1e5);
|
|
884
818
|
if (!gasBalance) {
|
|
885
|
-
const chainAssets = (await
|
|
819
|
+
const chainAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
886
820
|
const nativeAsset = chainAssets?.find((x) => x.denom.includes("-native"));
|
|
887
821
|
const zeroAddressAsset = chainAssets?.find(
|
|
888
822
|
(x) => x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
@@ -899,7 +833,7 @@ var validateEvmTokenApproval = async ({
|
|
|
899
833
|
);
|
|
900
834
|
}
|
|
901
835
|
if (chunk4R6OCWRR_cjs.BigNumber(gasBalance.amount).lt(Number(allowanceGasFee))) {
|
|
902
|
-
const chainAssets = (await
|
|
836
|
+
const chainAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
903
837
|
const asset = chainAssets?.find(
|
|
904
838
|
(x) => x.denom.includes("-native") || x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
905
839
|
);
|
|
@@ -947,8 +881,8 @@ var validateEvmGasBalance = async ({
|
|
|
947
881
|
useUnlimitedApproval
|
|
948
882
|
}) => {
|
|
949
883
|
const chainId = tx?.chainId ?? "";
|
|
950
|
-
const skipAssets = (await
|
|
951
|
-
const skipChains = await
|
|
884
|
+
const skipAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
|
|
885
|
+
const skipChains = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
|
|
952
886
|
const chain = skipChains?.find?.((chain2) => chain2.chainId === chainId);
|
|
953
887
|
if (!chain) {
|
|
954
888
|
throw new Error(`failed to find chain for chainId: '${chainId}'`);
|
|
@@ -956,7 +890,7 @@ var validateEvmGasBalance = async ({
|
|
|
956
890
|
if (!signer.account?.address) {
|
|
957
891
|
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
958
892
|
}
|
|
959
|
-
const skipBalances = (await
|
|
893
|
+
const skipBalances = (await chunkN4UW74AG_cjs.balances({
|
|
960
894
|
chains: {
|
|
961
895
|
[tx?.chainId ?? ""]: {
|
|
962
896
|
address: signer.account?.address
|
|
@@ -1042,7 +976,7 @@ var validateSvmGasBalance = async ({
|
|
|
1042
976
|
fee: null
|
|
1043
977
|
};
|
|
1044
978
|
}
|
|
1045
|
-
const endpoint = await
|
|
979
|
+
const endpoint = await chunk6LA66667_cjs.getRpcEndpointForChain(tx.chainId ?? "");
|
|
1046
980
|
const connection = new web3_js.Connection(endpoint);
|
|
1047
981
|
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
1048
982
|
if (!tx.tx) {
|
|
@@ -1107,7 +1041,9 @@ var validateGasBalances = async ({
|
|
|
1107
1041
|
disabledChainIds,
|
|
1108
1042
|
enabledChainIds,
|
|
1109
1043
|
useUnlimitedApproval,
|
|
1110
|
-
getCosmosPriorityFeeDenom
|
|
1044
|
+
getCosmosPriorityFeeDenom,
|
|
1045
|
+
routeId,
|
|
1046
|
+
options
|
|
1111
1047
|
}) => {
|
|
1112
1048
|
const validateResult = await Promise.all(
|
|
1113
1049
|
txs.map(async (tx, i) => {
|
|
@@ -1118,11 +1054,16 @@ var validateGasBalances = async ({
|
|
|
1118
1054
|
onValidateGasBalance?.({
|
|
1119
1055
|
status: "pending"
|
|
1120
1056
|
});
|
|
1057
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1058
|
+
status: "validating",
|
|
1059
|
+
routeId,
|
|
1060
|
+
options
|
|
1061
|
+
});
|
|
1121
1062
|
if (!tx?.cosmosTx?.msgs) {
|
|
1122
1063
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1123
1064
|
}
|
|
1124
1065
|
try {
|
|
1125
|
-
const res = await
|
|
1066
|
+
const res = await chunk46VB6RQK_cjs.validateCosmosGasBalance({
|
|
1126
1067
|
chainId: tx.cosmosTx.chainId ?? "",
|
|
1127
1068
|
signerAddress: tx.cosmosTx.signerAddress ?? "",
|
|
1128
1069
|
messages: tx.cosmosTx.msgs,
|
|
@@ -1146,6 +1087,11 @@ var validateGasBalances = async ({
|
|
|
1146
1087
|
onValidateGasBalance?.({
|
|
1147
1088
|
status: "pending"
|
|
1148
1089
|
});
|
|
1090
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1091
|
+
status: "validating",
|
|
1092
|
+
routeId,
|
|
1093
|
+
options
|
|
1094
|
+
});
|
|
1149
1095
|
const signer = await getEvmSigner?.(tx?.evmTx?.chainId ?? "");
|
|
1150
1096
|
if (!signer) {
|
|
1151
1097
|
throw new Error(
|
|
@@ -1173,6 +1119,11 @@ var validateGasBalances = async ({
|
|
|
1173
1119
|
onValidateGasBalance?.({
|
|
1174
1120
|
status: "pending"
|
|
1175
1121
|
});
|
|
1122
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1123
|
+
status: "validating",
|
|
1124
|
+
routeId,
|
|
1125
|
+
options
|
|
1126
|
+
});
|
|
1176
1127
|
try {
|
|
1177
1128
|
const res = await validateSvmGasBalance({
|
|
1178
1129
|
tx: tx.svmTx,
|
|
@@ -1198,13 +1149,37 @@ var validateGasBalances = async ({
|
|
|
1198
1149
|
onValidateGasBalance?.({
|
|
1199
1150
|
status: "error"
|
|
1200
1151
|
});
|
|
1201
|
-
|
|
1152
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = validateResult;
|
|
1202
1153
|
throw new Error(`${txError.error}`);
|
|
1203
1154
|
}
|
|
1204
1155
|
onValidateGasBalance?.({
|
|
1205
1156
|
status: "completed"
|
|
1206
1157
|
});
|
|
1207
|
-
|
|
1158
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = validateResult;
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
// src/private-functions/getChainIdsFromTxs.ts
|
|
1162
|
+
var getChainIdsFromTxs = (txs) => {
|
|
1163
|
+
return txs.map((tx) => {
|
|
1164
|
+
if ("cosmosTx" in tx) {
|
|
1165
|
+
return {
|
|
1166
|
+
chainType: "cosmos" /* Cosmos */,
|
|
1167
|
+
chainId: tx.cosmosTx?.chainId
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
if ("svmTx" in tx) {
|
|
1171
|
+
return {
|
|
1172
|
+
chainType: "svm" /* Svm */,
|
|
1173
|
+
chainId: tx.svmTx?.chainId
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
if ("evmTx" in tx) {
|
|
1177
|
+
return {
|
|
1178
|
+
chainType: "evm" /* Evm */,
|
|
1179
|
+
chainId: tx.evmTx?.chainId
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1208
1183
|
};
|
|
1209
1184
|
|
|
1210
1185
|
// src/private-functions/executeTransactions.ts
|
|
@@ -1212,7 +1187,6 @@ var executeTransactions = async (options) => {
|
|
|
1212
1187
|
const {
|
|
1213
1188
|
txs,
|
|
1214
1189
|
onTransactionBroadcast,
|
|
1215
|
-
onTransactionCompleted,
|
|
1216
1190
|
simulate = true,
|
|
1217
1191
|
batchSimulate = true,
|
|
1218
1192
|
getFallbackGasAmount = getDefaultFallbackGasAmount,
|
|
@@ -1220,37 +1194,35 @@ var executeTransactions = async (options) => {
|
|
|
1220
1194
|
getEvmSigner,
|
|
1221
1195
|
onValidateGasBalance,
|
|
1222
1196
|
trackTxPollingOptions,
|
|
1223
|
-
batchSignTxs = true
|
|
1197
|
+
batchSignTxs = true,
|
|
1198
|
+
routeId
|
|
1224
1199
|
} = options;
|
|
1225
1200
|
if (txs === void 0) {
|
|
1226
1201
|
throw new Error(
|
|
1227
1202
|
"executeTransactions error: txs is undefined in executeTransactions"
|
|
1228
1203
|
);
|
|
1229
1204
|
}
|
|
1230
|
-
const chainIds = txs
|
|
1205
|
+
const chainIds = getChainIdsFromTxs(txs);
|
|
1206
|
+
const transactionDetails = txs.map((tx) => {
|
|
1231
1207
|
if ("cosmosTx" in tx) {
|
|
1232
|
-
return {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
chainType: "svm",
|
|
1240
|
-
chainId: tx.svmTx?.chainId
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1243
|
-
if ("evmTx" in tx) {
|
|
1244
|
-
return {
|
|
1245
|
-
chainType: "evm",
|
|
1246
|
-
chainId: tx.evmTx?.chainId
|
|
1247
|
-
};
|
|
1208
|
+
return { chainId: tx.cosmosTx?.chainId };
|
|
1209
|
+
} else if ("evmTx" in tx) {
|
|
1210
|
+
return { chainId: tx.evmTx?.chainId };
|
|
1211
|
+
} else if ("svmTx" in tx) {
|
|
1212
|
+
return { chainId: tx.svmTx?.chainId };
|
|
1213
|
+
} else {
|
|
1214
|
+
throw new Error("executeRoute error: invalid message type");
|
|
1248
1215
|
}
|
|
1249
1216
|
});
|
|
1217
|
+
chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1218
|
+
transactionDetails,
|
|
1219
|
+
routeId,
|
|
1220
|
+
options
|
|
1221
|
+
});
|
|
1250
1222
|
const isGasStationSourceEVM = chainIds.find((item, i, array) => {
|
|
1251
|
-
return chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm"
|
|
1223
|
+
return chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm" /* Evm */;
|
|
1252
1224
|
});
|
|
1253
|
-
|
|
1225
|
+
chunkN4UW74AG_cjs.ClientState.validateGasResults = void 0;
|
|
1254
1226
|
const validateChainIds = !batchSimulate ? chainIds.map((x) => x?.chainId ?? "") : isGasStationSourceEVM ? chunkKZOSEIWH_cjs.GAS_STATION_CHAIN_IDS : [];
|
|
1255
1227
|
await validateGasBalances({
|
|
1256
1228
|
txs,
|
|
@@ -1260,7 +1232,9 @@ var executeTransactions = async (options) => {
|
|
|
1260
1232
|
onValidateGasBalance,
|
|
1261
1233
|
simulate,
|
|
1262
1234
|
disabledChainIds: validateChainIds,
|
|
1263
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1235
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1236
|
+
options,
|
|
1237
|
+
routeId
|
|
1264
1238
|
});
|
|
1265
1239
|
const validateEnabledChainIds = async (chainId) => {
|
|
1266
1240
|
await validateGasBalances({
|
|
@@ -1271,7 +1245,9 @@ var executeTransactions = async (options) => {
|
|
|
1271
1245
|
onValidateGasBalance,
|
|
1272
1246
|
simulate,
|
|
1273
1247
|
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
|
|
1274
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1248
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1249
|
+
options,
|
|
1250
|
+
routeId
|
|
1275
1251
|
});
|
|
1276
1252
|
};
|
|
1277
1253
|
let signedTxs = [];
|
|
@@ -1304,7 +1280,8 @@ var executeTransactions = async (options) => {
|
|
|
1304
1280
|
const signedTx = await signCosmosTransaction({
|
|
1305
1281
|
tx,
|
|
1306
1282
|
options,
|
|
1307
|
-
index: i
|
|
1283
|
+
index: i,
|
|
1284
|
+
routeId
|
|
1308
1285
|
});
|
|
1309
1286
|
signedTxs.push({
|
|
1310
1287
|
index: i,
|
|
@@ -1315,7 +1292,7 @@ var executeTransactions = async (options) => {
|
|
|
1315
1292
|
}
|
|
1316
1293
|
if ("svmTx" in tx) {
|
|
1317
1294
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1318
|
-
const signedTx = await signSvmTransaction({ tx, options, index: i });
|
|
1295
|
+
const signedTx = await signSvmTransaction({ tx, options, index: i, routeId });
|
|
1319
1296
|
if (!signedTx) {
|
|
1320
1297
|
throw new Error(`executeRoute error: signedTx is undefined`);
|
|
1321
1298
|
}
|
|
@@ -1328,15 +1305,15 @@ var executeTransactions = async (options) => {
|
|
|
1328
1305
|
}
|
|
1329
1306
|
}
|
|
1330
1307
|
}
|
|
1331
|
-
|
|
1332
|
-
const tx = txs[
|
|
1308
|
+
const executeTransaction = async (index) => {
|
|
1309
|
+
const tx = txs[index];
|
|
1333
1310
|
if (!tx) {
|
|
1334
|
-
throw new Error(`executeRoute error: invalid message at index ${
|
|
1311
|
+
throw new Error(`executeRoute error: invalid message at index ${index}`);
|
|
1335
1312
|
}
|
|
1336
1313
|
let txResult;
|
|
1337
|
-
const txSigned = signedTxs.find((item) => item.index ===
|
|
1314
|
+
const txSigned = signedTxs.find((item) => item.index === index);
|
|
1338
1315
|
if (txSigned) {
|
|
1339
|
-
const txResponse = await
|
|
1316
|
+
const txResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
1340
1317
|
chainId: txSigned.chainId,
|
|
1341
1318
|
tx: txSigned.tx
|
|
1342
1319
|
});
|
|
@@ -1351,34 +1328,32 @@ var executeTransactions = async (options) => {
|
|
|
1351
1328
|
txResult = await executeCosmosTransaction({
|
|
1352
1329
|
tx,
|
|
1353
1330
|
options,
|
|
1354
|
-
index
|
|
1331
|
+
index,
|
|
1332
|
+
routeId
|
|
1355
1333
|
});
|
|
1356
1334
|
} else if ("evmTx" in tx) {
|
|
1357
1335
|
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1358
|
-
const txResponse = await executeEvmTransaction(tx, options,
|
|
1336
|
+
const txResponse = await executeEvmTransaction(tx, options, index, routeId);
|
|
1359
1337
|
txResult = {
|
|
1360
1338
|
chainId: tx?.evmTx?.chainId ?? "",
|
|
1361
1339
|
txHash: txResponse.transactionHash
|
|
1362
1340
|
};
|
|
1363
1341
|
} else if ("svmTx" in tx) {
|
|
1364
1342
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1365
|
-
txResult = await executeSvmTransaction(tx, options,
|
|
1343
|
+
txResult = await executeSvmTransaction(tx, options, index, routeId);
|
|
1366
1344
|
} else {
|
|
1367
1345
|
throw new Error("executeRoute error: invalid message type");
|
|
1368
1346
|
}
|
|
1369
1347
|
}
|
|
1370
1348
|
await onTransactionBroadcast?.({ ...txResult });
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
status: txStatusResponse
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1349
|
+
return txResult;
|
|
1350
|
+
};
|
|
1351
|
+
await chunk7MC3BVQN_cjs.executeAndSubscribeToRouteStatus({
|
|
1352
|
+
transactionDetails,
|
|
1353
|
+
executeTransaction,
|
|
1354
|
+
routeId,
|
|
1355
|
+
options
|
|
1356
|
+
});
|
|
1382
1357
|
};
|
|
1383
1358
|
var EVM_GAS_AMOUNT = 15e4;
|
|
1384
1359
|
var COSMOS_GAS_AMOUNT = {
|
|
@@ -1391,7 +1366,7 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1391
1366
|
return EVM_GAS_AMOUNT;
|
|
1392
1367
|
}
|
|
1393
1368
|
if (chainType !== "cosmos" /* Cosmos */) return void 0;
|
|
1394
|
-
const venuesResult = await
|
|
1369
|
+
const venuesResult = await chunk5AYPH3ZR_cjs.venues();
|
|
1395
1370
|
const isSwapChain = venuesResult?.some(
|
|
1396
1371
|
(venue) => venue.chainId === chainId
|
|
1397
1372
|
) ?? false;
|
|
@@ -1405,6 +1380,10 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1405
1380
|
};
|
|
1406
1381
|
var executeRoute = async (options) => {
|
|
1407
1382
|
const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
|
|
1383
|
+
const { id: routeId } = chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1384
|
+
status: "unconfirmed",
|
|
1385
|
+
options
|
|
1386
|
+
});
|
|
1408
1387
|
let addressList = [];
|
|
1409
1388
|
userAddresses.forEach((userAddress, index) => {
|
|
1410
1389
|
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
@@ -1423,7 +1402,7 @@ var executeRoute = async (options) => {
|
|
|
1423
1402
|
if (!isUserAddressesValid) {
|
|
1424
1403
|
throw new Error("executeRoute error: invalid user addresses");
|
|
1425
1404
|
}
|
|
1426
|
-
const response = await
|
|
1405
|
+
const response = await chunkOZUCMWNE_cjs.messages({
|
|
1427
1406
|
timeoutSeconds,
|
|
1428
1407
|
amountIn: route?.amountIn,
|
|
1429
1408
|
amountOut: route.estimatedAmountOut || "0",
|
|
@@ -1434,7 +1413,7 @@ var executeRoute = async (options) => {
|
|
|
1434
1413
|
operations: route?.operations,
|
|
1435
1414
|
addressList,
|
|
1436
1415
|
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
1437
|
-
chainIdsToAffiliates:
|
|
1416
|
+
chainIdsToAffiliates: chunkERGJBZUC_cjs.ApiState.chainIdsToAffiliates,
|
|
1438
1417
|
postRouteHandler: options.postRouteHandler,
|
|
1439
1418
|
feePayerAddress: options.svmFeePayer?.address
|
|
1440
1419
|
});
|
|
@@ -1450,10 +1429,10 @@ var executeRoute = async (options) => {
|
|
|
1450
1429
|
lastTx.cosmosTx?.msgs?.push(afterMsg);
|
|
1451
1430
|
}
|
|
1452
1431
|
}
|
|
1453
|
-
await executeTransactions({ ...options, txs: response?.txs });
|
|
1432
|
+
await executeTransactions({ ...options, routeId, txs: response?.txs });
|
|
1454
1433
|
};
|
|
1455
1434
|
var validateUserAddresses = async (userAddresses) => {
|
|
1456
|
-
const chains2 = await
|
|
1435
|
+
const chains2 = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
|
|
1457
1436
|
const validations = userAddresses.map((userAddress) => {
|
|
1458
1437
|
const chain = chains2.find((chain2) => chain2.chainId === userAddress.chainId);
|
|
1459
1438
|
switch (chain?.chainType) {
|