@humanode-hyperlane/cli 1045.2.0 → 1045.2.2
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/bundle/230.index.js +262 -131
- package/bundle/308.index.js +2 -2
- package/bundle/546.index.js +1057 -0
- package/bundle/59.index.js +1368 -0
- package/bundle/655.index.js +361 -0
- package/bundle/748.index.js +2 -2
- package/bundle/index.js +2 -2
- package/package.json +6 -6
package/bundle/230.index.js
CHANGED
|
@@ -3,31 +3,33 @@ export const ids = [230];
|
|
|
3
3
|
export const modules = {
|
|
4
4
|
|
|
5
5
|
/***/ 65230:
|
|
6
|
-
/***/ ((
|
|
6
|
+
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
7
|
|
|
8
|
+
__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
8
9
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
10
|
/* harmony export */ LiFiBridge: () => (/* binding */ LiFiBridge)
|
|
10
11
|
/* harmony export */ });
|
|
11
|
-
/* harmony import */ var
|
|
12
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(38972);
|
|
12
13
|
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(88943);
|
|
13
|
-
/* harmony import */ var
|
|
14
|
-
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(16950);
|
|
14
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(91170);
|
|
15
15
|
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(89302);
|
|
16
|
-
/* harmony import */ var
|
|
17
|
-
/* harmony import */ var
|
|
18
|
-
/* harmony import */ var
|
|
16
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(68648);
|
|
17
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(83793);
|
|
18
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(38706);
|
|
19
19
|
/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(64537);
|
|
20
|
-
/* harmony import */ var
|
|
20
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16639);
|
|
21
21
|
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(93142);
|
|
22
|
-
/* harmony import */ var
|
|
22
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(21387);
|
|
23
23
|
/* harmony import */ var viem__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(27503);
|
|
24
24
|
/* harmony import */ var viem__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(20458);
|
|
25
|
-
/* harmony import */ var
|
|
26
|
-
/* harmony import */ var
|
|
27
|
-
/* harmony import */ var
|
|
28
|
-
/* harmony import */ var
|
|
29
|
-
/* harmony import */ var viem_chains__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(35540);
|
|
25
|
+
/* harmony import */ var viem_chains__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(55516);
|
|
26
|
+
/* harmony import */ var viem_chains__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(86296);
|
|
27
|
+
/* harmony import */ var viem_chains__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(70763);
|
|
28
|
+
/* harmony import */ var viem_chains__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(35540);
|
|
30
29
|
/* harmony import */ var _utils_solanaKeyParser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(97781);
|
|
30
|
+
/* harmony import */ var _lifiSubmission_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20363);
|
|
31
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_lifiSubmission_js__WEBPACK_IMPORTED_MODULE_2__]);
|
|
32
|
+
_lifiSubmission_js__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
|
|
@@ -37,7 +39,6 @@ export const modules = {
|
|
|
37
39
|
|
|
38
40
|
const TRAILING_ZEROES_REGEX = /\.?0+$/;
|
|
39
41
|
const API_KEY_REGEX = /apiKey=[^&]+/;
|
|
40
|
-
const TRANSACTION_LINK_REGEX = /\/tx\/([^/]+)/;
|
|
41
42
|
/**
|
|
42
43
|
* LiFi API base URL for REST endpoints.
|
|
43
44
|
* The SDK doesn't support toAmount quotes, so we use REST API directly.
|
|
@@ -48,10 +49,10 @@ const LIFI_API_BASE = 'https://li.quest/v1';
|
|
|
48
49
|
* TODO: can we think of a cleaner way to do this?
|
|
49
50
|
*/
|
|
50
51
|
const VIEM_CHAINS = {
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
54
|
-
[
|
|
52
|
+
[viem_chains__WEBPACK_IMPORTED_MODULE_3__/* .mainnet */ .r.id]: viem_chains__WEBPACK_IMPORTED_MODULE_3__/* .mainnet */ .r,
|
|
53
|
+
[viem_chains__WEBPACK_IMPORTED_MODULE_4__/* .arbitrum */ .D.id]: viem_chains__WEBPACK_IMPORTED_MODULE_4__/* .arbitrum */ .D,
|
|
54
|
+
[viem_chains__WEBPACK_IMPORTED_MODULE_5__/* .base */ .E.id]: viem_chains__WEBPACK_IMPORTED_MODULE_5__/* .base */ .E,
|
|
55
|
+
[viem_chains__WEBPACK_IMPORTED_MODULE_6__/* .optimism */ .R.id]: viem_chains__WEBPACK_IMPORTED_MODULE_6__/* .optimism */ .R,
|
|
55
56
|
};
|
|
56
57
|
/**
|
|
57
58
|
* Mapping from Hyperlane domain IDs to LiFi chain IDs for non-EVM chains.
|
|
@@ -140,7 +141,7 @@ class LiFiBridge {
|
|
|
140
141
|
const metadataByDomainId = new Map();
|
|
141
142
|
for (const metadata of Object.values(config.chainMetadata)) {
|
|
142
143
|
metadataByDomainId.set(metadata.domainId, metadata);
|
|
143
|
-
if (metadata.chainId !== undefined && (0,
|
|
144
|
+
if (metadata.chainId !== undefined && (0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .isEVMLike */ .Us)(metadata.protocol)) {
|
|
144
145
|
this.chainMetadataByChainId.set(Number(metadata.chainId), metadata);
|
|
145
146
|
}
|
|
146
147
|
}
|
|
@@ -160,7 +161,7 @@ class LiFiBridge {
|
|
|
160
161
|
initialize() {
|
|
161
162
|
if (this.initialized)
|
|
162
163
|
return;
|
|
163
|
-
(0,
|
|
164
|
+
(0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_8__/* .createConfig */ .Z)({
|
|
164
165
|
integrator: this.config.integrator,
|
|
165
166
|
apiKey: this.config.apiKey,
|
|
166
167
|
});
|
|
@@ -188,7 +189,7 @@ class LiFiBridge {
|
|
|
188
189
|
addressesEqual(a, b, chainId) {
|
|
189
190
|
const protocol = this.getProtocolTypeForChainId(chainId);
|
|
190
191
|
// Sealevel uses base58 addresses where case is significant.
|
|
191
|
-
if (protocol ===
|
|
192
|
+
if (protocol === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Sealevel) {
|
|
192
193
|
return a === b;
|
|
193
194
|
}
|
|
194
195
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -196,35 +197,30 @@ class LiFiBridge {
|
|
|
196
197
|
/**
|
|
197
198
|
* Configure the LiFi SDK provider for the route source protocol.
|
|
198
199
|
*/
|
|
199
|
-
configureLiFiProvider(protocol, key, fromChain, fromRpcUrl) {
|
|
200
|
+
configureLiFiProvider(protocol, key, fromChain, fromRpcUrl, submission, quote) {
|
|
200
201
|
const providers = [];
|
|
201
202
|
switch (protocol) {
|
|
202
|
-
case
|
|
203
|
-
const account =
|
|
203
|
+
case _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Ethereum: {
|
|
204
|
+
const account = submission.evmAccount((0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .ensure0x */ .Ho)(key));
|
|
204
205
|
const chain = getViemChain(fromChain, fromRpcUrl);
|
|
205
206
|
const walletClient = (0,viem__WEBPACK_IMPORTED_MODULE_10__/* .createWalletClient */ .F)({
|
|
206
207
|
account,
|
|
207
208
|
chain,
|
|
208
|
-
transport: (0,viem__WEBPACK_IMPORTED_MODULE_11__/* .http */ .L)(fromRpcUrl),
|
|
209
|
+
transport: submission.evmTransport((0,viem__WEBPACK_IMPORTED_MODULE_11__/* .http */ .L)(fromRpcUrl), fromChain, quote.requestParams.fromToken, quote.route.estimate.approvalAddress, quote.fromAmount),
|
|
209
210
|
});
|
|
210
211
|
providers.push((0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_12__/* .EVM */ .Z)({
|
|
211
212
|
getWalletClient: async () => walletClient,
|
|
212
213
|
switchChain: async (requiredChainId) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return (0,viem__WEBPACK_IMPORTED_MODULE_10__/* .createWalletClient */ .F)({
|
|
216
|
-
account,
|
|
217
|
-
chain: requiredChain,
|
|
218
|
-
transport: (0,viem__WEBPACK_IMPORTED_MODULE_11__/* .http */ .L)(switchRpcUrl),
|
|
219
|
-
});
|
|
214
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(requiredChainId === fromChain, 'LiFi cannot switch away from the source chain during execution');
|
|
215
|
+
return walletClient;
|
|
220
216
|
},
|
|
221
217
|
}));
|
|
222
218
|
break;
|
|
223
219
|
}
|
|
224
|
-
case
|
|
220
|
+
case _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Sealevel: {
|
|
225
221
|
const base58Key = toBase58SolanaKey(key);
|
|
226
|
-
providers.push((0,
|
|
227
|
-
getWalletAdapter: async () =>
|
|
222
|
+
providers.push((0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_14__/* .Solana */ .j)({
|
|
223
|
+
getWalletAdapter: async () => submission.solanaWallet(base58Key),
|
|
228
224
|
}));
|
|
229
225
|
break;
|
|
230
226
|
}
|
|
@@ -254,8 +250,8 @@ class LiFiBridge {
|
|
|
254
250
|
if (params.fromAmount === undefined && params.toAmount === undefined) {
|
|
255
251
|
throw new Error('Must specify either fromAmount or toAmount');
|
|
256
252
|
}
|
|
257
|
-
(0,
|
|
258
|
-
(0,
|
|
253
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(params.fromAmount === undefined || params.fromAmount > 0n, 'fromAmount must be positive');
|
|
254
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(params.toAmount === undefined || params.toAmount > 0n, 'toAmount must be positive');
|
|
259
255
|
// Dispatch to appropriate quote method
|
|
260
256
|
if (params.toAmount !== undefined) {
|
|
261
257
|
return this.quoteByReceivingAmount(params);
|
|
@@ -272,7 +268,7 @@ class LiFiBridge {
|
|
|
272
268
|
this.logger.debug({ params }, 'Requesting LiFi quote by spending amount');
|
|
273
269
|
const lifiFromChain = LiFiBridge.toLiFiChainId(params.fromChain);
|
|
274
270
|
const lifiToChain = LiFiBridge.toLiFiChainId(params.toChain);
|
|
275
|
-
const quote = await (0,
|
|
271
|
+
const quote = await (0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_16__/* .getQuote */ .fn)({
|
|
276
272
|
fromChain: lifiFromChain,
|
|
277
273
|
toChain: lifiToChain,
|
|
278
274
|
fromToken: params.fromToken,
|
|
@@ -405,91 +401,59 @@ class LiFiBridge {
|
|
|
405
401
|
* @param quote - Quote obtained from quote()
|
|
406
402
|
* @param privateKeys - Private keys keyed by protocol type for signing transactions
|
|
407
403
|
*/
|
|
408
|
-
async execute(quote, privateKeys) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
await prev;
|
|
433
|
-
let txHash;
|
|
434
|
-
let executedRoute;
|
|
435
|
-
try {
|
|
436
|
-
this.configureLiFiProvider(sourceProtocol, privateKeys[sourceProtocol], fromChain, fromRpcUrl);
|
|
437
|
-
// Execute route with update callbacks
|
|
438
|
-
executedRoute = await (0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_19__/* .executeRoute */ .Zk)(route, {
|
|
439
|
-
// Update callback for route progress
|
|
440
|
-
updateRouteHook: (updatedRoute) => {
|
|
441
|
-
this.logger.debug({ step: updatedRoute.steps[0]?.id }, 'Route step updated');
|
|
442
|
-
// Extract txHash from execution if available (RouteExtended has LiFiStepExtended with execution)
|
|
443
|
-
const execution = updatedRoute.steps[0]?.execution;
|
|
444
|
-
if (execution?.process) {
|
|
445
|
-
for (const process of execution.process) {
|
|
446
|
-
if (process.txHash) {
|
|
447
|
-
txHash = process.txHash;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
// Auto-accept rate updates for rebalancing
|
|
453
|
-
acceptExchangeRateUpdateHook: async () => true,
|
|
404
|
+
async execute(quote, privateKeys, options = {}) {
|
|
405
|
+
const submission = new _lifiSubmission_js__WEBPACK_IMPORTED_MODULE_2__/* .LiFiSubmission */ .d(options);
|
|
406
|
+
return submission.run(async () => {
|
|
407
|
+
this.initialize();
|
|
408
|
+
// Convert quote to route for execution
|
|
409
|
+
const route = (0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_17__/* .convertQuoteToRoute */ ._)(quote.route);
|
|
410
|
+
this.validateRouteAgainstRequest(route, quote.requestParams);
|
|
411
|
+
const fromChain = route.fromChainId;
|
|
412
|
+
const toChain = route.toChainId;
|
|
413
|
+
const fromProtocol = this.getProtocolTypeForChainId(fromChain);
|
|
414
|
+
const sourceProtocol = fromProtocol ?? _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Ethereum;
|
|
415
|
+
const sourceKey = privateKeys[sourceProtocol];
|
|
416
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(sourceKey, `Missing private key for source chain protocol ${sourceProtocol}`);
|
|
417
|
+
this.logger.info({
|
|
418
|
+
quoteId: quote.id,
|
|
419
|
+
tool: quote.tool,
|
|
420
|
+
fromChain,
|
|
421
|
+
toChain,
|
|
422
|
+
fromAmount: quote.fromAmount.toString(),
|
|
423
|
+
}, 'Executing LiFi bridge transfer');
|
|
424
|
+
const fromRpcUrl = this.getRpcUrlForChainId(fromChain);
|
|
425
|
+
let release;
|
|
426
|
+
const acquired = new Promise((resolve) => {
|
|
427
|
+
release = resolve;
|
|
454
428
|
});
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
429
|
+
const prev = this._executeLock;
|
|
430
|
+
this._executeLock = acquired;
|
|
431
|
+
await prev;
|
|
432
|
+
try {
|
|
433
|
+
this.configureLiFiProvider(sourceProtocol, sourceKey, fromChain, fromRpcUrl, submission, quote);
|
|
434
|
+
// Execute route with update callbacks
|
|
435
|
+
await (0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_18__/* .executeRoute */ .Zk)(route, {
|
|
436
|
+
disableMessageSigning: true,
|
|
437
|
+
// Update callback for route progress
|
|
438
|
+
updateRouteHook: (updatedRoute) => {
|
|
439
|
+
submission.observeRoute(updatedRoute);
|
|
440
|
+
this.logger.debug({ step: updatedRoute.steps[0]?.id }, 'Route step updated');
|
|
441
|
+
},
|
|
442
|
+
// A changed rate requires a new accepted quote before any source send.
|
|
443
|
+
acceptExchangeRateUpdateHook: async () => false,
|
|
444
|
+
});
|
|
469
445
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
throw new Error('No transaction hash found in executed route');
|
|
473
|
-
}
|
|
474
|
-
this.logger.info({ txHash, quoteId: quote.id }, 'LiFi bridge transaction executed');
|
|
475
|
-
// Extract transfer ID if available (some bridges provide this)
|
|
476
|
-
let transferId;
|
|
477
|
-
const processes = executedRoute.steps[0]?.execution?.process;
|
|
478
|
-
const txInfo = processes?.find((p) => p.txHash === txHash);
|
|
479
|
-
if (txInfo && 'lifiExplorerLink' in txInfo) {
|
|
480
|
-
// Extract transfer ID from explorer link if available
|
|
481
|
-
const link = txInfo.lifiExplorerLink;
|
|
482
|
-
const match = link?.match(TRANSACTION_LINK_REGEX);
|
|
483
|
-
if (match) {
|
|
484
|
-
transferId = match[1];
|
|
446
|
+
finally {
|
|
447
|
+
release();
|
|
485
448
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
449
|
+
const txHash = submission.requireSourceHash();
|
|
450
|
+
this.logger.info({ txHash, quoteId: quote.id }, 'LiFi bridge transaction executed');
|
|
451
|
+
return {
|
|
452
|
+
txHash,
|
|
453
|
+
fromChain,
|
|
454
|
+
toChain,
|
|
455
|
+
};
|
|
456
|
+
});
|
|
493
457
|
}
|
|
494
458
|
/**
|
|
495
459
|
* Validate that the route returned by LiFi matches the original request parameters.
|
|
@@ -500,22 +464,22 @@ class LiFiBridge {
|
|
|
500
464
|
* and route.steps[0].estimate.approvalAddress against a known whitelist.
|
|
501
465
|
*/
|
|
502
466
|
validateRouteAgainstRequest(route, requestParams) {
|
|
503
|
-
(0,
|
|
504
|
-
(0,
|
|
505
|
-
(0,
|
|
506
|
-
(0,
|
|
467
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(route.fromChainId === requestParams.fromChain, `Route fromChainId ${route.fromChainId} does not match requested ${requestParams.fromChain}`);
|
|
468
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(route.toChainId === requestParams.toChain, `Route toChainId ${route.toChainId} does not match requested ${requestParams.toChain}`);
|
|
469
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(this.addressesEqual(route.fromToken.address, requestParams.fromToken, route.fromChainId), `Route fromToken ${route.fromToken.address} does not match requested ${requestParams.fromToken}`);
|
|
470
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(this.addressesEqual(route.toToken.address, requestParams.toToken, route.toChainId), `Route toToken ${route.toToken.address} does not match requested ${requestParams.toToken}`);
|
|
507
471
|
const expectedToAddress = requestParams.toAddress ?? requestParams.fromAddress;
|
|
508
|
-
(0,
|
|
509
|
-
(0,
|
|
472
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(this.addressesEqual(route.toAddress ?? '', expectedToAddress, route.toChainId), `Route toAddress ${route.toAddress} does not match requested ${expectedToAddress}`);
|
|
473
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(this.addressesEqual(route.fromAddress ?? '', requestParams.fromAddress, route.fromChainId), `Route fromAddress ${route.fromAddress} does not match requested ${requestParams.fromAddress}`);
|
|
510
474
|
const routeFromAmount = BigInt(route.fromAmount);
|
|
511
475
|
if (requestParams.fromAmount !== undefined) {
|
|
512
|
-
(0,
|
|
476
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(routeFromAmount === requestParams.fromAmount, `Route fromAmount ${route.fromAmount} does not match requested ${requestParams.fromAmount}`);
|
|
513
477
|
}
|
|
514
478
|
if (requestParams.toAmount !== undefined) {
|
|
515
479
|
const routeToAmount = BigInt(route.toAmount);
|
|
516
|
-
(0,
|
|
480
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(routeToAmount >= requestParams.toAmount, `Route toAmount ${route.toAmount} is less than requested ${requestParams.toAmount}`);
|
|
517
481
|
}
|
|
518
|
-
(0,
|
|
482
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_13__/* .assert */ .v)(routeFromAmount > 0n, 'Route fromAmount must be positive');
|
|
519
483
|
}
|
|
520
484
|
/**
|
|
521
485
|
* Get the status of a bridge transfer.
|
|
@@ -524,7 +488,7 @@ class LiFiBridge {
|
|
|
524
488
|
async getStatus(txHash, fromChain, toChain) {
|
|
525
489
|
this.initialize();
|
|
526
490
|
try {
|
|
527
|
-
const status = await (0,
|
|
491
|
+
const status = await (0,_lifi_sdk__WEBPACK_IMPORTED_MODULE_16__/* .getStatus */ .BS)({
|
|
528
492
|
txHash,
|
|
529
493
|
fromChain: LiFiBridge.toLiFiChainId(fromChain),
|
|
530
494
|
toChain: LiFiBridge.toLiFiChainId(toChain),
|
|
@@ -566,6 +530,173 @@ class LiFiBridge {
|
|
|
566
530
|
}
|
|
567
531
|
}
|
|
568
532
|
//# sourceMappingURL=LiFiBridge.js.map
|
|
533
|
+
__webpack_async_result__();
|
|
534
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
535
|
+
|
|
536
|
+
/***/ }),
|
|
537
|
+
|
|
538
|
+
/***/ 20363:
|
|
539
|
+
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
540
|
+
|
|
541
|
+
__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
542
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
543
|
+
/* harmony export */ d: () => (/* binding */ LiFiSubmission)
|
|
544
|
+
/* harmony export */ });
|
|
545
|
+
/* harmony import */ var _lifi_sdk__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(16950);
|
|
546
|
+
/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(64537);
|
|
547
|
+
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(62418);
|
|
548
|
+
/* harmony import */ var viem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(83680);
|
|
549
|
+
/* harmony import */ var viem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(43469);
|
|
550
|
+
/* harmony import */ var viem_accounts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(67227);
|
|
551
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21387);
|
|
552
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(11666);
|
|
553
|
+
/* harmony import */ var _erc20Approve_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(51846);
|
|
554
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_erc20Approve_js__WEBPACK_IMPORTED_MODULE_1__]);
|
|
555
|
+
_erc20Approve_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
const approvalAbi = new ethers__WEBPACK_IMPORTED_MODULE_2__.ethers.utils.Interface([
|
|
564
|
+
'function approve(address spender, uint256 amount)',
|
|
565
|
+
]);
|
|
566
|
+
/** Observe the SDK's source transport; its route hooks run after confirmation. */
|
|
567
|
+
class LiFiSubmission {
|
|
568
|
+
options;
|
|
569
|
+
state = 'not_submitted';
|
|
570
|
+
approval;
|
|
571
|
+
confirmedApproval;
|
|
572
|
+
txHash;
|
|
573
|
+
constructor(options = {}) {
|
|
574
|
+
this.options = options;
|
|
575
|
+
}
|
|
576
|
+
/** Only transactions broadcast through our observed transport may authorize a transfer. */
|
|
577
|
+
evmAccount(key) {
|
|
578
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)((0,viem__WEBPACK_IMPORTED_MODULE_4__/* .isHex */ .q)(key) && key.length === 66, 'Invalid LiFi EVM private key');
|
|
579
|
+
const rejectAuthorization = async () => {
|
|
580
|
+
throw new Error('LiFi off-chain transfer authorization is unsupported');
|
|
581
|
+
};
|
|
582
|
+
return {
|
|
583
|
+
...(0,viem_accounts__WEBPACK_IMPORTED_MODULE_5__/* .privateKeyToAccount */ .R)(key),
|
|
584
|
+
signMessage: rejectAuthorization,
|
|
585
|
+
signTypedData: rejectAuthorization,
|
|
586
|
+
signAuthorization: rejectAuthorization,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
/** A completed SDK call without an observed identity cannot prove that nothing was sent. */
|
|
590
|
+
requireSourceHash() {
|
|
591
|
+
if (!this.txHash) {
|
|
592
|
+
this.state = 'unknown';
|
|
593
|
+
throw new Error('No observed source transaction hash in executed LiFi route');
|
|
594
|
+
}
|
|
595
|
+
return this.txHash;
|
|
596
|
+
}
|
|
597
|
+
async run(operation) {
|
|
598
|
+
try {
|
|
599
|
+
return await operation();
|
|
600
|
+
}
|
|
601
|
+
catch (error) {
|
|
602
|
+
if (this.state === 'not_submitted' && this.approval) {
|
|
603
|
+
throw new _erc20Approve_js__WEBPACK_IMPORTED_MODULE_1__/* .Erc20ApprovalError */ .Yn(error, 'unknown', this.approval.txHash, this.approval.token, this.approval.spender);
|
|
604
|
+
}
|
|
605
|
+
throw new _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_6__/* .TransactionSubmissionError */ .X(error, this.state, this.txHash);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
async attempt(hash) {
|
|
609
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(!this.txHash || this.txHash === hash, 'LiFi cannot submit a replacement or second source transaction');
|
|
610
|
+
await this.options.onSubmissionAttempt?.(hash);
|
|
611
|
+
this.txHash = hash;
|
|
612
|
+
this.state = 'unknown';
|
|
613
|
+
}
|
|
614
|
+
observeRoute(route) {
|
|
615
|
+
const processes = route.steps[0]?.execution?.process ?? [];
|
|
616
|
+
if (this.approval?.txHash &&
|
|
617
|
+
processes.some((process) => process.type === 'TOKEN_ALLOWANCE' &&
|
|
618
|
+
process.status === 'DONE' &&
|
|
619
|
+
process.chainId === route.fromChainId &&
|
|
620
|
+
process.txHash === this.approval?.txHash)) {
|
|
621
|
+
this.confirmedApproval = this.approval.txHash;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
evmTransport(transport, chainId, token, spender, maxAmount) {
|
|
625
|
+
return (parameters) => {
|
|
626
|
+
const base = transport(parameters);
|
|
627
|
+
return (0,viem__WEBPACK_IMPORTED_MODULE_7__/* .custom */ .I)({
|
|
628
|
+
request: async (request) => {
|
|
629
|
+
if (request.method !== 'eth_sendRawTransaction') {
|
|
630
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(!request.method.startsWith('eth_send') &&
|
|
631
|
+
!request.method.startsWith('eth_sign') &&
|
|
632
|
+
!request.method.startsWith('wallet_send') &&
|
|
633
|
+
!request.method.startsWith('wallet_sign') &&
|
|
634
|
+
request.method !== 'personal_sign', `LiFi unobserved authorization method is unsupported: ${request.method}`);
|
|
635
|
+
return base.request(request);
|
|
636
|
+
}
|
|
637
|
+
if (this.approval?.txHash &&
|
|
638
|
+
this.confirmedApproval === this.approval.txHash) {
|
|
639
|
+
await this.options.onApproval?.(undefined);
|
|
640
|
+
this.approval = undefined;
|
|
641
|
+
this.confirmedApproval = undefined;
|
|
642
|
+
}
|
|
643
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(Array.isArray(request.params) &&
|
|
644
|
+
request.params.length === 1 &&
|
|
645
|
+
typeof request.params[0] === 'string', 'LiFi raw transaction must be a single encoded string');
|
|
646
|
+
const raw = request.params[0];
|
|
647
|
+
const tx = ethers__WEBPACK_IMPORTED_MODULE_2__.ethers.utils.parseTransaction(raw);
|
|
648
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(tx.chainId === chainId, 'LiFi source transaction changed chain');
|
|
649
|
+
const hash = ethers__WEBPACK_IMPORTED_MODULE_2__.ethers.utils.keccak256(raw);
|
|
650
|
+
if (tx.data.startsWith(approvalAbi.getSighash('approve'))) {
|
|
651
|
+
const decoded = approvalAbi.decodeFunctionData('approve', tx.data);
|
|
652
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(tx.to?.toLowerCase() === token.toLowerCase() &&
|
|
653
|
+
spender?.toLowerCase() === decoded.spender.toLowerCase() &&
|
|
654
|
+
tx.value.isZero() &&
|
|
655
|
+
decoded.amount.toBigInt() <= maxAmount &&
|
|
656
|
+
approvalAbi.encodeFunctionData('approve', decoded) ===
|
|
657
|
+
tx.data, 'LiFi approval differs from accepted source allowance');
|
|
658
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(!this.txHash, 'LiFi approval after source submission is unsupported');
|
|
659
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(!this.approval || this.approval.txHash === hash, 'LiFi previous approval has not been reconciled');
|
|
660
|
+
const approval = { txHash: hash, token, spender };
|
|
661
|
+
await this.options.onApproval?.(approval);
|
|
662
|
+
this.approval = approval;
|
|
663
|
+
return base.request(request);
|
|
664
|
+
}
|
|
665
|
+
// LiFi waits for its approval receipt before submitting the source.
|
|
666
|
+
await this.options.onApproval?.(undefined);
|
|
667
|
+
this.approval = undefined;
|
|
668
|
+
await this.attempt(hash);
|
|
669
|
+
const result = await base.request(request);
|
|
670
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(String(result) === hash, 'LiFi RPC returned a different transaction hash');
|
|
671
|
+
this.state = 'submitted';
|
|
672
|
+
await this.options.onSubmitted?.(hash);
|
|
673
|
+
return result;
|
|
674
|
+
},
|
|
675
|
+
}, { retryCount: 0 })(parameters);
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
solanaWallet(key) {
|
|
679
|
+
const wallet = new _lifi_sdk__WEBPACK_IMPORTED_MODULE_8__/* .KeypairWalletAdapter */ .E(key);
|
|
680
|
+
const sign = wallet.signTransaction.bind(wallet);
|
|
681
|
+
wallet.signTransaction = async (transaction) => {
|
|
682
|
+
const signed = await sign(transaction);
|
|
683
|
+
const signature = 'version' in signed ? signed.signatures[0] : signed.signature;
|
|
684
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(signature, 'LiFi source transaction has no payer signature');
|
|
685
|
+
// The SDK owns the subsequent simulation/RPC. Handing it signed bytes
|
|
686
|
+
// exposes this identity even if it later hides the transport error.
|
|
687
|
+
await this.attempt(bs58__WEBPACK_IMPORTED_MODULE_0__["default"].encode(signature));
|
|
688
|
+
return signed;
|
|
689
|
+
};
|
|
690
|
+
wallet.signAllTransactions = async (transactions) => {
|
|
691
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(transactions.length === 1, 'LiFi multi-transaction Solana bundles are unsupported');
|
|
692
|
+
return [await wallet.signTransaction(transactions[0])];
|
|
693
|
+
};
|
|
694
|
+
return wallet;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
//# sourceMappingURL=lifiSubmission.js.map
|
|
698
|
+
__webpack_async_result__();
|
|
699
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
569
700
|
|
|
570
701
|
/***/ })
|
|
571
702
|
|
package/bundle/308.index.js
CHANGED
|
@@ -675,7 +675,7 @@ module.exports = { format, parse };
|
|
|
675
675
|
|
|
676
676
|
/***/ }),
|
|
677
677
|
|
|
678
|
-
/***/
|
|
678
|
+
/***/ 82051:
|
|
679
679
|
/***/ ((module) => {
|
|
680
680
|
|
|
681
681
|
|
|
@@ -745,7 +745,7 @@ module.exports = Limiter;
|
|
|
745
745
|
const zlib = __webpack_require__(43106);
|
|
746
746
|
|
|
747
747
|
const bufferUtil = __webpack_require__(16729);
|
|
748
|
-
const Limiter = __webpack_require__(
|
|
748
|
+
const Limiter = __webpack_require__(82051);
|
|
749
749
|
const { kStatusCode } = __webpack_require__(39557);
|
|
750
750
|
|
|
751
751
|
const FastBuffer = Buffer[Symbol.species];
|