@oydual31/more-vaults-sdk 1.1.5 → 1.1.7
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/viem/index.cjs +51 -26
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.js +51 -26
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/crossChainFlows.ts +63 -29
package/dist/viem/index.cjs
CHANGED
|
@@ -2148,6 +2148,9 @@ function parseContractError(err, vault, caller) {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
|
|
2150
2150
|
// src/viem/crossChainFlows.ts
|
|
2151
|
+
function isNativeDropCapError(e) {
|
|
2152
|
+
return String(e).includes("0x0084ce02");
|
|
2153
|
+
}
|
|
2151
2154
|
var LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
|
|
2152
2155
|
var FACTORY_COMPOSER_ABI = [
|
|
2153
2156
|
{
|
|
@@ -2289,6 +2292,22 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
|
|
|
2289
2292
|
],
|
|
2290
2293
|
[hopSendParam, minMsgValue]
|
|
2291
2294
|
);
|
|
2295
|
+
let needsPendingCompose = isStargate;
|
|
2296
|
+
if (!isStargate && resolvedExtraOptions !== "0x") {
|
|
2297
|
+
try {
|
|
2298
|
+
await publicClient.readContract({
|
|
2299
|
+
address: oft,
|
|
2300
|
+
abi: OFT_ABI,
|
|
2301
|
+
functionName: "quoteSend",
|
|
2302
|
+
args: [{ dstEid: hubEid, to: composerBytes32, amountLD: amount, minAmountLD: amount, extraOptions: resolvedExtraOptions, composeMsg: composeMsgBytes, oftCmd: resolvedOftCmd }, false]
|
|
2303
|
+
});
|
|
2304
|
+
} catch (e) {
|
|
2305
|
+
if (isNativeDropCapError(e)) {
|
|
2306
|
+
resolvedExtraOptions = "0x";
|
|
2307
|
+
needsPendingCompose = true;
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2292
2311
|
let resolvedMinAmountLD = minAmountLD;
|
|
2293
2312
|
if (resolvedMinAmountLD === void 0) {
|
|
2294
2313
|
try {
|
|
@@ -2347,9 +2366,8 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
|
|
|
2347
2366
|
account,
|
|
2348
2367
|
chain: walletClient.chain
|
|
2349
2368
|
});
|
|
2350
|
-
const stargate = isStargate;
|
|
2351
2369
|
let composeData;
|
|
2352
|
-
if (
|
|
2370
|
+
if (needsPendingCompose) {
|
|
2353
2371
|
const hubBlockStart = await hubClient.getBlockNumber();
|
|
2354
2372
|
composeData = {
|
|
2355
2373
|
endpoint: LZ_ENDPOINT,
|
|
@@ -2360,7 +2378,7 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
|
|
|
2360
2378
|
index: 0,
|
|
2361
2379
|
message: "0x",
|
|
2362
2380
|
// resolved by waitForCompose — from ComposeSent event
|
|
2363
|
-
isStargate
|
|
2381
|
+
isStargate,
|
|
2364
2382
|
hubChainId,
|
|
2365
2383
|
hubBlockStart
|
|
2366
2384
|
};
|
|
@@ -2434,12 +2452,16 @@ async function quoteDepositFromSpokeFee(publicClient, vault, spokeOFT, hubEid, s
|
|
|
2434
2452
|
composeMsg: composeMsgBytes,
|
|
2435
2453
|
oftCmd: resolvedOftCmd
|
|
2436
2454
|
};
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
abi: OFT_ABI,
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2455
|
+
let fee;
|
|
2456
|
+
try {
|
|
2457
|
+
fee = await publicClient.readContract({ address: oft, abi: OFT_ABI, functionName: "quoteSend", args: [sendParam, false] });
|
|
2458
|
+
} catch (e) {
|
|
2459
|
+
if (isNativeDropCapError(e)) {
|
|
2460
|
+
fee = await publicClient.readContract({ address: oft, abi: OFT_ABI, functionName: "quoteSend", args: [{ ...sendParam, extraOptions: "0x" }, false] });
|
|
2461
|
+
} else {
|
|
2462
|
+
throw e;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2443
2465
|
return fee.nativeFee;
|
|
2444
2466
|
}
|
|
2445
2467
|
var EMPTY_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
@@ -2491,31 +2513,34 @@ async function waitForCompose(hubPublicClient, composeData, receiver, pollInterv
|
|
|
2491
2513
|
for (const log of logs) {
|
|
2492
2514
|
const args = log.args;
|
|
2493
2515
|
if (args.to && viem.getAddress(args.to) === composer && args.message?.toLowerCase().includes(receiverNeedle)) {
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2516
|
+
try {
|
|
2517
|
+
const hash = await hubPublicClient.readContract({
|
|
2518
|
+
address: endpoint,
|
|
2519
|
+
abi: LZ_ENDPOINT_ABI,
|
|
2520
|
+
functionName: "composeQueue",
|
|
2521
|
+
args: [viem.getAddress(args.from), composer, args.guid, args.index ?? 0]
|
|
2522
|
+
});
|
|
2523
|
+
if (hash !== EMPTY_HASH && hash !== RECEIVED_HASH) {
|
|
2524
|
+
console.log(`[${elapsed}s] Poll #${attempt} \u2014 compose found! (block ${log.blockNumber}, scanned from ${startBlock})`);
|
|
2525
|
+
return {
|
|
2526
|
+
...composeData,
|
|
2527
|
+
from: viem.getAddress(args.from),
|
|
2528
|
+
to: composer,
|
|
2529
|
+
guid: args.guid,
|
|
2530
|
+
index: args.index ?? 0,
|
|
2531
|
+
message: args.message
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
} catch {
|
|
2510
2535
|
}
|
|
2511
2536
|
}
|
|
2512
2537
|
}
|
|
2538
|
+
scannedUpTo = chunkEnd;
|
|
2513
2539
|
} catch {
|
|
2514
2540
|
break;
|
|
2515
2541
|
}
|
|
2516
2542
|
from = chunkEnd + 1n;
|
|
2517
2543
|
}
|
|
2518
|
-
scannedUpTo = currentBlock;
|
|
2519
2544
|
} catch {
|
|
2520
2545
|
}
|
|
2521
2546
|
let guidMatchFound = false;
|