@skip-go/client 1.3.7 → 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/api/getAssets.cjs +4 -4
- package/dist/cjs/api/getAssetsBetweenChains.cjs +3 -3
- package/dist/cjs/api/getBridges.cjs +3 -3
- package/dist/cjs/api/getChains.cjs +3 -3
- package/dist/cjs/api/getVenues.cjs +3 -3
- package/dist/cjs/api/postAssetsFromSource.cjs +4 -4
- package/dist/cjs/api/postBalances.cjs +3 -3
- package/dist/cjs/api/postIbcOriginAssets.cjs +3 -3
- package/dist/cjs/api/postMessages.cjs +3 -3
- package/dist/cjs/api/postMessagesDirect.cjs +3 -3
- package/dist/cjs/api/postRecommendAssets.cjs +3 -3
- package/dist/cjs/api/postRoute.cjs +3 -3
- package/dist/cjs/api/postSubmitTransaction.cjs +3 -3
- package/dist/cjs/api/postTrackTransaction.cjs +3 -3
- package/dist/cjs/api/postTransactionStatus.cjs +3 -3
- package/dist/cjs/{chunk-2EKCOIWV.cjs → chunk-23YF4LFI.cjs} +185 -154
- package/dist/cjs/chunk-3M7YYWGL.cjs +295 -0
- package/dist/cjs/chunk-4YTACAVP.cjs +185 -0
- package/dist/cjs/{chunk-MW3TE7DC.cjs → chunk-5AYPH3ZR.cjs} +2 -2
- package/dist/cjs/{chunk-2CCLIBCC.cjs → chunk-5HDKZVOL.cjs} +2 -2
- package/dist/cjs/{chunk-YYBGBKRE.cjs → chunk-A26H4FVN.cjs} +4 -4
- package/dist/cjs/{chunk-P7CDAHIX.cjs → chunk-AXYRULAI.cjs} +2 -2
- package/dist/cjs/{chunk-E2P5MVX3.cjs → chunk-CUDPMOR6.cjs} +16 -9
- package/dist/cjs/{chunk-WMXUOVHN.cjs → chunk-DWOE6N5S.cjs} +248 -532
- package/dist/cjs/{chunk-7I2KQNIU.cjs → chunk-EJMC4JXF.cjs} +2 -2
- package/dist/cjs/{chunk-HKQ5VION.cjs → chunk-ERGJBZUC.cjs} +5 -1
- package/dist/cjs/{chunk-J5RC6ZU5.cjs → chunk-FNB244QI.cjs} +6 -6
- package/dist/cjs/chunk-GCJO6DZD.cjs +55 -0
- package/dist/cjs/{chunk-OEYY7NXT.cjs → chunk-HHZGD62Y.cjs} +256 -168
- package/dist/cjs/{chunk-DBDB2XWX.cjs → chunk-JBKNEFXB.cjs} +3 -3
- package/dist/cjs/{chunk-AF7EI5BT.cjs → chunk-K4YAPDUE.cjs} +2 -2
- package/dist/cjs/{chunk-MN6HFZJA.cjs → chunk-KM2D7PJL.cjs} +33 -33
- package/dist/cjs/{chunk-XGBCEYWI.cjs → chunk-LHY62HPI.cjs} +2 -2
- package/dist/cjs/{chunk-EXK2GDR5.cjs → chunk-LUVMRHAJ.cjs} +2 -2
- package/dist/cjs/{chunk-QSISUSYP.cjs → chunk-N4UW74AG.cjs} +4 -4
- package/dist/cjs/{chunk-FY56EEFB.cjs → chunk-OZUCMWNE.cjs} +2 -2
- package/dist/cjs/{chunk-2VQ2TNFM.cjs → chunk-QPM7H2YL.cjs} +2 -2
- package/dist/cjs/{chunk-FO25SR66.cjs → chunk-RCGCQD6T.cjs} +6 -6
- package/dist/cjs/chunk-UIQML2XG.cjs +455 -0
- package/dist/cjs/chunk-VF65UG3E.cjs +214 -0
- package/dist/cjs/{chunk-VKVHMUDR.cjs → chunk-W3KF3V57.cjs} +6 -6
- package/dist/cjs/{chunk-YN66ABRQ.cjs → chunk-X22PL5T7.cjs} +126 -16
- package/dist/cjs/{chunk-DCFIIF7G.cjs → chunk-X5AJHZ2J.cjs} +2 -2
- package/dist/cjs/{chunk-MCZ3F457.cjs → chunk-ZBPDDVQ2.cjs} +2 -2
- package/dist/cjs/index.cjs +66 -54
- package/dist/cjs/public-functions/executeMultipleRoutes.cjs +29 -0
- package/dist/cjs/public-functions/executeRoute.cjs +17 -15
- package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +5 -4
- package/dist/cjs/public-functions/getFeeInfoForChain.cjs +5 -5
- package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +6 -6
- package/dist/cjs/public-functions/getSigningStargateClient.cjs +6 -5
- package/dist/cjs/public-functions/setApiOptions.cjs +3 -3
- package/dist/cjs/public-functions/setClientOptions.cjs +6 -5
- package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +26 -0
- package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +9 -8
- package/dist/cjs/public-functions/waitForTransaction.cjs +5 -5
- package/dist/esm/api/getAssets.js +2 -2
- package/dist/esm/api/getAssetsBetweenChains.js +2 -2
- package/dist/esm/api/getBridges.js +2 -2
- package/dist/esm/api/getChains.js +2 -2
- package/dist/esm/api/getVenues.js +2 -2
- package/dist/esm/api/postAssetsFromSource.js +3 -3
- package/dist/esm/api/postBalances.js +2 -2
- package/dist/esm/api/postIbcOriginAssets.js +2 -2
- package/dist/esm/api/postMessages.js +2 -2
- package/dist/esm/api/postMessagesDirect.js +2 -2
- package/dist/esm/api/postRecommendAssets.js +2 -2
- package/dist/esm/api/postRoute.js +2 -2
- package/dist/esm/api/postSubmitTransaction.js +2 -2
- package/dist/esm/api/postTrackTransaction.d.ts +2 -1
- package/dist/esm/api/postTrackTransaction.js +2 -2
- package/dist/esm/api/postTransactionStatus.d.ts +1 -1
- package/dist/esm/api/postTransactionStatus.js +2 -2
- package/dist/esm/callbacks-CvqAtBJq.d.ts +130 -0
- package/dist/esm/{chunk-SJP6W2SK.js → chunk-3XOGEVJL.js} +1 -1
- package/dist/esm/{chunk-JSY7M43P.js → chunk-52PEBJRQ.js} +1 -1
- package/dist/esm/chunk-7RS3YIVC.js +53 -0
- package/dist/esm/{chunk-7ITTEUMR.js → chunk-7X4ERB3R.js} +1 -1
- package/dist/esm/{chunk-LZI7A4JI.js → chunk-A6KSECAH.js} +5 -1
- package/dist/esm/{chunk-7LSTJXAF.js → chunk-AND7HVIU.js} +1 -1
- package/dist/esm/{chunk-MXCJ2M3K.js → chunk-APRMN34M.js} +1 -1
- package/dist/esm/chunk-AZALP3WR.js +212 -0
- package/dist/esm/{chunk-5JZOTYDC.js → chunk-CX5N7ZLJ.js} +1 -1
- package/dist/esm/{chunk-JYUNVL4F.js → chunk-FH2YHZVV.js} +1 -1
- package/dist/esm/chunk-IUYOY23L.js +180 -0
- package/dist/esm/{chunk-IQQDEBLI.js → chunk-JKN4E5VN.js} +11 -4
- package/dist/esm/{chunk-OHV2LZEG.js → chunk-JQ4F4WBG.js} +1 -1
- package/dist/esm/{chunk-5FKIW2ZL.js → chunk-KLGGCB73.js} +2 -2
- package/dist/esm/{chunk-P76IRSIS.js → chunk-KNXMSLOB.js} +2 -2
- package/dist/esm/{chunk-IWXRHEX4.js → chunk-LHNGF5J2.js} +2 -2
- package/dist/esm/{chunk-KJVD5P3Q.js → chunk-MPSXXWKL.js} +109 -3
- package/dist/esm/{chunk-FFFVITWF.js → chunk-MTAS5XMN.js} +219 -132
- package/dist/esm/{chunk-JIADJKRD.js → chunk-OTS5KO43.js} +1 -1
- package/dist/esm/{chunk-CU6W3622.js → chunk-QIS6ILPS.js} +3 -3
- package/dist/esm/chunk-QO2CYYF5.js +278 -0
- package/dist/esm/{chunk-XXTECZG3.js → chunk-S4RO2LHD.js} +1 -1
- package/dist/esm/{chunk-7YN3UVVF.js → chunk-UI3SIFZN.js} +1 -1
- package/dist/esm/{chunk-TD63P2AG.js → chunk-UIDIKXMB.js} +65 -340
- package/dist/esm/chunk-VUXLWWLF.js +450 -0
- package/dist/esm/{chunk-OL7CWCPB.js → chunk-WBZVMPPV.js} +34 -3
- package/dist/esm/{chunk-HT6O3BQ7.js → chunk-Y2YCODZK.js} +1 -1
- package/dist/esm/{chunk-IPHFFTGO.js → chunk-ZI3SYUQH.js} +1 -1
- package/dist/esm/{chunk-2L7PKZDY.js → chunk-ZOUYAZU6.js} +1 -1
- package/dist/esm/client-types-Dk6ypWdO.d.ts +114 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +29 -25
- 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 +7 -76
- package/dist/esm/public-functions/executeRoute.js +16 -14
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +3 -2
- package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +4 -1
- package/dist/esm/public-functions/getFeeInfoForChain.js +4 -4
- package/dist/esm/public-functions/getRecommendedGasPrice.js +5 -5
- package/dist/esm/public-functions/getSigningStargateClient.js +5 -4
- package/dist/esm/public-functions/setApiOptions.js +2 -2
- package/dist/esm/public-functions/setClientOptions.d.ts +4 -2
- package/dist/esm/public-functions/setClientOptions.js +5 -4
- package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +12 -0
- package/dist/esm/public-functions/subscribeToRouteStatus.js +5 -0
- package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +7 -5
- package/dist/esm/public-functions/validateCosmosGasBalance.js +8 -7
- package/dist/esm/public-functions/waitForTransaction.d.ts +6 -2
- package/dist/esm/public-functions/waitForTransaction.js +4 -4
- package/dist/esm/{setClientOptions-BTRwCbmt.d.ts → setClientOptions-BD8e7m2x.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/cjs/chunk-7H6XRQAX.cjs +0 -185
- package/dist/esm/callbacks-CuL50GnB.d.ts +0 -38
- package/dist/esm/chunk-U6AH2WOP.js +0 -180
- package/dist/esm/client-types-B7Fin0mq.d.ts +0 -61
|
@@ -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 };
|