@skip-go/client 1.1.8 → 1.2.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/api/getAssets.d.ts +2 -2
- package/dist/api/getAssets.js +2 -2
- package/dist/api/getAssetsBetweenChains.d.ts +2 -2
- package/dist/api/getAssetsBetweenChains.js +2 -2
- package/dist/api/getBridges.d.ts +2 -2
- package/dist/api/getBridges.js +2 -2
- package/dist/api/getChains.d.ts +2 -2
- package/dist/api/getChains.js +2 -2
- package/dist/api/getVenues.d.ts +1 -1
- package/dist/api/getVenues.js +2 -2
- package/dist/api/postAssetsFromSource.d.ts +2 -2
- package/dist/api/postAssetsFromSource.js +3 -3
- package/dist/api/postBalances.d.ts +3 -3
- package/dist/api/postBalances.js +2 -2
- package/dist/api/postIbcOriginAssets.d.ts +1 -1
- package/dist/api/postIbcOriginAssets.js +2 -2
- package/dist/api/postMessages.d.ts +4 -3
- package/dist/api/postMessages.js +2 -2
- package/dist/api/postMessagesDirect.d.ts +196 -195
- package/dist/api/postMessagesDirect.js +2 -2
- package/dist/api/postRecommendAssets.d.ts +2 -2
- package/dist/api/postRecommendAssets.js +2 -2
- package/dist/api/postRoute.d.ts +191 -191
- package/dist/api/postRoute.js +2 -2
- package/dist/api/postSubmit.d.ts +3 -3
- package/dist/api/postSubmit.js +2 -2
- package/dist/api/postSubmitTransaction.d.ts +1 -1
- package/dist/api/postSubmitTransaction.js +2 -2
- package/dist/api/postTrackTransaction.d.ts +6 -8
- package/dist/api/postTrackTransaction.js +2 -2
- package/dist/api/postTransactionStatus.d.ts +3 -3
- package/dist/api/postTransactionStatus.js +2 -2
- package/dist/{apiState-CdzxTxYd.d.ts → apiState-DwZhwVul.d.ts} +1 -0
- package/dist/{callbacks-BGRu2Ule.d.ts → callbacks-CPh0dr86.d.ts} +2 -2
- package/dist/{chunk-FC6WR2AB.js → chunk-2YOWXBHH.js} +4 -3
- package/dist/{chunk-C3GDPTDO.js → chunk-4CXSWHQ6.js} +1 -1
- package/dist/{chunk-I7WONP6Y.js → chunk-4XUWIG3Z.js} +1 -1
- package/dist/{chunk-H42CXF2U.js → chunk-6SQTOOYP.js} +1 -1
- package/dist/{chunk-MSWIIMAD.js → chunk-72PK3PKI.js} +3 -3
- package/dist/{chunk-RP5COGN6.js → chunk-7MWYHGMD.js} +2 -2
- package/dist/{chunk-EZ65IQWB.js → chunk-A4M35XLF.js} +5 -4
- package/dist/{chunk-5UHQEC5K.js → chunk-A7FWC5OX.js} +1 -1
- package/dist/{chunk-GH36M7RI.js → chunk-DF3WCTFB.js} +1 -1
- package/dist/{chunk-FVI3HTIO.js → chunk-GOPRDIYL.js} +7 -5
- package/dist/chunk-IWMMZY56.js +20 -0
- package/dist/{chunk-QYJTS5PW.js → chunk-NQZYCFAA.js} +1 -1
- package/dist/{chunk-PXL7VX4V.js → chunk-O4IHON37.js} +1 -1
- package/dist/{chunk-I5GT57P3.js → chunk-OFBEDG4X.js} +1 -1
- package/dist/{chunk-WN4AUWSP.js → chunk-RE4YYQCE.js} +1 -1
- package/dist/{chunk-FRP5Y35B.js → chunk-THUBVEVZ.js} +1 -1
- package/dist/{chunk-IHHYXB3K.js → chunk-U6NXCWXE.js} +1 -1
- package/dist/{chunk-YSXM6ATC.js → chunk-UCUUIQHV.js} +1 -1
- package/dist/{chunk-6NMCE4AL.js → chunk-UNMBRIHZ.js} +156 -59
- package/dist/{chunk-M7EBNJWK.js → chunk-XZV42PVV.js} +1 -1
- package/dist/{chunk-H54ORPCL.js → chunk-YABXOO3H.js} +22 -14
- package/dist/{chunk-NQNYCD4R.js → chunk-Z3Z7A3YS.js} +1 -1
- package/dist/{client-types-BkeR6R_z.d.ts → client-types-DRmsTfeT.d.ts} +1 -1
- package/dist/generateApi-D7KXciAd.d.ts +55 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +22 -22
- package/dist/public-functions/executeRoute.d.ts +23 -4
- package/dist/public-functions/executeRoute.js +11 -11
- package/dist/public-functions/getCosmosGasAmountForMessage.d.ts +1 -1
- package/dist/public-functions/getEvmGasAmountForMessage.d.ts +2 -2
- package/dist/public-functions/getFeeInfoForChain.d.ts +2 -2
- package/dist/public-functions/getFeeInfoForChain.js +3 -3
- package/dist/public-functions/getRecommendedGasPrice.d.ts +1 -1
- package/dist/public-functions/getRecommendedGasPrice.js +4 -4
- package/dist/public-functions/getSigningStargateClient.js +3 -3
- package/dist/public-functions/setApiOptions.d.ts +2 -2
- package/dist/public-functions/setApiOptions.js +2 -2
- package/dist/public-functions/setClientOptions.d.ts +4 -4
- package/dist/public-functions/setClientOptions.js +3 -3
- package/dist/public-functions/waitForTransaction.d.ts +6 -6
- package/dist/public-functions/waitForTransaction.js +4 -4
- package/dist/{setClientOptions-CI_7IPLT.d.ts → setClientOptions-CwcM5Ps9.d.ts} +2 -2
- package/dist/{swaggerTypes-CAERZYPb.d.ts → swaggerTypes-BpJPRbC3.d.ts} +6 -2
- package/package.json +1 -1
- package/dist/chunk-Z7GQR23T.js +0 -11
- package/dist/generateApi-8YPJU-Al.d.ts +0 -22
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { transactionStatus } from './chunk-
|
|
2
|
-
import { trackTransaction } from './chunk-
|
|
3
|
-
import { wait } from './chunk-
|
|
1
|
+
import { transactionStatus } from './chunk-XZV42PVV.js';
|
|
2
|
+
import { trackTransaction } from './chunk-IWMMZY56.js';
|
|
3
|
+
import { wait } from './chunk-YABXOO3H.js';
|
|
4
4
|
|
|
5
5
|
// src/public-functions/waitForTransaction.ts
|
|
6
6
|
var waitForTransaction = async ({
|
|
7
7
|
chainId,
|
|
8
8
|
txHash,
|
|
9
|
-
onTransactionTracked
|
|
9
|
+
onTransactionTracked,
|
|
10
|
+
...trackTxPollingOptions
|
|
10
11
|
}) => {
|
|
11
12
|
const { explorerLink } = await trackTransaction({
|
|
12
13
|
chainId,
|
|
13
|
-
txHash
|
|
14
|
+
txHash,
|
|
15
|
+
...trackTxPollingOptions
|
|
14
16
|
});
|
|
15
17
|
await onTransactionTracked?.({ txHash, chainId, explorerLink });
|
|
16
18
|
while (true) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pollingApi } from './chunk-YABXOO3H.js';
|
|
2
|
+
|
|
3
|
+
// src/api/postTrackTransaction.ts
|
|
4
|
+
var trackTransaction = ({
|
|
5
|
+
maxRetries,
|
|
6
|
+
retryInterval,
|
|
7
|
+
backoffMultiplier = 2.5,
|
|
8
|
+
...trackTxRequest
|
|
9
|
+
}) => {
|
|
10
|
+
return pollingApi({
|
|
11
|
+
methodName: "track",
|
|
12
|
+
path: "/v2/tx/track",
|
|
13
|
+
method: "post",
|
|
14
|
+
maxRetries,
|
|
15
|
+
retryInterval,
|
|
16
|
+
backoffMultiplier
|
|
17
|
+
})(trackTxRequest);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { trackTransaction };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { waitForTransaction } from './chunk-
|
|
1
|
+
import { waitForTransaction } from './chunk-GOPRDIYL.js';
|
|
2
2
|
import { getEncodeObjectFromCosmosMessage, getCosmosGasAmountForMessage, getEncodeObjectFromCosmosMessageInjective } from './chunk-TV2XPAIF.js';
|
|
3
3
|
import { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
|
|
4
4
|
import { BigNumber } from './chunk-VQ5SIQWU.js';
|
|
5
5
|
import { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
|
|
6
|
-
import { getSigningStargateClient, getRpcEndpointForChain, accountParser } from './chunk-
|
|
6
|
+
import { getSigningStargateClient, getRpcEndpointForChain, accountParser } from './chunk-72PK3PKI.js';
|
|
7
7
|
import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-36MCR5DZ.js';
|
|
8
|
-
import { messages } from './chunk-
|
|
9
|
-
import { submit } from './chunk-
|
|
10
|
-
import { submitTransaction } from './chunk-
|
|
11
|
-
import { venues } from './chunk-
|
|
12
|
-
import { ClientState, balances } from './chunk-
|
|
13
|
-
import { ApiState, wait, createRequestClient, toCamel } from './chunk-
|
|
8
|
+
import { messages } from './chunk-A7FWC5OX.js';
|
|
9
|
+
import { submit } from './chunk-OFBEDG4X.js';
|
|
10
|
+
import { submitTransaction } from './chunk-DF3WCTFB.js';
|
|
11
|
+
import { venues } from './chunk-RE4YYQCE.js';
|
|
12
|
+
import { ClientState, balances } from './chunk-4XUWIG3Z.js';
|
|
13
|
+
import { ApiState, wait, createRequestClient, toCamel } from './chunk-YABXOO3H.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, GasPrice, calculateFee } from '@cosmjs/stargate';
|
|
@@ -45,14 +45,14 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
45
45
|
}
|
|
46
46
|
if (chain.apis?.rest?.length === 0 || !chain.apis?.rest) {
|
|
47
47
|
throw new Error(
|
|
48
|
-
`getRestEndpointForChain error: failed to find REST endpoint for chain '${chainId}'`
|
|
48
|
+
`getRestEndpointForChain error: failed to find REST endpoint for chain id '${chainId}'`
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
const endpoints = chain.apis?.rest?.map((api) => api.address);
|
|
52
52
|
const endpoint = await findFirstWorkingEndpoint(endpoints, "rest");
|
|
53
53
|
if (!endpoint) {
|
|
54
54
|
throw new Error(
|
|
55
|
-
`getRestEndpointForChain error: failed to find REST endpoint for chain '${chainId}'`
|
|
55
|
+
`getRestEndpointForChain error: failed to find REST endpoint for chain id '${chainId}'`
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
return endpoint;
|
|
@@ -340,9 +340,7 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
340
340
|
signatures: [fromBase64(signature.signature)]
|
|
341
341
|
});
|
|
342
342
|
};
|
|
343
|
-
|
|
344
|
-
// src/private-functions/cosmos/executeCosmosTransaction.ts
|
|
345
|
-
var executeCosmosTransaction = async ({
|
|
343
|
+
var signCosmosTransaction = async ({
|
|
346
344
|
tx,
|
|
347
345
|
options,
|
|
348
346
|
index
|
|
@@ -369,7 +367,7 @@ var executeCosmosTransaction = async ({
|
|
|
369
367
|
if (messages2 === void 0) {
|
|
370
368
|
throw new Error("no messages found for tx");
|
|
371
369
|
}
|
|
372
|
-
const {
|
|
370
|
+
const { signer } = await getSigningStargateClient({
|
|
373
371
|
chainId,
|
|
374
372
|
getOfflineSigner: options?.getCosmosSigner
|
|
375
373
|
});
|
|
@@ -416,6 +414,24 @@ var executeCosmosTransaction = async ({
|
|
|
416
414
|
});
|
|
417
415
|
const txBytes = TxRaw.encode(rawTx).finish();
|
|
418
416
|
const rawTxBase64 = Buffer.from(txBytes).toString("base64");
|
|
417
|
+
return rawTxBase64;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
// src/private-functions/cosmos/executeCosmosTransaction.ts
|
|
421
|
+
var executeCosmosTransaction = async ({
|
|
422
|
+
tx,
|
|
423
|
+
options,
|
|
424
|
+
index
|
|
425
|
+
}) => {
|
|
426
|
+
if (tx === void 0) {
|
|
427
|
+
throw new Error("executeCosmosTransaction error: tx is undefined");
|
|
428
|
+
}
|
|
429
|
+
const rawTxBase64 = await signCosmosTransaction({
|
|
430
|
+
tx,
|
|
431
|
+
options,
|
|
432
|
+
index
|
|
433
|
+
});
|
|
434
|
+
const chainId = tx.cosmosTx?.chainId;
|
|
419
435
|
const txResponse = await submit({
|
|
420
436
|
chainId,
|
|
421
437
|
tx: rawTxBase64
|
|
@@ -713,12 +729,17 @@ var executeEvmTransaction = async (message, options) => {
|
|
|
713
729
|
});
|
|
714
730
|
return receipt;
|
|
715
731
|
};
|
|
716
|
-
var
|
|
732
|
+
var signSvmTransaction = async ({
|
|
733
|
+
tx,
|
|
734
|
+
options
|
|
735
|
+
}) => {
|
|
717
736
|
const gasArray = ClientState.validateGasResults;
|
|
718
737
|
if (tx === void 0) {
|
|
719
738
|
throw new Error("executeSvmTransaction error: tx is undefined");
|
|
720
739
|
}
|
|
721
|
-
const gas = gasArray?.find(
|
|
740
|
+
const gas = gasArray?.find(
|
|
741
|
+
(gas2) => gas2?.error !== null && gas2?.error !== void 0
|
|
742
|
+
);
|
|
722
743
|
if (typeof gas?.error === "string") {
|
|
723
744
|
throw new Error(gas?.error);
|
|
724
745
|
}
|
|
@@ -735,25 +756,37 @@ var executeSvmTransaction = async (tx, options) => {
|
|
|
735
756
|
}
|
|
736
757
|
const txBuffer = Buffer.from(svmTx.tx ?? "", "base64");
|
|
737
758
|
const transaction = Transaction.from(txBuffer);
|
|
759
|
+
if (!("signTransaction" in signer)) return;
|
|
760
|
+
const signedTx = await signer.signTransaction(transaction);
|
|
761
|
+
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
762
|
+
const serializedTx = signedTx.serialize();
|
|
763
|
+
return serializedTx;
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// src/private-functions/svm/executeSvmTransaction.ts
|
|
767
|
+
var executeSvmTransaction = async (tx, options) => {
|
|
768
|
+
const svmTx = tx?.svmTx;
|
|
769
|
+
if (!svmTx?.chainId) {
|
|
770
|
+
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
771
|
+
}
|
|
772
|
+
const signedTx = await signSvmTransaction({ tx, options });
|
|
773
|
+
if (!signedTx) {
|
|
774
|
+
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
775
|
+
}
|
|
738
776
|
const endpoint = await getRpcEndpointForChain(svmTx.chainId);
|
|
739
777
|
const connection = new Connection(endpoint);
|
|
740
778
|
let signature;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
preflightCommitment: "confirmed",
|
|
753
|
-
maxRetries: 5
|
|
754
|
-
});
|
|
755
|
-
signature = rpcSig;
|
|
756
|
-
}
|
|
779
|
+
await submitTransaction({
|
|
780
|
+
chainId: svmTx.chainId,
|
|
781
|
+
tx: signedTx.toString("base64")
|
|
782
|
+
}).then((res) => {
|
|
783
|
+
signature = res?.txHash;
|
|
784
|
+
});
|
|
785
|
+
const rpcSig = await connection.sendRawTransaction(signedTx, {
|
|
786
|
+
preflightCommitment: "confirmed",
|
|
787
|
+
maxRetries: 5
|
|
788
|
+
});
|
|
789
|
+
signature = rpcSig;
|
|
757
790
|
if (!signature) {
|
|
758
791
|
throw new Error("executeSvmTransaction error: signature not found");
|
|
759
792
|
}
|
|
@@ -799,11 +832,11 @@ var validateCosmosGasBalance = async ({
|
|
|
799
832
|
const skipChains = await ClientState.getSkipChains();
|
|
800
833
|
const chain = skipChains?.find((c) => c.chainId === chainId);
|
|
801
834
|
if (!chain) {
|
|
802
|
-
throw new Error(`failed to find chain id
|
|
835
|
+
throw new Error(`failed to find chain id '${chainId}'`);
|
|
803
836
|
}
|
|
804
837
|
const { feeAssets } = chain;
|
|
805
838
|
if (!feeAssets) {
|
|
806
|
-
throw new Error(`failed to find fee assets for chain '${chainId}'`);
|
|
839
|
+
throw new Error(`failed to find fee assets for chain id '${chainId}'`);
|
|
807
840
|
}
|
|
808
841
|
const estimatedGasAmount = await (async () => {
|
|
809
842
|
try {
|
|
@@ -928,11 +961,11 @@ var validateCosmosGasBalance = async ({
|
|
|
928
961
|
if (!feeUsed) {
|
|
929
962
|
if (validatedAssets.length > 1) {
|
|
930
963
|
throw new Error(
|
|
931
|
-
validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${
|
|
964
|
+
validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${chain.prettyName}.`
|
|
932
965
|
);
|
|
933
966
|
}
|
|
934
967
|
throw new Error(
|
|
935
|
-
validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${
|
|
968
|
+
validatedAssets[0]?.error || `Insufficient fee token to initiate transfer on ${chain.prettyName}.`
|
|
936
969
|
);
|
|
937
970
|
}
|
|
938
971
|
return feeUsed;
|
|
@@ -1178,15 +1211,15 @@ var validateGasBalances = async ({
|
|
|
1178
1211
|
enabledChainIds,
|
|
1179
1212
|
useUnlimitedApproval
|
|
1180
1213
|
}) => {
|
|
1181
|
-
onValidateGasBalance?.({
|
|
1182
|
-
status: "pending"
|
|
1183
|
-
});
|
|
1184
1214
|
const validateResult = await Promise.all(
|
|
1185
1215
|
txs.map(async (tx, i) => {
|
|
1186
1216
|
if (!tx) {
|
|
1187
1217
|
throw new Error(`invalid tx at index ${i}`);
|
|
1188
1218
|
}
|
|
1189
1219
|
if ("cosmosTx" in tx && !disabledChainIds?.includes(tx?.cosmosTx?.chainId ?? "") && (enabledChainIds === void 0 || enabledChainIds.includes(tx?.cosmosTx?.chainId ?? ""))) {
|
|
1220
|
+
onValidateGasBalance?.({
|
|
1221
|
+
status: "pending"
|
|
1222
|
+
});
|
|
1190
1223
|
if (!tx?.cosmosTx?.msgs) {
|
|
1191
1224
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1192
1225
|
}
|
|
@@ -1211,9 +1244,14 @@ var validateGasBalances = async ({
|
|
|
1211
1244
|
}
|
|
1212
1245
|
}
|
|
1213
1246
|
if ("evmTx" in tx && !disabledChainIds?.includes(tx?.evmTx?.chainId ?? "") && (enabledChainIds === void 0 || enabledChainIds.includes(tx?.evmTx?.chainId ?? ""))) {
|
|
1247
|
+
onValidateGasBalance?.({
|
|
1248
|
+
status: "pending"
|
|
1249
|
+
});
|
|
1214
1250
|
const signer = await getEvmSigner?.(tx?.evmTx?.chainId ?? "");
|
|
1215
1251
|
if (!signer) {
|
|
1216
|
-
throw new Error(
|
|
1252
|
+
throw new Error(
|
|
1253
|
+
`failed to get signer for chain ${tx?.evmTx?.chainId}`
|
|
1254
|
+
);
|
|
1217
1255
|
}
|
|
1218
1256
|
try {
|
|
1219
1257
|
const res = await validateEvmGasBalance({
|
|
@@ -1233,6 +1271,9 @@ var validateGasBalances = async ({
|
|
|
1233
1271
|
}
|
|
1234
1272
|
}
|
|
1235
1273
|
if ("svmTx" in tx && !disabledChainIds?.includes(tx?.svmTx?.chainId ?? "") && (enabledChainIds === void 0 || enabledChainIds.includes(tx?.svmTx?.chainId ?? ""))) {
|
|
1274
|
+
onValidateGasBalance?.({
|
|
1275
|
+
status: "pending"
|
|
1276
|
+
});
|
|
1236
1277
|
try {
|
|
1237
1278
|
const res = await validateSvmGasBalance({
|
|
1238
1279
|
tx: tx.svmTx
|
|
@@ -1277,10 +1318,14 @@ var executeTransactions = async (options) => {
|
|
|
1277
1318
|
getFallbackGasAmount = getDefaultFallbackGasAmount,
|
|
1278
1319
|
getCosmosSigner,
|
|
1279
1320
|
getEvmSigner,
|
|
1280
|
-
onValidateGasBalance
|
|
1321
|
+
onValidateGasBalance,
|
|
1322
|
+
trackTxPollingOptions,
|
|
1323
|
+
batchSignTxs = true
|
|
1281
1324
|
} = options;
|
|
1282
1325
|
if (txs === void 0) {
|
|
1283
|
-
throw new Error(
|
|
1326
|
+
throw new Error(
|
|
1327
|
+
"executeTransactions error: txs is undefined in executeTransactions"
|
|
1328
|
+
);
|
|
1284
1329
|
}
|
|
1285
1330
|
const chainIds = txs.map((tx) => {
|
|
1286
1331
|
if ("cosmosTx" in tx) {
|
|
@@ -1327,35 +1372,84 @@ var executeTransactions = async (options) => {
|
|
|
1327
1372
|
enabledChainIds: !batchSimulate ? [chainId] : validateChainIds
|
|
1328
1373
|
});
|
|
1329
1374
|
};
|
|
1375
|
+
let signedTxs = [];
|
|
1376
|
+
if (batchSignTxs) {
|
|
1377
|
+
for (let i = 0; i < txs.length; i++) {
|
|
1378
|
+
const tx = txs[i];
|
|
1379
|
+
if (!tx) {
|
|
1380
|
+
throw new Error(`executeRoute error: invalid message at index ${i}`);
|
|
1381
|
+
}
|
|
1382
|
+
if ("cosmosTx" in tx) {
|
|
1383
|
+
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1384
|
+
const signedTx = await signCosmosTransaction({
|
|
1385
|
+
tx,
|
|
1386
|
+
options,
|
|
1387
|
+
index: i
|
|
1388
|
+
});
|
|
1389
|
+
signedTxs.push({
|
|
1390
|
+
index: i,
|
|
1391
|
+
chainId: tx.cosmosTx?.chainId ?? "",
|
|
1392
|
+
tx: signedTx,
|
|
1393
|
+
chainType: "cosmos" /* Cosmos */
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
if ("svmTx" in tx) {
|
|
1397
|
+
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1398
|
+
const signedTx = await signSvmTransaction({ tx, options });
|
|
1399
|
+
if (!signedTx) {
|
|
1400
|
+
throw new Error(`executeRoute error: signedTx is undefined`);
|
|
1401
|
+
}
|
|
1402
|
+
signedTxs.push({
|
|
1403
|
+
index: i,
|
|
1404
|
+
chainId: tx.svmTx?.chainId ?? "",
|
|
1405
|
+
tx: signedTx.toString("base64"),
|
|
1406
|
+
chainType: "svm" /* Svm */
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1330
1411
|
for (let i = 0; i < txs.length; i++) {
|
|
1331
1412
|
const tx = txs[i];
|
|
1332
1413
|
if (!tx) {
|
|
1333
1414
|
throw new Error(`executeRoute error: invalid message at index ${i}`);
|
|
1334
1415
|
}
|
|
1335
1416
|
let txResult;
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
index: i
|
|
1417
|
+
const txSigned = signedTxs.find((item) => item.index === i);
|
|
1418
|
+
if (txSigned) {
|
|
1419
|
+
const txResponse = await submit({
|
|
1420
|
+
chainId: txSigned.chainId,
|
|
1421
|
+
tx: txSigned.tx
|
|
1342
1422
|
});
|
|
1343
|
-
} else if ("evmTx" in tx) {
|
|
1344
|
-
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1345
|
-
const txResponse = await executeEvmTransaction(tx, options);
|
|
1346
1423
|
txResult = {
|
|
1347
|
-
chainId:
|
|
1348
|
-
txHash: txResponse
|
|
1424
|
+
chainId: txSigned.chainId,
|
|
1425
|
+
txHash: txResponse?.txHash ?? ""
|
|
1349
1426
|
};
|
|
1350
|
-
} else if ("svmTx" in tx) {
|
|
1351
|
-
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1352
|
-
txResult = await executeSvmTransaction(tx, options);
|
|
1353
1427
|
} else {
|
|
1354
|
-
|
|
1428
|
+
if ("cosmosTx" in tx) {
|
|
1429
|
+
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1430
|
+
txResult = await executeCosmosTransaction({
|
|
1431
|
+
tx,
|
|
1432
|
+
options,
|
|
1433
|
+
index: i
|
|
1434
|
+
});
|
|
1435
|
+
} else if ("evmTx" in tx) {
|
|
1436
|
+
await validateEnabledChainIds(tx.evmTx?.chainId ?? "");
|
|
1437
|
+
const txResponse = await executeEvmTransaction(tx, options);
|
|
1438
|
+
txResult = {
|
|
1439
|
+
chainId: tx?.evmTx?.chainId ?? "",
|
|
1440
|
+
txHash: txResponse.transactionHash
|
|
1441
|
+
};
|
|
1442
|
+
} else if ("svmTx" in tx) {
|
|
1443
|
+
await validateEnabledChainIds(tx.svmTx?.chainId ?? "");
|
|
1444
|
+
txResult = await executeSvmTransaction(tx, options);
|
|
1445
|
+
} else {
|
|
1446
|
+
throw new Error("executeRoute error: invalid message type");
|
|
1447
|
+
}
|
|
1355
1448
|
}
|
|
1356
1449
|
await onTransactionBroadcast?.({ ...txResult });
|
|
1357
1450
|
const txStatusResponse = await waitForTransaction({
|
|
1358
1451
|
...txResult,
|
|
1452
|
+
...trackTxPollingOptions,
|
|
1359
1453
|
onTransactionTracked: options.onTransactionTracked
|
|
1360
1454
|
});
|
|
1361
1455
|
await onTransactionCompleted?.({
|
|
@@ -1377,7 +1471,9 @@ var getDefaultFallbackGasAmount = async (chainId, chainType) => {
|
|
|
1377
1471
|
}
|
|
1378
1472
|
if (chainType !== "cosmos" /* Cosmos */) return void 0;
|
|
1379
1473
|
const venuesResult = await venues();
|
|
1380
|
-
const isSwapChain = venuesResult?.some(
|
|
1474
|
+
const isSwapChain = venuesResult?.some(
|
|
1475
|
+
(venue) => venue.chainId === chainId
|
|
1476
|
+
) ?? false;
|
|
1381
1477
|
const defaultGasAmount = Math.ceil(
|
|
1382
1478
|
isSwapChain ? COSMOS_GAS_AMOUNT.SWAP : COSMOS_GAS_AMOUNT.DEFAULT
|
|
1383
1479
|
);
|
|
@@ -1417,7 +1513,8 @@ var executeRoute = async (options) => {
|
|
|
1417
1513
|
operations: route?.operations,
|
|
1418
1514
|
addressList,
|
|
1419
1515
|
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
1420
|
-
chainIdsToAffiliates: ApiState.chainIdsToAffiliates
|
|
1516
|
+
chainIdsToAffiliates: ApiState.chainIdsToAffiliates,
|
|
1517
|
+
postRouteHandler: options.postRouteHandler
|
|
1421
1518
|
});
|
|
1422
1519
|
if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1423
1520
|
const firstTx = response?.txs?.[0];
|
|
@@ -24,14 +24,21 @@ function convertKeys(obj, convertKey) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/utils/generateApi.ts
|
|
27
|
-
var createRequestClient = ({
|
|
28
|
-
if (!
|
|
29
|
-
|
|
27
|
+
var createRequestClient = ({ apiUrl, apiKey, apiHeaders }) => {
|
|
28
|
+
if (!apiUrl?.endsWith("/")) {
|
|
29
|
+
apiUrl += "/";
|
|
30
|
+
}
|
|
31
|
+
const headers = new Headers({
|
|
32
|
+
"content-type": "application/json"
|
|
33
|
+
});
|
|
34
|
+
if (apiKey) {
|
|
35
|
+
headers.set("authorization", apiKey);
|
|
36
|
+
}
|
|
37
|
+
if (apiHeaders) {
|
|
38
|
+
new Headers(apiHeaders).forEach((value, key) => {
|
|
39
|
+
headers.set(key, value);
|
|
40
|
+
});
|
|
30
41
|
}
|
|
31
|
-
const defaultHeaders = {
|
|
32
|
-
"content-type": "application/json",
|
|
33
|
-
...apiKey ? { authorization: apiKey } : {}
|
|
34
|
-
};
|
|
35
42
|
const handleResponse = async (response) => {
|
|
36
43
|
const contentType = response.headers.get("content-type");
|
|
37
44
|
const isJson = contentType?.includes("application/json");
|
|
@@ -46,7 +53,7 @@ var createRequestClient = ({ baseUrl, apiKey }) => {
|
|
|
46
53
|
if (path?.startsWith("/")) {
|
|
47
54
|
console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
|
|
48
55
|
}
|
|
49
|
-
const url = new URL(path ?? "",
|
|
56
|
+
const url = new URL(path ?? "", apiUrl);
|
|
50
57
|
if (params && typeof params === "object") {
|
|
51
58
|
Object.entries(params).forEach(([key, value]) => {
|
|
52
59
|
if (value !== void 0 && value !== null) {
|
|
@@ -56,7 +63,7 @@ var createRequestClient = ({ baseUrl, apiKey }) => {
|
|
|
56
63
|
}
|
|
57
64
|
const response = await fetch(url.toString(), {
|
|
58
65
|
method: "GET",
|
|
59
|
-
headers
|
|
66
|
+
headers,
|
|
60
67
|
signal
|
|
61
68
|
});
|
|
62
69
|
return handleResponse(response);
|
|
@@ -65,9 +72,9 @@ var createRequestClient = ({ baseUrl, apiKey }) => {
|
|
|
65
72
|
if (path?.startsWith("/")) {
|
|
66
73
|
console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
|
|
67
74
|
}
|
|
68
|
-
const response = await fetch(new URL(path,
|
|
75
|
+
const response = await fetch(new URL(path, apiUrl).toString(), {
|
|
69
76
|
method: "POST",
|
|
70
|
-
headers
|
|
77
|
+
headers,
|
|
71
78
|
body: JSON.stringify(data),
|
|
72
79
|
signal
|
|
73
80
|
});
|
|
@@ -83,12 +90,13 @@ function createRequest({
|
|
|
83
90
|
}) {
|
|
84
91
|
let controller = null;
|
|
85
92
|
const request = async (options) => {
|
|
86
|
-
const { apiKey, apiUrl, abortDuplicateRequests, ...requestParams } = options ?? {};
|
|
93
|
+
const { apiKey, apiUrl, apiHeaders, abortDuplicateRequests, ...requestParams } = options ?? {};
|
|
87
94
|
let fetchClient = ApiState.client;
|
|
88
95
|
if (apiUrl || apiKey) {
|
|
89
96
|
fetchClient = createRequestClient({
|
|
90
|
-
|
|
91
|
-
apiKey
|
|
97
|
+
apiUrl: apiUrl || "https://api.skip.build",
|
|
98
|
+
apiKey,
|
|
99
|
+
apiHeaders
|
|
92
100
|
});
|
|
93
101
|
} else {
|
|
94
102
|
await ApiState.clientInitialized;
|
|
@@ -3,7 +3,7 @@ import { OfflineDirectSigner } from '@cosmjs/proto-signing';
|
|
|
3
3
|
import { StdFee, GasPrice, SignerData } from '@cosmjs/stargate';
|
|
4
4
|
import { WalletClient } from 'viem';
|
|
5
5
|
import { Adapter } from '@solana/wallet-adapter-base';
|
|
6
|
-
import { a3 as FeeAsset, L as ChainType, W as CosmosMsg } from './swaggerTypes-
|
|
6
|
+
import { a3 as FeeAsset, L as ChainType, W as CosmosMsg } from './swaggerTypes-BpJPRbC3.js';
|
|
7
7
|
|
|
8
8
|
/** Common Types */
|
|
9
9
|
type UserAddress = {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { bv as Api } from './swaggerTypes-BpJPRbC3.js';
|
|
2
|
+
|
|
3
|
+
type CamelKey<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<CamelKey<U>>}` : S;
|
|
4
|
+
type Camel<T> = T extends (infer U)[] ? Camel<U>[] : T extends object ? {
|
|
5
|
+
[K in keyof T as K extends string ? CamelKey<K> : never]: Camel<T[K]>;
|
|
6
|
+
} : T;
|
|
7
|
+
|
|
8
|
+
type ApiInstance = InstanceType<typeof Api>;
|
|
9
|
+
type FunctionKeys<T> = {
|
|
10
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
11
|
+
}[keyof T];
|
|
12
|
+
type ValidApiMethodKeys = {
|
|
13
|
+
[K in FunctionKeys<ApiInstance>]: Awaited<ReturnType<ApiInstance[K]>> extends {
|
|
14
|
+
data: unknown;
|
|
15
|
+
} ? K : never;
|
|
16
|
+
}[FunctionKeys<ApiInstance>];
|
|
17
|
+
type ApiRequest<K extends ValidApiMethodKeys> = NonNullable<Camel<Parameters<ApiInstance[K]>[0]>>;
|
|
18
|
+
type ApiResponse<K extends ValidApiMethodKeys> = Camel<Awaited<ReturnType<ApiInstance[K]>> extends {
|
|
19
|
+
data: infer D;
|
|
20
|
+
} ? D extends object ? D : never : never>;
|
|
21
|
+
type PollingProps<K extends ValidApiMethodKeys> = {
|
|
22
|
+
isSuccess?: (result: ApiResponse<K>) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of retries
|
|
25
|
+
* @default 5
|
|
26
|
+
*/
|
|
27
|
+
maxRetries?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Retry interval in milliseconds
|
|
30
|
+
* @default 1000
|
|
31
|
+
*/
|
|
32
|
+
retryInterval?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Backoff multiplier for retries
|
|
35
|
+
*
|
|
36
|
+
* example: `retryInterval` is set to 1000, backoffMultiplier is set to 2
|
|
37
|
+
*
|
|
38
|
+
* 1st retry: 1000ms
|
|
39
|
+
*
|
|
40
|
+
* 2nd retry: 2000ms
|
|
41
|
+
*
|
|
42
|
+
* 3rd retry: 4000ms
|
|
43
|
+
*
|
|
44
|
+
* 4th retry: 8000ms
|
|
45
|
+
*
|
|
46
|
+
* 5th retry: 16000ms
|
|
47
|
+
*
|
|
48
|
+
* @default 2
|
|
49
|
+
*/
|
|
50
|
+
backoffMultiplier?: number;
|
|
51
|
+
onError?: (error: unknown, attempt: number) => void;
|
|
52
|
+
onSuccess?: (result: ApiResponse<K>, attempt: number) => void;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type { ApiRequest as A, PollingProps as P, ApiResponse as a };
|