@humanode-hyperlane/cli 1045.2.1 → 1045.2.3
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/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 +2 -2
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
export const id = 655;
|
|
2
|
+
export const ids = [655];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 57655:
|
|
6
|
+
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
9
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
10
|
+
/* harmony export */ LayerZeroBridge: () => (/* binding */ LayerZeroBridge)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(62418);
|
|
13
|
+
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5884);
|
|
14
|
+
/* harmony import */ var _humanode_hyperlane_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8441);
|
|
15
|
+
/* harmony import */ var _humanode_hyperlane_sdk__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1430);
|
|
16
|
+
/* harmony import */ var _humanode_hyperlane_sdk__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(74728);
|
|
17
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(21387);
|
|
18
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16639);
|
|
19
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(11666);
|
|
20
|
+
/* harmony import */ var _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(93142);
|
|
21
|
+
/* harmony import */ var _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(61151);
|
|
22
|
+
/* harmony import */ var _erc20Approve_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(51846);
|
|
23
|
+
/* harmony import */ var _OftSettlementVerifier_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(17147);
|
|
24
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_erc20Approve_js__WEBPACK_IMPORTED_MODULE_2__, _OftSettlementVerifier_js__WEBPACK_IMPORTED_MODULE_3__]);
|
|
25
|
+
([_erc20Approve_js__WEBPACK_IMPORTED_MODULE_2__, _OftSettlementVerifier_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const LAYERZERO_TOOL = 'layerzero';
|
|
35
|
+
const MAX_QUOTE_ATTEMPTS = 8;
|
|
36
|
+
const BASIS_POINTS_DENOMINATOR = 10000n;
|
|
37
|
+
const DEFAULT_MAX_FEE_BPS = 50;
|
|
38
|
+
const DEFAULT_MAX_EVM_NATIVE_VALUE_WEI = 10000000000000000n;
|
|
39
|
+
const DEFAULT_MAX_TRON_NATIVE_VALUE_SUN = 20000000n;
|
|
40
|
+
const TransferIdentitySchema = zod__WEBPACK_IMPORTED_MODULE_4__/* .object */ .Ik({
|
|
41
|
+
warpRouteId: zod__WEBPACK_IMPORTED_MODULE_4__/* .string */ .Yj(),
|
|
42
|
+
fromChain: zod__WEBPACK_IMPORTED_MODULE_4__/* .number */ .ai(),
|
|
43
|
+
toChain: zod__WEBPACK_IMPORTED_MODULE_4__/* .number */ .ai(),
|
|
44
|
+
sourceEid: zod__WEBPACK_IMPORTED_MODULE_4__/* .number */ .ai().int().positive(),
|
|
45
|
+
destinationEid: zod__WEBPACK_IMPORTED_MODULE_4__/* .number */ .ai().int().positive(),
|
|
46
|
+
sourceOft: zod__WEBPACK_IMPORTED_MODULE_4__/* .string */ .Yj(),
|
|
47
|
+
destinationOft: zod__WEBPACK_IMPORTED_MODULE_4__/* .string */ .Yj(),
|
|
48
|
+
destinationRecipient: zod__WEBPACK_IMPORTED_MODULE_4__/* .string */ .Yj(),
|
|
49
|
+
minimumDestinationAmount: zod__WEBPACK_IMPORTED_MODULE_4__/* .string */ .Yj().regex(/^\d+$/),
|
|
50
|
+
});
|
|
51
|
+
class LayerZeroBridge {
|
|
52
|
+
config;
|
|
53
|
+
externalBridgeId = LAYERZERO_TOOL;
|
|
54
|
+
logger;
|
|
55
|
+
metadataByChainId = new Map();
|
|
56
|
+
maxFeeBps;
|
|
57
|
+
maxEvmNativeValueWei;
|
|
58
|
+
maxTronNativeValueSun;
|
|
59
|
+
settlement;
|
|
60
|
+
constructor(config, logger) {
|
|
61
|
+
this.config = config;
|
|
62
|
+
this.logger = logger;
|
|
63
|
+
this.settlement = new _OftSettlementVerifier_js__WEBPACK_IMPORTED_MODULE_3__/* .OftSettlementVerifier */ .j({ logger });
|
|
64
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(config.warpRoutes.length > 0, 'At least one OFT warp route is required');
|
|
65
|
+
this.maxFeeBps = config.maxFeeBps ?? DEFAULT_MAX_FEE_BPS;
|
|
66
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(Number.isInteger(this.maxFeeBps) &&
|
|
67
|
+
this.maxFeeBps >= 0 &&
|
|
68
|
+
this.maxFeeBps <= Number(BASIS_POINTS_DENOMINATOR), 'maxFeeBps must be an integer between 0 and 10000');
|
|
69
|
+
this.maxEvmNativeValueWei =
|
|
70
|
+
config.maxEvmNativeValueWei ?? DEFAULT_MAX_EVM_NATIVE_VALUE_WEI;
|
|
71
|
+
this.maxTronNativeValueSun =
|
|
72
|
+
config.maxTronNativeValueSun ?? DEFAULT_MAX_TRON_NATIVE_VALUE_SUN;
|
|
73
|
+
for (const metadata of Object.values(config.chainMetadata)) {
|
|
74
|
+
if (metadata.chainId === undefined ||
|
|
75
|
+
metadata.availability?.status === _humanode_hyperlane_sdk__WEBPACK_IMPORTED_MODULE_6__/* .ChainStatus */ .AT.Disabled ||
|
|
76
|
+
(metadata.protocol !== _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Ethereum &&
|
|
77
|
+
metadata.protocol !== _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Tron)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const chainId = Number(metadata.chainId);
|
|
81
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(Number.isSafeInteger(chainId), `Invalid chain ID for ${metadata.name}`);
|
|
82
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(!this.metadataByChainId.has(chainId), `Duplicate chain metadata for chain ID ${chainId}`);
|
|
83
|
+
this.metadataByChainId.set(chainId, metadata);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async quote(params) {
|
|
87
|
+
this.validateQuoteParams(params);
|
|
88
|
+
const targetAmount = params.toAmount ?? params.fromAmount;
|
|
89
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(targetAmount !== undefined, 'Missing OFT transfer amount');
|
|
90
|
+
let quoted = await this.quoteDestinationAmount(params, targetAmount);
|
|
91
|
+
if (params.fromAmount !== undefined) {
|
|
92
|
+
for (let attempt = 0; quoted.grossAmount > params.fromAmount && attempt < MAX_QUOTE_ATTEMPTS; attempt++) {
|
|
93
|
+
const excess = quoted.grossAmount - params.fromAmount;
|
|
94
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(quoted.amount > excess, 'OFT fee consumes the entire source amount');
|
|
95
|
+
quoted = await this.quoteDestinationAmount(params, quoted.amount - excess);
|
|
96
|
+
}
|
|
97
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(quoted.grossAmount <= params.fromAmount, 'Unable to derive an OFT transfer within the source amount');
|
|
98
|
+
}
|
|
99
|
+
return this.toBridgeQuote(params, quoted);
|
|
100
|
+
}
|
|
101
|
+
execute(quote, privateKeys, options) {
|
|
102
|
+
return new _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_8__/* .TransactionSubmission */ .P(options).run((observers) => this.executeTransfer(quote, privateKeys, { ...options, ...observers }));
|
|
103
|
+
}
|
|
104
|
+
async executeTransfer(quote, privateKeys, options) {
|
|
105
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(quote.tool === LAYERZERO_TOOL, 'Quote was not created by LayerZero');
|
|
106
|
+
const params = quote.requestParams;
|
|
107
|
+
const route = this.resolveRoute(params.fromChain, params.toChain, quote.route.warpRouteId);
|
|
108
|
+
const protocol = this.protocol(route.sourceMetadata);
|
|
109
|
+
const privateKey = privateKeys[protocol];
|
|
110
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(privateKey, `Missing private key for ${protocol} chain`);
|
|
111
|
+
const wallet = this.wallet(protocol, privateKey, route.sourceMetadata);
|
|
112
|
+
const sender = await wallet.getAddress();
|
|
113
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .eqAddress */ .fv)(evmAddress(sender), evmAddress(params.fromAddress)), `${protocol} private key does not match inventory signer`);
|
|
114
|
+
const refreshed = await this.quoteDestinationAmount(params, quote.toAmount);
|
|
115
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(refreshed.route.warpRouteId === quote.route.warpRouteId, 'OFT route changed during execution');
|
|
116
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(refreshed.grossAmount <= quote.fromAmount, 'OFT input increased after the accepted quote');
|
|
117
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(refreshed.nativeFee <= quote.route.nativeFee, 'OFT native fee increased after the accepted quote');
|
|
118
|
+
// Persist the expected beneficiary and amount before any source submission.
|
|
119
|
+
// An ambiguous broadcast must remain verifiable without execute() returning.
|
|
120
|
+
const sourceContract = this.contract(route.source.addressOrDenom, this.provider(route.sourceMetadata));
|
|
121
|
+
const destinationContract = this.contract(route.destination.addressOrDenom, this.provider(route.destinationMetadata));
|
|
122
|
+
const [sourceOft, destinationOft, sourceEid, destinationEid] = await Promise.all([
|
|
123
|
+
sourceContract.oft(),
|
|
124
|
+
destinationContract.oft(),
|
|
125
|
+
destinationContract.hyperlaneDomainToLzEid(Number(route.sourceMetadata.domainId)),
|
|
126
|
+
sourceContract.hyperlaneDomainToLzEid(Number(route.destinationMetadata.domainId)),
|
|
127
|
+
]);
|
|
128
|
+
const transferId = JSON.stringify({
|
|
129
|
+
warpRouteId: route.warpRouteId,
|
|
130
|
+
fromChain: params.fromChain,
|
|
131
|
+
toChain: params.toChain,
|
|
132
|
+
sourceEid,
|
|
133
|
+
destinationEid,
|
|
134
|
+
sourceOft: evmAddress(sourceOft),
|
|
135
|
+
destinationOft: evmAddress(destinationOft),
|
|
136
|
+
destinationRecipient: evmAddress(params.toAddress ?? params.fromAddress),
|
|
137
|
+
minimumDestinationAmount: quote.toAmountMin.toString(),
|
|
138
|
+
});
|
|
139
|
+
await options?.onTransferId?.(transferId);
|
|
140
|
+
await (0,_erc20Approve_js__WEBPACK_IMPORTED_MODULE_2__/* .approveErc20IfNeeded */ .Cp)(wallet, refreshed.token, route.source.addressOrDenom, refreshed.grossAmount, this.logger, { onApproval: options?.onApproval });
|
|
141
|
+
const contract = this.contract(route.source.addressOrDenom, wallet);
|
|
142
|
+
const request = await contract.populateTransaction.transferRemote(Number(route.destinationMetadata.domainId), refreshed.recipient, refreshed.amount, { value: refreshed.nativeFee });
|
|
143
|
+
await wallet.estimateGas(request);
|
|
144
|
+
const response = await (0,_humanode_hyperlane_sdk__WEBPACK_IMPORTED_MODULE_10__/* .submitEvmLikeTransaction */ .k)(wallet, request, options);
|
|
145
|
+
return {
|
|
146
|
+
txHash: response.hash,
|
|
147
|
+
fromChain: params.fromChain,
|
|
148
|
+
toChain: params.toChain,
|
|
149
|
+
transferId,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async getStatus(txHash, fromChain, toChain, transferId) {
|
|
153
|
+
// Old/missing identities cannot establish the accepted recipient. Never
|
|
154
|
+
// turn an unbound API result into permission to spend inventory again.
|
|
155
|
+
if (!transferId)
|
|
156
|
+
return { status: 'pending', substatus: 'IDENTITY_MISSING' };
|
|
157
|
+
try {
|
|
158
|
+
const identity = TransferIdentitySchema.parse(JSON.parse(transferId));
|
|
159
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(identity.fromChain === fromChain && identity.toChain === toChain, 'LayerZero settlement chain mismatch');
|
|
160
|
+
const route = this.resolveRoute(fromChain, toChain, identity.warpRouteId);
|
|
161
|
+
const sourceProvider = this.provider(route.sourceMetadata);
|
|
162
|
+
const sourceReceipt = await sourceProvider.getTransactionReceipt((0,_OftSettlementVerifier_js__WEBPACK_IMPORTED_MODULE_3__/* .normalizeTxHash */ .O)(txHash));
|
|
163
|
+
if (!sourceReceipt || sourceReceipt.status !== 1) {
|
|
164
|
+
return { status: 'pending', substatus: 'SOURCE_RECEIPT_UNVERIFIED' };
|
|
165
|
+
}
|
|
166
|
+
if (sourceProvider instanceof _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__/* .TronJsonRpcProvider */ .yb &&
|
|
167
|
+
sourceReceipt.blockNumber >
|
|
168
|
+
(await sourceProvider.getFinalizedBlockNumber())) {
|
|
169
|
+
return { status: 'pending', substatus: 'SOURCE_NOT_FINAL' };
|
|
170
|
+
}
|
|
171
|
+
const blocks = route.sourceMetadata.blocks;
|
|
172
|
+
if (sourceReceipt.confirmations < (blocks?.confirmations ?? 1)) {
|
|
173
|
+
return { status: 'pending', substatus: 'SOURCE_NOT_FINAL' };
|
|
174
|
+
}
|
|
175
|
+
const reorgPeriod = blocks?.reorgPeriod ?? 32;
|
|
176
|
+
if (typeof reorgPeriod === 'number') {
|
|
177
|
+
if (sourceReceipt.confirmations <= reorgPeriod) {
|
|
178
|
+
return { status: 'pending', substatus: 'SOURCE_NOT_FINAL' };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (!(sourceProvider instanceof _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__/* .TronJsonRpcProvider */ .yb)) {
|
|
182
|
+
const finalized = await sourceProvider.getBlock(reorgPeriod);
|
|
183
|
+
if (!finalized || sourceReceipt.blockNumber > finalized.number) {
|
|
184
|
+
return { status: 'pending', substatus: 'SOURCE_NOT_FINAL' };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const ref = await this.settlement.initFromReceipt({
|
|
188
|
+
...identity,
|
|
189
|
+
destination: route.destinationMetadata.name,
|
|
190
|
+
destinationDomain: Number(route.destinationMetadata.domainId),
|
|
191
|
+
bridge: evmAddress(route.source.addressOrDenom),
|
|
192
|
+
sourceTokenDecimals: route.source.decimals,
|
|
193
|
+
destinationTokenDecimals: route.destination.decimals,
|
|
194
|
+
minimumDestinationAmount: BigInt(identity.minimumDestinationAmount),
|
|
195
|
+
receipt: sourceReceipt,
|
|
196
|
+
});
|
|
197
|
+
const provider = this.provider(route.destinationMetadata);
|
|
198
|
+
const destinationBlocks = route.destinationMetadata.blocks;
|
|
199
|
+
const destinationReorgPeriod = destinationBlocks?.reorgPeriod ?? 32;
|
|
200
|
+
const blockTag = typeof destinationReorgPeriod === 'number'
|
|
201
|
+
? Math.max(0, (await provider.getBlockNumber()) - destinationReorgPeriod)
|
|
202
|
+
: provider instanceof _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__/* .TronJsonRpcProvider */ .yb
|
|
203
|
+
? await provider.getFinalizedBlockNumber()
|
|
204
|
+
: (await provider.getBlock(destinationReorgPeriod))?.number;
|
|
205
|
+
if (blockTag === undefined)
|
|
206
|
+
return { status: 'pending', substatus: 'DESTINATION_NOT_FINAL' };
|
|
207
|
+
const status = await this.settlement.pollStatus(ref, {
|
|
208
|
+
provider,
|
|
209
|
+
blocks: destinationBlocks,
|
|
210
|
+
blockTag,
|
|
211
|
+
});
|
|
212
|
+
if (status.status === 'complete') {
|
|
213
|
+
const amount = status.ref.data.amountReceivedLD;
|
|
214
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(typeof amount === 'string', 'Verified OFT amount missing');
|
|
215
|
+
return {
|
|
216
|
+
status: 'complete',
|
|
217
|
+
receivingTxHash: status.receivingTxHash,
|
|
218
|
+
receivedAmount: BigInt(amount),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return { status: 'pending', substatus: status.substatus };
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
this.logger.warn({ txHash, fromChain, toChain, error }, 'LayerZero settlement remains unverified');
|
|
225
|
+
return { status: 'pending', substatus: 'SETTLEMENT_UNVERIFIED' };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async quoteDestinationAmount(params, amount) {
|
|
229
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(amount > 0n, 'OFT transfer amount must be positive');
|
|
230
|
+
const route = this.resolveRoute(params.fromChain, params.toChain);
|
|
231
|
+
const recipient = this.recipientBytes32(params.toAddress ?? params.fromAddress);
|
|
232
|
+
const sourceContract = this.contract(route.source.addressOrDenom, this.provider(route.sourceMetadata));
|
|
233
|
+
const destinationContract = this.contract(route.destination.addressOrDenom, this.provider(route.destinationMetadata));
|
|
234
|
+
const [sourceToken, destinationToken, quotes] = await Promise.all([
|
|
235
|
+
sourceContract.token(),
|
|
236
|
+
destinationContract.token(),
|
|
237
|
+
sourceContract.quoteTransferRemote(Number(route.destinationMetadata.domainId), recipient, amount),
|
|
238
|
+
]);
|
|
239
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .eqAddress */ .fv)(evmAddress(sourceToken), evmAddress(params.fromToken)), `OFT source token mismatch: ${sourceToken}`);
|
|
240
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .eqAddress */ .fv)(evmAddress(destinationToken), evmAddress(params.toToken)), `OFT destination token mismatch: ${destinationToken}`);
|
|
241
|
+
const nativeQuotes = quotes.filter((quote) => quote.token === ethers__WEBPACK_IMPORTED_MODULE_11__.ethers.constants.AddressZero);
|
|
242
|
+
const tokenQuotes = quotes.filter((quote) => quote.token !== ethers__WEBPACK_IMPORTED_MODULE_11__.ethers.constants.AddressZero &&
|
|
243
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .eqAddress */ .fv)(evmAddress(quote.token), evmAddress(sourceToken)));
|
|
244
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(nativeQuotes.length === 1 && tokenQuotes.length === 1, 'OFT quote must contain one native fee and one source-token amount');
|
|
245
|
+
const nativeFee = BigInt(nativeQuotes[0].amount.toString());
|
|
246
|
+
const grossAmount = BigInt(tokenQuotes[0].amount.toString());
|
|
247
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(grossAmount >= amount, 'OFT gross amount is below destination amount');
|
|
248
|
+
this.assertCosts(route, amount, grossAmount, nativeFee);
|
|
249
|
+
return {
|
|
250
|
+
route,
|
|
251
|
+
recipient,
|
|
252
|
+
amount,
|
|
253
|
+
grossAmount,
|
|
254
|
+
nativeFee,
|
|
255
|
+
token: sourceToken,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
toBridgeQuote(params, quoted) {
|
|
259
|
+
return {
|
|
260
|
+
id: crypto.randomUUID(),
|
|
261
|
+
tool: LAYERZERO_TOOL,
|
|
262
|
+
fromAmount: quoted.grossAmount,
|
|
263
|
+
toAmount: quoted.amount,
|
|
264
|
+
toAmountMin: quoted.amount,
|
|
265
|
+
executionDuration: 120,
|
|
266
|
+
gasCosts: quoted.nativeFee,
|
|
267
|
+
feeCosts: quoted.grossAmount - quoted.amount,
|
|
268
|
+
route: {
|
|
269
|
+
warpRouteId: quoted.route.warpRouteId,
|
|
270
|
+
sourceAdapter: quoted.route.source.addressOrDenom,
|
|
271
|
+
destinationAdapter: quoted.route.destination.addressOrDenom,
|
|
272
|
+
destinationDomain: Number(quoted.route.destinationMetadata.domainId),
|
|
273
|
+
recipient: quoted.recipient,
|
|
274
|
+
amount: quoted.amount,
|
|
275
|
+
nativeFee: quoted.nativeFee,
|
|
276
|
+
},
|
|
277
|
+
requestParams: { ...params },
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
resolveRoute(fromChain, toChain, warpRouteId) {
|
|
281
|
+
const sourceMetadata = this.metadataByChainId.get(fromChain);
|
|
282
|
+
const destinationMetadata = this.metadataByChainId.get(toChain);
|
|
283
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(sourceMetadata, `Missing metadata for source chain ${fromChain}`);
|
|
284
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(destinationMetadata, `Missing metadata for destination chain ${toChain}`);
|
|
285
|
+
this.protocol(sourceMetadata);
|
|
286
|
+
this.protocol(destinationMetadata);
|
|
287
|
+
for (const route of this.config.warpRoutes) {
|
|
288
|
+
if (warpRouteId && route.id !== warpRouteId)
|
|
289
|
+
continue;
|
|
290
|
+
const source = route.config.tokens.find((token) => token.chainName === sourceMetadata.name);
|
|
291
|
+
const destination = route.config.tokens.find((token) => token.chainName === destinationMetadata.name);
|
|
292
|
+
if (!source || !destination)
|
|
293
|
+
continue;
|
|
294
|
+
const connected = source.connections?.some((connection) => connection.token.split('|')[1] === destination.chainName);
|
|
295
|
+
if (!connected)
|
|
296
|
+
continue;
|
|
297
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(source.tokenType === 'collateralOft' &&
|
|
298
|
+
destination.tokenType === 'collateralOft', `Warp route ${route.id} is not an OFT adapter route`);
|
|
299
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(source.decimals === destination.decimals, `OFT inventory route ${route.id} requires equal local token decimals`);
|
|
300
|
+
return {
|
|
301
|
+
warpRouteId: route.id,
|
|
302
|
+
source,
|
|
303
|
+
destination,
|
|
304
|
+
sourceMetadata,
|
|
305
|
+
destinationMetadata,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
throw new Error(`No configured OFT route supports ${sourceMetadata.name} -> ${destinationMetadata.name}`);
|
|
309
|
+
}
|
|
310
|
+
validateQuoteParams(params) {
|
|
311
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(params.fromChain !== params.toChain, 'Source and destination must differ');
|
|
312
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((params.fromAmount === undefined) !== (params.toAmount === undefined), 'Provide exactly one of fromAmount or toAmount');
|
|
313
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(params.toAddress, 'OFT destination recipient is required');
|
|
314
|
+
}
|
|
315
|
+
assertCosts(route, amount, grossAmount, nativeFee) {
|
|
316
|
+
const fee = grossAmount - amount;
|
|
317
|
+
const feeBps = fee === 0n
|
|
318
|
+
? 0n
|
|
319
|
+
: (fee * BASIS_POINTS_DENOMINATOR + grossAmount - 1n) / grossAmount;
|
|
320
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(feeBps <= BigInt(this.maxFeeBps), `OFT fee too high: ${feeBps} bps. Max allowed: ${this.maxFeeBps} bps`);
|
|
321
|
+
const nativeCap = this.protocol(route.sourceMetadata) === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Tron
|
|
322
|
+
? this.maxTronNativeValueSun
|
|
323
|
+
: this.maxEvmNativeValueWei;
|
|
324
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(nativeFee <= nativeCap, `OFT native fee ${nativeFee} exceeds cap ${nativeCap}`);
|
|
325
|
+
}
|
|
326
|
+
provider(metadata) {
|
|
327
|
+
const rpcUrl = metadata.rpcUrls[0]?.http;
|
|
328
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(rpcUrl, `Missing RPC URL for ${metadata.name}`);
|
|
329
|
+
return this.protocol(metadata) === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Tron
|
|
330
|
+
? new _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__/* .TronJsonRpcProvider */ .yb(rpcUrl)
|
|
331
|
+
: new ethers__WEBPACK_IMPORTED_MODULE_11__.ethers.providers.StaticJsonRpcProvider(rpcUrl, metadata.chainId);
|
|
332
|
+
}
|
|
333
|
+
wallet(protocol, privateKey, metadata) {
|
|
334
|
+
const provider = this.provider(metadata);
|
|
335
|
+
return protocol === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Tron
|
|
336
|
+
? new _humanode_hyperlane_tron_sdk_runtime__WEBPACK_IMPORTED_MODULE_1__/* .TronWallet */ .t$(privateKey, metadata.rpcUrls[0].http)
|
|
337
|
+
: new ethers__WEBPACK_IMPORTED_MODULE_11__.ethers.Wallet(privateKey, provider);
|
|
338
|
+
}
|
|
339
|
+
contract(address, signerOrProvider) {
|
|
340
|
+
return (this.config.contractFactory?.(address, signerOrProvider) ??
|
|
341
|
+
_humanode_hyperlane_core__WEBPACK_IMPORTED_MODULE_0__/* .TokenBridgeOft__factory */ .ijY.connect(address, signerOrProvider));
|
|
342
|
+
}
|
|
343
|
+
protocol(metadata) {
|
|
344
|
+
(0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(metadata.protocol === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Ethereum ||
|
|
345
|
+
metadata.protocol === _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Tron, `OFT inventory bridge does not support ${metadata.protocol}`);
|
|
346
|
+
return metadata.protocol;
|
|
347
|
+
}
|
|
348
|
+
recipientBytes32(address) {
|
|
349
|
+
return (0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .addressToBytes32 */ .In)(address);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function evmAddress(address) {
|
|
353
|
+
return (0,_humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_9__/* .convertToProtocolAddress */ .Vj)(address, _humanode_hyperlane_utils__WEBPACK_IMPORTED_MODULE_7__/* .ProtocolType */ .Hb.Ethereum);
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=LayerZeroBridge.js.map
|
|
356
|
+
__webpack_async_result__();
|
|
357
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
358
|
+
|
|
359
|
+
/***/ })
|
|
360
|
+
|
|
361
|
+
};
|
package/bundle/748.index.js
CHANGED
|
@@ -632,8 +632,8 @@ function createSvmForkManager(config) {
|
|
|
632
632
|
return new SvmForkManager(config);
|
|
633
633
|
}
|
|
634
634
|
//# sourceMappingURL=svm-fork-manager.js.map
|
|
635
|
-
// EXTERNAL MODULE: ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js +
|
|
636
|
-
var schemas = __webpack_require__(
|
|
635
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js + 5 modules
|
|
636
|
+
var schemas = __webpack_require__(5884);
|
|
637
637
|
;// CONCATENATED MODULE: ../svm-sdk/dist/fork/svm-fork-config.js
|
|
638
638
|
|
|
639
639
|
const PrintableSvmTransactionSchema = schemas/* object */.Ik({
|
package/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bundle/index.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 70561654 bytes
|
|
4
|
+
sha256: 18e85151e500136f1cfe3cdd54ae9631942859caaddfc06701cb4dd3a01a6ae9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanode-hyperlane/cli",
|
|
3
|
-
"version": "1045.2.
|
|
3
|
+
"version": "1045.2.3",
|
|
4
4
|
"description": "A command-line utility for common Hyperlane operations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@humanode-hyperlane/rebalancer": "1029.1.1",
|
|
46
46
|
"@humanode-hyperlane/registry": "1026.3.1",
|
|
47
47
|
"@humanode-hyperlane/relayer": "1004.1.1",
|
|
48
|
-
"@humanode-hyperlane/sdk": "1045.2.
|
|
48
|
+
"@humanode-hyperlane/sdk": "1045.2.3",
|
|
49
49
|
"@humanode-hyperlane/sealevel-sdk": "1045.2.0",
|
|
50
50
|
"@humanode-hyperlane/starknet-sdk": "1030.0.6",
|
|
51
51
|
"@humanode-hyperlane/tron-sdk": "1026.0.4",
|