@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,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_GAS_DENOM_OVERRIDES } from './chunk-SWYON2RG.js';
|
|
2
|
-
import { chains } from './chunk-
|
|
3
|
-
import { ClientState } from './chunk-
|
|
2
|
+
import { chains } from './chunk-3J6O2PVK.js';
|
|
3
|
+
import { ClientState } from './chunk-ZOUYAZU6.js';
|
|
4
4
|
|
|
5
5
|
// src/private-functions/getDefaultGasTokenForChain.ts
|
|
6
6
|
var getDefaultGasTokenForChain = async (chainId) => {
|
|
@@ -45,7 +45,11 @@ var createRequestClient = ({ apiUrl, apiKey, apiHeaders }) => {
|
|
|
45
45
|
const body = isJson ? await response.json() : await response.text();
|
|
46
46
|
if (!response.ok) {
|
|
47
47
|
const message = typeof body === "object" && body?.message ? body.message : response.statusText;
|
|
48
|
-
|
|
48
|
+
const error = new Error(message);
|
|
49
|
+
if (body?.code) {
|
|
50
|
+
error.code = body.code;
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
49
53
|
}
|
|
50
54
|
return body;
|
|
51
55
|
};
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getEncodeObjectFromCosmosMessage
|
|
1
|
+
import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-RQ7DXNSS.js';
|
|
2
|
+
import { validateCosmosGasBalance } from './chunk-GHNH5QC3.js';
|
|
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-
|
|
8
|
-
import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-
|
|
9
|
-
import { messages } from './chunk-
|
|
10
|
-
import { submitTransaction } from './chunk-
|
|
11
|
-
import { venues } from './chunk-
|
|
12
|
-
import { ClientState, balances } from './chunk-
|
|
13
|
-
import { ApiState, toCamel, wait } from './chunk-
|
|
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';
|
|
10
|
+
import { submitTransaction } from './chunk-JQ4F4WBG.js';
|
|
11
|
+
import { venues } from './chunk-52PEBJRQ.js';
|
|
12
|
+
import { ClientState, balances } from './chunk-ZOUYAZU6.js';
|
|
13
|
+
import { ApiState, toCamel, wait } from './chunk-A6KSECAH.js';
|
|
14
14
|
import { PublicKey, Transaction, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
15
15
|
import { bech32m, bech32 } from 'bech32';
|
|
16
16
|
import { StargateClient } from '@cosmjs/stargate';
|
|
17
17
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
18
18
|
import { isOfflineDirectSigner, makeAuthInfoBytes, makeSignDoc, encodePubkey } from '@cosmjs/proto-signing';
|
|
19
|
-
import { fromBase64, toBase64 } from '@cosmjs/encoding';
|
|
20
|
-
import { ChainRestTendermintApi, createTransactionWithSigners } from '@injectivelabs/sdk-ts';
|
|
21
|
-
import { BigNumberInBase, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_STD_FEE } from '@injectivelabs/utils';
|
|
22
19
|
import { pubkeyType as pubkeyType$1, makeSignDoc as makeSignDoc$1, encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
20
|
+
import { fromBase64, toBase64 } from '@cosmjs/encoding';
|
|
23
21
|
import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys.js';
|
|
24
22
|
import { Any } from 'cosmjs-types/google/protobuf/any.js';
|
|
25
23
|
import { Int53 } from '@cosmjs/math';
|
|
@@ -106,95 +104,6 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
106
104
|
sequence
|
|
107
105
|
};
|
|
108
106
|
};
|
|
109
|
-
function createTransaction({
|
|
110
|
-
chainId,
|
|
111
|
-
message,
|
|
112
|
-
timeoutHeight,
|
|
113
|
-
memo = "",
|
|
114
|
-
fee = DEFAULT_STD_FEE,
|
|
115
|
-
signMode = 1,
|
|
116
|
-
pubKey,
|
|
117
|
-
accountNumber,
|
|
118
|
-
sequence
|
|
119
|
-
}) {
|
|
120
|
-
const signers = {
|
|
121
|
-
pubKey,
|
|
122
|
-
accountNumber,
|
|
123
|
-
sequence
|
|
124
|
-
};
|
|
125
|
-
return createTransactionWithSigners({
|
|
126
|
-
fee,
|
|
127
|
-
memo,
|
|
128
|
-
message,
|
|
129
|
-
signers,
|
|
130
|
-
chainId,
|
|
131
|
-
signMode,
|
|
132
|
-
timeoutHeight
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/private-functions/cosmos/signCosmosMessageDirectEvmos.ts
|
|
137
|
-
var signCosmosMessageDirectEvmos = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
138
|
-
const accounts = await signer.getAccounts();
|
|
139
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
140
|
-
if (!accountFromSigner) {
|
|
141
|
-
throw new Error("signCosmosMessageDirectEvmos: failed to retrieve account from signer");
|
|
142
|
-
}
|
|
143
|
-
const messages2 = cosmosMsgs.map(
|
|
144
|
-
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
145
|
-
);
|
|
146
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
147
|
-
const { signDoc } = createTransaction({
|
|
148
|
-
pubKey: pk,
|
|
149
|
-
chainId,
|
|
150
|
-
message: messages2,
|
|
151
|
-
sequence,
|
|
152
|
-
accountNumber,
|
|
153
|
-
timeoutHeight: 0,
|
|
154
|
-
fee
|
|
155
|
-
});
|
|
156
|
-
const directSignResponse = await signer.signDirect(signerAddress, signDoc);
|
|
157
|
-
return TxRaw.fromPartial({
|
|
158
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
159
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
160
|
-
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
164
|
-
const accounts = await signer.getAccounts();
|
|
165
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
166
|
-
if (!accountFromSigner) {
|
|
167
|
-
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
168
|
-
}
|
|
169
|
-
const restEndpoint = await getRestEndpointForChain(chainId);
|
|
170
|
-
const chainRestTendermintApi = new ChainRestTendermintApi(restEndpoint);
|
|
171
|
-
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
172
|
-
const latestHeight = latestBlock.header.height;
|
|
173
|
-
const timeoutHeight = new BigNumberInBase(latestHeight).plus(DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
174
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
175
|
-
const messages2 = cosmosMsgs.map(
|
|
176
|
-
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
177
|
-
);
|
|
178
|
-
const { signDoc } = createTransaction({
|
|
179
|
-
pubKey: pk,
|
|
180
|
-
chainId,
|
|
181
|
-
message: messages2,
|
|
182
|
-
sequence,
|
|
183
|
-
accountNumber,
|
|
184
|
-
timeoutHeight: timeoutHeight.toNumber(),
|
|
185
|
-
fee
|
|
186
|
-
});
|
|
187
|
-
const directSignResponse = await signer.signDirect(
|
|
188
|
-
signerAddress,
|
|
189
|
-
// @ts-expect-error TODO: Fix this
|
|
190
|
-
signDoc
|
|
191
|
-
);
|
|
192
|
-
return TxRaw.fromPartial({
|
|
193
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
194
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
195
|
-
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
107
|
var pubkeyType = {
|
|
199
108
|
ethsecp256k1: "ethermint/PubKeyEthSecp256k1",
|
|
200
109
|
...pubkeyType$1
|
|
@@ -258,20 +167,6 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
258
167
|
fee,
|
|
259
168
|
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
260
169
|
} = options;
|
|
261
|
-
if (chainId.includes("evmos")) {
|
|
262
|
-
return signCosmosMessageDirectEvmos(signerAddress, signer, cosmosMsgs, fee, {
|
|
263
|
-
accountNumber,
|
|
264
|
-
sequence,
|
|
265
|
-
chainId: signerChainId
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
if (chainId.includes("injective")) {
|
|
269
|
-
return signCosmosMessageDirectInjective(signerAddress, signer, cosmosMsgs, fee, {
|
|
270
|
-
accountNumber,
|
|
271
|
-
sequence,
|
|
272
|
-
chainId: signerChainId
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
170
|
const accounts = await signer.getAccounts();
|
|
276
171
|
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
277
172
|
if (!accountFromSigner) {
|
|
@@ -354,7 +249,8 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
354
249
|
var signCosmosTransaction = async ({
|
|
355
250
|
tx,
|
|
356
251
|
options,
|
|
357
|
-
index
|
|
252
|
+
index,
|
|
253
|
+
routeId
|
|
358
254
|
}) => {
|
|
359
255
|
const { userAddresses } = options;
|
|
360
256
|
if (tx === void 0) {
|
|
@@ -417,6 +313,11 @@ var signCosmosTransaction = async ({
|
|
|
417
313
|
txIndex: index,
|
|
418
314
|
signerAddress: currentUserAddress
|
|
419
315
|
});
|
|
316
|
+
updateRouteDetails({
|
|
317
|
+
status: "signing",
|
|
318
|
+
routeId,
|
|
319
|
+
options
|
|
320
|
+
});
|
|
420
321
|
if (isOfflineDirectSigner(signer)) {
|
|
421
322
|
rawTx = await signCosmosMessageDirect({
|
|
422
323
|
...commonRawTxBody,
|
|
@@ -428,6 +329,11 @@ var signCosmosTransaction = async ({
|
|
|
428
329
|
options?.onTransactionSigned?.({
|
|
429
330
|
chainId
|
|
430
331
|
});
|
|
332
|
+
updateRouteDetails({
|
|
333
|
+
status: "pending",
|
|
334
|
+
routeId,
|
|
335
|
+
options
|
|
336
|
+
});
|
|
431
337
|
const txBytes = TxRaw.encode(rawTx).finish();
|
|
432
338
|
const rawTxBase64 = Buffer.from(txBytes).toString("base64");
|
|
433
339
|
return rawTxBase64;
|
|
@@ -437,7 +343,8 @@ var signCosmosTransaction = async ({
|
|
|
437
343
|
var executeCosmosTransaction = async ({
|
|
438
344
|
tx,
|
|
439
345
|
options,
|
|
440
|
-
index
|
|
346
|
+
index,
|
|
347
|
+
routeId
|
|
441
348
|
}) => {
|
|
442
349
|
if (tx === void 0) {
|
|
443
350
|
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
@@ -445,7 +352,8 @@ var executeCosmosTransaction = async ({
|
|
|
445
352
|
const rawTxBase64 = await signCosmosTransaction({
|
|
446
353
|
tx,
|
|
447
354
|
options,
|
|
448
|
-
index
|
|
355
|
+
index,
|
|
356
|
+
routeId
|
|
449
357
|
});
|
|
450
358
|
const chainId = tx.cosmosTx?.chainId;
|
|
451
359
|
const txResponse = await submitTransaction({
|
|
@@ -660,7 +568,7 @@ var erc20ABI = /* @__PURE__ */ createAbi([
|
|
|
660
568
|
]);
|
|
661
569
|
|
|
662
570
|
// src/private-functions/evm/executeEvmTransaction.ts
|
|
663
|
-
var executeEvmTransaction = async (message, options, index) => {
|
|
571
|
+
var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
664
572
|
const gasArray = ClientState.validateGasResults;
|
|
665
573
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
666
574
|
if (typeof gas?.error === "string") {
|
|
@@ -707,6 +615,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
707
615
|
status: "pending",
|
|
708
616
|
allowance: requiredApproval
|
|
709
617
|
});
|
|
618
|
+
updateRouteDetails({
|
|
619
|
+
status: "allowance",
|
|
620
|
+
routeId,
|
|
621
|
+
options
|
|
622
|
+
});
|
|
710
623
|
const txHash2 = await extendedSigner.writeContract({
|
|
711
624
|
account: evmSigner.account,
|
|
712
625
|
address: requiredApproval.tokenContract,
|
|
@@ -736,6 +649,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
736
649
|
signerAddress: evmSigner.account.address,
|
|
737
650
|
txIndex: index
|
|
738
651
|
});
|
|
652
|
+
updateRouteDetails({
|
|
653
|
+
status: "signing",
|
|
654
|
+
routeId,
|
|
655
|
+
options
|
|
656
|
+
});
|
|
739
657
|
const txHash = await extendedSigner.sendTransaction({
|
|
740
658
|
account: evmSigner.account,
|
|
741
659
|
to: evmTx.to,
|
|
@@ -743,6 +661,11 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
743
661
|
chain: evmSigner.chain,
|
|
744
662
|
value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
|
|
745
663
|
});
|
|
664
|
+
updateRouteDetails({
|
|
665
|
+
status: "pending",
|
|
666
|
+
routeId,
|
|
667
|
+
options
|
|
668
|
+
});
|
|
746
669
|
onTransactionSigned?.({
|
|
747
670
|
chainId: evmTx.chainId
|
|
748
671
|
});
|
|
@@ -754,7 +677,8 @@ var executeEvmTransaction = async (message, options, index) => {
|
|
|
754
677
|
var signSvmTransaction = async ({
|
|
755
678
|
tx,
|
|
756
679
|
options,
|
|
757
|
-
index
|
|
680
|
+
index,
|
|
681
|
+
routeId
|
|
758
682
|
}) => {
|
|
759
683
|
const gasArray = ClientState.validateGasResults;
|
|
760
684
|
if (tx === void 0) {
|
|
@@ -793,19 +717,29 @@ var signSvmTransaction = async ({
|
|
|
793
717
|
signerAddress: signer.publicKey?.toBase58(),
|
|
794
718
|
txIndex: index
|
|
795
719
|
});
|
|
720
|
+
updateRouteDetails({
|
|
721
|
+
status: "signing",
|
|
722
|
+
routeId,
|
|
723
|
+
options
|
|
724
|
+
});
|
|
796
725
|
const signedTx = await signer.signTransaction(transaction);
|
|
797
726
|
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
727
|
+
updateRouteDetails({
|
|
728
|
+
status: "pending",
|
|
729
|
+
routeId,
|
|
730
|
+
options
|
|
731
|
+
});
|
|
798
732
|
const serializedTx = signedTx.serialize();
|
|
799
733
|
return serializedTx;
|
|
800
734
|
};
|
|
801
735
|
|
|
802
736
|
// src/private-functions/svm/executeSvmTransaction.ts
|
|
803
|
-
var executeSvmTransaction = async (tx, options, index) => {
|
|
737
|
+
var executeSvmTransaction = async (tx, options, index, routeId) => {
|
|
804
738
|
const svmTx = tx?.svmTx;
|
|
805
739
|
if (!svmTx?.chainId) {
|
|
806
740
|
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
807
741
|
}
|
|
808
|
-
const signedTx = await signSvmTransaction({ tx, options, index });
|
|
742
|
+
const signedTx = await signSvmTransaction({ tx, options, index, routeId });
|
|
809
743
|
if (!signedTx) {
|
|
810
744
|
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
811
745
|
}
|
|
@@ -1105,7 +1039,9 @@ var validateGasBalances = async ({
|
|
|
1105
1039
|
disabledChainIds,
|
|
1106
1040
|
enabledChainIds,
|
|
1107
1041
|
useUnlimitedApproval,
|
|
1108
|
-
getCosmosPriorityFeeDenom
|
|
1042
|
+
getCosmosPriorityFeeDenom,
|
|
1043
|
+
routeId,
|
|
1044
|
+
options
|
|
1109
1045
|
}) => {
|
|
1110
1046
|
const validateResult = await Promise.all(
|
|
1111
1047
|
txs.map(async (tx, i) => {
|
|
@@ -1116,6 +1052,11 @@ var validateGasBalances = async ({
|
|
|
1116
1052
|
onValidateGasBalance?.({
|
|
1117
1053
|
status: "pending"
|
|
1118
1054
|
});
|
|
1055
|
+
updateRouteDetails({
|
|
1056
|
+
status: "validating",
|
|
1057
|
+
routeId,
|
|
1058
|
+
options
|
|
1059
|
+
});
|
|
1119
1060
|
if (!tx?.cosmosTx?.msgs) {
|
|
1120
1061
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1121
1062
|
}
|
|
@@ -1144,6 +1085,11 @@ var validateGasBalances = async ({
|
|
|
1144
1085
|
onValidateGasBalance?.({
|
|
1145
1086
|
status: "pending"
|
|
1146
1087
|
});
|
|
1088
|
+
updateRouteDetails({
|
|
1089
|
+
status: "validating",
|
|
1090
|
+
routeId,
|
|
1091
|
+
options
|
|
1092
|
+
});
|
|
1147
1093
|
const signer = await getEvmSigner?.(tx?.evmTx?.chainId ?? "");
|
|
1148
1094
|
if (!signer) {
|
|
1149
1095
|
throw new Error(
|
|
@@ -1171,6 +1117,11 @@ var validateGasBalances = async ({
|
|
|
1171
1117
|
onValidateGasBalance?.({
|
|
1172
1118
|
status: "pending"
|
|
1173
1119
|
});
|
|
1120
|
+
updateRouteDetails({
|
|
1121
|
+
status: "validating",
|
|
1122
|
+
routeId,
|
|
1123
|
+
options
|
|
1124
|
+
});
|
|
1174
1125
|
try {
|
|
1175
1126
|
const res = await validateSvmGasBalance({
|
|
1176
1127
|
tx: tx.svmTx,
|
|
@@ -1205,12 +1156,35 @@ var validateGasBalances = async ({
|
|
|
1205
1156
|
ClientState.validateGasResults = validateResult;
|
|
1206
1157
|
};
|
|
1207
1158
|
|
|
1159
|
+
// src/private-functions/getChainIdsFromTxs.ts
|
|
1160
|
+
var getChainIdsFromTxs = (txs) => {
|
|
1161
|
+
return txs.map((tx) => {
|
|
1162
|
+
if ("cosmosTx" in tx) {
|
|
1163
|
+
return {
|
|
1164
|
+
chainType: "cosmos" /* Cosmos */,
|
|
1165
|
+
chainId: tx.cosmosTx?.chainId
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
if ("svmTx" in tx) {
|
|
1169
|
+
return {
|
|
1170
|
+
chainType: "svm" /* Svm */,
|
|
1171
|
+
chainId: tx.svmTx?.chainId
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
if ("evmTx" in tx) {
|
|
1175
|
+
return {
|
|
1176
|
+
chainType: "evm" /* Evm */,
|
|
1177
|
+
chainId: tx.evmTx?.chainId
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1208
1183
|
// src/private-functions/executeTransactions.ts
|
|
1209
1184
|
var executeTransactions = async (options) => {
|
|
1210
1185
|
const {
|
|
1211
1186
|
txs,
|
|
1212
1187
|
onTransactionBroadcast,
|
|
1213
|
-
onTransactionCompleted,
|
|
1214
1188
|
simulate = true,
|
|
1215
1189
|
batchSimulate = true,
|
|
1216
1190
|
getFallbackGasAmount = getDefaultFallbackGasAmount,
|
|
@@ -1218,35 +1192,33 @@ var executeTransactions = async (options) => {
|
|
|
1218
1192
|
getEvmSigner,
|
|
1219
1193
|
onValidateGasBalance,
|
|
1220
1194
|
trackTxPollingOptions,
|
|
1221
|
-
batchSignTxs = true
|
|
1195
|
+
batchSignTxs = true,
|
|
1196
|
+
routeId
|
|
1222
1197
|
} = options;
|
|
1223
1198
|
if (txs === void 0) {
|
|
1224
1199
|
throw new Error(
|
|
1225
1200
|
"executeTransactions error: txs is undefined in executeTransactions"
|
|
1226
1201
|
);
|
|
1227
1202
|
}
|
|
1228
|
-
const chainIds = txs
|
|
1203
|
+
const chainIds = getChainIdsFromTxs(txs);
|
|
1204
|
+
const transactionDetails = txs.map((tx) => {
|
|
1229
1205
|
if ("cosmosTx" in tx) {
|
|
1230
|
-
return {
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
chainType: "svm",
|
|
1238
|
-
chainId: tx.svmTx?.chainId
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
if ("evmTx" in tx) {
|
|
1242
|
-
return {
|
|
1243
|
-
chainType: "evm",
|
|
1244
|
-
chainId: tx.evmTx?.chainId
|
|
1245
|
-
};
|
|
1206
|
+
return { chainId: tx.cosmosTx?.chainId };
|
|
1207
|
+
} else if ("evmTx" in tx) {
|
|
1208
|
+
return { chainId: tx.evmTx?.chainId };
|
|
1209
|
+
} else if ("svmTx" in tx) {
|
|
1210
|
+
return { chainId: tx.svmTx?.chainId };
|
|
1211
|
+
} else {
|
|
1212
|
+
throw new Error("executeRoute error: invalid message type");
|
|
1246
1213
|
}
|
|
1247
1214
|
});
|
|
1215
|
+
updateRouteDetails({
|
|
1216
|
+
transactionDetails,
|
|
1217
|
+
routeId,
|
|
1218
|
+
options
|
|
1219
|
+
});
|
|
1248
1220
|
const isGasStationSourceEVM = chainIds.find((item, i, array) => {
|
|
1249
|
-
return GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm"
|
|
1221
|
+
return GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm" /* Evm */;
|
|
1250
1222
|
});
|
|
1251
1223
|
ClientState.validateGasResults = void 0;
|
|
1252
1224
|
const validateChainIds = !batchSimulate ? chainIds.map((x) => x?.chainId ?? "") : isGasStationSourceEVM ? GAS_STATION_CHAIN_IDS : [];
|
|
@@ -1258,7 +1230,9 @@ var executeTransactions = async (options) => {
|
|
|
1258
1230
|
onValidateGasBalance,
|
|
1259
1231
|
simulate,
|
|
1260
1232
|
disabledChainIds: validateChainIds,
|
|
1261
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1233
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1234
|
+
options,
|
|
1235
|
+
routeId
|
|
1262
1236
|
});
|
|
1263
1237
|
const validateEnabledChainIds = async (chainId) => {
|
|
1264
1238
|
await validateGasBalances({
|
|
@@ -1269,7 +1243,9 @@ var executeTransactions = async (options) => {
|
|
|
1269
1243
|
onValidateGasBalance,
|
|
1270
1244
|
simulate,
|
|
1271
1245
|
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
|
|
1272
|
-
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom
|
|
1246
|
+
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1247
|
+
options,
|
|
1248
|
+
routeId
|
|
1273
1249
|
});
|
|
1274
1250
|
};
|
|
1275
1251
|
let signedTxs = [];
|
|
@@ -1302,7 +1278,8 @@ var executeTransactions = async (options) => {
|
|
|
1302
1278
|
const signedTx = await signCosmosTransaction({
|
|
1303
1279
|
tx,
|
|
1304
1280
|
options,
|
|
1305
|
-
index: i
|
|
1281
|
+
index: i,
|
|
1282
|
+
routeId
|
|
1306
1283
|
});
|
|
1307
1284
|
signedTxs.push({
|
|
1308
1285
|
index: i,
|
|
@@ -1313,7 +1290,7 @@ var executeTransactions = async (options) => {
|
|
|
1313
1290
|
}
|
|
1314
1291
|
if ("svmTx" in tx) {
|
|
1315
1292
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1316
|
-
const signedTx = await signSvmTransaction({ tx, options, index: i });
|
|
1293
|
+
const signedTx = await signSvmTransaction({ tx, options, index: i, routeId });
|
|
1317
1294
|
if (!signedTx) {
|
|
1318
1295
|
throw new Error(`executeRoute error: signedTx is undefined`);
|
|
1319
1296
|
}
|
|
@@ -1326,13 +1303,13 @@ var executeTransactions = async (options) => {
|
|
|
1326
1303
|
}
|
|
1327
1304
|
}
|
|
1328
1305
|
}
|
|
1329
|
-
|
|
1330
|
-
const tx = txs[
|
|
1306
|
+
const executeTransaction = async (index) => {
|
|
1307
|
+
const tx = txs[index];
|
|
1331
1308
|
if (!tx) {
|
|
1332
|
-
throw new Error(`executeRoute error: invalid message at index ${
|
|
1309
|
+
throw new Error(`executeRoute error: invalid message at index ${index}`);
|
|
1333
1310
|
}
|
|
1334
1311
|
let txResult;
|
|
1335
|
-
const txSigned = signedTxs.find((item) => item.index ===
|
|
1312
|
+
const txSigned = signedTxs.find((item) => item.index === index);
|
|
1336
1313
|
if (txSigned) {
|
|
1337
1314
|
const txResponse = await submitTransaction({
|
|
1338
1315
|
chainId: txSigned.chainId,
|
|
@@ -1349,34 +1326,32 @@ var executeTransactions = async (options) => {
|
|
|
1349
1326
|
txResult = await executeCosmosTransaction({
|
|
1350
1327
|
tx,
|
|
1351
1328
|
options,
|
|
1352
|
-
index
|
|
1329
|
+
index,
|
|
1330
|
+
routeId
|
|
1353
1331
|
});
|
|
1354
1332
|
} else if ("evmTx" in tx) {
|
|
1355
1333
|
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1356
|
-
const txResponse = await executeEvmTransaction(tx, options,
|
|
1334
|
+
const txResponse = await executeEvmTransaction(tx, options, index, routeId);
|
|
1357
1335
|
txResult = {
|
|
1358
1336
|
chainId: tx?.evmTx?.chainId ?? "",
|
|
1359
1337
|
txHash: txResponse.transactionHash
|
|
1360
1338
|
};
|
|
1361
1339
|
} else if ("svmTx" in tx) {
|
|
1362
1340
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1363
|
-
txResult = await executeSvmTransaction(tx, options,
|
|
1341
|
+
txResult = await executeSvmTransaction(tx, options, index, routeId);
|
|
1364
1342
|
} else {
|
|
1365
1343
|
throw new Error("executeRoute error: invalid message type");
|
|
1366
1344
|
}
|
|
1367
1345
|
}
|
|
1368
1346
|
await onTransactionBroadcast?.({ ...txResult });
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
status: txStatusResponse
|
|
1378
|
-
});
|
|
1379
|
-
}
|
|
1347
|
+
return txResult;
|
|
1348
|
+
};
|
|
1349
|
+
await executeAndSubscribeToRouteStatus({
|
|
1350
|
+
transactionDetails,
|
|
1351
|
+
executeTransaction,
|
|
1352
|
+
routeId,
|
|
1353
|
+
options
|
|
1354
|
+
});
|
|
1380
1355
|
};
|
|
1381
1356
|
var EVM_GAS_AMOUNT = 15e4;
|
|
1382
1357
|
var COSMOS_GAS_AMOUNT = {
|
|
@@ -1403,6 +1378,10 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1403
1378
|
};
|
|
1404
1379
|
var executeRoute = async (options) => {
|
|
1405
1380
|
const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
|
|
1381
|
+
const { id: routeId } = updateRouteDetails({
|
|
1382
|
+
status: "unconfirmed",
|
|
1383
|
+
options
|
|
1384
|
+
});
|
|
1406
1385
|
let addressList = [];
|
|
1407
1386
|
userAddresses.forEach((userAddress, index) => {
|
|
1408
1387
|
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
@@ -1448,7 +1427,7 @@ var executeRoute = async (options) => {
|
|
|
1448
1427
|
lastTx.cosmosTx?.msgs?.push(afterMsg);
|
|
1449
1428
|
}
|
|
1450
1429
|
}
|
|
1451
|
-
await executeTransactions({ ...options, txs: response?.txs });
|
|
1430
|
+
await executeTransactions({ ...options, routeId, txs: response?.txs });
|
|
1452
1431
|
};
|
|
1453
1432
|
var validateUserAddresses = async (userAddresses) => {
|
|
1454
1433
|
const chains2 = await ClientState.getSkipChains();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getCosmosGasAmountForMessage } from './chunk-
|
|
1
|
+
import { getCosmosGasAmountForMessage } from './chunk-KNXMSLOB.js';
|
|
2
2
|
import { BigNumber } from './chunk-VQ5SIQWU.js';
|
|
3
|
-
import { getSigningStargateClient } from './chunk-
|
|
4
|
-
import { ClientState, balances } from './chunk-
|
|
3
|
+
import { getSigningStargateClient } from './chunk-KYDY7QRT.js';
|
|
4
|
+
import { ClientState, balances } from './chunk-ZOUYAZU6.js';
|
|
5
5
|
import { GasPrice, calculateFee } from '@cosmjs/stargate';
|
|
6
6
|
import { Decimal } from '@cosmjs/math';
|
|
7
7
|
|