@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.
@@ -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 (stargate) {
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: true,
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
- const fee = await publicClient.readContract({
2438
- address: oft,
2439
- abi: OFT_ABI,
2440
- functionName: "quoteSend",
2441
- args: [sendParam, false]
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
- const hash = await hubPublicClient.readContract({
2495
- address: endpoint,
2496
- abi: LZ_ENDPOINT_ABI,
2497
- functionName: "composeQueue",
2498
- args: [viem.getAddress(args.from), composer, args.guid, args.index ?? 0]
2499
- });
2500
- if (hash !== EMPTY_HASH && hash !== RECEIVED_HASH) {
2501
- console.log(`[${elapsed}s] Poll #${attempt} \u2014 compose found! (block ${log.blockNumber}, scanned from ${startBlock})`);
2502
- return {
2503
- ...composeData,
2504
- from: viem.getAddress(args.from),
2505
- to: composer,
2506
- guid: args.guid,
2507
- index: args.index ?? 0,
2508
- message: args.message
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;