@skip-go/client 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{chunk-IDEJORRT.cjs → chunk-23YF4LFI.cjs} +30 -0
- package/dist/cjs/chunk-4YTACAVP.cjs +185 -0
- package/dist/cjs/{chunk-46VB6RQK.cjs → chunk-CUDPMOR6.cjs} +10 -3
- package/dist/cjs/chunk-GCJO6DZD.cjs +55 -0
- package/dist/cjs/{chunk-ZKBSNSHQ.cjs → chunk-HHZGD62Y.cjs} +120 -116
- package/dist/cjs/{chunk-ZAATXQBG.cjs → chunk-K4YAPDUE.cjs} +2 -2
- package/dist/cjs/{chunk-7MC3BVQN.cjs → chunk-UIQML2XG.cjs} +113 -28
- package/dist/cjs/chunk-VF65UG3E.cjs +214 -0
- package/dist/cjs/{chunk-Q43XCBMX.cjs → chunk-W3KF3V57.cjs} +4 -4
- package/dist/cjs/{chunk-6LA66667.cjs → chunk-X22PL5T7.cjs} +3 -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/{callbacks-B3kjKg0v.d.ts → callbacks-CvqAtBJq.d.ts} +19 -64
- package/dist/esm/chunk-7RS3YIVC.js +53 -0
- package/dist/esm/chunk-AZALP3WR.js +212 -0
- package/dist/esm/{chunk-CIAOTO3M.js → chunk-CX5N7ZLJ.js} +1 -1
- package/dist/esm/chunk-IUYOY23L.js +180 -0
- package/dist/esm/{chunk-GHNH5QC3.js → chunk-JKN4E5VN.js} +9 -2
- package/dist/esm/{chunk-4RLJWCQR.js → chunk-KLGGCB73.js} +1 -1
- package/dist/esm/{chunk-KYDY7QRT.js → chunk-MPSXXWKL.js} +1 -1
- package/dist/esm/{chunk-BAJFQZDT.js → chunk-MTAS5XMN.js} +99 -96
- package/dist/esm/{chunk-RQ7DXNSS.js → chunk-VUXLWWLF.js} +113 -28
- package/dist/esm/{chunk-REWUSU53.js → chunk-WBZVMPPV.js} +30 -0
- package/dist/esm/client-types-Dk6ypWdO.d.ts +114 -0
- package/dist/esm/index.d.ts +4 -3
- 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 +3 -3
- package/dist/esm/public-functions/executeRoute.js +7 -6
- package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +4 -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/setClientOptions.d.ts +4 -2
- package/dist/esm/public-functions/setClientOptions.js +1 -1
- package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +3 -3
- package/dist/esm/public-functions/subscribeToRouteStatus.js +1 -1
- package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +5 -4
- package/dist/esm/public-functions/validateCosmosGasBalance.js +4 -4
- package/dist/esm/public-functions/waitForTransaction.d.ts +3 -3
- package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-BD8e7m2x.d.ts} +1 -1
- 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
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkGCJO6DZD_cjs = require('../chunk-GCJO6DZD.cjs');
|
|
4
|
+
require('../chunk-HHZGD62Y.cjs');
|
|
5
|
+
require('../chunk-UIQML2XG.cjs');
|
|
6
|
+
require('../chunk-CUDPMOR6.cjs');
|
|
6
7
|
require('../chunk-KM2D7PJL.cjs');
|
|
8
|
+
require('../chunk-DWOE6N5S.cjs');
|
|
7
9
|
require('../chunk-F3EB2AQG.cjs');
|
|
8
10
|
require('../chunk-4R6OCWRR.cjs');
|
|
9
11
|
require('../chunk-KZOSEIWH.cjs');
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-VIG2BHYJ.cjs');
|
|
12
|
-
require('../chunk-DWOE6N5S.cjs');
|
|
12
|
+
require('../chunk-X22PL5T7.cjs');
|
|
13
13
|
require('../chunk-3M7YYWGL.cjs');
|
|
14
|
+
require('../chunk-4YTACAVP.cjs');
|
|
14
15
|
require('../chunk-OZUCMWNE.cjs');
|
|
15
16
|
require('../chunk-5HDKZVOL.cjs');
|
|
16
17
|
require('../chunk-LUVMRHAJ.cjs');
|
|
@@ -24,5 +25,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
24
25
|
|
|
25
26
|
Object.defineProperty(exports, "executeRoute", {
|
|
26
27
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkGCJO6DZD_cjs.executeRoute; }
|
|
28
29
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkW3KF3V57_cjs = require('../chunk-W3KF3V57.cjs');
|
|
4
4
|
require('../chunk-KZOSEIWH.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-4YTACAVP.cjs');
|
|
6
6
|
require('../chunk-N4UW74AG.cjs');
|
|
7
7
|
require('../chunk-ERGJBZUC.cjs');
|
|
8
8
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -11,5 +11,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "getFeeInfoForChain", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkW3KF3V57_cjs.getFeeInfoForChain; }
|
|
15
15
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkK4YAPDUE_cjs = require('../chunk-K4YAPDUE.cjs');
|
|
4
4
|
require('../chunk-4R6OCWRR.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-W3KF3V57.cjs');
|
|
6
6
|
require('../chunk-KZOSEIWH.cjs');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-4YTACAVP.cjs');
|
|
8
8
|
require('../chunk-N4UW74AG.cjs');
|
|
9
9
|
require('../chunk-ERGJBZUC.cjs');
|
|
10
10
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -13,5 +13,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
13
13
|
|
|
14
14
|
Object.defineProperty(exports, "getRecommendedGasPrice", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkK4YAPDUE_cjs.getRecommendedGasPrice; }
|
|
17
17
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-VIG2BHYJ.cjs');
|
|
3
|
+
var chunkX22PL5T7_cjs = require('../chunk-X22PL5T7.cjs');
|
|
5
4
|
require('../chunk-3M7YYWGL.cjs');
|
|
5
|
+
require('../chunk-4YTACAVP.cjs');
|
|
6
6
|
require('../chunk-N4UW74AG.cjs');
|
|
7
7
|
require('../chunk-ERGJBZUC.cjs');
|
|
8
8
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -11,5 +11,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "getSigningStargateClient", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkX22PL5T7_cjs.getSigningStargateClient; }
|
|
15
15
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk23YF4LFI_cjs = require('../chunk-23YF4LFI.cjs');
|
|
4
4
|
require('../chunk-DWOE6N5S.cjs');
|
|
5
5
|
require('../chunk-3M7YYWGL.cjs');
|
|
6
6
|
require('../chunk-N4UW74AG.cjs');
|
|
@@ -11,5 +11,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "setClientOptions", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk23YF4LFI_cjs.setClientOptions; }
|
|
15
15
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUIQML2XG_cjs = require('../chunk-UIQML2XG.cjs');
|
|
4
4
|
require('../chunk-LUVMRHAJ.cjs');
|
|
5
5
|
require('../chunk-QPM7H2YL.cjs');
|
|
6
6
|
require('../chunk-ERGJBZUC.cjs');
|
|
@@ -10,17 +10,17 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "executeAndSubscribeToRouteStatus", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkUIQML2XG_cjs.executeAndSubscribeToRouteStatus; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getTransactionStatus", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkUIQML2XG_cjs.getTransactionStatus; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "subscribeToRouteStatus", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkUIQML2XG_cjs.subscribeToRouteStatus; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "updateRouteDetails", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkUIQML2XG_cjs.updateRouteDetails; }
|
|
26
26
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCUDPMOR6_cjs = require('../chunk-CUDPMOR6.cjs');
|
|
4
4
|
require('../chunk-KM2D7PJL.cjs');
|
|
5
|
-
require('../chunk-4R6OCWRR.cjs');
|
|
6
|
-
require('../chunk-6LA66667.cjs');
|
|
7
|
-
require('../chunk-VIG2BHYJ.cjs');
|
|
8
5
|
require('../chunk-DWOE6N5S.cjs');
|
|
6
|
+
require('../chunk-4R6OCWRR.cjs');
|
|
7
|
+
require('../chunk-X22PL5T7.cjs');
|
|
9
8
|
require('../chunk-3M7YYWGL.cjs');
|
|
9
|
+
require('../chunk-4YTACAVP.cjs');
|
|
10
10
|
require('../chunk-N4UW74AG.cjs');
|
|
11
11
|
require('../chunk-ERGJBZUC.cjs');
|
|
12
12
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -15,5 +15,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
15
15
|
|
|
16
16
|
Object.defineProperty(exports, "validateCosmosGasBalance", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkCUDPMOR6_cjs.validateCosmosGasBalance; }
|
|
19
19
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TxStatusResponse } from './api/postTransactionStatus.js';
|
|
2
2
|
import { aS as TransferState, k as AxelarTransferState, p as CCTPTransferState, a8 as HyperlaneTransferState, aO as OPInitTransferState, w as GoFastTransferState, s as StargateTransferState, aP as LayerZeroTransferState, bf as RouteResponse, W as CosmosMsg, an as PostHandler, aT as TransferAssetRelease, aJ as TransactionState, aq as Route, aU as TransferStatus, T as Erc20Approval } from './swaggerTypes-DDwqIjap.js';
|
|
3
3
|
import { A as ApiRequest } from './generateApi-C_xgtxrO.js';
|
|
4
|
-
import { S as SignerGetters, b as GasOptions, U as UserAddress, T as TxResult } from './client-types-
|
|
5
|
-
import { TrackTxPollingProps } from './api/postTrackTransaction.js';
|
|
4
|
+
import { S as SignerGetters, b as GasOptions, B as BaseSettings, U as UserAddress, T as TxResult } from './client-types-Dk6ypWdO.js';
|
|
6
5
|
|
|
7
6
|
type TransferEventStatus = "unconfirmed" | "signing" | "pending" | "completed" | "failed" | "approving" | "incomplete";
|
|
8
7
|
type ClientTransferEvent = {
|
|
@@ -16,71 +15,20 @@ type ClientTransferEvent = {
|
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
/** Execute Route Options */
|
|
19
|
-
type ExecuteRouteOptions = SignerGetters & GasOptions & TransactionCallbacks & Pick<ApiRequest<"msgs">, "timeoutSeconds"> & {
|
|
18
|
+
type ExecuteRouteOptions = SignerGetters & GasOptions & TransactionCallbacks & BaseSettings & Pick<ApiRequest<"msgs">, "timeoutSeconds"> & {
|
|
20
19
|
route: RouteResponse;
|
|
21
20
|
/**
|
|
22
|
-
* Addresses should be in the same order with the `
|
|
21
|
+
* Addresses should be in the same order with the `requiredChainAddresses` in the `route`
|
|
23
22
|
*/
|
|
24
23
|
userAddresses: UserAddress[];
|
|
25
|
-
simulate?: boolean;
|
|
26
|
-
slippageTolerancePercent?: string;
|
|
27
24
|
/**
|
|
28
|
-
*
|
|
25
|
+
* If `appendCosmosMsgs` is provided, it will append the specified Cosmos messages to the transactions.
|
|
29
26
|
*/
|
|
30
|
-
|
|
31
|
-
afterMsg?: CosmosMsg;
|
|
32
|
-
/**
|
|
33
|
-
* Set allowance amount to max if EVM transaction requires allowance approval.
|
|
34
|
-
*/
|
|
35
|
-
useUnlimitedApproval?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
/**
|
|
38
|
-
* If `skipApproval` is set to `true`, the router will bypass checking whether
|
|
39
|
-
* the signer has granted approval for the specified token contract on an EVM chain.
|
|
40
|
-
* This can be useful if approval has already been handled externally or there are race conditions.
|
|
41
|
-
*/
|
|
42
|
-
bypassApprovalCheck?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* defaults to true
|
|
45
|
-
* If `batchSimulate` is set to `true`, it will simulate all messages in a batch before the first tx run.
|
|
46
|
-
* If `batchSimulate` is set to `false`, it will simulate each message one by one.
|
|
47
|
-
*/
|
|
48
|
-
batchSimulate?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Optional configuration for transaction polling behavior.
|
|
51
|
-
* - `maxRetries`: Maximum number of polling attempts (default: 5)
|
|
52
|
-
* - `retryInterval`: Retry interval in milliseconds (default: 1000)
|
|
53
|
-
* - `backoffMultiplier`: Exponential backoff multiplier for increasing delay between retries (default: 2.5)
|
|
54
|
-
* Example backoff with retryInterval = 1000 and backoffMultiplier = 2:
|
|
55
|
-
* 1st retry: 1000ms → 2nd: 2000ms → 3rd: 4000ms → 4th: 8000ms ...
|
|
56
|
-
*/
|
|
57
|
-
trackTxPollingOptions?: TrackTxPollingProps;
|
|
58
|
-
/**
|
|
59
|
-
* If `batchSignTxs` is set to `true`, it will sign all transactions in a batch up front.
|
|
60
|
-
* If `batchSignTxs` is set to `false`, it will sign each transaction one by one.
|
|
61
|
-
*/
|
|
62
|
-
batchSignTxs?: boolean;
|
|
27
|
+
appendCosmosMsgs?: Record<string, CosmosMsg[]>;
|
|
63
28
|
/**
|
|
64
29
|
* Specify actions to perform after the route is completed
|
|
65
30
|
*/
|
|
66
31
|
postRouteHandler?: PostHandler;
|
|
67
|
-
/**
|
|
68
|
-
* If `cosmosPriorityFeeDenom` is provided, it will be used to set the priority fee for Cosmos transactions.
|
|
69
|
-
* It should be a function that takes a chainId and returns the denom for the priority fee.
|
|
70
|
-
*/
|
|
71
|
-
getCosmosPriorityFeeDenom?: (chainId: string) => Promise<string | undefined>;
|
|
72
|
-
/**
|
|
73
|
-
* SVM Fee Payer
|
|
74
|
-
*
|
|
75
|
-
* This is used to pay for the transaction fees on SVM chains.
|
|
76
|
-
* It should be an object with the following properties:
|
|
77
|
-
* `address`: The address of the fee payer.
|
|
78
|
-
* `signTransaction`: A function that takes the data to sign and returns a Promise that resolves to the signed transaction.
|
|
79
|
-
*/
|
|
80
|
-
svmFeePayer?: {
|
|
81
|
-
address: string;
|
|
82
|
-
signTransaction: (dataToSign: Buffer) => Promise<Uint8Array>;
|
|
83
|
-
};
|
|
84
32
|
};
|
|
85
33
|
declare const executeRoute: (options: ExecuteRouteOptions) => Promise<void>;
|
|
86
34
|
|
|
@@ -92,8 +40,10 @@ type TransactionDetails = {
|
|
|
92
40
|
status?: TransactionStatus;
|
|
93
41
|
statusResponse?: TxStatusResponse;
|
|
94
42
|
explorerLink?: string;
|
|
43
|
+
routeKeyToStatus?: Record<string, TransactionStatus>;
|
|
44
|
+
routeKey?: string;
|
|
95
45
|
};
|
|
96
|
-
type SimpleRoute = Partial<Pick<Route, "amountIn" | "amountOut" | "sourceAssetDenom" | "sourceAssetChainId" | "destAssetDenom" | "destAssetChainId" | "estimatedRouteDurationSeconds">>;
|
|
46
|
+
type SimpleRoute = Partial<Pick<Route, "usdAmountIn" | "usdAmountOut" | "amountIn" | "amountOut" | "sourceAssetDenom" | "sourceAssetChainId" | "destAssetDenom" | "destAssetChainId" | "estimatedRouteDurationSeconds">>;
|
|
97
47
|
type RouteDetails = {
|
|
98
48
|
id: string;
|
|
99
49
|
timestamp: number;
|
|
@@ -104,14 +54,16 @@ type RouteDetails = {
|
|
|
104
54
|
transactionDetails: TransactionDetails[];
|
|
105
55
|
transferEvents: ClientTransferEvent[];
|
|
106
56
|
transferAssetRelease?: TransferAssetRelease;
|
|
107
|
-
|
|
108
|
-
|
|
57
|
+
transferIndexToRouteKey?: Record<number, string>;
|
|
58
|
+
mainRouteId?: string;
|
|
59
|
+
relatedRoutes?: Partial<RouteDetails>[];
|
|
60
|
+
routeKey?: string;
|
|
61
|
+
userAddresses: UserAddress[];
|
|
109
62
|
};
|
|
110
63
|
declare function getTransactionStatus(state?: TransactionState): TransactionStatus;
|
|
111
64
|
type subscribeToRouteStatusProps = {
|
|
112
|
-
routeDetails?: RouteDetails;
|
|
65
|
+
routeDetails?: RouteDetails | RouteDetails[];
|
|
113
66
|
onRouteStatusUpdated?: ExecuteRouteOptions["onRouteStatusUpdated"];
|
|
114
|
-
unsubscribe?: () => void;
|
|
115
67
|
};
|
|
116
68
|
type executeAndSubscribeToRouteStatusProps = {
|
|
117
69
|
routeDetails?: RouteDetails;
|
|
@@ -133,8 +85,11 @@ type updateRouteDetailsProps = {
|
|
|
133
85
|
options?: Partial<ExecuteRouteOptions>;
|
|
134
86
|
status?: RouteStatus;
|
|
135
87
|
routeId?: string;
|
|
88
|
+
mainRouteId?: string;
|
|
89
|
+
transferIndexToRouteKey?: Record<number, string>;
|
|
90
|
+
relatedRoutes?: Partial<RouteDetails>[];
|
|
136
91
|
};
|
|
137
|
-
declare const updateRouteDetails: ({ transactionDetails, routeDetails, options, status, routeId, }: updateRouteDetailsProps) => RouteDetails;
|
|
92
|
+
declare const updateRouteDetails: ({ transactionDetails, routeDetails, options, status, routeId, mainRouteId, transferIndexToRouteKey, relatedRoutes, }: updateRouteDetailsProps) => RouteDetails;
|
|
138
93
|
|
|
139
94
|
type CallbackStatus = "error" | "pending" | "completed";
|
|
140
95
|
type TransactionCallbacks = {
|
|
@@ -172,4 +127,4 @@ type TransactionCallbacks = {
|
|
|
172
127
|
}) => Promise<void>;
|
|
173
128
|
};
|
|
174
129
|
|
|
175
|
-
export { type ExecuteRouteOptions as E, type RouteDetails as R, type TransactionDetails as T, type RouteStatus as a, type
|
|
130
|
+
export { type ExecuteRouteOptions as E, type RouteDetails as R, type TransactionDetails as T, type RouteStatus as a, type TransactionStatus as b, type TransferEventStatus as c, type TransactionCallbacks as d, executeRoute as e, type subscribeToRouteStatusProps as f, getTransactionStatus as g, type executeAndSubscribeToRouteStatusProps as h, executeAndSubscribeToRouteStatus as i, subscribeToRouteStatus as s, updateRouteDetails as u };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createValidAddressList, executeTransactions } from './chunk-MTAS5XMN.js';
|
|
2
|
+
import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-VUXLWWLF.js';
|
|
3
|
+
import { messages } from './chunk-AND7HVIU.js';
|
|
4
|
+
import { ApiState } from './chunk-A6KSECAH.js';
|
|
5
|
+
|
|
6
|
+
// src/public-functions/executeRoute.ts
|
|
7
|
+
var executeRoute = async (options) => {
|
|
8
|
+
const { route, userAddresses, appendCosmosMsgs, timeoutSeconds } = options;
|
|
9
|
+
const { id: routeId } = updateRouteDetails({
|
|
10
|
+
status: "unconfirmed",
|
|
11
|
+
options
|
|
12
|
+
});
|
|
13
|
+
const addressList = await createValidAddressList({
|
|
14
|
+
userAddresses,
|
|
15
|
+
route
|
|
16
|
+
});
|
|
17
|
+
const response = await messages({
|
|
18
|
+
timeoutSeconds,
|
|
19
|
+
amountIn: route?.amountIn,
|
|
20
|
+
amountOut: route.estimatedAmountOut || "0",
|
|
21
|
+
sourceAssetChainId: route?.sourceAssetChainId,
|
|
22
|
+
sourceAssetDenom: route?.sourceAssetDenom,
|
|
23
|
+
destAssetChainId: route?.destAssetChainId,
|
|
24
|
+
destAssetDenom: route?.destAssetDenom,
|
|
25
|
+
operations: route?.operations,
|
|
26
|
+
addressList,
|
|
27
|
+
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
28
|
+
chainIdsToAffiliates: ApiState.chainIdsToAffiliates,
|
|
29
|
+
postRouteHandler: options.postRouteHandler,
|
|
30
|
+
feePayerAddress: options.svmFeePayer?.address
|
|
31
|
+
});
|
|
32
|
+
if (appendCosmosMsgs) {
|
|
33
|
+
Object.entries(appendCosmosMsgs).forEach(([chainId, msgs]) => {
|
|
34
|
+
const txIndex = response?.txs?.findIndex(
|
|
35
|
+
(tx2) => "cosmosTx" in tx2 && tx2.cosmosTx.chainId === chainId
|
|
36
|
+
);
|
|
37
|
+
if (txIndex === void 0 || txIndex === -1) return;
|
|
38
|
+
const tx = response?.txs?.[txIndex];
|
|
39
|
+
if (tx && "cosmosTx" in tx) {
|
|
40
|
+
tx.cosmosTx.msgs?.unshift(...msgs);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const { transactionDetails, executeTransaction } = await executeTransactions({ ...options, routeId, txs: response?.txs });
|
|
45
|
+
await executeAndSubscribeToRouteStatus({
|
|
46
|
+
transactionDetails,
|
|
47
|
+
executeTransaction,
|
|
48
|
+
routeId,
|
|
49
|
+
options
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { executeRoute };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createValidAddressList, executeTransactions } from './chunk-MTAS5XMN.js';
|
|
2
|
+
import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-VUXLWWLF.js';
|
|
3
|
+
import { messages } from './chunk-AND7HVIU.js';
|
|
4
|
+
import { trackTransaction } from './chunk-7X4ERB3R.js';
|
|
5
|
+
import { ApiState } from './chunk-A6KSECAH.js';
|
|
6
|
+
import 'uuid';
|
|
7
|
+
|
|
8
|
+
var executeMultipleRoutes = async (options) => {
|
|
9
|
+
const {
|
|
10
|
+
route,
|
|
11
|
+
userAddresses,
|
|
12
|
+
appendCosmosMsgs,
|
|
13
|
+
postRouteHandler,
|
|
14
|
+
slippageTolerancePercent,
|
|
15
|
+
...restOptions
|
|
16
|
+
} = options;
|
|
17
|
+
const addressList = {};
|
|
18
|
+
for (const [routeKey, routeValue] of Object.entries(route)) {
|
|
19
|
+
const _userAddresses = userAddresses[routeKey];
|
|
20
|
+
if (_userAddresses === void 0) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`executeMultipleRoutes error: no user addresses found for route: ${routeKey}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const routeAddressList = await createValidAddressList({
|
|
26
|
+
userAddresses: _userAddresses,
|
|
27
|
+
route: routeValue
|
|
28
|
+
});
|
|
29
|
+
addressList[routeKey] = routeAddressList;
|
|
30
|
+
}
|
|
31
|
+
const msgsResponses = await Promise.all(
|
|
32
|
+
Object.entries(route).map(async ([routeKey, routeValue]) => {
|
|
33
|
+
const routeAddressList = addressList[routeKey];
|
|
34
|
+
if (routeAddressList === void 0) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`executeMultipleRoutes error: address list not found for route ${routeKey}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return await messages({
|
|
40
|
+
timeoutSeconds: options.timeoutSeconds,
|
|
41
|
+
amountIn: routeValue?.amountIn,
|
|
42
|
+
amountOut: routeValue.estimatedAmountOut || "0",
|
|
43
|
+
sourceAssetChainId: routeValue?.sourceAssetChainId,
|
|
44
|
+
sourceAssetDenom: routeValue?.sourceAssetDenom,
|
|
45
|
+
destAssetChainId: routeValue?.destAssetChainId,
|
|
46
|
+
destAssetDenom: routeValue?.destAssetDenom,
|
|
47
|
+
operations: routeValue?.operations,
|
|
48
|
+
addressList: routeAddressList,
|
|
49
|
+
slippageTolerancePercent: slippageTolerancePercent?.[routeKey] || "1",
|
|
50
|
+
chainIdsToAffiliates: ApiState.chainIdsToAffiliates,
|
|
51
|
+
postRouteHandler: postRouteHandler?.[routeKey],
|
|
52
|
+
feePayerAddress: options.svmFeePayer?.address
|
|
53
|
+
});
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
let msgsRecord = {};
|
|
57
|
+
msgsResponses.forEach((msg, index2) => {
|
|
58
|
+
const routeKey = Object.keys(route)[index2];
|
|
59
|
+
if (!routeKey) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`executeMultipleRoutes error: route key not found for index ${index2}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const addedCosmosMsgs = appendCosmosMsgs?.[routeKey];
|
|
65
|
+
if (addedCosmosMsgs) {
|
|
66
|
+
Object.entries(addedCosmosMsgs).forEach(([chainId, msgs]) => {
|
|
67
|
+
const txIndex = msg?.txs?.findIndex(
|
|
68
|
+
(tx2) => "cosmosTx" in tx2 && tx2.cosmosTx.chainId === chainId
|
|
69
|
+
);
|
|
70
|
+
if (txIndex === void 0 || txIndex === -1) return;
|
|
71
|
+
const tx = msg?.txs?.[txIndex];
|
|
72
|
+
if (tx && "cosmosTx" in tx) {
|
|
73
|
+
tx.cosmosTx.msgs?.unshift(...msgs);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
msgsRecord[routeKey] = msg;
|
|
78
|
+
});
|
|
79
|
+
let transferIndexToRouteKey = void 0;
|
|
80
|
+
const cosmosTxIndex0Map = /* @__PURE__ */ new Map();
|
|
81
|
+
let transferIndex = 0;
|
|
82
|
+
for (const [routeKey, msgs] of Object.entries(msgsRecord)) {
|
|
83
|
+
const firstTx = msgs?.txs?.[0];
|
|
84
|
+
if (firstTx && "cosmosTx" in firstTx) {
|
|
85
|
+
const { chainId, msgs: firstTxMsgs } = firstTx.cosmosTx;
|
|
86
|
+
if (!transferIndexToRouteKey) {
|
|
87
|
+
transferIndexToRouteKey = {};
|
|
88
|
+
}
|
|
89
|
+
transferIndexToRouteKey[transferIndex] = routeKey;
|
|
90
|
+
transferIndex++;
|
|
91
|
+
if (!cosmosTxIndex0Map.has(chainId)) {
|
|
92
|
+
cosmosTxIndex0Map.set(chainId, {
|
|
93
|
+
routeKey,
|
|
94
|
+
firstCosmosTx: firstTx.cosmosTx
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
const existing = cosmosTxIndex0Map.get(chainId);
|
|
98
|
+
if (existing && firstTxMsgs) {
|
|
99
|
+
const modifyTarget = msgsRecord[existing.routeKey]?.txs?.[0];
|
|
100
|
+
if (modifyTarget && "cosmosTx" in modifyTarget) {
|
|
101
|
+
modifyTarget.cosmosTx.msgs?.push(...firstTxMsgs);
|
|
102
|
+
msgsRecord[routeKey]?.txs?.shift();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
Object.entries(msgsRecord).forEach(([routeKey, msgs]) => {
|
|
109
|
+
if (msgs?.txs?.length === 0) {
|
|
110
|
+
delete msgsRecord[routeKey];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
let mainRouteId = void 0;
|
|
114
|
+
let msgsRecordIndexToRouteId = {};
|
|
115
|
+
let index = 0;
|
|
116
|
+
const transactionDetailsList = {};
|
|
117
|
+
const executeTransactionList = {};
|
|
118
|
+
const mergedMainAndSecondaryRoutes = Object.entries(msgsRecord).length !== Object.entries(route).length;
|
|
119
|
+
for (const [routeKey, msgsResponse] of Object.entries(msgsRecord)) {
|
|
120
|
+
const { id: routeId } = updateRouteDetails({
|
|
121
|
+
status: "unconfirmed",
|
|
122
|
+
options: {
|
|
123
|
+
route: route[routeKey],
|
|
124
|
+
...restOptions
|
|
125
|
+
},
|
|
126
|
+
mainRouteId,
|
|
127
|
+
transferIndexToRouteKey
|
|
128
|
+
});
|
|
129
|
+
msgsRecordIndexToRouteId[index] = routeId;
|
|
130
|
+
if (routeKey === "mainRoute") {
|
|
131
|
+
mainRouteId = routeId;
|
|
132
|
+
}
|
|
133
|
+
const { transactionDetails, executeTransaction: _executeTransaction } = await executeTransactions({
|
|
134
|
+
...restOptions,
|
|
135
|
+
routeId,
|
|
136
|
+
txs: msgsResponse?.txs,
|
|
137
|
+
route: route[routeKey],
|
|
138
|
+
userAddresses: userAddresses[routeKey],
|
|
139
|
+
isMultiRoutes: true
|
|
140
|
+
});
|
|
141
|
+
const executeTransaction = async (index2) => {
|
|
142
|
+
const txResult = await _executeTransaction(index2);
|
|
143
|
+
if (routeKey !== "mainRoute" || mergedMainAndSecondaryRoutes) {
|
|
144
|
+
const relatedRoutes = Object.entries(route).filter(([key]) => key !== "mainRoute").map(([key, route2]) => ({ route: route2, routeKey: key, status: "pending" }));
|
|
145
|
+
updateRouteDetails({
|
|
146
|
+
options: {
|
|
147
|
+
route: route[routeKey],
|
|
148
|
+
...restOptions
|
|
149
|
+
},
|
|
150
|
+
routeId: mainRouteId,
|
|
151
|
+
transferIndexToRouteKey,
|
|
152
|
+
relatedRoutes
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return txResult;
|
|
156
|
+
};
|
|
157
|
+
if (transactionDetails[0]?.chainType === "evm" /* Evm */) {
|
|
158
|
+
for (const [index2, transactionDetail] of transactionDetails.entries()) {
|
|
159
|
+
const txResult = await executeTransaction(index2);
|
|
160
|
+
if (txResult.txHash) {
|
|
161
|
+
const trackResponse = await trackTransaction({
|
|
162
|
+
chainId: transactionDetail.chainId,
|
|
163
|
+
txHash: txResult.txHash,
|
|
164
|
+
...options.trackTxPollingOptions
|
|
165
|
+
});
|
|
166
|
+
await options?.onTransactionTracked?.({
|
|
167
|
+
txHash: txResult.txHash,
|
|
168
|
+
chainId: transactionDetail.chainId,
|
|
169
|
+
explorerLink: trackResponse.explorerLink
|
|
170
|
+
});
|
|
171
|
+
transactionDetail.txHash = txResult.txHash;
|
|
172
|
+
transactionDetail.explorerLink = trackResponse.explorerLink;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
executeTransactionList[index] = executeTransaction;
|
|
177
|
+
}
|
|
178
|
+
transactionDetailsList[index] = transactionDetails;
|
|
179
|
+
index++;
|
|
180
|
+
}
|
|
181
|
+
await Promise.all(
|
|
182
|
+
Object.entries(msgsRecord).map(([routeKey, msgsResponse], index2) => {
|
|
183
|
+
return executeAndSubscribeToRouteStatus({
|
|
184
|
+
transactionDetails: transactionDetailsList[index2],
|
|
185
|
+
executeTransaction: executeTransactionList[index2],
|
|
186
|
+
routeId: msgsRecordIndexToRouteId[index2],
|
|
187
|
+
options: {
|
|
188
|
+
route: route[routeKey],
|
|
189
|
+
userAddresses: userAddresses[routeKey],
|
|
190
|
+
...restOptions,
|
|
191
|
+
onRouteStatusUpdated: (routeStatus) => {
|
|
192
|
+
const relatedRoutes = Object.entries(route).filter(([key]) => key !== "mainRoute").map(([key, route2]) => ({ route: route2, routeKey: key, status: routeStatus.status }));
|
|
193
|
+
if (routeKey !== "mainRoute") {
|
|
194
|
+
updateRouteDetails({
|
|
195
|
+
options: {
|
|
196
|
+
route: route[routeKey],
|
|
197
|
+
...restOptions
|
|
198
|
+
},
|
|
199
|
+
routeId: mainRouteId,
|
|
200
|
+
transferIndexToRouteKey,
|
|
201
|
+
relatedRoutes
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
options.onRouteStatusUpdated?.(routeStatus);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export { executeMultipleRoutes };
|