@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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
-
import {
|
|
2
|
+
import { bE as ContentType, J as BridgeType } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
3
3
|
|
|
4
4
|
declare const bridges: (options?: ({
|
|
5
5
|
cache?: RequestCache | undefined;
|
|
6
6
|
credentials?: RequestCredentials | undefined;
|
|
7
|
-
headers?:
|
|
7
|
+
headers?: {
|
|
8
8
|
[x: string]: string;
|
|
9
|
-
} | {
|
|
9
|
+
} | string[][] | {
|
|
10
10
|
append: {};
|
|
11
11
|
delete: {};
|
|
12
12
|
get: {};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { c as Asset } from '../swaggerTypes-DDwqIjap.js';
|
|
2
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
+
import { ao as Reason, c as Asset } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
3
3
|
|
|
4
4
|
declare const assetsFromSource: (options?: ({
|
|
5
5
|
sourceAssetDenom: string;
|
|
6
6
|
sourceAssetChainId: string;
|
|
7
7
|
allowMultiTx?: boolean | undefined;
|
|
8
|
+
recommendationReason?: Reason | undefined;
|
|
9
|
+
includeSwaps?: boolean | undefined;
|
|
10
|
+
swapVenues?: {
|
|
11
|
+
chainId?: string | undefined;
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
logoUri?: string | undefined;
|
|
14
|
+
}[] | undefined;
|
|
15
|
+
nativeOnly?: boolean | undefined;
|
|
16
|
+
groupBy?: string | undefined;
|
|
8
17
|
includeCw20Assets?: boolean | undefined;
|
|
9
18
|
} & SkipApiOptions & {
|
|
10
19
|
abortDuplicateRequests?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
-
import { A as ApiRequest, a as ApiResponse } from '../generateApi-
|
|
3
|
-
import '../swaggerTypes-
|
|
2
|
+
import { A as ApiRequest, a as ApiResponse } from '../generateApi-CwM4Ca30.js';
|
|
3
|
+
import '../swaggerTypes-Bh6hu5Q-.js';
|
|
4
4
|
|
|
5
5
|
declare const balances: (options?: ({
|
|
6
6
|
chains?: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b3 as FeeType, J as BridgeType, b4 as FeeBehavior } from '../swaggerTypes-
|
|
1
|
+
import { b3 as FeeType, J as BridgeType, b4 as FeeBehavior } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
2
2
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
3
|
-
import { A as ApiRequest, a as ApiResponse } from '../generateApi-
|
|
3
|
+
import { A as ApiRequest, a as ApiResponse } from '../generateApi-CwM4Ca30.js';
|
|
4
4
|
|
|
5
5
|
declare const messages: (request: MessagesRequest) => Promise<{
|
|
6
6
|
msgs?: ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
-
import { f as AutopilotAction, J as BridgeType, ap as RoutePriceWarningType, b3 as FeeType, b4 as FeeBehavior } from '../swaggerTypes-
|
|
2
|
+
import { f as AutopilotAction, J as BridgeType, ap as RoutePriceWarningType, b3 as FeeType, b4 as FeeBehavior } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
3
3
|
|
|
4
4
|
declare const messagesDirect: (options?: ({
|
|
5
5
|
sourceAssetDenom?: string | undefined;
|
|
@@ -275,6 +275,8 @@ declare const messagesDirect: (options?: ({
|
|
|
275
275
|
bridgeId?: BridgeType | undefined;
|
|
276
276
|
denomIn?: string | undefined;
|
|
277
277
|
denomOut?: string | undefined;
|
|
278
|
+
sourceDomain?: string | undefined;
|
|
279
|
+
destinationDomain?: string | undefined;
|
|
278
280
|
fee?: {
|
|
279
281
|
feeAsset: {
|
|
280
282
|
chainId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { J as BridgeType, ap as RoutePriceWarningType, b3 as FeeType, b4 as FeeBehavior } from '../swaggerTypes-
|
|
1
|
+
import { J as BridgeType, ap as RoutePriceWarningType, b3 as FeeType, b4 as FeeBehavior } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
2
2
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
3
|
-
import { A as ApiRequest } from '../generateApi-
|
|
3
|
+
import { A as ApiRequest } from '../generateApi-CwM4Ca30.js';
|
|
4
4
|
|
|
5
5
|
declare const route: (request: RouteRequest) => Promise<{
|
|
6
6
|
amountIn: string;
|
|
@@ -163,6 +163,8 @@ declare const route: (request: RouteRequest) => Promise<{
|
|
|
163
163
|
bridgeId?: BridgeType | undefined;
|
|
164
164
|
denomIn?: string | undefined;
|
|
165
165
|
denomOut?: string | undefined;
|
|
166
|
+
sourceDomain?: string | undefined;
|
|
167
|
+
destinationDomain?: string | undefined;
|
|
166
168
|
fee?: {
|
|
167
169
|
feeAsset: {
|
|
168
170
|
chainId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
-
import { A as ApiRequest, a as ApiResponse } from '../generateApi-
|
|
3
|
-
import '../swaggerTypes-
|
|
2
|
+
import { A as ApiRequest, a as ApiResponse } from '../generateApi-CwM4Ca30.js';
|
|
3
|
+
import '../swaggerTypes-Bh6hu5Q-.js';
|
|
4
4
|
|
|
5
5
|
declare const submitTransaction: (options?: ({
|
|
6
6
|
tx?: string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
2
|
-
import { A as ApiRequest, P as PollingProps } from '../generateApi-
|
|
3
|
-
import '../swaggerTypes-
|
|
2
|
+
import { A as ApiRequest, P as PollingProps } from '../generateApi-CwM4Ca30.js';
|
|
3
|
+
import '../swaggerTypes-Bh6hu5Q-.js';
|
|
4
4
|
|
|
5
5
|
type TrackTxRequest = ApiRequest<"status"> & TrackTxPollingProps & SkipApiOptions;
|
|
6
6
|
type TrackTxPollingProps = Omit<PollingProps<"status">, "isSuccess" | "onError" | "onSuccess">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { av as StatusErrorType, aJ as TransactionState, al as PacketErrorType, aS as TransferState, k as AxelarTransferState, O as ContractCallWithTokenErrorType, as as SendTokenErrorType, l as AxelarTransferType, p as CCTPTransferState, a8 as HyperlaneTransferState, aO as OPInitTransferState, s as StargateTransferState, w as GoFastTransferState, aP as LayerZeroTransferState } from '../swaggerTypes-
|
|
2
|
-
import { a as ApiResponse } from '../generateApi-
|
|
1
|
+
import { av as StatusErrorType, aJ as TransactionState, al as PacketErrorType, aS as TransferState, k as AxelarTransferState, O as ContractCallWithTokenErrorType, as as SendTokenErrorType, l as AxelarTransferType, p as CCTPTransferState, a8 as HyperlaneTransferState, aO as OPInitTransferState, s as StargateTransferState, w as GoFastTransferState, aP as LayerZeroTransferState } from '../swaggerTypes-Bh6hu5Q-.js';
|
|
2
|
+
import { a as ApiResponse } from '../generateApi-CwM4Ca30.js';
|
|
3
3
|
import { S as SkipApiOptions } from '../apiState-DwZhwVul.js';
|
|
4
4
|
|
|
5
5
|
declare const transactionStatus: (params?: ({
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TxStatusResponse } from './api/postTransactionStatus.js';
|
|
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,
|
|
3
|
-
import { A as ApiRequest } from './generateApi-
|
|
4
|
-
import { S as SignerGetters, b as GasOptions, U as UserAddress, T as TxResult } from './client-types-
|
|
5
|
-
import { TrackTxPollingProps } from './api/postTrackTransaction.js';
|
|
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, bo 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-Bh6hu5Q-.js';
|
|
3
|
+
import { A as ApiRequest } from './generateApi-CwM4Ca30.js';
|
|
4
|
+
import { S as SignerGetters, b as GasOptions, B as BaseSettings, U as UserAddress, T as TxResult } from './client-types-BSZasIDd.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;
|
|
@@ -119,22 +71,23 @@ type executeAndSubscribeToRouteStatusProps = {
|
|
|
119
71
|
trackTxPollingOptions?: ExecuteRouteOptions["trackTxPollingOptions"];
|
|
120
72
|
onRouteStatusUpdated?: ExecuteRouteOptions["onRouteStatusUpdated"];
|
|
121
73
|
executeTransaction?: (index: number) => Promise<TxResult>;
|
|
122
|
-
onTransactionTracked?: ExecuteRouteOptions["onTransactionTracked"];
|
|
123
|
-
onTransactionCompleted?: ExecuteRouteOptions["onTransactionCompleted"];
|
|
124
74
|
options?: ExecuteRouteOptions;
|
|
125
75
|
routeId?: string;
|
|
126
76
|
isCancelled?: () => boolean;
|
|
127
77
|
};
|
|
128
78
|
declare const subscribeToRouteStatus: (props: subscribeToRouteStatusProps) => () => void;
|
|
129
|
-
declare const executeAndSubscribeToRouteStatus: ({ transactionDetails, executeTransaction, trackTxPollingOptions,
|
|
79
|
+
declare const executeAndSubscribeToRouteStatus: ({ transactionDetails, executeTransaction, trackTxPollingOptions, routeDetails, onRouteStatusUpdated, options, routeId, isCancelled, }: executeAndSubscribeToRouteStatusProps) => Promise<void>;
|
|
130
80
|
type updateRouteDetailsProps = {
|
|
131
81
|
routeDetails?: RouteDetails;
|
|
132
82
|
transactionDetails?: TransactionDetails[];
|
|
133
83
|
options?: Partial<ExecuteRouteOptions>;
|
|
134
84
|
status?: RouteStatus;
|
|
135
85
|
routeId?: string;
|
|
86
|
+
mainRouteId?: string;
|
|
87
|
+
transferIndexToRouteKey?: Record<number, string>;
|
|
88
|
+
relatedRoutes?: Partial<RouteDetails>[];
|
|
136
89
|
};
|
|
137
|
-
declare const updateRouteDetails: ({ transactionDetails, routeDetails, options, status, routeId, }: updateRouteDetailsProps) => RouteDetails;
|
|
90
|
+
declare const updateRouteDetails: ({ transactionDetails, routeDetails, options, status, routeId, mainRouteId, transferIndexToRouteKey, relatedRoutes, }: updateRouteDetailsProps) => RouteDetails;
|
|
138
91
|
|
|
139
92
|
type CallbackStatus = "error" | "pending" | "completed";
|
|
140
93
|
type TransactionCallbacks = {
|
|
@@ -172,4 +125,4 @@ type TransactionCallbacks = {
|
|
|
172
125
|
}) => Promise<void>;
|
|
173
126
|
};
|
|
174
127
|
|
|
175
|
-
export { type ExecuteRouteOptions as E, type RouteDetails as R, type TransactionDetails as T, type RouteStatus as a, type
|
|
128
|
+
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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_GAS_DENOM_OVERRIDES } from './chunk-SWYON2RG.js';
|
|
2
|
-
import { chains } from './chunk-
|
|
2
|
+
import { chains } from './chunk-RHGDUD76.js';
|
|
3
3
|
import { ClientState } from './chunk-ZOUYAZU6.js';
|
|
4
4
|
|
|
5
5
|
// src/private-functions/getDefaultGasTokenForChain.ts
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createValidAddressList, executeTransactions } from './chunk-W5EGS2G4.js';
|
|
2
|
+
import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-XYYXRVFN.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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { chains, findFirstWorkingEndpoint } from './chunk-3J6O2PVK.js';
|
|
2
1
|
import { BaseAccount as BaseAccount$1, isSet, bytesFromBase64, base64FromBytes } from './chunk-QO2CYYF5.js';
|
|
2
|
+
import { chains, findFirstWorkingEndpoint } from './chunk-RHGDUD76.js';
|
|
3
3
|
import { ClientState } from './chunk-ZOUYAZU6.js';
|
|
4
4
|
import { accountFromAny, SigningStargateClient } from '@cosmjs/stargate';
|
|
5
5
|
import { assertDefinedAndNotNull } from '@cosmjs/utils';
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createValidAddressList, executeTransactions } from './chunk-W5EGS2G4.js';
|
|
2
|
+
import { updateRouteDetails, executeAndSubscribeToRouteStatus } from './chunk-XYYXRVFN.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 };
|