@matterlabs/zksync-js 0.0.12 → 0.0.14

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.
Files changed (69) hide show
  1. package/dist/adapters/ethers/client.cjs +735 -8
  2. package/dist/adapters/ethers/client.cjs.map +1 -1
  3. package/dist/adapters/ethers/client.js +7 -6
  4. package/dist/adapters/ethers/index.cjs +1421 -441
  5. package/dist/adapters/ethers/index.cjs.map +1 -1
  6. package/dist/adapters/ethers/index.js +10 -9
  7. package/dist/adapters/ethers/resources/deposits/routes/priority.d.ts +12 -0
  8. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +4 -0
  9. package/dist/adapters/ethers/resources/interop/index.d.ts +14 -14
  10. package/dist/adapters/ethers/resources/interop/resolvers.d.ts +3 -8
  11. package/dist/adapters/ethers/resources/interop/routes/types.d.ts +2 -1
  12. package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +10 -0
  13. package/dist/adapters/ethers/resources/interop/services/fee.d.ts +12 -0
  14. package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +1 -1
  15. package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +1 -1
  16. package/dist/adapters/ethers/resources/interop/types.d.ts +6 -14
  17. package/dist/adapters/ethers/sdk.cjs +3068 -1685
  18. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  19. package/dist/adapters/ethers/sdk.d.ts +6 -1
  20. package/dist/adapters/ethers/sdk.js +8 -7
  21. package/dist/adapters/viem/client.cjs +10 -8
  22. package/dist/adapters/viem/client.cjs.map +1 -1
  23. package/dist/adapters/viem/client.js +7 -6
  24. package/dist/adapters/viem/index.cjs +317 -77
  25. package/dist/adapters/viem/index.cjs.map +1 -1
  26. package/dist/adapters/viem/index.js +10 -9
  27. package/dist/adapters/viem/resources/deposits/routes/priority.d.ts +13 -0
  28. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +4 -0
  29. package/dist/adapters/viem/sdk.cjs +307 -69
  30. package/dist/adapters/viem/sdk.cjs.map +1 -1
  31. package/dist/adapters/viem/sdk.js +7 -7
  32. package/dist/{chunk-E3KP7XCG.js → chunk-3HHUZXSV.js} +1 -1
  33. package/dist/{chunk-4PFO3J7W.js → chunk-5RRJDPAJ.js} +10 -2
  34. package/dist/{chunk-AUN5Y2A3.js → chunk-75IOOODG.js} +253 -53
  35. package/dist/{chunk-LWA7LC3N.js → chunk-7CAVFIMW.js} +5 -4
  36. package/dist/chunk-BWKWWLY4.js +9 -0
  37. package/dist/{chunk-NBQVHW2N.js → chunk-DYJKK5FW.js} +19 -19
  38. package/dist/{chunk-I5VQBVQ2.js → chunk-EOBXYHTZ.js} +35 -7
  39. package/dist/{chunk-GMNLOTNG.js → chunk-HP3EWKJL.js} +1 -1
  40. package/dist/{chunk-IUSH7YBZ.js → chunk-J47RI3G7.js} +1 -1
  41. package/dist/{chunk-6CLYCJMV.js → chunk-JY62QO3W.js} +759 -22
  42. package/dist/{chunk-QQ2OR434.js → chunk-MT4X5FEO.js} +18 -2
  43. package/dist/{chunk-BGUNJK2H.js → chunk-OTXPSNNC.js} +5 -4
  44. package/dist/{chunk-TE2YQHVI.js → chunk-XDRCN4FC.js} +2 -2
  45. package/dist/{chunk-6JM4PE62.js → chunk-XKRNLFET.js} +407 -210
  46. package/dist/core/abi.d.ts +2 -0
  47. package/dist/core/constants.cjs +17 -1
  48. package/dist/core/constants.cjs.map +1 -1
  49. package/dist/core/constants.d.ts +9 -1
  50. package/dist/core/constants.js +1 -1
  51. package/dist/core/index.cjs +768 -28
  52. package/dist/core/index.cjs.map +1 -1
  53. package/dist/core/index.js +6 -5
  54. package/dist/core/internal/abis/IERC7786Attributes.d.ts +21 -11
  55. package/dist/core/internal/abis/IInteropCenter.d.ts +4 -0
  56. package/dist/core/internal/abis/IInteropErrors.d.ts +197 -0
  57. package/dist/core/internal/abis/IL1ContractErrors.d.ts +1021 -0
  58. package/dist/core/resources/deposits/priority.d.ts +37 -0
  59. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  60. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  61. package/dist/core/resources/interop/plan.d.ts +11 -3
  62. package/dist/core/rpc/types.d.ts +1 -1
  63. package/dist/core/rpc/zks.d.ts +5 -1
  64. package/dist/core/types/errors.d.ts +5 -0
  65. package/dist/core/types/flows/interop.d.ts +11 -18
  66. package/dist/index.cjs +785 -29
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.js +6 -5
  69. package/package.json +1 -1
@@ -48,7 +48,15 @@ var TX_OVERHEAD_GAS = 10000n;
48
48
  var TX_MEMORY_OVERHEAD_GAS = 10n;
49
49
  var DEFAULT_PUBDATA_BYTES = 155n;
50
50
  var DEFAULT_ABI_BYTES = 400n;
51
- var SAFE_L1_BRIDGE_GAS = 800000n;
51
+ var SAFE_L1_BRIDGE_GAS = 3000000n;
52
+ var L1_TX_INTRINSIC_L2_GAS = 167157n;
53
+ var L1_TX_INTRINSIC_PUBDATA = 88n;
54
+ var L1_TX_MIN_L2_GAS_BASE = 173484n;
55
+ var L1_TX_DELTA_544_ENCODING_BYTES = 1656n;
56
+ var L1_TX_DELTA_FACTORY_DEPS_L2_GAS = 2473n;
57
+ var L1_TX_DELTA_FACTORY_DEPS_PUBDATA = 64n;
58
+ var TX_SLOT_OVERHEAD_L2_GAS = 10000n;
59
+ var PRIORITY_TX_MAX_GAS_LIMIT = 72000000n;
52
60
 
53
61
  // src/core/utils/addr.ts
54
62
  function isAddress(x) {
@@ -413,6 +421,11 @@ var OP_INTEROP = {
413
421
  wait: {
414
422
  poll: "interop.svc.wait:poll",
415
423
  timeout: "interop.svc.wait:timeout"
424
+ },
425
+ fees: {
426
+ zkInteropFee: "interop.svc.fees:zkInteropFee",
427
+ zkToken: "interop.svc.fees:zkToken",
428
+ protocolFee: "interop.svc.fees:protocolFee"
416
429
  }
417
430
  }
418
431
  };
@@ -481,6 +494,7 @@ function normalizeProof(p) {
481
494
  const raw = p ?? {};
482
495
  const idRaw = raw?.id ?? raw?.index;
483
496
  const bnRaw = raw?.batch_number ?? raw?.batchNumber;
497
+ const gwBlockNumberRaw = raw?.gatewayBlockNumber;
484
498
  if (idRaw == null || bnRaw == null) {
485
499
  throw createError("RPC", {
486
500
  resource: "zksrpc",
@@ -501,7 +515,8 @@ function normalizeProof(p) {
501
515
  id: toBig(idRaw),
502
516
  batchNumber: toBig(bnRaw),
503
517
  proof: toHexArray(raw?.proof),
504
- root: raw.root
518
+ root: raw.root,
519
+ gatewayBlockNumber: gwBlockNumberRaw != null ? toBig(gwBlockNumberRaw) : void 0
505
520
  };
506
521
  } catch (e) {
507
522
  if (isZKsyncError(e)) throw e;
@@ -524,8 +539,8 @@ function ensureHex(value, field, context) {
524
539
  });
525
540
  }
526
541
  function ensureNumber(value, field, opts) {
527
- const operation = opts?.operation ?? "zksrpc.normalizeGenesis";
528
- const messagePrefix = opts?.messagePrefix ?? "Malformed genesis response";
542
+ const operation = opts?.operation;
543
+ const messagePrefix = opts?.messagePrefix;
529
544
  if (isNumber(value)) return value;
530
545
  if (isBigint(value)) return Number(value);
531
546
  if (typeof value === "string" && value.trim() !== "") {
@@ -663,7 +678,6 @@ function normalizeGenesis(raw) {
663
678
  context: { valueType: typeof contractsRaw }
664
679
  });
665
680
  }
666
- const executionVersion = ensureNumber(record["execution_version"], "execution_version");
667
681
  const genesisRoot = ensureHex(record["genesis_root"], "genesis_root", {});
668
682
  const initialContracts = contractsRaw.map(
669
683
  (entry, index) => normalizeContractTuple(entry, index)
@@ -672,7 +686,6 @@ function normalizeGenesis(raw) {
672
686
  return {
673
687
  initialContracts,
674
688
  additionalStorage,
675
- executionVersion,
676
689
  genesisRoot
677
690
  };
678
691
  } catch (e) {
@@ -780,13 +793,15 @@ function createZksRpc(transport) {
780
793
  );
781
794
  },
782
795
  // Fetches a proof for an L2→L1 log emitted in the given transaction.
783
- async getL2ToL1LogProof(txHash, index) {
796
+ async getL2ToL1LogProof(txHash, index, proofTarget) {
784
797
  return withRpcOp(
785
798
  "zksrpc.getL2ToL1LogProof",
786
799
  "Failed to fetch L2\u2192L1 log proof.",
787
- { txHash, index },
800
+ { txHash, index, proofTarget },
788
801
  async () => {
789
- const proof = await transport(METHODS.getL2ToL1LogProof, [txHash, index]);
802
+ const params = [txHash, index];
803
+ if (proofTarget != void 0) params.push(proofTarget);
804
+ const proof = await transport(METHODS.getL2ToL1LogProof, params);
790
805
  if (!proof) {
791
806
  throw createError("STATE", {
792
807
  resource: "zksrpc",
@@ -4969,56 +4984,69 @@ var IERC20_default = IERC20ABI;
4969
4984
  // src/core/internal/abis/IERC7786Attributes.ts
4970
4985
  var IERC7786AttributesABI = [
4971
4986
  {
4987
+ type: "function",
4988
+ name: "executionAddress",
4972
4989
  inputs: [
4973
4990
  {
4974
- internalType: "bytes",
4975
4991
  name: "_executionAddress",
4976
- type: "bytes"
4992
+ type: "bytes",
4993
+ internalType: "bytes"
4977
4994
  }
4978
4995
  ],
4979
- name: "executionAddress",
4980
4996
  outputs: [],
4981
- stateMutability: "pure",
4982
- type: "function"
4997
+ stateMutability: "pure"
4983
4998
  },
4984
4999
  {
5000
+ type: "function",
5001
+ name: "indirectCall",
4985
5002
  inputs: [
4986
5003
  {
4987
- internalType: "uint256",
4988
5004
  name: "_indirectCallMessageValue",
4989
- type: "uint256"
5005
+ type: "uint256",
5006
+ internalType: "uint256"
4990
5007
  }
4991
5008
  ],
4992
- name: "indirectCall",
4993
5009
  outputs: [],
4994
- stateMutability: "pure",
4995
- type: "function"
5010
+ stateMutability: "pure"
4996
5011
  },
4997
5012
  {
5013
+ type: "function",
5014
+ name: "interopCallValue",
4998
5015
  inputs: [
4999
5016
  {
5000
- internalType: "uint256",
5001
5017
  name: "_interopCallValue",
5002
- type: "uint256"
5018
+ type: "uint256",
5019
+ internalType: "uint256"
5003
5020
  }
5004
5021
  ],
5005
- name: "interopCallValue",
5006
5022
  outputs: [],
5007
- stateMutability: "pure",
5008
- type: "function"
5023
+ stateMutability: "pure"
5009
5024
  },
5010
5025
  {
5026
+ type: "function",
5027
+ name: "unbundlerAddress",
5011
5028
  inputs: [
5012
5029
  {
5013
- internalType: "bytes",
5014
5030
  name: "_unbundlerAddress",
5015
- type: "bytes"
5031
+ type: "bytes",
5032
+ internalType: "bytes"
5016
5033
  }
5017
5034
  ],
5018
- name: "unbundlerAddress",
5019
5035
  outputs: [],
5020
- stateMutability: "pure",
5021
- type: "function"
5036
+ stateMutability: "pure"
5037
+ },
5038
+ {
5039
+ type: "function",
5040
+ name: "useFixedFee",
5041
+ inputs: [
5042
+ {
5043
+ name: "_useFixed",
5044
+ type: "bool",
5045
+ internalType: "bool"
5046
+ }
5047
+ ],
5048
+ outputs: [],
5049
+ stateMutability: "pure"
5022
5050
  }
5023
5051
  ];
5024
5052
  var IERC7786Attributes_default = IERC7786AttributesABI;
@@ -5866,6 +5894,11 @@ var IInteropCenterABI = [
5866
5894
  type: "uint256",
5867
5895
  internalType: "uint256"
5868
5896
  },
5897
+ {
5898
+ name: "destinationBaseTokenAssetId",
5899
+ type: "bytes32",
5900
+ internalType: "bytes32"
5901
+ },
5869
5902
  {
5870
5903
  name: "interopBundleSalt",
5871
5904
  type: "bytes32",
@@ -6764,197 +6797,917 @@ var L2MessageVerificationABI = [
6764
6797
  ];
6765
6798
  var L2MessageVerification_default = L2MessageVerificationABI;
6766
6799
 
6767
- // src/core/types/primitives.ts
6768
- var ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
6769
-
6770
- // src/core/errors/error-ops.ts
6771
- function resolveMessage(op, msg) {
6772
- if (!msg) return `Error during ${op}.`;
6773
- return typeof msg === "function" ? msg() : msg;
6774
- }
6775
- function createErrorOps(decodeRevert2) {
6776
- function toZKsyncError2(type, base, err) {
6777
- if (isZKsyncError(err)) return err;
6778
- const revert = decodeRevert2 ? decodeRevert2(err) : void 0;
6779
- return createError(type, { ...base, ...revert ? { revert } : {}, cause: shapeCause(err) });
6780
- }
6781
- function createErrorHandlers2(resource) {
6782
- async function run(kind, operation, fn, opts) {
6783
- try {
6784
- return await fn();
6785
- } catch (e) {
6786
- if (isZKsyncError(e)) throw e;
6787
- const message = resolveMessage(operation, opts?.message);
6788
- throw toZKsyncError2(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
6800
+ // src/core/internal/abis/IInteropErrors.ts
6801
+ var IInteropErrorsABI = [
6802
+ {
6803
+ type: "error",
6804
+ name: "AttributeAlreadySet",
6805
+ inputs: [
6806
+ {
6807
+ name: "selector",
6808
+ type: "bytes4"
6789
6809
  }
6790
- }
6791
- function wrap7(operation, fn, opts) {
6792
- return run("INTERNAL", operation, fn, opts);
6793
- }
6794
- function wrapAs10(kind, operation, fn, opts) {
6795
- return run(kind, operation, fn, opts);
6796
- }
6797
- async function toResult3(operation, fn, opts) {
6798
- try {
6799
- const value = await wrap7(operation, fn, opts);
6800
- return { ok: true, value };
6801
- } catch (e) {
6802
- const shaped = isZKsyncError(e) ? e : toZKsyncError2(
6803
- "INTERNAL",
6804
- {
6805
- resource,
6806
- operation,
6807
- context: opts?.ctx ?? {},
6808
- message: resolveMessage(operation, opts?.message)
6809
- },
6810
- e
6811
- );
6812
- return { ok: false, error: shaped };
6810
+ ]
6811
+ },
6812
+ {
6813
+ type: "error",
6814
+ name: "AttributeViolatesRestriction",
6815
+ inputs: [
6816
+ {
6817
+ name: "selector",
6818
+ type: "bytes4"
6819
+ },
6820
+ {
6821
+ name: "restriction",
6822
+ type: "uint256"
6813
6823
  }
6814
- }
6815
- return { wrap: wrap7, wrapAs: wrapAs10, toResult: toResult3 };
6816
- }
6817
- return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
6818
- }
6819
-
6820
- // src/core/errors/withdrawal-revert-map.ts
6821
- var REVERT_TO_READINESS = {
6822
- // Already done
6823
- WithdrawalAlreadyFinalized: { kind: "FINALIZED" },
6824
- // Temporary — try later
6825
- BatchNotExecuted: { kind: "NOT_READY", reason: "batch-not-executed" },
6826
- LocalRootIsZero: { kind: "NOT_READY", reason: "root-missing" },
6827
- // Permanent — won’t become ready for this tx
6828
- WrongL2Sender: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6829
- InvalidSelector: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6830
- L2WithdrawalMessageWrongLength: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6831
- WrongMsgLength: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6832
- TokenNotLegacy: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6833
- TokenIsLegacy: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6834
- InvalidProof: { kind: "UNFINALIZABLE", reason: "message-invalid" },
6835
- InvalidChainId: { kind: "UNFINALIZABLE", reason: "invalid-chain" },
6836
- NotSettlementLayer: { kind: "UNFINALIZABLE", reason: "settlement-layer" },
6837
- // Likely environment mismatch — treat as permanent for this tx
6838
- OnlyEraSupported: { kind: "UNFINALIZABLE", reason: "unsupported" },
6839
- LocalRootMustBeZero: { kind: "UNFINALIZABLE", reason: "unsupported" }
6840
- };
6841
-
6842
- // src/adapters/ethers/errors/revert.ts
6843
- var ERROR_IFACES = [];
6844
- var IFACE_ERROR_STRING = new ethers.Interface(["error Error(string)"]);
6845
- var IFACE_PANIC = new ethers.Interface(["error Panic(uint256)"]);
6846
- (function bootstrapDefaultIfaces() {
6847
- try {
6848
- ERROR_IFACES.push({
6849
- name: "IL1Nullifier",
6850
- iface: new ethers.Interface(IL1Nullifier_default)
6851
- });
6852
- } catch {
6853
- }
6854
- try {
6855
- ERROR_IFACES.push({ name: "IERC20", iface: new ethers.Interface(IERC20_default) });
6856
- } catch {
6857
- }
6858
- try {
6859
- ERROR_IFACES.push({
6860
- name: "IL1NativeTokenVault",
6861
- iface: new ethers.Interface(L1NativeTokenVault_default)
6862
- });
6863
- } catch {
6864
- }
6865
- try {
6866
- ERROR_IFACES.push({
6867
- name: "IL2NativeTokenVault",
6868
- iface: new ethers.Interface(L2NativeTokenVault_default)
6869
- });
6870
- } catch {
6871
- }
6872
- try {
6873
- ERROR_IFACES.push({ name: "Mailbox", iface: new ethers.Interface(Mailbox_default) });
6874
- } catch {
6875
- }
6876
- })();
6877
- function registerErrorAbi(name, abi2) {
6878
- const existing = ERROR_IFACES.findIndex((x) => x.name === name);
6879
- const entry = { name, iface: new ethers.Interface(abi2) };
6880
- if (existing >= 0) ERROR_IFACES[existing] = entry;
6881
- else ERROR_IFACES.push(entry);
6882
- }
6883
- function extractRevertData(e) {
6884
- const maybe = (
6885
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6886
- e?.data?.data ?? e?.error?.data ?? e?.data ?? e?.error?.error?.data ?? e?.info?.error?.data
6887
- );
6888
- if (typeof maybe === "string" && maybe.startsWith("0x") && maybe.length >= 10) {
6889
- return maybe;
6890
- }
6891
- return void 0;
6892
- }
6893
- function decodeRevert(e) {
6894
- const data = extractRevertData(e);
6895
- if (!data) return;
6896
- const selector = `0x${data.slice(2, 10)}`;
6897
- try {
6898
- const parsed = IFACE_ERROR_STRING.parseError(data);
6899
- if (parsed?.name === "Error") {
6900
- const args = parsed.args ? Array.from(parsed.args) : void 0;
6901
- return { selector, name: "Error", args };
6902
- }
6903
- } catch {
6904
- }
6905
- try {
6906
- const parsed = IFACE_PANIC.parseError(data);
6907
- if (parsed?.name === "Panic") {
6908
- const args = parsed.args ? Array.from(parsed.args) : void 0;
6909
- return { selector, name: "Panic", args };
6910
- }
6911
- } catch {
6912
- }
6913
- for (const { name, iface } of ERROR_IFACES) {
6914
- try {
6915
- const parsed = iface.parseError(data);
6916
- if (parsed) {
6917
- const args = parsed.args ? Array.from(parsed.args) : void 0;
6918
- return {
6919
- selector,
6920
- name: parsed.name,
6921
- args,
6922
- contract: name
6923
- };
6824
+ ]
6825
+ },
6826
+ {
6827
+ type: "error",
6828
+ name: "BundleAlreadyProcessed",
6829
+ inputs: [
6830
+ {
6831
+ name: "bundleHash",
6832
+ type: "bytes32"
6924
6833
  }
6925
- } catch {
6926
- }
6927
- }
6928
- return { selector };
6929
- }
6930
- function classifyReadinessFromRevert(e) {
6931
- const r = decodeRevert(e);
6932
- const name = r?.name;
6933
- if (name && REVERT_TO_READINESS[name]) return REVERT_TO_READINESS[name];
6934
- const msg = (() => {
6935
- if (typeof e !== "object" || e === null) return "";
6936
- const obj = e;
6937
- const maybeMsg = obj["shortMessage"] ?? obj["message"];
6938
- return typeof maybeMsg === "string" ? maybeMsg : "";
6939
- })();
6940
- const lower = String(msg).toLowerCase();
6941
- if (lower.includes("paused")) return { kind: "NOT_READY", reason: "paused" };
6942
- if (name || r?.selector) {
6943
- return { kind: "UNFINALIZABLE", reason: "unsupported", detail: name ?? r?.selector };
6944
- }
6945
- return { kind: "NOT_READY", reason: "unknown", detail: lower || void 0 };
6946
- }
6947
-
6948
- // src/adapters/ethers/errors/error-ops.ts
6949
- var { toZKsyncError, createErrorHandlers } = createErrorOps(decodeRevert);
6950
-
6951
- // src/adapters/ethers/client.ts
6952
- var { wrapAs, wrap } = createErrorHandlers("client");
6953
- var ChainTypeManagerABI = [
6954
- "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)"
6955
- ];
6956
- function createEthersClient(args) {
6957
- const { l1, l2, signer } = args;
6834
+ ]
6835
+ },
6836
+ {
6837
+ type: "error",
6838
+ name: "CallAlreadyExecuted",
6839
+ inputs: [
6840
+ {
6841
+ name: "bundleHash",
6842
+ type: "bytes32"
6843
+ },
6844
+ {
6845
+ name: "callIndex",
6846
+ type: "uint256"
6847
+ }
6848
+ ]
6849
+ },
6850
+ {
6851
+ type: "error",
6852
+ name: "CallNotExecutable",
6853
+ inputs: [
6854
+ {
6855
+ name: "bundleHash",
6856
+ type: "bytes32"
6857
+ },
6858
+ {
6859
+ name: "callIndex",
6860
+ type: "uint256"
6861
+ }
6862
+ ]
6863
+ },
6864
+ {
6865
+ type: "error",
6866
+ name: "CanNotUnbundle",
6867
+ inputs: [
6868
+ {
6869
+ name: "bundleHash",
6870
+ type: "bytes32"
6871
+ }
6872
+ ]
6873
+ },
6874
+ {
6875
+ type: "error",
6876
+ name: "DestinationChainNotRegistered",
6877
+ inputs: [
6878
+ {
6879
+ name: "destinationChainId",
6880
+ type: "uint256"
6881
+ }
6882
+ ]
6883
+ },
6884
+ {
6885
+ type: "error",
6886
+ name: "ExecutingNotAllowed",
6887
+ inputs: [
6888
+ {
6889
+ name: "bundleHash",
6890
+ type: "bytes32"
6891
+ },
6892
+ {
6893
+ name: "callerAddress",
6894
+ type: "bytes"
6895
+ },
6896
+ {
6897
+ name: "executionAddress",
6898
+ type: "bytes"
6899
+ }
6900
+ ]
6901
+ },
6902
+ {
6903
+ type: "error",
6904
+ name: "FeeWithdrawalFailed",
6905
+ inputs: []
6906
+ },
6907
+ {
6908
+ type: "error",
6909
+ name: "IndirectCallValueMismatch",
6910
+ inputs: [
6911
+ {
6912
+ name: "expected",
6913
+ type: "uint256"
6914
+ },
6915
+ {
6916
+ name: "actual",
6917
+ type: "uint256"
6918
+ }
6919
+ ]
6920
+ },
6921
+ {
6922
+ type: "error",
6923
+ name: "InteroperableAddressChainReferenceNotEmpty",
6924
+ inputs: [
6925
+ {
6926
+ name: "interoperableAddress",
6927
+ type: "bytes"
6928
+ }
6929
+ ]
6930
+ },
6931
+ {
6932
+ type: "error",
6933
+ name: "InteroperableAddressNotEmpty",
6934
+ inputs: [
6935
+ {
6936
+ name: "interoperableAddress",
6937
+ type: "bytes"
6938
+ }
6939
+ ]
6940
+ },
6941
+ {
6942
+ type: "error",
6943
+ name: "InvalidInteropBundleVersion",
6944
+ inputs: []
6945
+ },
6946
+ {
6947
+ type: "error",
6948
+ name: "InvalidInteropCallVersion",
6949
+ inputs: []
6950
+ },
6951
+ {
6952
+ type: "error",
6953
+ name: "InteropRootAlreadyExists",
6954
+ inputs: []
6955
+ },
6956
+ {
6957
+ type: "error",
6958
+ name: "MessageNotIncluded",
6959
+ inputs: []
6960
+ },
6961
+ {
6962
+ type: "error",
6963
+ name: "SidesLengthNotOne",
6964
+ inputs: []
6965
+ },
6966
+ {
6967
+ type: "error",
6968
+ name: "UnauthorizedMessageSender",
6969
+ inputs: [
6970
+ {
6971
+ name: "expected",
6972
+ type: "address"
6973
+ },
6974
+ {
6975
+ name: "actual",
6976
+ type: "address"
6977
+ }
6978
+ ]
6979
+ },
6980
+ {
6981
+ type: "error",
6982
+ name: "UnbundlingNotAllowed",
6983
+ inputs: [
6984
+ {
6985
+ name: "bundleHash",
6986
+ type: "bytes32"
6987
+ },
6988
+ {
6989
+ name: "callerAddress",
6990
+ type: "bytes"
6991
+ },
6992
+ {
6993
+ name: "unbundlerAddress",
6994
+ type: "bytes"
6995
+ }
6996
+ ]
6997
+ },
6998
+ {
6999
+ type: "error",
7000
+ name: "WrongCallStatusLength",
7001
+ inputs: [
7002
+ {
7003
+ name: "bundleCallsLength",
7004
+ type: "uint256"
7005
+ },
7006
+ {
7007
+ name: "providedCallStatusLength",
7008
+ type: "uint256"
7009
+ }
7010
+ ]
7011
+ },
7012
+ {
7013
+ type: "error",
7014
+ name: "WrongDestinationChainId",
7015
+ inputs: [
7016
+ {
7017
+ name: "bundleHash",
7018
+ type: "bytes32"
7019
+ },
7020
+ {
7021
+ name: "expected",
7022
+ type: "uint256"
7023
+ },
7024
+ {
7025
+ name: "actual",
7026
+ type: "uint256"
7027
+ }
7028
+ ]
7029
+ },
7030
+ {
7031
+ type: "error",
7032
+ name: "WrongDestinationBaseTokenAssetId",
7033
+ inputs: [
7034
+ {
7035
+ name: "bundleHash",
7036
+ type: "bytes32"
7037
+ },
7038
+ {
7039
+ name: "expected",
7040
+ type: "bytes32"
7041
+ },
7042
+ {
7043
+ name: "actual",
7044
+ type: "bytes32"
7045
+ }
7046
+ ]
7047
+ },
7048
+ {
7049
+ type: "error",
7050
+ name: "WrongSourceChainId",
7051
+ inputs: [
7052
+ {
7053
+ name: "bundleHash",
7054
+ type: "bytes32"
7055
+ },
7056
+ {
7057
+ name: "expected",
7058
+ type: "uint256"
7059
+ },
7060
+ {
7061
+ name: "actual",
7062
+ type: "uint256"
7063
+ }
7064
+ ]
7065
+ },
7066
+ {
7067
+ type: "error",
7068
+ name: "ZKTokenNotAvailable",
7069
+ inputs: []
7070
+ }
7071
+ ];
7072
+ var IInteropErrors_default = IInteropErrorsABI;
7073
+
7074
+ // src/core/internal/abis/IL1ContractErrors.ts
7075
+ var IL1ContractErrorsABI = [
7076
+ {
7077
+ type: "error",
7078
+ name: "AccessToFallbackDenied",
7079
+ inputs: [
7080
+ { name: "target", type: "address" },
7081
+ { name: "invoker", type: "address" }
7082
+ ]
7083
+ },
7084
+ {
7085
+ type: "error",
7086
+ name: "AccessToFunctionDenied",
7087
+ inputs: [
7088
+ { name: "target", type: "address" },
7089
+ { name: "selector", type: "bytes4" },
7090
+ { name: "invoker", type: "address" }
7091
+ ]
7092
+ },
7093
+ { type: "error", name: "AddressAlreadySet", inputs: [{ name: "addr", type: "address" }] },
7094
+ { type: "error", name: "AddressHasNoCode", inputs: [{ name: "", type: "address" }] },
7095
+ {
7096
+ type: "error",
7097
+ name: "AddressMismatch",
7098
+ inputs: [
7099
+ { name: "expected", type: "address" },
7100
+ { name: "supplied", type: "address" }
7101
+ ]
7102
+ },
7103
+ { type: "error", name: "AlreadyPermanentRollup", inputs: [] },
7104
+ { type: "error", name: "AlreadyWhitelisted", inputs: [{ name: "", type: "address" }] },
7105
+ { type: "error", name: "AmountMustBeGreaterThanZero", inputs: [] },
7106
+ {
7107
+ type: "error",
7108
+ name: "AssetHandlerDoesNotExist",
7109
+ inputs: [{ name: "assetId", type: "bytes32" }]
7110
+ },
7111
+ {
7112
+ type: "error",
7113
+ name: "AssetHandlerNotRegistered",
7114
+ inputs: [{ name: "assetId", type: "bytes32" }]
7115
+ },
7116
+ { type: "error", name: "AssetIdAlreadyRegistered", inputs: [] },
7117
+ {
7118
+ type: "error",
7119
+ name: "AssetIdMismatch",
7120
+ inputs: [
7121
+ { name: "expected", type: "bytes32" },
7122
+ { name: "supplied", type: "bytes32" }
7123
+ ]
7124
+ },
7125
+ { type: "error", name: "AssetIdNotSupported", inputs: [{ name: "assetId", type: "bytes32" }] },
7126
+ { type: "error", name: "AssetRouterAllowanceNotZero", inputs: [] },
7127
+ { type: "error", name: "BaseTokenGasPriceDenominatorNotSet", inputs: [] },
7128
+ {
7129
+ type: "error",
7130
+ name: "BatchHashMismatch",
7131
+ inputs: [
7132
+ { name: "expected", type: "bytes32" },
7133
+ { name: "actual", type: "bytes32" }
7134
+ ]
7135
+ },
7136
+ { type: "error", name: "BatchNotExecuted", inputs: [{ name: "batchNumber", type: "uint256" }] },
7137
+ {
7138
+ type: "error",
7139
+ name: "BatchNumberMismatch",
7140
+ inputs: [
7141
+ { name: "expectedBatchNumber", type: "uint256" },
7142
+ { name: "providedBatchNumber", type: "uint256" }
7143
+ ]
7144
+ },
7145
+ { type: "error", name: "BridgeHubAlreadyRegistered", inputs: [] },
7146
+ { type: "error", name: "BridgeMintNotImplemented", inputs: [] },
7147
+ { type: "error", name: "BurningNativeWETHNotSupported", inputs: [] },
7148
+ {
7149
+ type: "error",
7150
+ name: "BytecodeAlreadyPublished",
7151
+ inputs: [{ name: "bytecodeHash", type: "bytes32" }]
7152
+ },
7153
+ { type: "error", name: "CallerNotTimerAdmin", inputs: [] },
7154
+ { type: "error", name: "CallNotAllowed", inputs: [{ name: "call", type: "bytes" }] },
7155
+ { type: "error", name: "CanOnlyProcessOneBatch", inputs: [] },
7156
+ { type: "error", name: "CantExecuteUnprovenBatches", inputs: [] },
7157
+ { type: "error", name: "CantRevertExecutedBatch", inputs: [] },
7158
+ { type: "error", name: "ChainAlreadyLive", inputs: [] },
7159
+ { type: "error", name: "ChainIdAlreadyExists", inputs: [] },
7160
+ { type: "error", name: "ChainIdCantBeCurrentChain", inputs: [] },
7161
+ { type: "error", name: "ChainIdMismatch", inputs: [] },
7162
+ { type: "error", name: "ChainIdNotRegistered", inputs: [{ name: "chainId", type: "uint256" }] },
7163
+ { type: "error", name: "ChainIdTooBig", inputs: [] },
7164
+ { type: "error", name: "CTMAlreadyRegistered", inputs: [] },
7165
+ { type: "error", name: "CTMNotRegistered", inputs: [] },
7166
+ { type: "error", name: "DeadlineNotYetPassed", inputs: [] },
7167
+ { type: "error", name: "DefaultAdminTransferNotAllowed", inputs: [] },
7168
+ { type: "error", name: "DelegateCallFailed", inputs: [{ name: "returnData", type: "bytes" }] },
7169
+ { type: "error", name: "DenominatorIsZero", inputs: [] },
7170
+ { type: "error", name: "DeployFailed", inputs: [] },
7171
+ { type: "error", name: "DeployingBridgedTokenForNativeToken", inputs: [] },
7172
+ { type: "error", name: "DepositDoesNotExist", inputs: [] },
7173
+ { type: "error", name: "DepositExists", inputs: [] },
7174
+ { type: "error", name: "DiamondAlreadyFrozen", inputs: [] },
7175
+ { type: "error", name: "DiamondNotFrozen", inputs: [] },
7176
+ { type: "error", name: "EmptyAddress", inputs: [] },
7177
+ { type: "error", name: "EmptyAssetId", inputs: [] },
7178
+ { type: "error", name: "EmptyBytes32", inputs: [] },
7179
+ { type: "error", name: "EmptyData", inputs: [] },
7180
+ { type: "error", name: "EmptyDeposit", inputs: [] },
7181
+ { type: "error", name: "EmptyPrecommitData", inputs: [{ name: "batchNumber", type: "uint256" }] },
7182
+ { type: "error", name: "EmptyProofLength", inputs: [] },
7183
+ { type: "error", name: "ETHDepositNotSupported", inputs: [] },
7184
+ {
7185
+ type: "error",
7186
+ name: "FacetExists",
7187
+ inputs: [
7188
+ { name: "selector", type: "bytes4" },
7189
+ { name: "", type: "address" }
7190
+ ]
7191
+ },
7192
+ { type: "error", name: "GasPerPubdataMismatch", inputs: [] },
7193
+ { type: "error", name: "GenesisBatchCommitmentZero", inputs: [] },
7194
+ { type: "error", name: "GenesisBatchHashZero", inputs: [] },
7195
+ { type: "error", name: "GenesisIndexStorageZero", inputs: [] },
7196
+ { type: "error", name: "GenesisUpgradeZero", inputs: [] },
7197
+ { type: "error", name: "HashedLogIsDefault", inputs: [] },
7198
+ {
7199
+ type: "error",
7200
+ name: "HashMismatch",
7201
+ inputs: [
7202
+ { name: "expected", type: "bytes32" },
7203
+ { name: "actual", type: "bytes32" }
7204
+ ]
7205
+ },
7206
+ {
7207
+ type: "error",
7208
+ name: "IncorrectBatchBounds",
7209
+ inputs: [
7210
+ { name: "processFromExpected", type: "uint256" },
7211
+ { name: "processToExpected", type: "uint256" },
7212
+ { name: "processFromProvided", type: "uint256" },
7213
+ { name: "processToProvided", type: "uint256" }
7214
+ ]
7215
+ },
7216
+ {
7217
+ type: "error",
7218
+ name: "IncorrectBridgeHubAddress",
7219
+ inputs: [{ name: "bridgehub", type: "address" }]
7220
+ },
7221
+ {
7222
+ type: "error",
7223
+ name: "IncorrectTokenAddressFromNTV",
7224
+ inputs: [
7225
+ { name: "assetId", type: "bytes32" },
7226
+ { name: "tokenAddress", type: "address" }
7227
+ ]
7228
+ },
7229
+ { type: "error", name: "InsufficientChainBalance", inputs: [] },
7230
+ {
7231
+ type: "error",
7232
+ name: "InvalidBatchNumber",
7233
+ inputs: [
7234
+ { name: "provided", type: "uint256" },
7235
+ { name: "expected", type: "uint256" }
7236
+ ]
7237
+ },
7238
+ { type: "error", name: "InvalidCaller", inputs: [{ name: "", type: "address" }] },
7239
+ { type: "error", name: "InvalidDAForPermanentRollup", inputs: [] },
7240
+ { type: "error", name: "InvalidDelay", inputs: [] },
7241
+ {
7242
+ type: "error",
7243
+ name: "InvalidLogSender",
7244
+ inputs: [
7245
+ { name: "sender", type: "address" },
7246
+ { name: "logKey", type: "uint256" }
7247
+ ]
7248
+ },
7249
+ {
7250
+ type: "error",
7251
+ name: "InvalidMessageRoot",
7252
+ inputs: [
7253
+ { name: "expectedMessageRoot", type: "bytes32" },
7254
+ { name: "providedMessageRoot", type: "bytes32" }
7255
+ ]
7256
+ },
7257
+ { type: "error", name: "InvalidNTVBurnData", inputs: [] },
7258
+ {
7259
+ type: "error",
7260
+ name: "InvalidNumberOfBlobs",
7261
+ inputs: [
7262
+ { name: "expected", type: "uint256" },
7263
+ { name: "numCommitments", type: "uint256" },
7264
+ { name: "numHashes", type: "uint256" }
7265
+ ]
7266
+ },
7267
+ {
7268
+ type: "error",
7269
+ name: "InvalidPackedPrecommitmentLength",
7270
+ inputs: [{ name: "length", type: "uint256" }]
7271
+ },
7272
+ { type: "error", name: "InvalidProof", inputs: [] },
7273
+ { type: "error", name: "InvalidProofLengthForFinalNode", inputs: [] },
7274
+ { type: "error", name: "InvalidProtocolVersion", inputs: [] },
7275
+ { type: "error", name: "InvalidPubdataPricingMode", inputs: [] },
7276
+ { type: "error", name: "InvalidSelector", inputs: [{ name: "func", type: "bytes4" }] },
7277
+ { type: "error", name: "InvalidSystemLogsLength", inputs: [] },
7278
+ { type: "error", name: "InvalidUpgradeTxn", inputs: [{ name: "", type: "uint8" }] },
7279
+ { type: "error", name: "L2TimestampTooBig", inputs: [] },
7280
+ {
7281
+ type: "error",
7282
+ name: "L2WithdrawalMessageWrongLength",
7283
+ inputs: [{ name: "messageLen", type: "uint256" }]
7284
+ },
7285
+ { type: "error", name: "LegacyBridgeNotSet", inputs: [] },
7286
+ { type: "error", name: "LegacyBridgeUsesNonNativeToken", inputs: [] },
7287
+ { type: "error", name: "LegacyEncodingUsedForNonL1Token", inputs: [] },
7288
+ { type: "error", name: "LegacyMethodForNonL1Token", inputs: [] },
7289
+ {
7290
+ type: "error",
7291
+ name: "LengthIsNotDivisibleBy32",
7292
+ inputs: [{ name: "length", type: "uint256" }]
7293
+ },
7294
+ { type: "error", name: "LogAlreadyProcessed", inputs: [{ name: "", type: "uint8" }] },
7295
+ { type: "error", name: "MalformedBytecode", inputs: [{ name: "", type: "uint8" }] },
7296
+ { type: "error", name: "MerkleIndexOrHeightMismatch", inputs: [] },
7297
+ { type: "error", name: "MerkleIndexOutOfBounds", inputs: [] },
7298
+ { type: "error", name: "MerkleNothingToProve", inputs: [] },
7299
+ { type: "error", name: "MerklePathEmpty", inputs: [] },
7300
+ {
7301
+ type: "error",
7302
+ name: "MerklePathLengthMismatch",
7303
+ inputs: [
7304
+ { name: "pathLength", type: "uint256" },
7305
+ { name: "expectedLength", type: "uint256" }
7306
+ ]
7307
+ },
7308
+ { type: "error", name: "MerklePathOutOfBounds", inputs: [] },
7309
+ {
7310
+ type: "error",
7311
+ name: "MerkleWrongIndex",
7312
+ inputs: [
7313
+ { name: "index", type: "uint256" },
7314
+ { name: "maxNodeNumber", type: "uint256" }
7315
+ ]
7316
+ },
7317
+ {
7318
+ type: "error",
7319
+ name: "MerkleWrongLength",
7320
+ inputs: [
7321
+ { name: "newLeavesLength", type: "uint256" },
7322
+ { name: "leafNumber", type: "uint256" }
7323
+ ]
7324
+ },
7325
+ { type: "error", name: "MigrationPaused", inputs: [] },
7326
+ { type: "error", name: "MigrationsNotPaused", inputs: [] },
7327
+ {
7328
+ type: "error",
7329
+ name: "MissingSystemLogs",
7330
+ inputs: [
7331
+ { name: "expected", type: "uint256" },
7332
+ { name: "actual", type: "uint256" }
7333
+ ]
7334
+ },
7335
+ {
7336
+ type: "error",
7337
+ name: "MsgValueMismatch",
7338
+ inputs: [
7339
+ { name: "expectedMsgValue", type: "uint256" },
7340
+ { name: "providedMsgValue", type: "uint256" }
7341
+ ]
7342
+ },
7343
+ {
7344
+ type: "error",
7345
+ name: "MsgValueTooLow",
7346
+ inputs: [
7347
+ { name: "required", type: "uint256" },
7348
+ { name: "provided", type: "uint256" }
7349
+ ]
7350
+ },
7351
+ { type: "error", name: "NewDeadlineExceedsMaxDeadline", inputs: [] },
7352
+ { type: "error", name: "NewDeadlineNotGreaterThanCurrent", inputs: [] },
7353
+ { type: "error", name: "NoCallsProvided", inputs: [] },
7354
+ { type: "error", name: "NoCTMForAssetId", inputs: [{ name: "assetId", type: "bytes32" }] },
7355
+ { type: "error", name: "NoFunctionsForDiamondCut", inputs: [] },
7356
+ { type: "error", name: "NoFundsTransferred", inputs: [] },
7357
+ { type: "error", name: "NoLegacySharedBridge", inputs: [] },
7358
+ { type: "error", name: "NonEmptyCalldata", inputs: [] },
7359
+ { type: "error", name: "NonEmptyMsgValue", inputs: [] },
7360
+ { type: "error", name: "NonIncreasingTimestamp", inputs: [] },
7361
+ { type: "error", name: "NonSequentialBatch", inputs: [] },
7362
+ { type: "error", name: "NonSequentialVersion", inputs: [] },
7363
+ { type: "error", name: "NotAllowed", inputs: [{ name: "addr", type: "address" }] },
7364
+ { type: "error", name: "NotARestriction", inputs: [{ name: "addr", type: "address" }] },
7365
+ { type: "error", name: "NotAZKChain", inputs: [{ name: "addr", type: "address" }] },
7366
+ { type: "error", name: "NotInitializedReentrancyGuard", inputs: [] },
7367
+ { type: "error", name: "NotWhitelisted", inputs: [{ name: "", type: "address" }] },
7368
+ { type: "error", name: "OnlyEraSupported", inputs: [] },
7369
+ { type: "error", name: "OnlySelfAllowed", inputs: [] },
7370
+ { type: "error", name: "OperationExists", inputs: [] },
7371
+ { type: "error", name: "OperationMustBePending", inputs: [] },
7372
+ { type: "error", name: "OperationMustBeReady", inputs: [] },
7373
+ { type: "error", name: "OriginChainIdNotFound", inputs: [] },
7374
+ {
7375
+ type: "error",
7376
+ name: "PrecommitmentMismatch",
7377
+ inputs: [
7378
+ { name: "batchNumber", type: "uint256" },
7379
+ { name: "expected", type: "bytes32" },
7380
+ { name: "found", type: "bytes32" }
7381
+ ]
7382
+ },
7383
+ { type: "error", name: "PreviousOperationNotExecuted", inputs: [] },
7384
+ { type: "error", name: "PriorityOperationsRollingHashMismatch", inputs: [] },
7385
+ { type: "error", name: "PriorityTxPubdataExceedsMaxPubDataPerBatch", inputs: [] },
7386
+ {
7387
+ type: "error",
7388
+ name: "ProtocolIdMismatch",
7389
+ inputs: [
7390
+ { name: "expectedProtocolVersion", type: "uint256" },
7391
+ { name: "providedProtocolId", type: "uint256" }
7392
+ ]
7393
+ },
7394
+ { type: "error", name: "ProtocolIdNotGreater", inputs: [] },
7395
+ {
7396
+ type: "error",
7397
+ name: "PubdataGreaterThanLimit",
7398
+ inputs: [
7399
+ { name: "limit", type: "uint256" },
7400
+ { name: "length", type: "uint256" }
7401
+ ]
7402
+ },
7403
+ { type: "error", name: "QueueIsEmpty", inputs: [] },
7404
+ { type: "error", name: "Reentrancy", inputs: [] },
7405
+ {
7406
+ type: "error",
7407
+ name: "RemoveFunctionFacetAddressNotZero",
7408
+ inputs: [{ name: "facet", type: "address" }]
7409
+ },
7410
+ { type: "error", name: "RemoveFunctionFacetAddressZero", inputs: [] },
7411
+ { type: "error", name: "RemovingPermanentRestriction", inputs: [] },
7412
+ { type: "error", name: "ReplaceFunctionFacetAddressZero", inputs: [] },
7413
+ {
7414
+ type: "error",
7415
+ name: "RestrictionWasAlreadyPresent",
7416
+ inputs: [{ name: "restriction", type: "address" }]
7417
+ },
7418
+ {
7419
+ type: "error",
7420
+ name: "RestrictionWasNotPresent",
7421
+ inputs: [{ name: "restriction", type: "address" }]
7422
+ },
7423
+ { type: "error", name: "RevertedBatchNotAfterNewLastBatch", inputs: [] },
7424
+ {
7425
+ type: "error",
7426
+ name: "RoleAccessDenied",
7427
+ inputs: [
7428
+ { name: "chainAddress", type: "address" },
7429
+ { name: "role", type: "bytes32" },
7430
+ { name: "account", type: "address" }
7431
+ ]
7432
+ },
7433
+ { type: "error", name: "SelectorsMustAllHaveSameFreezability", inputs: [] },
7434
+ { type: "error", name: "SettlementLayersMustSettleOnL1", inputs: [] },
7435
+ { type: "error", name: "SharedBridgeNotSet", inputs: [] },
7436
+ { type: "error", name: "SharedBridgeValueNotSet", inputs: [{ name: "", type: "uint8" }] },
7437
+ { type: "error", name: "SlotOccupied", inputs: [] },
7438
+ { type: "error", name: "SystemLogsSizeTooBig", inputs: [] },
7439
+ {
7440
+ type: "error",
7441
+ name: "TimeNotReached",
7442
+ inputs: [
7443
+ { name: "expectedTimestamp", type: "uint256" },
7444
+ { name: "actualTimestamp", type: "uint256" }
7445
+ ]
7446
+ },
7447
+ { type: "error", name: "TimerAlreadyStarted", inputs: [] },
7448
+ { type: "error", name: "TimestampError", inputs: [] },
7449
+ { type: "error", name: "TokenIsLegacy", inputs: [] },
7450
+ { type: "error", name: "TokenNotLegacy", inputs: [] },
7451
+ { type: "error", name: "TokenNotSupported", inputs: [{ name: "token", type: "address" }] },
7452
+ { type: "error", name: "TokensWithFeesNotSupported", inputs: [] },
7453
+ { type: "error", name: "TooHighDeploymentNonce", inputs: [] },
7454
+ { type: "error", name: "TooManyFactoryDeps", inputs: [] },
7455
+ { type: "error", name: "TooMuchGas", inputs: [] },
7456
+ { type: "error", name: "TransactionNotAllowed", inputs: [] },
7457
+ { type: "error", name: "TxHashMismatch", inputs: [] },
7458
+ { type: "error", name: "TxnBodyGasLimitNotEnoughGas", inputs: [] },
7459
+ {
7460
+ type: "error",
7461
+ name: "UnallowedImplementation",
7462
+ inputs: [{ name: "implementationHash", type: "bytes32" }]
7463
+ },
7464
+ { type: "error", name: "Unauthorized", inputs: [{ name: "caller", type: "address" }] },
7465
+ { type: "error", name: "UndefinedDiamondCutAction", inputs: [] },
7466
+ { type: "error", name: "UnexpectedSystemLog", inputs: [{ name: "logKey", type: "uint256" }] },
7467
+ { type: "error", name: "UnknownVerifierType", inputs: [] },
7468
+ {
7469
+ type: "error",
7470
+ name: "UnsupportedCommitBatchEncoding",
7471
+ inputs: [{ name: "version", type: "uint8" }]
7472
+ },
7473
+ { type: "error", name: "UnsupportedEncodingVersion", inputs: [] },
7474
+ {
7475
+ type: "error",
7476
+ name: "UnsupportedExecuteBatchEncoding",
7477
+ inputs: [{ name: "version", type: "uint8" }]
7478
+ },
7479
+ {
7480
+ type: "error",
7481
+ name: "UnsupportedProofBatchEncoding",
7482
+ inputs: [{ name: "version", type: "uint8" }]
7483
+ },
7484
+ { type: "error", name: "UpgradeBatchNumberIsNotZero", inputs: [] },
7485
+ { type: "error", name: "ValidateTxnNotEnoughGas", inputs: [] },
7486
+ {
7487
+ type: "error",
7488
+ name: "ValueMismatch",
7489
+ inputs: [
7490
+ { name: "expected", type: "uint256" },
7491
+ { name: "actual", type: "uint256" }
7492
+ ]
7493
+ },
7494
+ { type: "error", name: "VerifiedBatchesExceedsCommittedBatches", inputs: [] },
7495
+ { type: "error", name: "WithdrawalAlreadyFinalized", inputs: [] },
7496
+ { type: "error", name: "WithdrawFailed", inputs: [] },
7497
+ { type: "error", name: "WrappedBaseTokenAlreadyRegistered", inputs: [] },
7498
+ {
7499
+ type: "error",
7500
+ name: "WrongMagicValue",
7501
+ inputs: [
7502
+ { name: "expectedMagicValue", type: "uint256" },
7503
+ { name: "providedMagicValue", type: "uint256" }
7504
+ ]
7505
+ },
7506
+ { type: "error", name: "ZeroAddress", inputs: [] },
7507
+ { type: "error", name: "ZeroChainId", inputs: [] },
7508
+ { type: "error", name: "ZKChainLimitReached", inputs: [] }
7509
+ ];
7510
+ var IL1ContractErrors_default = IL1ContractErrorsABI;
7511
+
7512
+ // src/core/types/primitives.ts
7513
+ var ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
7514
+
7515
+ // src/core/errors/error-ops.ts
7516
+ function resolveMessage(op, msg) {
7517
+ if (!msg) return `Error during ${op}.`;
7518
+ return typeof msg === "function" ? msg() : msg;
7519
+ }
7520
+ function createErrorOps(decodeRevert2) {
7521
+ function toZKsyncError2(type, base, err) {
7522
+ if (isZKsyncError(err)) return err;
7523
+ const revert = decodeRevert2 ? decodeRevert2(err) : void 0;
7524
+ return createError(type, { ...base, ...revert ? { revert } : {}, cause: shapeCause(err) });
7525
+ }
7526
+ function createErrorHandlers2(resource) {
7527
+ async function run(kind, operation, fn, opts) {
7528
+ try {
7529
+ return await fn();
7530
+ } catch (e) {
7531
+ if (isZKsyncError(e)) throw e;
7532
+ const message = resolveMessage(operation, opts?.message);
7533
+ throw toZKsyncError2(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
7534
+ }
7535
+ }
7536
+ function wrap8(operation, fn, opts) {
7537
+ return run("INTERNAL", operation, fn, opts);
7538
+ }
7539
+ function wrapAs10(kind, operation, fn, opts) {
7540
+ return run(kind, operation, fn, opts);
7541
+ }
7542
+ async function toResult3(operation, fn, opts) {
7543
+ try {
7544
+ const value = await wrap8(operation, fn, opts);
7545
+ return { ok: true, value };
7546
+ } catch (e) {
7547
+ const shaped = isZKsyncError(e) ? e : toZKsyncError2(
7548
+ "INTERNAL",
7549
+ {
7550
+ resource,
7551
+ operation,
7552
+ context: opts?.ctx ?? {},
7553
+ message: resolveMessage(operation, opts?.message)
7554
+ },
7555
+ e
7556
+ );
7557
+ return { ok: false, error: shaped };
7558
+ }
7559
+ }
7560
+ return { wrap: wrap8, wrapAs: wrapAs10, toResult: toResult3 };
7561
+ }
7562
+ return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
7563
+ }
7564
+
7565
+ // src/core/errors/withdrawal-revert-map.ts
7566
+ var REVERT_TO_READINESS = {
7567
+ // Already done
7568
+ WithdrawalAlreadyFinalized: { kind: "FINALIZED" },
7569
+ // Temporary — try later
7570
+ BatchNotExecuted: { kind: "NOT_READY", reason: "batch-not-executed" },
7571
+ LocalRootIsZero: { kind: "NOT_READY", reason: "root-missing" },
7572
+ // Permanent — won’t become ready for this tx
7573
+ WrongL2Sender: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7574
+ InvalidSelector: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7575
+ L2WithdrawalMessageWrongLength: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7576
+ WrongMsgLength: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7577
+ TokenNotLegacy: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7578
+ TokenIsLegacy: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7579
+ InvalidProof: { kind: "UNFINALIZABLE", reason: "message-invalid" },
7580
+ InvalidChainId: { kind: "UNFINALIZABLE", reason: "invalid-chain" },
7581
+ NotSettlementLayer: { kind: "UNFINALIZABLE", reason: "settlement-layer" },
7582
+ // Likely environment mismatch — treat as permanent for this tx
7583
+ OnlyEraSupported: { kind: "UNFINALIZABLE", reason: "unsupported" },
7584
+ LocalRootMustBeZero: { kind: "UNFINALIZABLE", reason: "unsupported" }
7585
+ };
7586
+
7587
+ // src/adapters/ethers/errors/revert.ts
7588
+ var ERROR_IFACES = [];
7589
+ var IFACE_ERROR_STRING = new ethers.Interface(["error Error(string)"]);
7590
+ var IFACE_PANIC = new ethers.Interface(["error Panic(uint256)"]);
7591
+ (function bootstrapDefaultIfaces() {
7592
+ try {
7593
+ ERROR_IFACES.push({
7594
+ name: "IL1Nullifier",
7595
+ iface: new ethers.Interface(IL1Nullifier_default)
7596
+ });
7597
+ } catch {
7598
+ }
7599
+ try {
7600
+ ERROR_IFACES.push({ name: "IERC20", iface: new ethers.Interface(IERC20_default) });
7601
+ } catch {
7602
+ }
7603
+ try {
7604
+ ERROR_IFACES.push({
7605
+ name: "IL1NativeTokenVault",
7606
+ iface: new ethers.Interface(L1NativeTokenVault_default)
7607
+ });
7608
+ } catch {
7609
+ }
7610
+ try {
7611
+ ERROR_IFACES.push({
7612
+ name: "IL2NativeTokenVault",
7613
+ iface: new ethers.Interface(L2NativeTokenVault_default)
7614
+ });
7615
+ } catch {
7616
+ }
7617
+ try {
7618
+ ERROR_IFACES.push({ name: "Mailbox", iface: new ethers.Interface(Mailbox_default) });
7619
+ } catch {
7620
+ }
7621
+ try {
7622
+ ERROR_IFACES.push({ name: "IL1ContractErrors", iface: new ethers.Interface(IL1ContractErrors_default) });
7623
+ } catch {
7624
+ }
7625
+ try {
7626
+ ERROR_IFACES.push({ name: "IInteropErrors", iface: new ethers.Interface(IInteropErrors_default) });
7627
+ } catch {
7628
+ }
7629
+ })();
7630
+ function registerErrorAbi(name, abi2) {
7631
+ const existing = ERROR_IFACES.findIndex((x) => x.name === name);
7632
+ const entry = { name, iface: new ethers.Interface(abi2) };
7633
+ if (existing >= 0) ERROR_IFACES[existing] = entry;
7634
+ else ERROR_IFACES.push(entry);
7635
+ }
7636
+ function extractRevertData(e) {
7637
+ const maybe = (
7638
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7639
+ e?.data?.data ?? e?.error?.data ?? e?.data ?? e?.error?.error?.data ?? e?.info?.error?.data
7640
+ );
7641
+ if (typeof maybe === "string" && maybe.startsWith("0x") && maybe.length >= 10) {
7642
+ return maybe;
7643
+ }
7644
+ return void 0;
7645
+ }
7646
+ function decodeRevert(e) {
7647
+ const data = extractRevertData(e);
7648
+ if (!data) return;
7649
+ const selector = `0x${data.slice(2, 10)}`;
7650
+ try {
7651
+ const parsed = IFACE_ERROR_STRING.parseError(data);
7652
+ if (parsed?.name === "Error") {
7653
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
7654
+ return { selector, name: "Error", args };
7655
+ }
7656
+ } catch {
7657
+ }
7658
+ try {
7659
+ const parsed = IFACE_PANIC.parseError(data);
7660
+ if (parsed?.name === "Panic") {
7661
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
7662
+ return { selector, name: "Panic", args };
7663
+ }
7664
+ } catch {
7665
+ }
7666
+ for (const { name, iface } of ERROR_IFACES) {
7667
+ try {
7668
+ const parsed = iface.parseError(data);
7669
+ if (parsed) {
7670
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
7671
+ return {
7672
+ selector,
7673
+ name: parsed.name,
7674
+ args,
7675
+ contract: name
7676
+ };
7677
+ }
7678
+ } catch {
7679
+ }
7680
+ }
7681
+ return { selector };
7682
+ }
7683
+ function classifyReadinessFromRevert(e) {
7684
+ const r = decodeRevert(e);
7685
+ const name = r?.name;
7686
+ if (name && REVERT_TO_READINESS[name]) return REVERT_TO_READINESS[name];
7687
+ const msg = (() => {
7688
+ if (typeof e !== "object" || e === null) return "";
7689
+ const obj = e;
7690
+ const maybeMsg = obj["shortMessage"] ?? obj["message"];
7691
+ return typeof maybeMsg === "string" ? maybeMsg : "";
7692
+ })();
7693
+ const lower = String(msg).toLowerCase();
7694
+ if (lower.includes("paused")) return { kind: "NOT_READY", reason: "paused" };
7695
+ if (name || r?.selector) {
7696
+ return { kind: "UNFINALIZABLE", reason: "unsupported", detail: name ?? r?.selector };
7697
+ }
7698
+ return { kind: "NOT_READY", reason: "unknown", detail: lower || void 0 };
7699
+ }
7700
+
7701
+ // src/adapters/ethers/errors/error-ops.ts
7702
+ var { toZKsyncError, createErrorHandlers } = createErrorOps(decodeRevert);
7703
+
7704
+ // src/adapters/ethers/client.ts
7705
+ var { wrapAs, wrap } = createErrorHandlers("client");
7706
+ var ChainTypeManagerABI = [
7707
+ "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)"
7708
+ ];
7709
+ function createEthersClient(args) {
7710
+ const { l1, l2, signer } = args;
6958
7711
  let boundSigner = signer;
6959
7712
  const signerProvider = signer.provider;
6960
7713
  const isBrowserProvider = signerProvider instanceof ethers.BrowserProvider;
@@ -7336,11 +8089,10 @@ async function quoteL1Gas(input) {
7336
8089
  const est = await estimator.estimateGas(tx);
7337
8090
  const buffered = BigInt(est) * (100n + BUFFER) / 100n;
7338
8091
  return makeGasQuote({ gasLimit: buffered, maxFeePerGas, maxPriorityFeePerGas });
7339
- } catch (err) {
8092
+ } catch {
7340
8093
  if (fallbackGasLimit != null) {
7341
8094
  return makeGasQuote({ gasLimit: fallbackGasLimit, maxFeePerGas, maxPriorityFeePerGas });
7342
8095
  }
7343
- console.warn("L1 gas estimation failed", err);
7344
8096
  return void 0;
7345
8097
  }
7346
8098
  }
@@ -7378,8 +8130,7 @@ async function quoteL2Gas(input) {
7378
8130
  maxFeePerGas,
7379
8131
  gasPerPubdata: pp
7380
8132
  });
7381
- } catch (err) {
7382
- console.warn("L2 gas estimation failed", err);
8133
+ } catch {
7383
8134
  return makeGasQuote({
7384
8135
  gasLimit: l2GasLimit ?? 0n,
7385
8136
  maxFeePerGas,
@@ -7542,8 +8293,22 @@ async function determineNonBaseL2Gas(input) {
7542
8293
  try {
7543
8294
  const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token));
7544
8295
  if (l2TokenAddress === ZERO_L2_TOKEN_ADDRESS) {
8296
+ if (input.undeployedGasLimit != null) {
8297
+ return quoteL2Gas2({
8298
+ ctx,
8299
+ route,
8300
+ overrideGasLimit: input.undeployedGasLimit
8301
+ });
8302
+ }
7545
8303
  return fallbackQuote();
7546
8304
  }
8305
+ if (input.priorityFloorGasLimit != null) {
8306
+ return quoteL2Gas2({
8307
+ ctx,
8308
+ route,
8309
+ overrideGasLimit: input.priorityFloorGasLimit
8310
+ });
8311
+ }
7547
8312
  const modelTx = {
7548
8313
  to: input.modelTx?.to ?? ctx.sender,
7549
8314
  from: input.modelTx?.from ?? ctx.sender,
@@ -7559,8 +8324,7 @@ async function determineNonBaseL2Gas(input) {
7559
8324
  return fallbackQuote();
7560
8325
  }
7561
8326
  return gas;
7562
- } catch (err) {
7563
- console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
8327
+ } catch {
7564
8328
  return fallbackQuote();
7565
8329
  }
7566
8330
  }
@@ -7577,7 +8341,9 @@ async function determineEthNonBaseL2Gas(input) {
7577
8341
  route: "eth-nonbase",
7578
8342
  l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
7579
8343
  knownL2Token: input.ctx.resolvedToken?.l2,
7580
- modelTx: input.modelTx
8344
+ modelTx: input.modelTx,
8345
+ priorityFloorGasLimit: input.priorityFloorGasLimit,
8346
+ undeployedGasLimit: input.undeployedGasLimit
7581
8347
  });
7582
8348
  }
7583
8349
 
@@ -7609,41 +8375,112 @@ function buildFeeBreakdown(p) {
7609
8375
  };
7610
8376
  }
7611
8377
 
8378
+ // src/core/resources/deposits/priority.ts
8379
+ var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
8380
+ var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
8381
+ var maxBigInt = (a, b) => a > b ? a : b;
8382
+ var ceilDiv = (a, b) => (a + b - 1n) / b;
8383
+ function derivePriorityTxGasBreakdown(input) {
8384
+ const factoryDepsCount = input.factoryDepsCount ?? 0n;
8385
+ const minBodyGas = maxBigInt(
8386
+ L1_TX_INTRINSIC_L2_GAS + ceilDiv(
8387
+ input.encodedLength * L1_TX_DELTA_544_ENCODING_BYTES,
8388
+ PRIORITY_TX_ENCODING_STEP_BYTES
8389
+ ) + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_L2_GAS,
8390
+ L1_TX_MIN_L2_GAS_BASE
8391
+ ) + L1_TX_INTRINSIC_PUBDATA * input.gasPerPubdata + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * input.gasPerPubdata;
8392
+ const overhead = maxBigInt(TX_SLOT_OVERHEAD_L2_GAS, TX_MEMORY_OVERHEAD_GAS * input.encodedLength);
8393
+ const derivedBodyGas = minBodyGas;
8394
+ return {
8395
+ encodedLength: input.encodedLength,
8396
+ minBodyGas,
8397
+ overhead,
8398
+ derivedBodyGas,
8399
+ derivedL2GasLimit: derivedBodyGas + overhead,
8400
+ priorityTxMaxGasLimit: PRIORITY_TX_MAX_GAS_LIMIT,
8401
+ priorityTxMaxGasLimitExceeded: derivedBodyGas > PRIORITY_TX_MAX_GAS_LIMIT
8402
+ };
8403
+ }
8404
+ function derivePriorityBodyGasEstimateCap(input) {
8405
+ return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
8406
+ }
8407
+
8408
+ // src/adapters/ethers/resources/deposits/routes/priority.ts
8409
+ var EMPTY_BYTES = "0x";
8410
+ var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
8411
+ var L2_CANONICAL_TRANSACTION_TUPLE = "tuple(uint256 txType,uint256 from,uint256 to,uint256 gasLimit,uint256 gasPerPubdataByteLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,uint256 paymaster,uint256 nonce,uint256 value,uint256[4] reserved,bytes data,bytes signature,uint256[] factoryDeps,bytes paymasterInput,bytes reservedDynamic)";
8412
+ function hexByteLength(hex) {
8413
+ return BigInt(Math.max(hex.length - 2, 0) / 2);
8414
+ }
8415
+ function getPriorityTxEncodedLength(input) {
8416
+ const encoded = ethers.AbiCoder.defaultAbiCoder().encode(
8417
+ [L2_CANONICAL_TRANSACTION_TUPLE],
8418
+ [
8419
+ [
8420
+ 0n,
8421
+ BigInt(input.sender),
8422
+ BigInt(input.l2Contract),
8423
+ 0n,
8424
+ input.gasPerPubdata,
8425
+ 0n,
8426
+ 0n,
8427
+ 0n,
8428
+ 0n,
8429
+ input.l2Value,
8430
+ ZERO_RESERVED_WORDS,
8431
+ input.l2Calldata,
8432
+ EMPTY_BYTES,
8433
+ input.factoryDepsHashes ?? [],
8434
+ EMPTY_BYTES,
8435
+ EMPTY_BYTES
8436
+ ]
8437
+ ]
8438
+ );
8439
+ return hexByteLength(encoded);
8440
+ }
8441
+ function getPriorityTxGasBreakdown(input) {
8442
+ return derivePriorityTxGasBreakdown({
8443
+ encodedLength: getPriorityTxEncodedLength(input),
8444
+ gasPerPubdata: input.gasPerPubdata,
8445
+ factoryDepsCount: BigInt(input.factoryDepsHashes?.length ?? 0)
8446
+ });
8447
+ }
8448
+
7612
8449
  // src/adapters/ethers/resources/deposits/routes/eth.ts
8450
+ var EMPTY_BYTES2 = "0x";
7613
8451
  function routeEthDirect() {
7614
8452
  return {
7615
8453
  async build(p, ctx) {
7616
8454
  const bh = await ctx.contracts.bridgehub();
7617
- const l2TxModel = {
7618
- to: p.to ?? ctx.sender,
7619
- from: ctx.sender,
7620
- data: "0x",
7621
- value: 0n
7622
- };
8455
+ const l2Contract = p.to ?? ctx.sender;
8456
+ const l2Value = p.amount;
8457
+ const l2Calldata = EMPTY_BYTES2;
8458
+ const priorityFloorBreakdown = getPriorityTxGasBreakdown({
8459
+ sender: ctx.sender,
8460
+ l2Contract,
8461
+ l2Value,
8462
+ l2Calldata,
8463
+ gasPerPubdata: ctx.gasPerPubdata
8464
+ });
8465
+ const quotedL2GasLimit = ctx.l2GasLimit ?? priorityFloorBreakdown.derivedL2GasLimit;
7623
8466
  const l2GasParams = await quoteL2Gas2({
7624
8467
  ctx,
7625
8468
  route: "eth-base",
7626
- l2TxForModeling: l2TxModel,
7627
- overrideGasLimit: ctx.l2GasLimit,
7628
- stateOverrides: {
7629
- [ctx.sender]: {
7630
- balance: "0xffffffffffffffffffff"
7631
- }
7632
- }
8469
+ overrideGasLimit: quotedL2GasLimit
7633
8470
  });
7634
8471
  if (!l2GasParams) {
7635
8472
  throw new Error("Failed to estimate L2 gas for deposit.");
7636
8473
  }
7637
8474
  const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
7638
- const mintValue = baseCost + ctx.operatorTip + p.amount;
8475
+ const mintValue = baseCost + ctx.operatorTip + l2Value;
7639
8476
  const req = buildDirectRequestStruct({
7640
8477
  chainId: ctx.chainIdL2,
7641
8478
  mintValue,
7642
8479
  l2GasLimit: l2GasParams.gasLimit,
7643
8480
  gasPerPubdata: ctx.gasPerPubdata,
7644
8481
  refundRecipient: ctx.refundRecipient,
7645
- l2Contract: p.to ?? ctx.sender,
7646
- l2Value: p.amount
8482
+ l2Contract,
8483
+ l2Value
7647
8484
  });
7648
8485
  const data = bh.interface.encodeFunctionData("requestL2TransactionDirect", [req]);
7649
8486
  const l1TxCandidate = {
@@ -7688,6 +8525,53 @@ function routeEthDirect() {
7688
8525
  };
7689
8526
  }
7690
8527
  var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
8528
+ var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
8529
+ var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
8530
+ async function getPriorityGasModel(input) {
8531
+ try {
8532
+ const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
8533
+ const l1AssetRouter = await input.ctx.contracts.l1AssetRouter();
8534
+ const { chainId: l1ChainId } = await input.ctx.client.l1.getNetwork();
8535
+ const isFirstBridge = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID || input.ctx.resolvedToken.originChainId === 0n;
8536
+ const erc20MetadataOriginChainId = isFirstBridge ? BigInt(l1ChainId) : input.ctx.resolvedToken.originChainId;
8537
+ const erc20Metadata = await l1NativeTokenVault.getERC20Getters(
8538
+ input.token,
8539
+ erc20MetadataOriginChainId
8540
+ );
8541
+ const bridgeMintCalldata = ethers.AbiCoder.defaultAbiCoder().encode(
8542
+ ["address", "address", "address", "uint256", "bytes"],
8543
+ [input.ctx.sender, input.receiver, input.token, input.amount, erc20Metadata]
8544
+ );
8545
+ const l2Calldata = isFirstBridge ? new ethers.Interface(IL2AssetRouter_default).encodeFunctionData(
8546
+ "finalizeDeposit(address,address,address,uint256,bytes)",
8547
+ [input.ctx.sender, input.receiver, input.token, input.amount, erc20Metadata]
8548
+ ) : await (() => {
8549
+ return l1AssetRouter.getDepositCalldata(
8550
+ input.ctx.sender,
8551
+ input.ctx.resolvedToken.assetId,
8552
+ bridgeMintCalldata
8553
+ );
8554
+ })();
8555
+ const priorityFloorBreakdown = getPriorityTxGasBreakdown({
8556
+ sender: input.ctx.l1AssetRouter,
8557
+ l2Contract: L2_ASSET_ROUTER_ADDRESS,
8558
+ l2Value: 0n,
8559
+ l2Calldata,
8560
+ gasPerPubdata: input.ctx.gasPerPubdata
8561
+ });
8562
+ const model = {
8563
+ priorityFloorGasLimit: priorityFloorBreakdown.derivedL2GasLimit
8564
+ };
8565
+ if (isFirstBridge || input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS2) {
8566
+ model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
8567
+ minBodyGas: priorityFloorBreakdown.minBodyGas
8568
+ }) + priorityFloorBreakdown.overhead;
8569
+ }
8570
+ return model;
8571
+ } catch {
8572
+ return {};
8573
+ }
8574
+ }
7691
8575
  function routeErc20NonBase() {
7692
8576
  return {
7693
8577
  async preflight(p, ctx) {
@@ -7708,11 +8592,29 @@ function routeErc20NonBase() {
7708
8592
  const l1Signer = ctx.client.getL1Signer();
7709
8593
  const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
7710
8594
  const baseIsEth = ctx.baseIsEth ?? isETH(baseToken);
8595
+ const receiver = p.to ?? ctx.sender;
8596
+ const secondBridgeCalldata = await wrapAs3(
8597
+ "INTERNAL",
8598
+ OP_DEPOSITS.nonbase.encodeCalldata,
8599
+ () => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, receiver)),
8600
+ {
8601
+ ctx: { where: "encodeSecondBridgeErc20Args" },
8602
+ message: "Failed to encode bridging calldata."
8603
+ }
8604
+ );
8605
+ const priorityGasModel = await getPriorityGasModel({
8606
+ ctx,
8607
+ token: p.token,
8608
+ amount: p.amount,
8609
+ receiver
8610
+ });
7711
8611
  const l2GasParams = await determineErc20L2Gas({
7712
8612
  ctx,
7713
8613
  l1Token: p.token,
8614
+ priorityFloorGasLimit: priorityGasModel.priorityFloorGasLimit,
8615
+ undeployedGasLimit: priorityGasModel.undeployedGasLimit,
7714
8616
  modelTx: {
7715
- to: p.to ?? ctx.sender,
8617
+ to: receiver,
7716
8618
  from: ctx.sender,
7717
8619
  data: "0x",
7718
8620
  value: 0n
@@ -7774,15 +8676,6 @@ function routeErc20NonBase() {
7774
8676
  });
7775
8677
  }
7776
8678
  }
7777
- const secondBridgeCalldata = await wrapAs3(
7778
- "INTERNAL",
7779
- OP_DEPOSITS.nonbase.encodeCalldata,
7780
- () => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, p.to ?? ctx.sender)),
7781
- {
7782
- ctx: { where: "encodeSecondBridgeErc20Args" },
7783
- message: "Failed to encode bridging calldata."
7784
- }
7785
- );
7786
8679
  const requestStruct = {
7787
8680
  chainId: ctx.chainIdL2,
7788
8681
  mintValue,
@@ -7839,7 +8732,68 @@ function routeErc20NonBase() {
7839
8732
  }
7840
8733
  };
7841
8734
  }
8735
+
8736
+ // src/core/codec/ntv.ts
8737
+ function createNTVCodec(deps) {
8738
+ function encodeAssetId(originChainId, ntvAddress, tokenAddress) {
8739
+ const encoded = deps.encode(
8740
+ ["uint256", "address", "address"],
8741
+ [originChainId, ntvAddress, tokenAddress]
8742
+ );
8743
+ return deps.keccak256(encoded);
8744
+ }
8745
+ return {
8746
+ encodeAssetId
8747
+ };
8748
+ }
8749
+
8750
+ // src/adapters/ethers/resources/deposits/routes/eth-nonbase.ts
7842
8751
  var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
8752
+ var ZERO_L2_TOKEN_ADDRESS3 = "0x0000000000000000000000000000000000000000";
8753
+ var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
8754
+ var ntvCodec = createNTVCodec({
8755
+ encode: (types, values) => ethers.AbiCoder.defaultAbiCoder().encode(types, values),
8756
+ keccak256: (data) => ethers.keccak256(data)
8757
+ });
8758
+ async function getPriorityGasModel2(input) {
8759
+ try {
8760
+ const l1AssetRouter = await input.ctx.contracts.l1AssetRouter();
8761
+ const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
8762
+ const originChainId = input.ctx.resolvedToken.originChainId !== 0n ? input.ctx.resolvedToken.originChainId : BigInt((await input.ctx.client.l1.getNetwork()).chainId);
8763
+ const resolvedAssetId = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID2 ? ntvCodec.encodeAssetId(originChainId, L2_NATIVE_TOKEN_VAULT_ADDRESS, ETH_ADDRESS) : input.ctx.resolvedToken.assetId;
8764
+ const erc20Metadata = await l1NativeTokenVault.getERC20Getters(
8765
+ ETH_ADDRESS,
8766
+ originChainId
8767
+ );
8768
+ const bridgeMintCalldata = ethers.AbiCoder.defaultAbiCoder().encode(
8769
+ ["address", "address", "address", "uint256", "bytes"],
8770
+ [input.ctx.sender, input.receiver, ETH_ADDRESS, input.amount, erc20Metadata]
8771
+ );
8772
+ const l2Calldata = await l1AssetRouter.getDepositCalldata(
8773
+ input.ctx.sender,
8774
+ resolvedAssetId,
8775
+ bridgeMintCalldata
8776
+ );
8777
+ const priorityFloorBreakdown = getPriorityTxGasBreakdown({
8778
+ sender: input.ctx.l1AssetRouter,
8779
+ l2Contract: L2_ASSET_ROUTER_ADDRESS,
8780
+ l2Value: 0n,
8781
+ l2Calldata,
8782
+ gasPerPubdata: input.ctx.gasPerPubdata
8783
+ });
8784
+ const model = {
8785
+ priorityFloorGasLimit: priorityFloorBreakdown.derivedL2GasLimit
8786
+ };
8787
+ if (input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS3) {
8788
+ model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
8789
+ minBodyGas: priorityFloorBreakdown.minBodyGas
8790
+ }) + priorityFloorBreakdown.overhead;
8791
+ }
8792
+ return model;
8793
+ } catch {
8794
+ return {};
8795
+ }
8796
+ }
7843
8797
  function routeEthNonBase() {
7844
8798
  return {
7845
8799
  async preflight(p, ctx) {
@@ -7888,15 +8842,23 @@ function routeEthNonBase() {
7888
8842
  async build(p, ctx) {
7889
8843
  const l1Signer = ctx.client.getL1Signer();
7890
8844
  const baseToken = ctx.baseTokenL1;
8845
+ const receiver = p.to ?? ctx.sender;
8846
+ const priorityGasModel = await getPriorityGasModel2({
8847
+ ctx,
8848
+ amount: p.amount,
8849
+ receiver
8850
+ });
7891
8851
  const l2TxModel = {
7892
- to: p.to ?? ctx.sender,
8852
+ to: receiver,
7893
8853
  from: ctx.sender,
7894
8854
  data: "0x",
7895
8855
  value: 0n
7896
8856
  };
7897
8857
  const l2GasParams = await determineEthNonBaseL2Gas({
7898
8858
  ctx,
7899
- modelTx: l2TxModel
8859
+ modelTx: l2TxModel,
8860
+ priorityFloorGasLimit: priorityGasModel.priorityFloorGasLimit,
8861
+ undeployedGasLimit: priorityGasModel.undeployedGasLimit
7900
8862
  });
7901
8863
  if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
7902
8864
  const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
@@ -7930,12 +8892,12 @@ function routeEthNonBase() {
7930
8892
  const secondBridgeCalldata = await wrapAs4(
7931
8893
  "INTERNAL",
7932
8894
  OP_DEPOSITS.ethNonBase.encodeCalldata,
7933
- () => Promise.resolve(encodeSecondBridgeEthArgs(p.amount, p.to ?? ctx.sender)),
8895
+ () => Promise.resolve(encodeSecondBridgeEthArgs(p.amount, receiver)),
7934
8896
  {
7935
8897
  ctx: {
7936
8898
  where: "encodeSecondBridgeEthArgs",
7937
8899
  amount: p.amount.toString(),
7938
- to: p.to ?? ctx.sender
8900
+ to: receiver
7939
8901
  }
7940
8902
  }
7941
8903
  );
@@ -7996,6 +8958,7 @@ function routeEthNonBase() {
7996
8958
  };
7997
8959
  }
7998
8960
  var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
8961
+ var EMPTY_BYTES3 = "0x";
7999
8962
  function routeErc20Base() {
8000
8963
  return {
8001
8964
  async preflight(p, ctx) {
@@ -8026,17 +8989,21 @@ function routeErc20Base() {
8026
8989
  async build(p, ctx) {
8027
8990
  const l1Signer = ctx.client.getL1Signer();
8028
8991
  const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
8029
- const l2TxModel = {
8030
- to: p.to ?? ctx.sender,
8031
- from: ctx.sender,
8032
- data: "0x",
8033
- value: 0n
8034
- };
8992
+ const l2Contract = p.to ?? ctx.sender;
8993
+ const l2Value = p.amount;
8994
+ const l2Calldata = EMPTY_BYTES3;
8995
+ const priorityFloorBreakdown = getPriorityTxGasBreakdown({
8996
+ sender: ctx.sender,
8997
+ l2Contract,
8998
+ l2Value,
8999
+ l2Calldata,
9000
+ gasPerPubdata: ctx.gasPerPubdata
9001
+ });
9002
+ const quotedL2GasLimit = ctx.l2GasLimit ?? priorityFloorBreakdown.derivedL2GasLimit;
8035
9003
  const l2GasParams = await quoteL2Gas2({
8036
9004
  ctx,
8037
9005
  route: "erc20-base",
8038
- l2TxForModeling: l2TxModel,
8039
- overrideGasLimit: ctx.l2GasLimit
9006
+ overrideGasLimit: quotedL2GasLimit
8040
9007
  });
8041
9008
  if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
8042
9009
  const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
@@ -8075,8 +9042,8 @@ function routeErc20Base() {
8075
9042
  l2GasLimit: l2GasParams.gasLimit,
8076
9043
  gasPerPubdata: ctx.gasPerPubdata,
8077
9044
  refundRecipient: ctx.refundRecipient,
8078
- l2Contract: p.to ?? ctx.sender,
8079
- l2Value: p.amount
9045
+ l2Contract,
9046
+ l2Value
8080
9047
  });
8081
9048
  const bridgehub = await ctx.contracts.bridgehub();
8082
9049
  const data = bridgehub.interface.encodeFunctionData("requestL2TransactionDirect", [
@@ -8123,25 +9090,9 @@ function routeErc20Base() {
8123
9090
  }
8124
9091
  };
8125
9092
  }
8126
-
8127
- // src/core/codec/ntv.ts
8128
- function createNTVCodec(deps) {
8129
- function encodeAssetId(originChainId, ntvAddress, tokenAddress) {
8130
- const encoded = deps.encode(
8131
- ["uint256", "address", "address"],
8132
- [originChainId, ntvAddress, tokenAddress]
8133
- );
8134
- return deps.keccak256(encoded);
8135
- }
8136
- return {
8137
- encodeAssetId
8138
- };
8139
- }
8140
-
8141
- // src/adapters/ethers/resources/tokens/tokens.ts
8142
9093
  var { wrapAs: wrapAs6 } = createErrorHandlers("tokens");
8143
9094
  var abi = ethers.AbiCoder.defaultAbiCoder();
8144
- var ntvCodec = createNTVCodec({
9095
+ var ntvCodec2 = createNTVCodec({
8145
9096
  encode: (types, values) => abi.encode(types, values),
8146
9097
  keccak256: (data) => ethers.ethers.keccak256(data)
8147
9098
  });
@@ -8260,7 +9211,7 @@ function createTokensResource(client) {
8260
9211
  return wrapAs6("CONTRACT", "tokens.isChainEthBased", async () => {
8261
9212
  const baseAssetId = await getBaseTokenAssetId();
8262
9213
  const l1ChainId = await getL1ChainId();
8263
- const ethAssetId = ntvCodec.encodeAssetId(
9214
+ const ethAssetId = ntvCodec2.encodeAssetId(
8264
9215
  l1ChainId,
8265
9216
  L2_NATIVE_TOKEN_VAULT_ADDRESS,
8266
9217
  ETH_ADDRESS
@@ -9271,7 +10222,7 @@ var ROUTES2 = {
9271
10222
  };
9272
10223
  function createWithdrawalsResource(client, tokens, contracts) {
9273
10224
  const svc = createFinalizationServices(client);
9274
- const { wrap: wrap7, toResult: toResult3 } = createErrorHandlers("withdrawals");
10225
+ const { wrap: wrap8, toResult: toResult3 } = createErrorHandlers("withdrawals");
9275
10226
  const tokensResource = tokens ?? createTokensResource(client);
9276
10227
  const contractsResource = contracts ?? createContractsResource(client);
9277
10228
  async function buildPlan(p) {
@@ -9292,7 +10243,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9292
10243
  };
9293
10244
  }
9294
10245
  const finalizeCache = /* @__PURE__ */ new Map();
9295
- const quote = (p) => wrap7(
10246
+ const quote = (p) => wrap8(
9296
10247
  OP_WITHDRAWALS.quote,
9297
10248
  async () => {
9298
10249
  const plan = await buildPlan(p);
@@ -9314,7 +10265,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9314
10265
  ctx: { token: p.token, where: "withdrawals.tryQuote" }
9315
10266
  }
9316
10267
  );
9317
- const prepare = (p) => wrap7(OP_WITHDRAWALS.prepare, () => buildPlan(p), {
10268
+ const prepare = (p) => wrap8(OP_WITHDRAWALS.prepare, () => buildPlan(p), {
9318
10269
  message: "Internal error while preparing a withdrawal plan.",
9319
10270
  ctx: { token: p.token, where: "withdrawals.prepare" }
9320
10271
  });
@@ -9322,7 +10273,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9322
10273
  message: "Internal error while preparing a withdrawal plan.",
9323
10274
  ctx: { token: p.token, where: "withdrawals.tryPrepare" }
9324
10275
  });
9325
- const create = (p) => wrap7(
10276
+ const create = (p) => wrap8(
9326
10277
  OP_WITHDRAWALS.create,
9327
10278
  async () => {
9328
10279
  const plan = await prepare(p);
@@ -9393,7 +10344,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9393
10344
  message: "Internal error while creating withdrawal transactions.",
9394
10345
  ctx: { token: p.token, amount: p.amount, to: p.to, where: "withdrawals.tryCreate" }
9395
10346
  });
9396
- const status = (h) => wrap7(
10347
+ const status = (h) => wrap8(
9397
10348
  OP_WITHDRAWALS.status,
9398
10349
  async () => {
9399
10350
  const l2TxHash = typeof h === "string" ? h : "l2TxHash" in h && h.l2TxHash ? h.l2TxHash : "0x";
@@ -9448,7 +10399,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9448
10399
  const wait = (h, opts = {
9449
10400
  for: "l2",
9450
10401
  pollMs: 5500
9451
- }) => wrap7(
10402
+ }) => wrap8(
9452
10403
  OP_WITHDRAWALS.wait,
9453
10404
  async () => {
9454
10405
  const l2Hash = typeof h === "string" ? h : "l2TxHash" in h && h.l2TxHash ? h.l2TxHash : "0x";
@@ -9513,7 +10464,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
9513
10464
  }
9514
10465
  }
9515
10466
  );
9516
- const finalize = (l2TxHash) => wrap7(
10467
+ const finalize = (l2TxHash) => wrap8(
9517
10468
  OP_WITHDRAWALS.finalize.send,
9518
10469
  async () => {
9519
10470
  const pack = await (async () => {
@@ -9639,9 +10590,11 @@ function createCallAttributes(codec) {
9639
10590
  function createBundleAttributes(codec) {
9640
10591
  const executionAddress = (executor) => codec.encode("executionAddress", [executor]);
9641
10592
  const unbundlerAddress = (addr) => codec.encode("unbundlerAddress", [addr]);
10593
+ const useFixedFee = (enabled) => codec.encode("useFixedFee", [enabled]);
9642
10594
  return {
9643
10595
  executionAddress,
9644
- unbundlerAddress
10596
+ unbundlerAddress,
10597
+ useFixedFee
9645
10598
  };
9646
10599
  }
9647
10600
 
@@ -9662,6 +10615,7 @@ function getInteropAttributes(params, ctx) {
9662
10615
  if (params.unbundling?.by) {
9663
10616
  bundleAttributes.push(ctx.attributes.bundle.unbundlerAddress(params.unbundling.by));
9664
10617
  }
10618
+ bundleAttributes.push(ctx.attributes.bundle.useFixedFee(params.fee?.useFixed ?? false));
9665
10619
  const callAttributes = params.actions.map((action) => {
9666
10620
  switch (action.type) {
9667
10621
  case "sendNative": {
@@ -9691,11 +10645,6 @@ function createEthersAttributesResource(opts = {}) {
9691
10645
  }
9692
10646
 
9693
10647
  // src/core/types/flows/interop.ts
9694
- function isInteropExpectedRoot(obj) {
9695
- if (typeof obj !== "object" || obj === null) return false;
9696
- const root = obj;
9697
- return isBigint(root.rootChainId) && isBigint(root.batchNumber) && isHash(root.expectedRoot);
9698
- }
9699
10648
  function isInteropMessageProof(obj) {
9700
10649
  if (typeof obj !== "object" || obj === null) return false;
9701
10650
  const proof = obj;
@@ -9704,7 +10653,7 @@ function isInteropMessageProof(obj) {
9704
10653
  function isInteropFinalizationInfo(obj) {
9705
10654
  if (typeof obj !== "object" || obj === null) return false;
9706
10655
  const info = obj;
9707
- return isHash66(info.l2SrcTxHash) && isHash66(info.bundleHash) && isBigint(info.dstChainId) && isHash(info.encodedData) && isInteropExpectedRoot(info.expectedRoot) && isInteropMessageProof(info.proof);
10656
+ return isHash66(info.l2SrcTxHash) && isHash66(info.bundleHash) && isBigint(info.dstChainId) && isHash(info.encodedData) && isInteropMessageProof(info.proof);
9708
10657
  }
9709
10658
 
9710
10659
  // src/core/resources/interop/route.ts
@@ -9757,7 +10706,7 @@ function preflightDirect(params, ctx) {
9757
10706
  }
9758
10707
  }
9759
10708
  }
9760
- function buildDirectBundle(params, ctx, attrs) {
10709
+ function buildDirectBundle(params, ctx, attrs, interopFeeInfo) {
9761
10710
  const totalActionValue = sumActionMsgValue(params.actions);
9762
10711
  const starters = params.actions.map((action, index) => {
9763
10712
  const to = ctx.codec.formatAddress(action.to);
@@ -9775,7 +10724,8 @@ function buildDirectBundle(params, ctx, attrs) {
9775
10724
  dstChain: ctx.codec.formatChain(ctx.dstChainId),
9776
10725
  starters,
9777
10726
  bundleAttributes: attrs.bundleAttributes,
9778
- approvals: [],
10727
+ approvals: interopFeeInfo.approval ? [interopFeeInfo.approval] : [],
10728
+ interopFee: interopFeeInfo.fee,
9779
10729
  quoteExtras: {
9780
10730
  totalActionValue,
9781
10731
  bridgedTokenTotal: 0n
@@ -9820,7 +10770,7 @@ function preflightIndirect(params, ctx) {
9820
10770
  }
9821
10771
  }
9822
10772
  }
9823
- function buildIndirectBundle(params, ctx, attrs, starterData) {
10773
+ function buildIndirectBundle(params, ctx, attrs, starterData, interopFeeInfo) {
9824
10774
  const totalActionValue = sumActionMsgValue(params.actions);
9825
10775
  const bridgedTokenTotal = sumErc20Amounts(params.actions);
9826
10776
  const approvalMap = /* @__PURE__ */ new Map();
@@ -9839,6 +10789,7 @@ function buildIndirectBundle(params, ctx, attrs, starterData) {
9839
10789
  }
9840
10790
  }
9841
10791
  const approvals = Array.from(approvalMap.values());
10792
+ if (interopFeeInfo.approval) approvals.push(interopFeeInfo.approval);
9842
10793
  const starters = params.actions.map((action, index) => {
9843
10794
  const callAttributes = attrs.callAttributes[index] ?? [];
9844
10795
  if (starterData[index]?.assetRouterPayload) {
@@ -9862,6 +10813,7 @@ function buildIndirectBundle(params, ctx, attrs, starterData) {
9862
10813
  starters,
9863
10814
  bundleAttributes: attrs.bundleAttributes,
9864
10815
  approvals,
10816
+ interopFee: interopFeeInfo.fee,
9865
10817
  quoteExtras: {
9866
10818
  totalActionValue,
9867
10819
  bridgedTokenTotal
@@ -9908,6 +10860,29 @@ function buildEnsureTokenSteps(erc20Tokens, ctx) {
9908
10860
  }
9909
10861
  }));
9910
10862
  }
10863
+ async function buildApproveSteps(approvals, ctx) {
10864
+ const steps = [];
10865
+ for (const approval of approvals) {
10866
+ const erc20 = new ethers.Contract(approval.token, IERC20_default, ctx.client.l2);
10867
+ const currentAllowance = await erc20.allowance(ctx.sender, approval.spender);
10868
+ if (currentAllowance < approval.amount) {
10869
+ steps.push({
10870
+ key: `approve:${approval.token}:${approval.spender}`,
10871
+ kind: "approve",
10872
+ description: `Approve ${approval.spender} to spend ${approval.amount} of ${approval.token}`,
10873
+ tx: {
10874
+ to: approval.token,
10875
+ data: erc20.interface.encodeFunctionData("approve", [
10876
+ approval.spender,
10877
+ approval.amount
10878
+ ]),
10879
+ ...ctx.gasOverrides
10880
+ }
10881
+ });
10882
+ }
10883
+ }
10884
+ return steps;
10885
+ }
9911
10886
  async function resolveErc20AssetIds(erc20Tokens, ctx) {
9912
10887
  const assetIds = /* @__PURE__ */ new Map();
9913
10888
  if (erc20Tokens.length === 0) return assetIds;
@@ -9961,6 +10936,44 @@ async function getStarterData(params, ctx, erc20AssetIds) {
9961
10936
  }
9962
10937
  return starterData;
9963
10938
  }
10939
+ var { wrap: wrap3 } = createErrorHandlers("interop");
10940
+ async function buildFeeInfo(params, ctx, numStarters) {
10941
+ const useFixed = params.fee?.useFixed ?? false;
10942
+ const interopCenter = new ethers.Contract(ctx.interopCenter, IInteropCenter_default, ctx.client.l2);
10943
+ if (useFixed) {
10944
+ const zkFeePerCall = await wrap3(
10945
+ OP_INTEROP.svc.fees.zkInteropFee,
10946
+ () => interopCenter.ZK_INTEROP_FEE(),
10947
+ { message: "Failed to fetch ZK interop fee from InteropCenter." }
10948
+ );
10949
+ const zkFeeTotal = zkFeePerCall * BigInt(numStarters);
10950
+ const zkTokenAddress = await wrap3(
10951
+ OP_INTEROP.svc.fees.zkToken,
10952
+ () => interopCenter.zkToken(),
10953
+ { message: "Failed to fetch ZK token address from InteropCenter." }
10954
+ );
10955
+ const approval = {
10956
+ token: zkTokenAddress,
10957
+ spender: ctx.interopCenter,
10958
+ amount: zkFeeTotal
10959
+ };
10960
+ return {
10961
+ approval,
10962
+ fee: { token: zkTokenAddress, amount: zkFeeTotal }
10963
+ };
10964
+ } else {
10965
+ const protocolFeePerCall = await wrap3(
10966
+ OP_INTEROP.svc.fees.protocolFee,
10967
+ () => interopCenter.interopProtocolFee(),
10968
+ { message: "Failed to fetch interop protocol fee from InteropCenter." }
10969
+ );
10970
+ const totalFee = protocolFeePerCall * BigInt(numStarters);
10971
+ return {
10972
+ approval: null,
10973
+ fee: { token: ctx.baseTokens.src, amount: totalFee }
10974
+ };
10975
+ }
10976
+ }
9964
10977
 
9965
10978
  // src/adapters/ethers/resources/interop/routes/indirect.ts
9966
10979
  function routeIndirect() {
@@ -9976,7 +10989,10 @@ function routeIndirect() {
9976
10989
  async build(params, ctx) {
9977
10990
  const steps = [];
9978
10991
  const erc20Tokens = getErc20Tokens(params);
9979
- const erc20AssetIds = await resolveErc20AssetIds(erc20Tokens, ctx);
10992
+ const [erc20AssetIds, feeInfo] = await Promise.all([
10993
+ resolveErc20AssetIds(erc20Tokens, ctx),
10994
+ buildFeeInfo(params, ctx, params.actions.length)
10995
+ ]);
9980
10996
  const attributes = getInteropAttributes(params, ctx);
9981
10997
  const starterData = await getStarterData(params, ctx, erc20AssetIds);
9982
10998
  const bundle = buildIndirectBundle(
@@ -9989,32 +11005,11 @@ function routeIndirect() {
9989
11005
  codec: interopCodec
9990
11006
  },
9991
11007
  attributes,
9992
- starterData
11008
+ starterData,
11009
+ feeInfo
9993
11010
  );
9994
11011
  steps.push(...buildEnsureTokenSteps(erc20Tokens, ctx));
9995
- for (const approval of bundle.approvals) {
9996
- const erc20 = new ethers.Contract(approval.token, IERC20_default, ctx.client.l2);
9997
- const currentAllowance = await erc20.allowance(
9998
- ctx.sender,
9999
- ctx.l2NativeTokenVault
10000
- );
10001
- if (currentAllowance < approval.amount) {
10002
- const approveData = erc20.interface.encodeFunctionData("approve", [
10003
- ctx.l2NativeTokenVault,
10004
- approval.amount
10005
- ]);
10006
- steps.push({
10007
- key: `approve:${approval.token}:${ctx.l2NativeTokenVault}`,
10008
- kind: "approve",
10009
- description: `Approve ${ctx.l2NativeTokenVault} to spend ${approval.amount} of ${approval.token}`,
10010
- tx: {
10011
- to: approval.token,
10012
- data: approveData,
10013
- ...ctx.gasOverrides
10014
- }
10015
- });
10016
- }
10017
- }
11012
+ steps.push(...await buildApproveSteps(bundle.approvals, ctx));
10018
11013
  const data = ctx.ifaces.interopCenter.encodeFunctionData("sendBundle", [
10019
11014
  bundle.dstChain,
10020
11015
  bundle.starters,
@@ -10027,14 +11022,15 @@ function routeIndirect() {
10027
11022
  tx: {
10028
11023
  to: ctx.interopCenter,
10029
11024
  data,
10030
- value: bundle.quoteExtras.totalActionValue,
11025
+ value: bundle.quoteExtras.totalActionValue + feeInfo.fee.amount,
10031
11026
  ...ctx.gasOverrides
10032
11027
  }
10033
11028
  });
10034
11029
  return {
10035
11030
  steps,
10036
11031
  approvals: bundle.approvals,
10037
- quoteExtras: bundle.quoteExtras
11032
+ quoteExtras: bundle.quoteExtras,
11033
+ interopFee: feeInfo.fee
10038
11034
  };
10039
11035
  }
10040
11036
  };
@@ -10051,10 +11047,10 @@ function routeDirect() {
10051
11047
  l2AssetRouter: ctx.l2AssetRouter,
10052
11048
  l2NativeTokenVault: ctx.l2NativeTokenVault});
10053
11049
  },
10054
- // eslint-disable-next-line @typescript-eslint/require-await
10055
11050
  async build(params, ctx) {
10056
11051
  const steps = [];
10057
11052
  const attrs = getInteropAttributes(params, ctx);
11053
+ const feeInfo = await buildFeeInfo(params, ctx, params.actions.length);
10058
11054
  const built = buildDirectBundle(
10059
11055
  params,
10060
11056
  {
@@ -10064,8 +11060,10 @@ function routeDirect() {
10064
11060
  l2NativeTokenVault: ctx.l2NativeTokenVault,
10065
11061
  codec: interopCodec
10066
11062
  },
10067
- attrs
11063
+ attrs,
11064
+ feeInfo
10068
11065
  );
11066
+ steps.push(...await buildApproveSteps(built.approvals, ctx));
10069
11067
  const data = ctx.ifaces.interopCenter.encodeFunctionData("sendBundle", [
10070
11068
  built.dstChain,
10071
11069
  built.starters,
@@ -10075,19 +11073,19 @@ function routeDirect() {
10075
11073
  key: "sendBundle",
10076
11074
  kind: "interop.center",
10077
11075
  description: `Send interop bundle (direct route; ${params.actions.length} actions)`,
10078
- // In direct route, msg.value equals the total forwarded value across
10079
- // all calls (sendNative.amount + call.value).
11076
+ // msg.value = forwarded action value + protocol fee.
10080
11077
  tx: {
10081
11078
  to: ctx.interopCenter,
10082
11079
  data,
10083
- value: built.quoteExtras.totalActionValue,
11080
+ value: built.quoteExtras.totalActionValue + feeInfo.fee.amount,
10084
11081
  ...ctx.gasOverrides
10085
11082
  }
10086
11083
  });
10087
11084
  return {
10088
11085
  steps,
10089
11086
  approvals: built.approvals,
10090
- quoteExtras: built.quoteExtras
11087
+ quoteExtras: built.quoteExtras,
11088
+ interopFee: feeInfo.fee
10091
11089
  };
10092
11090
  }
10093
11091
  };
@@ -10167,7 +11165,7 @@ function getTopics() {
10167
11165
  };
10168
11166
  return { topics, centerIface };
10169
11167
  }
10170
- var { wrap: wrap3 } = createErrorHandlers("interop");
11168
+ var { wrap: wrap4 } = createErrorHandlers("interop");
10171
11169
  var DEFAULT_BLOCKS_RANGE_SIZE = 1e4;
10172
11170
  var DEFAULT_MAX_BLOCKS_BACK = 2e4;
10173
11171
  var SAFE_BLOCKS_RANGE_SIZE = 1e3;
@@ -10180,7 +11178,7 @@ function parseMaxBlockRangeLimit(error) {
10180
11178
  return Number.isInteger(limit) && limit > 0 ? limit : null;
10181
11179
  }
10182
11180
  async function getTxReceipt(provider, txHash) {
10183
- const receipt = await wrap3(
11181
+ const receipt = await wrap4(
10184
11182
  OP_INTEROP.svc.status.sourceReceipt,
10185
11183
  () => provider.getTransactionReceipt(txHash),
10186
11184
  {
@@ -10201,7 +11199,7 @@ async function getTxReceipt(provider, txHash) {
10201
11199
  async function getLogs(provider, address, topics, opts) {
10202
11200
  const maxBlocksBack = opts?.maxBlocksBack ?? DEFAULT_MAX_BLOCKS_BACK;
10203
11201
  const initialChunkSize = opts?.logChunkSize ?? DEFAULT_BLOCKS_RANGE_SIZE;
10204
- return await wrap3(
11202
+ return await wrap4(
10205
11203
  OP_INTEROP.svc.status.dstLogs,
10206
11204
  async () => {
10207
11205
  const currentBlock = await provider.getBlockNumber();
@@ -10248,7 +11246,7 @@ async function getLogs(provider, address, topics, opts) {
10248
11246
  );
10249
11247
  }
10250
11248
  async function getInteropRoot(provider, rootChainId, batchNumber) {
10251
- return await wrap3(
11249
+ return await wrap4(
10252
11250
  OP_INTEROP.svc.status.getRoot,
10253
11251
  async () => {
10254
11252
  const rootStorage = new ethers.Contract(
@@ -10266,7 +11264,7 @@ async function getInteropRoot(provider, rootChainId, batchNumber) {
10266
11264
  }
10267
11265
 
10268
11266
  // src/adapters/ethers/resources/interop/services/finalization/bundle.ts
10269
- var { wrap: wrap4 } = createErrorHandlers("interop");
11267
+ var { wrap: wrap5 } = createErrorHandlers("interop");
10270
11268
  async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
10271
11269
  const { interopHandler } = await client.ensureAddresses();
10272
11270
  const bundleLogs = await getLogs(dstProvider, interopHandler, [null, bundleHash], opts);
@@ -10298,7 +11296,7 @@ async function executeBundle(client, dstProvider, info, opts) {
10298
11296
  context: { bundleHash }
10299
11297
  });
10300
11298
  }
10301
- const signer = await wrap4(OP_INTEROP.exec.sendStep, () => client.signerFor(dstProvider), {
11299
+ const signer = await wrap5(OP_INTEROP.exec.sendStep, () => client.signerFor(dstProvider), {
10302
11300
  message: "Failed to resolve destination signer."
10303
11301
  });
10304
11302
  const { interopHandler } = await client.ensureAddresses();
@@ -10460,11 +11458,6 @@ function getBundleEncodedData(messageData) {
10460
11458
  return `0x${messageData.slice(4)}`;
10461
11459
  }
10462
11460
  function buildFinalizationInfo(ids, bundleInfo, proof, messageData) {
10463
- const expectedRoot = {
10464
- rootChainId: bundleInfo.sourceChainId,
10465
- batchNumber: proof.batchNumber,
10466
- expectedRoot: proof.root
10467
- };
10468
11461
  const messageProof = {
10469
11462
  chainId: bundleInfo.sourceChainId,
10470
11463
  l1BatchNumber: proof.batchNumber,
@@ -10480,7 +11473,6 @@ function buildFinalizationInfo(ids, bundleInfo, proof, messageData) {
10480
11473
  l2SrcTxHash: ids.l2SrcTxHash,
10481
11474
  bundleHash: bundleInfo.bundleHash,
10482
11475
  dstChainId: bundleInfo.dstChainId,
10483
- expectedRoot,
10484
11476
  proof: messageProof,
10485
11477
  encodedData: getBundleEncodedData(messageData)
10486
11478
  };
@@ -10503,7 +11495,7 @@ function decodeL1MessageData(log) {
10503
11495
  }
10504
11496
 
10505
11497
  // src/adapters/ethers/resources/interop/services/finalization/polling.ts
10506
- var { wrap: wrap5 } = createErrorHandlers("interop");
11498
+ var { wrap: wrap6 } = createErrorHandlers("interop");
10507
11499
  function isProofNotReadyError(error) {
10508
11500
  return isZKsyncError(error, {
10509
11501
  operation: "zksrpc.getL2ToL1LogProof",
@@ -10540,30 +11532,26 @@ async function waitForProof(client, l2SrcTxHash, logIndex, blockNumber, pollMs,
10540
11532
  });
10541
11533
  }
10542
11534
  try {
10543
- return await client.zks.getL2ToL1LogProof(l2SrcTxHash, logIndex);
11535
+ return await client.zks.getL2ToL1LogProof(l2SrcTxHash, logIndex, "messageRoot" /* MessageRoot */);
10544
11536
  } catch (error) {
10545
11537
  if (!isProofNotReadyError(error)) throw error;
10546
11538
  }
10547
11539
  await sleep(pollMs);
10548
11540
  }
10549
11541
  }
10550
- async function waitForRoot(provider, expectedRoot, pollMs, deadline) {
11542
+ async function waitForRoot(provider, chainId, batchNumber, pollMs, deadline) {
10551
11543
  while (true) {
10552
11544
  if (Date.now() > deadline) {
10553
11545
  throw createError("TIMEOUT", {
10554
11546
  resource: "interop",
10555
11547
  operation: OP_INTEROP.svc.wait.timeout,
10556
11548
  message: "Timed out waiting for interop root to become available.",
10557
- context: { expectedRoot }
11549
+ context: { chainId, batchNumber }
10558
11550
  });
10559
11551
  }
10560
11552
  let interopRoot = null;
10561
11553
  try {
10562
- const root = await getInteropRoot(
10563
- provider,
10564
- expectedRoot.rootChainId,
10565
- expectedRoot.batchNumber
10566
- );
11554
+ const root = await getInteropRoot(provider, chainId, batchNumber);
10567
11555
  if (root !== ZERO_HASH) {
10568
11556
  interopRoot = root;
10569
11557
  }
@@ -10572,18 +11560,7 @@ async function waitForRoot(provider, expectedRoot, pollMs, deadline) {
10572
11560
  interopRoot = null;
10573
11561
  }
10574
11562
  if (interopRoot) {
10575
- if (interopRoot.toLowerCase() === expectedRoot.expectedRoot.toLowerCase()) {
10576
- return;
10577
- }
10578
- throw createError("STATE", {
10579
- resource: "interop",
10580
- operation: OP_INTEROP.wait,
10581
- message: "Interop root mismatch.",
10582
- context: {
10583
- expected: expectedRoot.expectedRoot,
10584
- got: interopRoot
10585
- }
10586
- });
11563
+ return interopRoot;
10587
11564
  }
10588
11565
  await sleep(pollMs);
10589
11566
  }
@@ -10598,7 +11575,7 @@ async function waitForTxReceipt(client, txHash, pollMs, deadline) {
10598
11575
  context: { txHash }
10599
11576
  });
10600
11577
  }
10601
- const receipt = await wrap5(
11578
+ const receipt = await wrap6(
10602
11579
  OP_INTEROP.svc.status.sourceReceipt,
10603
11580
  () => client.zks.getReceiptWithL2ToL1(txHash),
10604
11581
  {
@@ -10612,7 +11589,7 @@ async function waitForTxReceipt(client, txHash, pollMs, deadline) {
10612
11589
  await sleep(pollMs);
10613
11590
  }
10614
11591
  }
10615
- async function waitForFinalization(client, dstProvider, input, opts) {
11592
+ async function waitForFinalization(client, dstProvider, gwProvider, input, opts) {
10616
11593
  const { topics, centerIface } = getTopics();
10617
11594
  const pollMs = opts?.pollMs ?? DEFAULT_POLL_MS;
10618
11595
  const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -10661,7 +11638,16 @@ async function waitForFinalization(client, dstProvider, input, opts) {
10661
11638
  proof,
10662
11639
  bundleInfo.l1MessageData
10663
11640
  );
10664
- await waitForRoot(dstProvider, finalizationInfo.expectedRoot, pollMs, deadline);
11641
+ if (proof.gatewayBlockNumber == null) {
11642
+ throw createError("STATE", {
11643
+ resource: "interop",
11644
+ operation: OP_INTEROP.svc.wait.timeout,
11645
+ message: "Proof missing gatewayBlockNumber required for interop finalization.",
11646
+ context: { l2SrcTxHash: ids.l2SrcTxHash }
11647
+ });
11648
+ }
11649
+ const { chainId: gwChainId } = await gwProvider.getNetwork();
11650
+ await waitForRoot(dstProvider, gwChainId, proof.gatewayBlockNumber, pollMs, deadline);
10665
11651
  return finalizationInfo;
10666
11652
  }
10667
11653
 
@@ -10707,8 +11693,8 @@ function createInteropFinalizationServices(client) {
10707
11693
  status(dstProvider, input, opts) {
10708
11694
  return getStatus(client, dstProvider, input, opts);
10709
11695
  },
10710
- wait(dstProvider, input, opts) {
10711
- return waitForFinalization(client, dstProvider, input, opts);
11696
+ wait(dstProvider, gwProvider, input, opts) {
11697
+ return waitForFinalization(client, dstProvider, gwProvider, input, opts);
10712
11698
  },
10713
11699
  async finalize(dstProvider, info, opts) {
10714
11700
  const execResult = await executeBundle(client, dstProvider, info, opts);
@@ -10720,24 +11706,31 @@ function createInteropFinalizationServices(client) {
10720
11706
  }
10721
11707
  };
10722
11708
  }
10723
- function resolveDstProvider(dstChain) {
10724
- return typeof dstChain === "string" ? new ethers.JsonRpcProvider(dstChain) : dstChain;
10725
- }
10726
- function resolveWaitableInput(waitableInput) {
10727
- const input = waitableInput;
10728
- return {
10729
- dstProvider: resolveDstProvider(waitableInput.dstChain),
10730
- waitable: input.waitable ? input.waitable : waitableInput
10731
- };
11709
+ function resolveChainRef(ref) {
11710
+ return typeof ref === "string" ? new ethers.JsonRpcProvider(ref) : ref;
10732
11711
  }
10733
11712
 
10734
11713
  // src/adapters/ethers/resources/interop/index.ts
10735
- var { wrap: wrap6, toResult: toResult2 } = createErrorHandlers("interop");
11714
+ var { wrap: wrap7, toResult: toResult2 } = createErrorHandlers("interop");
10736
11715
  var ROUTES3 = {
10737
11716
  direct: routeDirect(),
10738
11717
  indirect: routeIndirect()
10739
11718
  };
10740
- function createInteropResource(client, tokens, contracts, attributes) {
11719
+ function createInteropResource(client, config, tokens, contracts, attributes) {
11720
+ let gwProviderCache;
11721
+ function requireConfig() {
11722
+ if (!config)
11723
+ throw createError("STATE", {
11724
+ resource: "interop",
11725
+ operation: "interop.init",
11726
+ message: "Interop is not configured. Pass gwChain in createEthersSdk options."
11727
+ });
11728
+ return config;
11729
+ }
11730
+ function getGwProvider() {
11731
+ if (!gwProviderCache) gwProviderCache = resolveChainRef(requireConfig().gwChain);
11732
+ return gwProviderCache;
11733
+ }
10741
11734
  const svc = createInteropFinalizationServices(client);
10742
11735
  const tokensResource = tokens ?? createTokensResource(client);
10743
11736
  const contractsResource = contracts ?? createContractsResource(client);
@@ -10761,11 +11754,11 @@ function createInteropResource(client, tokens, contracts, attributes) {
10761
11754
  baseTokenDst: ctx.baseTokens.dst
10762
11755
  }
10763
11756
  });
10764
- await wrap6(OP_INTEROP.routes[route].preflight, () => ROUTES3[route].preflight?.(params, ctx), {
11757
+ await wrap7(OP_INTEROP.routes[route].preflight, () => ROUTES3[route].preflight?.(params, ctx), {
10765
11758
  message: "Interop preflight failed.",
10766
11759
  ctx: { where: `routes.${route}.preflight` }
10767
11760
  });
10768
- const { steps, approvals, quoteExtras } = await wrap6(
11761
+ const { steps, approvals, quoteExtras, interopFee } = await wrap7(
10769
11762
  OP_INTEROP.routes[route].build,
10770
11763
  () => ROUTES3[route].build(params, ctx),
10771
11764
  {
@@ -10777,7 +11770,8 @@ function createInteropResource(client, tokens, contracts, attributes) {
10777
11770
  route,
10778
11771
  approvalsNeeded: approvals,
10779
11772
  totalActionValue: quoteExtras.totalActionValue,
10780
- bridgedTokenTotal: quoteExtras.bridgedTokenTotal
11773
+ bridgedTokenTotal: quoteExtras.bridgedTokenTotal,
11774
+ interopFee
10781
11775
  };
10782
11776
  return { plan: { route, summary, steps }, ctx };
10783
11777
  }
@@ -10785,20 +11779,23 @@ function createInteropResource(client, tokens, contracts, attributes) {
10785
11779
  const { plan } = await buildPlanWithCtx(dstProvider, params);
10786
11780
  return plan;
10787
11781
  }
10788
- const quote = (params) => wrap6(OP_INTEROP.quote, async () => {
10789
- const plan = await buildPlan(resolveDstProvider(params.dstChain), params);
11782
+ const quote = (dstChain, params) => wrap7(OP_INTEROP.quote, async () => {
11783
+ const plan = await buildPlan(resolveChainRef(dstChain), params);
10790
11784
  return plan.summary;
10791
11785
  });
10792
- const tryQuote = (params) => toResult2(OP_INTEROP.tryQuote, () => quote(params));
10793
- const prepare = (params) => wrap6(OP_INTEROP.prepare, () => buildPlan(resolveDstProvider(params.dstChain), params), {
11786
+ const tryQuote = (dstChain, params) => toResult2(OP_INTEROP.tryQuote, () => quote(dstChain, params));
11787
+ const prepare = (dstChain, params) => wrap7(OP_INTEROP.prepare, () => buildPlan(resolveChainRef(dstChain), params), {
10794
11788
  message: "Internal error while preparing an interop plan.",
10795
11789
  ctx: { where: "interop.prepare" }
10796
11790
  });
10797
- const tryPrepare = (params) => toResult2(OP_INTEROP.tryPrepare, () => prepare(params));
10798
- const create = (params) => wrap6(
11791
+ const tryPrepare = (dstChain, params) => toResult2(
11792
+ OP_INTEROP.tryPrepare,
11793
+ () => prepare(dstChain, params)
11794
+ );
11795
+ const create = (dstChain, params) => wrap7(
10799
11796
  OP_INTEROP.create,
10800
11797
  async () => {
10801
- const { plan, ctx } = await buildPlanWithCtx(resolveDstProvider(params.dstChain), params);
11798
+ const { plan, ctx } = await buildPlanWithCtx(resolveChainRef(dstChain), params);
10802
11799
  const signer = ctx.client.signerFor(ctx.client.l2);
10803
11800
  const srcProvider = ctx.client.l2;
10804
11801
  const from = await signer.getAddress();
@@ -10841,23 +11838,25 @@ function createInteropResource(client, tokens, contracts, attributes) {
10841
11838
  }
10842
11839
  } catch (e) {
10843
11840
  if (isZKsyncError(e)) throw e;
10844
- throw createError("EXECUTION", {
10845
- resource: "interop",
10846
- operation: "interop.create.sendTransaction",
10847
- message: "Failed to send or confirm an interop transaction step.",
10848
- context: {
10849
- step: step.key,
10850
- txHash: hash,
10851
- nonce: Number(step.tx.nonce ?? -1)
11841
+ throw toZKsyncError(
11842
+ "EXECUTION",
11843
+ {
11844
+ resource: "interop",
11845
+ operation: "interop.create.sendTransaction",
11846
+ message: "Failed to send or confirm an interop transaction step.",
11847
+ context: {
11848
+ step: step.key,
11849
+ txHash: hash,
11850
+ nonce: Number(step.tx.nonce ?? -1)
11851
+ }
10852
11852
  },
10853
- cause: e
10854
- });
11853
+ e
11854
+ );
10855
11855
  }
10856
11856
  }
10857
11857
  const last = Object.values(stepHashes).pop();
10858
11858
  return {
10859
11859
  kind: "interop",
10860
- dstChain: params.dstChain,
10861
11860
  stepHashes,
10862
11861
  plan,
10863
11862
  l2SrcTxHash: last ?? "0x"
@@ -10868,46 +11867,27 @@ function createInteropResource(client, tokens, contracts, attributes) {
10868
11867
  ctx: { where: "interop.create" }
10869
11868
  }
10870
11869
  );
10871
- const tryCreate = (params) => toResult2(OP_INTEROP.tryCreate, () => create(params));
10872
- const status = (h, opts) => {
10873
- const { dstProvider, waitable } = resolveWaitableInput(h);
10874
- return wrap6(OP_INTEROP.status, () => svc.status(dstProvider, waitable, opts), {
10875
- message: "Internal error while checking interop status.",
10876
- ctx: { where: "interop.status" }
10877
- });
10878
- };
10879
- const wait = (h, opts) => {
10880
- const { dstProvider, waitable } = resolveWaitableInput(h);
10881
- return wrap6(
10882
- OP_INTEROP.wait,
10883
- async () => {
10884
- const info = await svc.wait(dstProvider, waitable, opts);
10885
- return { ...info, dstChain: h.dstChain };
10886
- },
10887
- {
10888
- message: "Internal error while waiting for interop finalization.",
10889
- ctx: { where: "interop.wait" }
10890
- }
10891
- );
10892
- };
10893
- const tryWait = (h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(h, opts));
10894
- const finalize = (h, opts) => wrap6(
11870
+ const tryCreate = (dstChain, params) => toResult2(
11871
+ OP_INTEROP.tryCreate,
11872
+ () => create(dstChain, params)
11873
+ );
11874
+ const status = (dstChain, h, opts) => wrap7(OP_INTEROP.status, () => svc.status(resolveChainRef(dstChain), h, opts), {
11875
+ message: "Internal error while checking interop status.",
11876
+ ctx: { where: "interop.status" }
11877
+ });
11878
+ const wait = (dstChain, h, opts) => wrap7(OP_INTEROP.wait, () => svc.wait(resolveChainRef(dstChain), getGwProvider(), h, opts), {
11879
+ message: "Internal error while waiting for interop finalization.",
11880
+ ctx: { where: "interop.wait" }
11881
+ });
11882
+ const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
11883
+ const finalize = (dstChain, h, opts) => wrap7(
10895
11884
  OP_INTEROP.finalize,
10896
11885
  async () => {
11886
+ const dstProvider = resolveChainRef(dstChain);
10897
11887
  if (isInteropFinalizationInfo(h)) {
10898
- if (h.dstChain == null) {
10899
- throw createError("STATE", {
10900
- resource: "interop",
10901
- operation: OP_INTEROP.finalize,
10902
- message: "Missing dstChain in interop finalization info.",
10903
- context: { input: h }
10904
- });
10905
- }
10906
- const dstProvider2 = resolveDstProvider(h.dstChain);
10907
- return svc.finalize(dstProvider2, h, opts);
11888
+ return svc.finalize(dstProvider, h, opts);
10908
11889
  }
10909
- const { dstProvider, waitable } = resolveWaitableInput(h);
10910
- const info = await svc.wait(dstProvider, waitable);
11890
+ const info = await svc.wait(dstProvider, getGwProvider(), h);
10911
11891
  return svc.finalize(dstProvider, info, opts);
10912
11892
  },
10913
11893
  {
@@ -10915,7 +11895,7 @@ function createInteropResource(client, tokens, contracts, attributes) {
10915
11895
  ctx: { where: "interop.finalize" }
10916
11896
  }
10917
11897
  );
10918
- const tryFinalize = (h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(h, opts));
11898
+ const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
10919
11899
  return {
10920
11900
  quote,
10921
11901
  tryQuote,
@@ -10932,10 +11912,10 @@ function createInteropResource(client, tokens, contracts, attributes) {
10932
11912
  }
10933
11913
 
10934
11914
  // src/adapters/ethers/sdk.ts
10935
- function createEthersSdk(client) {
11915
+ function createEthersSdk(client, options) {
10936
11916
  const tokens = createTokensResource(client);
10937
11917
  const contracts = createContractsResource(client);
10938
- const interop = createInteropResource(client);
11918
+ const interop = createInteropResource(client, options?.interop, tokens, contracts);
10939
11919
  return {
10940
11920
  deposits: createDepositsResource(client, tokens, contracts),
10941
11921
  withdrawals: createWithdrawalsResource(client, tokens, contracts),