@continuumdao/ctm-mpc-defi 0.1.3 → 0.1.4

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.
@@ -580,16 +580,36 @@ function parseExtraJsonObject(detail) {
580
580
  }
581
581
  return null;
582
582
  }
583
+ function uniswapV4EvmTypeFromBatchMeta(ex, batchIndex) {
584
+ if (!ex) return false;
585
+ const bm = ex.batchMeta;
586
+ if (!Array.isArray(bm) || !bm[batchIndex] || typeof bm[batchIndex] !== "object" || Array.isArray(bm[batchIndex])) {
587
+ return false;
588
+ }
589
+ const evm0 = bm[batchIndex].evm;
590
+ if (!evm0 || typeof evm0 !== "object" || Array.isArray(evm0)) return false;
591
+ return String(evm0.type ?? "") === "uniswap_v4_swap_tx";
592
+ }
593
+ function uniswapV4AuditFromDetail(ex, batchIndex) {
594
+ if (!ex) return void 0;
595
+ const index = batchIndex != null && batchIndex >= 0 ? batchIndex : 0;
596
+ const bm = ex.batchMeta;
597
+ if (Array.isArray(bm) && bm[index] && typeof bm[index] === "object" && !Array.isArray(bm[index])) {
598
+ const nested = bm[index].uniswapV4;
599
+ if (nested && typeof nested === "object" && !Array.isArray(nested)) {
600
+ return nested;
601
+ }
602
+ }
603
+ const root = ex.uniswapV4;
604
+ if (root && typeof root === "object" && !Array.isArray(root)) return root;
605
+ return void 0;
606
+ }
583
607
  function isUniswapV4SwapEvmSignRequest(detail, batchIndex) {
584
608
  const ex = parseExtraJsonObject(detail);
585
- if (batchIndex != null && batchIndex >= 0 && ex) {
586
- const bm = ex.batchMeta;
587
- if (Array.isArray(bm) && bm[batchIndex] && typeof bm[batchIndex] === "object" && !Array.isArray(bm[batchIndex])) {
588
- const evm0 = bm[batchIndex].evm;
589
- if (evm0 && typeof evm0 === "object" && !Array.isArray(evm0)) {
590
- if (String(evm0.type ?? "") === "uniswap_v4_swap_tx") return true;
591
- }
592
- }
609
+ if (batchIndex != null && batchIndex >= 0) {
610
+ if (uniswapV4EvmTypeFromBatchMeta(ex, batchIndex)) return true;
611
+ } else if (uniswapV4EvmTypeFromBatchMeta(ex, 0)) {
612
+ return true;
593
613
  }
594
614
  const evm = ex?.evm;
595
615
  if (!evm || typeof evm !== "object" || Array.isArray(evm)) return false;
@@ -619,10 +639,10 @@ function resolveRouterSwapGasUnitsFromSignRequest(detail, batchIndex) {
619
639
  }
620
640
  }
621
641
  const ex = parseExtraJsonObject(detail);
622
- const u4 = ex?.uniswapV4;
623
- if (u4 && typeof u4 === "object") {
642
+ const u4 = uniswapV4AuditFromDetail(ex, batchIndex);
643
+ if (u4) {
624
644
  const uc = u4.uniswapCreateSwap;
625
- const gb = uc?.gasBuild;
645
+ const gb = uc?.gasBuildSwap ?? uc?.gasBuild;
626
646
  const base = parseOptionalGasLimitString(gb?.baseGasUnits);
627
647
  if (base != null && base > 0n) return base;
628
648
  const snap = u4.fullQuoteFromPermitSnapshot;