@skip-go/client 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{chunk-IDEJORRT.cjs → chunk-23YF4LFI.cjs} +30 -0
- package/dist/cjs/{chunk-Q43XCBMX.cjs → chunk-5CB6SPCX.cjs} +4 -4
- package/dist/cjs/{chunk-ZKBSNSHQ.cjs → chunk-EZGHN6ZL.cjs} +120 -116
- package/dist/cjs/{chunk-7MC3BVQN.cjs → chunk-KHJQE3DI.cjs} +133 -35
- package/dist/cjs/chunk-KSJ5QYMR.cjs +185 -0
- package/dist/cjs/chunk-N5V3YW5K.cjs +55 -0
- package/dist/cjs/chunk-NDSHB4I6.cjs +214 -0
- package/dist/cjs/{chunk-ZAATXQBG.cjs → chunk-QZ2BGX6O.cjs} +2 -2
- package/dist/cjs/{chunk-6LA66667.cjs → chunk-RVXCF6AL.cjs} +3 -3
- package/dist/cjs/{chunk-46VB6RQK.cjs → chunk-V3FWWJG2.cjs} +10 -3
- package/dist/cjs/index.cjs +26 -20
- package/dist/cjs/public-functions/executeMultipleRoutes.cjs +29 -0
- package/dist/cjs/public-functions/executeRoute.cjs +8 -7
- package/dist/cjs/public-functions/getFeeInfoForChain.cjs +3 -3
- package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +4 -4
- package/dist/cjs/public-functions/getSigningStargateClient.cjs +3 -3
- package/dist/cjs/public-functions/setClientOptions.cjs +2 -2
- package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +5 -5
- package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +5 -5
- package/dist/esm/api/getAssets.d.ts +1 -1
- package/dist/esm/api/getAssetsBetweenChains.d.ts +1 -1
- package/dist/esm/api/getBridges.d.ts +3 -3
- package/dist/esm/api/getChains.d.ts +1 -1
- package/dist/esm/api/postAssetsFromSource.d.ts +10 -1
- package/dist/esm/api/postBalances.d.ts +2 -2
- package/dist/esm/api/postMessages.d.ts +2 -2
- package/dist/esm/api/postMessagesDirect.d.ts +3 -1
- package/dist/esm/api/postRecommendAssets.d.ts +1 -1
- package/dist/esm/api/postRoute.d.ts +4 -2
- package/dist/esm/api/postSubmitTransaction.d.ts +2 -2
- package/dist/esm/api/postTrackTransaction.d.ts +2 -2
- package/dist/esm/api/postTransactionStatus.d.ts +2 -2
- package/dist/esm/{callbacks-B3kjKg0v.d.ts → callbacks-DCqqd0D9.d.ts} +22 -69
- package/dist/esm/{chunk-CIAOTO3M.js → chunk-2DD5F6PK.js} +1 -1
- package/dist/esm/{chunk-4RLJWCQR.js → chunk-3J5IMMMB.js} +1 -1
- package/dist/esm/chunk-562J5DCB.js +53 -0
- package/dist/esm/{chunk-KYDY7QRT.js → chunk-BZDVQMHK.js} +1 -1
- package/dist/esm/chunk-FVQFGEL2.js +212 -0
- package/dist/esm/chunk-RHGDUD76.js +180 -0
- package/dist/esm/{chunk-GHNH5QC3.js → chunk-VZGOU6MB.js} +9 -2
- package/dist/esm/{chunk-BAJFQZDT.js → chunk-W5EGS2G4.js} +99 -96
- package/dist/esm/{chunk-REWUSU53.js → chunk-WBZVMPPV.js} +30 -0
- package/dist/esm/{chunk-RQ7DXNSS.js → chunk-XYYXRVFN.js} +133 -35
- package/dist/esm/client-types-BSZasIDd.d.ts +114 -0
- package/dist/esm/{generateApi-C_xgtxrO.d.ts → generateApi-CwM4Ca30.d.ts} +1 -1
- package/dist/esm/index.d.ts +216 -6
- package/dist/esm/index.js +12 -10
- 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 +5 -5
- package/dist/esm/public-functions/executeRoute.js +7 -6
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.d.ts +1 -1
- package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +5 -2
- package/dist/esm/public-functions/getFeeInfoForChain.d.ts +1 -1
- package/dist/esm/public-functions/getFeeInfoForChain.js +2 -2
- package/dist/esm/public-functions/getRecommendedGasPrice.js +3 -3
- package/dist/esm/public-functions/getSigningStargateClient.js +2 -2
- package/dist/esm/public-functions/setApiOptions.d.ts +1 -1
- package/dist/esm/public-functions/setClientOptions.d.ts +5 -3
- package/dist/esm/public-functions/setClientOptions.js +1 -1
- package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +5 -5
- package/dist/esm/public-functions/subscribeToRouteStatus.js +1 -1
- package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +7 -6
- package/dist/esm/public-functions/validateCosmosGasBalance.js +4 -4
- package/dist/esm/public-functions/waitForTransaction.d.ts +5 -5
- package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-0DYCj_A5.d.ts} +1 -1
- package/dist/esm/{swaggerTypes-DDwqIjap.d.ts → swaggerTypes-Bh6hu5Q-.d.ts} +220 -196
- package/package.json +1 -1
- package/dist/cjs/chunk-VIG2BHYJ.cjs +0 -185
- package/dist/esm/chunk-3J6O2PVK.js +0 -180
- package/dist/esm/client-types-B7Fin0mq.d.ts +0 -61
|
@@ -2206,6 +2206,34 @@ var evmosAminoConverters = {
|
|
|
2206
2206
|
...AminoConverter5
|
|
2207
2207
|
};
|
|
2208
2208
|
var evmosProtoRegistry = [...registry2, ...registry3, ...registry4, ...registry5];
|
|
2209
|
+
|
|
2210
|
+
// src/codegen/initia/move/v1/tx.amino.ts
|
|
2211
|
+
var AminoConverter6 = {
|
|
2212
|
+
"/initia.move.v1.MsgExecute": {
|
|
2213
|
+
aminoType: "/initia.move.v1.MsgExecute",
|
|
2214
|
+
toAmino: chunkDWOE6N5S_cjs.MsgExecute.toAmino,
|
|
2215
|
+
fromAmino: chunkDWOE6N5S_cjs.MsgExecute.fromAmino
|
|
2216
|
+
}
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
// src/codegen/initia/client.ts
|
|
2220
|
+
var initiaAminoConverters = {
|
|
2221
|
+
...AminoConverter6
|
|
2222
|
+
};
|
|
2223
|
+
|
|
2224
|
+
// src/codegen/opinit/ophost/v1/tx.amino.ts
|
|
2225
|
+
var AminoConverter7 = {
|
|
2226
|
+
"/opinit.ophost.v1.MsgInitiateTokenDeposit": {
|
|
2227
|
+
aminoType: "ophost/MsgInitiateTokenDeposit",
|
|
2228
|
+
toAmino: chunkDWOE6N5S_cjs.MsgInitiateTokenDeposit.toAmino,
|
|
2229
|
+
fromAmino: chunkDWOE6N5S_cjs.MsgInitiateTokenDeposit.fromAmino
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2233
|
+
// src/codegen/opinit/client.ts
|
|
2234
|
+
var opinitAminoConverters = {
|
|
2235
|
+
...AminoConverter7
|
|
2236
|
+
};
|
|
2209
2237
|
var setClientOptions = (options = {}) => {
|
|
2210
2238
|
chunkERGJBZUC_cjs.ApiState.client = chunkERGJBZUC_cjs.createRequestClient({
|
|
2211
2239
|
apiUrl: options.apiUrl || "https://api.skip.build",
|
|
@@ -2218,6 +2246,8 @@ var setClientOptions = (options = {}) => {
|
|
|
2218
2246
|
...cosmwasmStargate.createWasmAminoConverters(),
|
|
2219
2247
|
...circleAminoConverters,
|
|
2220
2248
|
...evmosAminoConverters,
|
|
2249
|
+
...initiaAminoConverters,
|
|
2250
|
+
...opinitAminoConverters,
|
|
2221
2251
|
...options.aminoTypes ?? {}
|
|
2222
2252
|
});
|
|
2223
2253
|
chunkN4UW74AG_cjs.ClientState.registry = new protoSigning.Registry([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkKSJ5QYMR_cjs = require('./chunk-KSJ5QYMR.cjs');
|
|
5
5
|
var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
|
|
6
6
|
|
|
7
7
|
// src/private-functions/getDefaultGasTokenForChain.ts
|
|
@@ -10,7 +10,7 @@ var getDefaultGasTokenForChain = async (chainId) => {
|
|
|
10
10
|
if (gasDenom) {
|
|
11
11
|
return gasDenom;
|
|
12
12
|
}
|
|
13
|
-
const chain =
|
|
13
|
+
const chain = chunkKSJ5QYMR_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
14
14
|
if (!chain) {
|
|
15
15
|
return void 0;
|
|
16
16
|
}
|
|
@@ -39,7 +39,7 @@ var getDefaultGasTokenForChain = async (chainId) => {
|
|
|
39
39
|
return chain.fees.feeTokens[0]?.denom;
|
|
40
40
|
};
|
|
41
41
|
var getStakingTokensForChain = (chainId) => {
|
|
42
|
-
const chain =
|
|
42
|
+
const chain = chunkKSJ5QYMR_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
43
43
|
if (!chain) {
|
|
44
44
|
throw new Error(
|
|
45
45
|
`getStakingTokensForChain error: failed to find chain id '${chainId}' in registry`
|
|
@@ -69,7 +69,7 @@ var getFeeInfoForChain = async ({ chainId, apiUrl, apiKey }) => {
|
|
|
69
69
|
if (skipFeeInfo && skipFeeInfo.gasPrice !== null) {
|
|
70
70
|
return skipFeeInfo;
|
|
71
71
|
}
|
|
72
|
-
const chain =
|
|
72
|
+
const chain = chunkKSJ5QYMR_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
73
73
|
if (!chain) {
|
|
74
74
|
return void 0;
|
|
75
75
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkKHJQE3DI_cjs = require('./chunk-KHJQE3DI.cjs');
|
|
4
|
+
var chunkV3FWWJG2_cjs = require('./chunk-V3FWWJG2.cjs');
|
|
5
5
|
var chunkKM2D7PJL_cjs = require('./chunk-KM2D7PJL.cjs');
|
|
6
6
|
var chunkF3EB2AQG_cjs = require('./chunk-F3EB2AQG.cjs');
|
|
7
7
|
var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
|
|
8
8
|
var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var chunkOZUCMWNE_cjs = require('./chunk-OZUCMWNE.cjs');
|
|
9
|
+
var chunkRVXCF6AL_cjs = require('./chunk-RVXCF6AL.cjs');
|
|
10
|
+
var chunkKSJ5QYMR_cjs = require('./chunk-KSJ5QYMR.cjs');
|
|
12
11
|
var chunk5HDKZVOL_cjs = require('./chunk-5HDKZVOL.cjs');
|
|
13
12
|
var chunk5AYPH3ZR_cjs = require('./chunk-5AYPH3ZR.cjs');
|
|
14
13
|
var chunkN4UW74AG_cjs = require('./chunk-N4UW74AG.cjs');
|
|
15
14
|
var chunkERGJBZUC_cjs = require('./chunk-ERGJBZUC.cjs');
|
|
16
|
-
var web3_js = require('@solana/web3.js');
|
|
17
|
-
var bech32 = require('bech32');
|
|
18
15
|
var stargate = require('@cosmjs/stargate');
|
|
19
16
|
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
20
17
|
var protoSigning = require('@cosmjs/proto-signing');
|
|
@@ -25,6 +22,8 @@ var any_js = require('cosmjs-types/google/protobuf/any.js');
|
|
|
25
22
|
var math = require('@cosmjs/math');
|
|
26
23
|
var signing_js = require('cosmjs-types/cosmos/tx/signing/v1beta1/signing.js');
|
|
27
24
|
var viem = require('viem');
|
|
25
|
+
var web3_js = require('@solana/web3.js');
|
|
26
|
+
var bech32 = require('bech32');
|
|
28
27
|
|
|
29
28
|
// src/private-functions/getRestEndpointForChain.ts
|
|
30
29
|
var getRestEndpointForChain = async (chainId) => {
|
|
@@ -37,7 +36,7 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
37
36
|
return endpointOptions.rest;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
const chain =
|
|
39
|
+
const chain = chunkKSJ5QYMR_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 chunkKSJ5QYMR_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
|
|
65
|
+
const endpoint = await chunkRVXCF6AL_cjs.getRpcEndpointForChain(chainId);
|
|
67
66
|
const client = chunkN4UW74AG_cjs.ClientState.signingStargateClientByChainId[chainId] ?? await stargate.StargateClient.connect(endpoint, {
|
|
68
|
-
accountParser:
|
|
67
|
+
accountParser: chunkRVXCF6AL_cjs.accountParser
|
|
69
68
|
});
|
|
70
69
|
const account = await client.getAccount(address);
|
|
71
70
|
if (!account) {
|
|
@@ -126,7 +125,7 @@ function encodeEthSecp256k1Pubkey(pubkey) {
|
|
|
126
125
|
|
|
127
126
|
// src/proto-signing/pubkey.ts
|
|
128
127
|
function makePubkeyAnyFromAccount(account, chainId) {
|
|
129
|
-
const isEthermint =
|
|
128
|
+
const isEthermint = chunkKSJ5QYMR_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 = chunkKSJ5QYMR_cjs.getIsInitia(chainId);
|
|
151
150
|
const pubkeyProto = keys_js.PubKey.fromPartial({
|
|
152
151
|
key: encoding.fromBase64(pubkey.value)
|
|
153
152
|
});
|
|
@@ -174,11 +173,11 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
174
173
|
if (!accountFromSigner) {
|
|
175
174
|
throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
|
|
176
175
|
}
|
|
177
|
-
const
|
|
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
183
|
const txBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(txBodyEncodeObject);
|
|
@@ -209,26 +208,40 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
209
208
|
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
210
209
|
} = options;
|
|
211
210
|
const accounts = await signer.getAccounts();
|
|
212
|
-
const accountFromSigner = accounts.find(
|
|
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
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 = chunkN4UW74AG_cjs.ClientState.registry.encode(
|
|
242
|
+
const signedTxBodyBytes = chunkN4UW74AG_cjs.ClientState.registry.encode(
|
|
243
|
+
signedTxBodyEncodeObject
|
|
244
|
+
);
|
|
232
245
|
const signedGasLimit = math.Int53.fromString(signed.fee.gas).toNumber();
|
|
233
246
|
const signedSequence = math.Int53.fromString(signed.sequence).toNumber();
|
|
234
247
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
@@ -259,7 +272,7 @@ var signCosmosTransaction = async ({
|
|
|
259
272
|
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
260
273
|
}
|
|
261
274
|
const chainId = tx.cosmosTx?.chainId;
|
|
262
|
-
const
|
|
275
|
+
const messages = tx.cosmosTx?.msgs;
|
|
263
276
|
const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
264
277
|
const gasArray = chunkN4UW74AG_cjs.ClientState.validateGasResults;
|
|
265
278
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
@@ -273,10 +286,10 @@ var signCosmosTransaction = async ({
|
|
|
273
286
|
if (chainId === void 0) {
|
|
274
287
|
throw new Error("no chainId found for tx");
|
|
275
288
|
}
|
|
276
|
-
if (
|
|
289
|
+
if (messages === void 0) {
|
|
277
290
|
throw new Error("no messages found for tx");
|
|
278
291
|
}
|
|
279
|
-
const { signer } = await
|
|
292
|
+
const { signer } = await chunkRVXCF6AL_cjs.getSigningStargateClient({
|
|
280
293
|
chainId,
|
|
281
294
|
getOfflineSigner: options?.getCosmosSigner
|
|
282
295
|
});
|
|
@@ -302,7 +315,7 @@ var signCosmosTransaction = async ({
|
|
|
302
315
|
const commonRawTxBody = {
|
|
303
316
|
signerAddress: currentUserAddress,
|
|
304
317
|
chainId,
|
|
305
|
-
cosmosMsgs:
|
|
318
|
+
cosmosMsgs: messages,
|
|
306
319
|
fee,
|
|
307
320
|
signerData: {
|
|
308
321
|
accountNumber,
|
|
@@ -315,7 +328,7 @@ var signCosmosTransaction = async ({
|
|
|
315
328
|
txIndex: index,
|
|
316
329
|
signerAddress: currentUserAddress
|
|
317
330
|
});
|
|
318
|
-
|
|
331
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
319
332
|
status: "signing",
|
|
320
333
|
routeId,
|
|
321
334
|
options
|
|
@@ -331,7 +344,7 @@ var signCosmosTransaction = async ({
|
|
|
331
344
|
options?.onTransactionSigned?.({
|
|
332
345
|
chainId
|
|
333
346
|
});
|
|
334
|
-
|
|
347
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
335
348
|
status: "pending",
|
|
336
349
|
routeId,
|
|
337
350
|
options
|
|
@@ -617,7 +630,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
|
617
630
|
status: "pending",
|
|
618
631
|
allowance: requiredApproval
|
|
619
632
|
});
|
|
620
|
-
|
|
633
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
621
634
|
status: "allowance",
|
|
622
635
|
routeId,
|
|
623
636
|
options
|
|
@@ -651,7 +664,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
|
651
664
|
signerAddress: evmSigner.account.address,
|
|
652
665
|
txIndex: index
|
|
653
666
|
});
|
|
654
|
-
|
|
667
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
655
668
|
status: "signing",
|
|
656
669
|
routeId,
|
|
657
670
|
options
|
|
@@ -663,7 +676,7 @@ var executeEvmTransaction = async (message, options, index, routeId) => {
|
|
|
663
676
|
chain: evmSigner.chain,
|
|
664
677
|
value: evmTx.value === "" ? void 0 : BigInt(evmTx.value)
|
|
665
678
|
});
|
|
666
|
-
|
|
679
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
667
680
|
status: "pending",
|
|
668
681
|
routeId,
|
|
669
682
|
options
|
|
@@ -719,14 +732,14 @@ var signSvmTransaction = async ({
|
|
|
719
732
|
signerAddress: signer.publicKey?.toBase58(),
|
|
720
733
|
txIndex: index
|
|
721
734
|
});
|
|
722
|
-
|
|
735
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
723
736
|
status: "signing",
|
|
724
737
|
routeId,
|
|
725
738
|
options
|
|
726
739
|
});
|
|
727
740
|
const signedTx = await signer.signTransaction(transaction);
|
|
728
741
|
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
729
|
-
|
|
742
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
730
743
|
status: "pending",
|
|
731
744
|
routeId,
|
|
732
745
|
options
|
|
@@ -745,7 +758,7 @@ var executeSvmTransaction = async (tx, options, index, routeId) => {
|
|
|
745
758
|
if (!signedTx) {
|
|
746
759
|
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
747
760
|
}
|
|
748
|
-
const endpoint = await
|
|
761
|
+
const endpoint = await chunkRVXCF6AL_cjs.getRpcEndpointForChain(svmTx.chainId);
|
|
749
762
|
const connection = new web3_js.Connection(endpoint);
|
|
750
763
|
let signature;
|
|
751
764
|
const submitTxResponse = await chunk5HDKZVOL_cjs.submitTransaction({
|
|
@@ -878,7 +891,8 @@ var validateEvmGasBalance = async ({
|
|
|
878
891
|
signer,
|
|
879
892
|
tx,
|
|
880
893
|
getFallbackGasAmount,
|
|
881
|
-
useUnlimitedApproval
|
|
894
|
+
useUnlimitedApproval,
|
|
895
|
+
bypassApprovalCheck
|
|
882
896
|
}) => {
|
|
883
897
|
const chainId = tx?.chainId ?? "";
|
|
884
898
|
const skipAssets = (await chunkN4UW74AG_cjs.ClientState.getSkipAssets({ chainId }))?.[chainId];
|
|
@@ -903,7 +917,7 @@ var validateEvmGasBalance = async ({
|
|
|
903
917
|
)?.[1];
|
|
904
918
|
const gasBalance = nativeGasBalance || zeroAddressGasBalance;
|
|
905
919
|
const { requiredErc20Approvals } = tx;
|
|
906
|
-
if (requiredErc20Approvals) {
|
|
920
|
+
if (!bypassApprovalCheck && requiredErc20Approvals) {
|
|
907
921
|
try {
|
|
908
922
|
await validateEvmTokenApproval({
|
|
909
923
|
requiredErc20Approvals,
|
|
@@ -976,7 +990,7 @@ var validateSvmGasBalance = async ({
|
|
|
976
990
|
fee: null
|
|
977
991
|
};
|
|
978
992
|
}
|
|
979
|
-
const endpoint = await
|
|
993
|
+
const endpoint = await chunkRVXCF6AL_cjs.getRpcEndpointForChain(tx.chainId ?? "");
|
|
980
994
|
const connection = new web3_js.Connection(endpoint);
|
|
981
995
|
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
982
996
|
if (!tx.tx) {
|
|
@@ -1040,10 +1054,10 @@ var validateGasBalances = async ({
|
|
|
1040
1054
|
simulate,
|
|
1041
1055
|
disabledChainIds,
|
|
1042
1056
|
enabledChainIds,
|
|
1043
|
-
useUnlimitedApproval,
|
|
1044
1057
|
getCosmosPriorityFeeDenom,
|
|
1045
1058
|
routeId,
|
|
1046
|
-
options
|
|
1059
|
+
options,
|
|
1060
|
+
isMultiRoutes
|
|
1047
1061
|
}) => {
|
|
1048
1062
|
const validateResult = await Promise.all(
|
|
1049
1063
|
txs.map(async (tx, i) => {
|
|
@@ -1054,7 +1068,7 @@ var validateGasBalances = async ({
|
|
|
1054
1068
|
onValidateGasBalance?.({
|
|
1055
1069
|
status: "pending"
|
|
1056
1070
|
});
|
|
1057
|
-
|
|
1071
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
1058
1072
|
status: "validating",
|
|
1059
1073
|
routeId,
|
|
1060
1074
|
options
|
|
@@ -1063,7 +1077,7 @@ var validateGasBalances = async ({
|
|
|
1063
1077
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1064
1078
|
}
|
|
1065
1079
|
try {
|
|
1066
|
-
const res = await
|
|
1080
|
+
const res = await chunkV3FWWJG2_cjs.validateCosmosGasBalance({
|
|
1067
1081
|
chainId: tx.cosmosTx.chainId ?? "",
|
|
1068
1082
|
signerAddress: tx.cosmosTx.signerAddress ?? "",
|
|
1069
1083
|
messages: tx.cosmosTx.msgs,
|
|
@@ -1071,7 +1085,8 @@ var validateGasBalances = async ({
|
|
|
1071
1085
|
getOfflineSigner: getCosmosSigner,
|
|
1072
1086
|
txIndex: i,
|
|
1073
1087
|
simulate,
|
|
1074
|
-
getCosmosPriorityFeeDenom
|
|
1088
|
+
getCosmosPriorityFeeDenom,
|
|
1089
|
+
isMultiRoutes
|
|
1075
1090
|
});
|
|
1076
1091
|
return res;
|
|
1077
1092
|
} catch (e) {
|
|
@@ -1087,7 +1102,7 @@ var validateGasBalances = async ({
|
|
|
1087
1102
|
onValidateGasBalance?.({
|
|
1088
1103
|
status: "pending"
|
|
1089
1104
|
});
|
|
1090
|
-
|
|
1105
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
1091
1106
|
status: "validating",
|
|
1092
1107
|
routeId,
|
|
1093
1108
|
options
|
|
@@ -1103,7 +1118,8 @@ var validateGasBalances = async ({
|
|
|
1103
1118
|
tx: tx.evmTx,
|
|
1104
1119
|
signer,
|
|
1105
1120
|
getFallbackGasAmount,
|
|
1106
|
-
useUnlimitedApproval
|
|
1121
|
+
useUnlimitedApproval: options?.useUnlimitedApproval,
|
|
1122
|
+
bypassApprovalCheck: options?.bypassApprovalCheck
|
|
1107
1123
|
});
|
|
1108
1124
|
return res;
|
|
1109
1125
|
} catch (e) {
|
|
@@ -1119,7 +1135,7 @@ var validateGasBalances = async ({
|
|
|
1119
1135
|
onValidateGasBalance?.({
|
|
1120
1136
|
status: "pending"
|
|
1121
1137
|
});
|
|
1122
|
-
|
|
1138
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
1123
1139
|
status: "validating",
|
|
1124
1140
|
routeId,
|
|
1125
1141
|
options
|
|
@@ -1195,7 +1211,8 @@ var executeTransactions = async (options) => {
|
|
|
1195
1211
|
onValidateGasBalance,
|
|
1196
1212
|
trackTxPollingOptions,
|
|
1197
1213
|
batchSignTxs = true,
|
|
1198
|
-
routeId
|
|
1214
|
+
routeId,
|
|
1215
|
+
isMultiRoutes
|
|
1199
1216
|
} = options;
|
|
1200
1217
|
if (txs === void 0) {
|
|
1201
1218
|
throw new Error(
|
|
@@ -1205,16 +1222,16 @@ var executeTransactions = async (options) => {
|
|
|
1205
1222
|
const chainIds = getChainIdsFromTxs(txs);
|
|
1206
1223
|
const transactionDetails = txs.map((tx) => {
|
|
1207
1224
|
if ("cosmosTx" in tx) {
|
|
1208
|
-
return { chainId: tx.cosmosTx?.chainId };
|
|
1225
|
+
return { chainId: tx.cosmosTx?.chainId, chainType: "cosmos" /* Cosmos */ };
|
|
1209
1226
|
} else if ("evmTx" in tx) {
|
|
1210
|
-
return { chainId: tx.evmTx?.chainId };
|
|
1227
|
+
return { chainId: tx.evmTx?.chainId, chainType: "evm" /* Evm */ };
|
|
1211
1228
|
} else if ("svmTx" in tx) {
|
|
1212
|
-
return { chainId: tx.svmTx?.chainId };
|
|
1229
|
+
return { chainId: tx.svmTx?.chainId, chainType: "svm" /* Svm */ };
|
|
1213
1230
|
} else {
|
|
1214
1231
|
throw new Error("executeRoute error: invalid message type");
|
|
1215
1232
|
}
|
|
1216
1233
|
});
|
|
1217
|
-
|
|
1234
|
+
chunkKHJQE3DI_cjs.updateRouteDetails({
|
|
1218
1235
|
transactionDetails,
|
|
1219
1236
|
routeId,
|
|
1220
1237
|
options
|
|
@@ -1234,7 +1251,8 @@ var executeTransactions = async (options) => {
|
|
|
1234
1251
|
disabledChainIds: validateChainIds,
|
|
1235
1252
|
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1236
1253
|
options,
|
|
1237
|
-
routeId
|
|
1254
|
+
routeId,
|
|
1255
|
+
isMultiRoutes
|
|
1238
1256
|
});
|
|
1239
1257
|
const validateEnabledChainIds = async (chainId) => {
|
|
1240
1258
|
await validateGasBalances({
|
|
@@ -1247,7 +1265,8 @@ var executeTransactions = async (options) => {
|
|
|
1247
1265
|
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds,
|
|
1248
1266
|
getCosmosPriorityFeeDenom: options.getCosmosPriorityFeeDenom,
|
|
1249
1267
|
options,
|
|
1250
|
-
routeId
|
|
1268
|
+
routeId,
|
|
1269
|
+
isMultiRoutes
|
|
1251
1270
|
});
|
|
1252
1271
|
};
|
|
1253
1272
|
let signedTxs = [];
|
|
@@ -1261,11 +1280,16 @@ var executeTransactions = async (options) => {
|
|
|
1261
1280
|
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1262
1281
|
const isAllowedToBatchSignTxsUpfront = await (async () => {
|
|
1263
1282
|
try {
|
|
1264
|
-
const currentUserAddress = options.userAddresses.find(
|
|
1283
|
+
const currentUserAddress = options.userAddresses.find(
|
|
1284
|
+
(x) => x.chainId === tx.cosmosTx?.chainId
|
|
1285
|
+
)?.address;
|
|
1265
1286
|
if (!currentUserAddress) {
|
|
1266
1287
|
return false;
|
|
1267
1288
|
}
|
|
1268
|
-
const { accountNumber } = await getAccountNumberAndSequence(
|
|
1289
|
+
const { accountNumber } = await getAccountNumberAndSequence(
|
|
1290
|
+
currentUserAddress,
|
|
1291
|
+
tx.cosmosTx?.chainId
|
|
1292
|
+
);
|
|
1269
1293
|
if (accountNumber) {
|
|
1270
1294
|
return true;
|
|
1271
1295
|
}
|
|
@@ -1292,7 +1316,12 @@ var executeTransactions = async (options) => {
|
|
|
1292
1316
|
}
|
|
1293
1317
|
if ("svmTx" in tx) {
|
|
1294
1318
|
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1295
|
-
const signedTx = await signSvmTransaction({
|
|
1319
|
+
const signedTx = await signSvmTransaction({
|
|
1320
|
+
tx,
|
|
1321
|
+
options,
|
|
1322
|
+
index: i,
|
|
1323
|
+
routeId
|
|
1324
|
+
});
|
|
1296
1325
|
if (!signedTx) {
|
|
1297
1326
|
throw new Error(`executeRoute error: signedTx is undefined`);
|
|
1298
1327
|
}
|
|
@@ -1333,7 +1362,12 @@ var executeTransactions = async (options) => {
|
|
|
1333
1362
|
});
|
|
1334
1363
|
} else if ("evmTx" in tx) {
|
|
1335
1364
|
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1336
|
-
const txResponse = await executeEvmTransaction(
|
|
1365
|
+
const txResponse = await executeEvmTransaction(
|
|
1366
|
+
tx,
|
|
1367
|
+
options,
|
|
1368
|
+
index,
|
|
1369
|
+
routeId
|
|
1370
|
+
);
|
|
1337
1371
|
txResult = {
|
|
1338
1372
|
chainId: tx?.evmTx?.chainId ?? "",
|
|
1339
1373
|
txHash: txResponse.transactionHash
|
|
@@ -1348,12 +1382,10 @@ var executeTransactions = async (options) => {
|
|
|
1348
1382
|
await onTransactionBroadcast?.({ ...txResult });
|
|
1349
1383
|
return txResult;
|
|
1350
1384
|
};
|
|
1351
|
-
|
|
1385
|
+
return {
|
|
1352
1386
|
transactionDetails,
|
|
1353
|
-
executeTransaction
|
|
1354
|
-
|
|
1355
|
-
options
|
|
1356
|
-
});
|
|
1387
|
+
executeTransaction
|
|
1388
|
+
};
|
|
1357
1389
|
};
|
|
1358
1390
|
var EVM_GAS_AMOUNT = 15e4;
|
|
1359
1391
|
var COSMOS_GAS_AMOUNT = {
|
|
@@ -1378,59 +1410,6 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1378
1410
|
}
|
|
1379
1411
|
return defaultGasAmount;
|
|
1380
1412
|
};
|
|
1381
|
-
var executeRoute = async (options) => {
|
|
1382
|
-
const { route, userAddresses, beforeMsg, afterMsg, timeoutSeconds } = options;
|
|
1383
|
-
const { id: routeId } = chunk7MC3BVQN_cjs.updateRouteDetails({
|
|
1384
|
-
status: "unconfirmed",
|
|
1385
|
-
options
|
|
1386
|
-
});
|
|
1387
|
-
let addressList = [];
|
|
1388
|
-
userAddresses.forEach((userAddress, index) => {
|
|
1389
|
-
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
1390
|
-
if (requiredChainAddress === userAddress?.chainId) {
|
|
1391
|
-
addressList.push(userAddress.address);
|
|
1392
|
-
}
|
|
1393
|
-
});
|
|
1394
|
-
if (addressList.length !== route.requiredChainAddresses.length) {
|
|
1395
|
-
addressList = userAddresses.map((x) => x.address);
|
|
1396
|
-
}
|
|
1397
|
-
const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
|
|
1398
|
-
if (!validLength) {
|
|
1399
|
-
throw new Error("executeRoute error: invalid address list");
|
|
1400
|
-
}
|
|
1401
|
-
const isUserAddressesValid = await validateUserAddresses(userAddresses);
|
|
1402
|
-
if (!isUserAddressesValid) {
|
|
1403
|
-
throw new Error("executeRoute error: invalid user addresses");
|
|
1404
|
-
}
|
|
1405
|
-
const response = await chunkOZUCMWNE_cjs.messages({
|
|
1406
|
-
timeoutSeconds,
|
|
1407
|
-
amountIn: route?.amountIn,
|
|
1408
|
-
amountOut: route.estimatedAmountOut || "0",
|
|
1409
|
-
sourceAssetChainId: route?.sourceAssetChainId,
|
|
1410
|
-
sourceAssetDenom: route?.sourceAssetDenom,
|
|
1411
|
-
destAssetChainId: route?.destAssetChainId,
|
|
1412
|
-
destAssetDenom: route?.destAssetDenom,
|
|
1413
|
-
operations: route?.operations,
|
|
1414
|
-
addressList,
|
|
1415
|
-
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
1416
|
-
chainIdsToAffiliates: chunkERGJBZUC_cjs.ApiState.chainIdsToAffiliates,
|
|
1417
|
-
postRouteHandler: options.postRouteHandler,
|
|
1418
|
-
feePayerAddress: options.svmFeePayer?.address
|
|
1419
|
-
});
|
|
1420
|
-
if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1421
|
-
const firstTx = response?.txs?.[0];
|
|
1422
|
-
if (firstTx && "cosmosTx" in firstTx) {
|
|
1423
|
-
firstTx.cosmosTx?.msgs?.unshift(beforeMsg);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
if (afterMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1427
|
-
const lastTx = response?.txs?.[response.txs.length - 1];
|
|
1428
|
-
if (lastTx && "cosmosTx" in lastTx) {
|
|
1429
|
-
lastTx.cosmosTx?.msgs?.push(afterMsg);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
await executeTransactions({ ...options, routeId, txs: response?.txs });
|
|
1433
|
-
};
|
|
1434
1413
|
var validateUserAddresses = async (userAddresses) => {
|
|
1435
1414
|
const chains2 = await chunkN4UW74AG_cjs.ClientState.getSkipChains();
|
|
1436
1415
|
const validations = userAddresses.map((userAddress) => {
|
|
@@ -1470,5 +1449,30 @@ var validateUserAddresses = async (userAddresses) => {
|
|
|
1470
1449
|
});
|
|
1471
1450
|
return validations.every((validation) => validation);
|
|
1472
1451
|
};
|
|
1452
|
+
var createValidAddressList = async ({
|
|
1453
|
+
userAddresses,
|
|
1454
|
+
route
|
|
1455
|
+
}) => {
|
|
1456
|
+
let addressList = [];
|
|
1457
|
+
userAddresses.forEach((userAddress, index) => {
|
|
1458
|
+
const requiredChainAddress = route.requiredChainAddresses[index];
|
|
1459
|
+
if (requiredChainAddress === userAddress?.chainId) {
|
|
1460
|
+
addressList.push(userAddress.address);
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
if (addressList.length !== route.requiredChainAddresses.length) {
|
|
1464
|
+
addressList = userAddresses.map((x) => x.address);
|
|
1465
|
+
}
|
|
1466
|
+
const validLength = addressList.length === route.requiredChainAddresses.length || addressList.length === route.chainIds?.length;
|
|
1467
|
+
if (!validLength) {
|
|
1468
|
+
throw new Error("createValidAddressList error: invalid address list");
|
|
1469
|
+
}
|
|
1470
|
+
const isUserAddressesValid = await validateUserAddresses(userAddresses);
|
|
1471
|
+
if (!isUserAddressesValid) {
|
|
1472
|
+
throw new Error("createValidAddressList error: invalid user addresses");
|
|
1473
|
+
}
|
|
1474
|
+
return addressList;
|
|
1475
|
+
};
|
|
1473
1476
|
|
|
1474
|
-
exports.
|
|
1477
|
+
exports.createValidAddressList = createValidAddressList;
|
|
1478
|
+
exports.executeTransactions = executeTransactions;
|