@matterlabs/zksync-js 0.0.24 → 0.0.26

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.
@@ -1,10 +1,10 @@
1
- import { createNTVCodec, createAttributesResource, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, pickInteropRoute, ZERO_HASH, toGasOverrides, clampPriorityL2GasLimit, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, applyL1ToL2Alias, derivePriorityBodyGasEstimateCap, assertProtocolVersion, resolveRegisteredTokenPriorityL2GasLimit, quoteL2Gas2 } from './chunk-5S63J6DW.js';
1
+ import { createNTVCodec, createAttributesResource, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, pickInteropRoute, ZERO_HASH, toGasOverrides, clampPriorityL2GasLimit, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, resolveBaseTokenPriorityL2GasLimit, quoteL2Gas, quoteL1Fees, quoteL1Gas, applyL1ToL2Alias, derivePriorityBodyGasEstimateCap, assertProtocolVersion, ZK_CHAIN_PRICING_GETTERS_ABI, PUBDATA_PRICING_MODE_ROLLUP, resolveRegisteredTokenPriorityL2GasLimit, quoteL2Gas2 } from './chunk-FMBQ7PVA.js';
2
2
  import { detectWithdrawalProtocol, buildWithdrawalFinalization, parseBundleHashFromLogs, classifyWithdrawalOutcome, phaseFromReadiness, buildWithdrawalBundle } from './chunk-BQ2YCWV2.js';
3
3
  import { findL1MessageSentLog, messengerLogIndex, l1MessageSentSender, pickWithdrawRoute } from './chunk-OEUDZFXH.js';
4
4
  import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-H5A6GU3D.js';
5
5
  import { IERC7786Attributes_default, isHash66, IL1Nullifier_default, IInteropHandler_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, IL1NullifierV32_default, OP_INTEROP, IInteropRootStorage_default, IInteropCenter_default, sleep, IBridgehub_default, isETH, normalizeAddrEq, IL2AssetRouter_default, L2NativeTokenVault_default, IBaseToken_default, assertNever } from './chunk-JNS4XZE2.js';
6
6
  import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L1_MESSENGER_ADDRESS, L2_INTEROP_ROOT_STORAGE_ADDRESS, BUFFER, SAFE_L1_BRIDGE_GAS, L2_ASSET_ROUTER_ADDRESS, FORMAL_ETH_ADDRESS, ZKSYNC_OS_PRIORITY_TX_TYPE } from './chunk-3IPSDGHO.js';
7
- import { keccak256, encodeAbiParameters, toBytes, encodeFunctionData, concat, decodeEventLog, createWalletClient, custom, decodeAbiParameters, createPublicClient, http, encodeEventTopics, numberToHex, zeroAddress, getAddress, toHex } from 'viem';
7
+ import { keccak256, encodeAbiParameters, toBytes, encodeFunctionData, concat, decodeEventLog, createWalletClient, custom, decodeAbiParameters, createPublicClient, http, encodeEventTopics, numberToHex, zeroAddress, getAddress, toHex, BaseError, ContractFunctionRevertedError } from 'viem';
8
8
 
9
9
  // src/adapters/viem/resources/deposits/context.ts
10
10
  async function commonCtx(p, client, tokens, contracts) {
@@ -97,8 +97,6 @@ function buildDirectRequestStruct(args) {
97
97
  refundRecipient: args.refundRecipient
98
98
  };
99
99
  }
100
-
101
- // src/adapters/viem/estimator.ts
102
100
  function toCoreTx(tx) {
103
101
  return {
104
102
  to: tx.to,
@@ -157,6 +155,7 @@ function viemToGasEstimator(client) {
157
155
  from: tx.from,
158
156
  to: tx.to,
159
157
  data: tx.data,
158
+ ...tx.value != null ? { value: toHex(tx.value) } : {},
160
159
  type: ZKSYNC_OS_PRIORITY_TX_TYPE
161
160
  }
162
161
  ]
@@ -195,6 +194,7 @@ function viemToGasEstimator(client) {
195
194
  }
196
195
 
197
196
  // src/adapters/viem/resources/deposits/services/gas.ts
197
+ var { wrapAs } = createErrorHandlers("deposits");
198
198
  var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
199
199
  async function estimatePriorityTxL2Gas(ctx, leg) {
200
200
  if (!leg) return void 0;
@@ -204,6 +204,60 @@ async function estimatePriorityTxL2Gas(ctx, leg) {
204
204
  return void 0;
205
205
  }
206
206
  }
207
+ async function resolvePriorityTxL2Sender(ctx) {
208
+ try {
209
+ const code = await ctx.client.l1.getCode({ address: ctx.sender });
210
+ if (!code || code === "0x") return ctx.sender;
211
+ } catch {
212
+ }
213
+ return applyL1ToL2Alias(ctx.sender);
214
+ }
215
+ var chainPricingCache = /* @__PURE__ */ new WeakMap();
216
+ var isContractRevert = (err) => err instanceof BaseError && err.walk((e) => e instanceof ContractFunctionRevertedError) != null;
217
+ async function readChainPricing(ctx) {
218
+ const cached = chainPricingCache.get(ctx.client)?.get(ctx.chainIdL2);
219
+ if (cached) return cached;
220
+ try {
221
+ const zkChain = await ctx.client.l1.readContract({
222
+ address: ctx.bridgehub,
223
+ abi: IBridgehub_default,
224
+ functionName: "getZKChain",
225
+ args: [ctx.chainIdL2]
226
+ });
227
+ const read = (functionName) => ctx.client.l1.readContract({
228
+ address: zkChain,
229
+ abi: ZK_CHAIN_PRICING_GETTERS_ABI,
230
+ functionName
231
+ });
232
+ let zksyncOS;
233
+ try {
234
+ zksyncOS = await read("getZKsyncOS");
235
+ } catch (err) {
236
+ if (!isContractRevert(err)) throw err;
237
+ zksyncOS = false;
238
+ }
239
+ const chargesPubdata = zksyncOS && Number(await read("getPubdataPricingMode")) === PUBDATA_PRICING_MODE_ROLLUP;
240
+ const pricing = { zksyncOS, chargesPubdata };
241
+ const perClient = chainPricingCache.get(ctx.client) ?? /* @__PURE__ */ new Map();
242
+ perClient.set(ctx.chainIdL2, pricing);
243
+ chainPricingCache.set(ctx.client, perClient);
244
+ return pricing;
245
+ } catch {
246
+ return void 0;
247
+ }
248
+ }
249
+ async function quoteL1Fees2(input) {
250
+ const { ctx } = input;
251
+ return wrapAs(
252
+ "RPC",
253
+ "deposits.fees.l1",
254
+ () => quoteL1Fees({
255
+ estimator: viemToGasEstimator(ctx.client.l1),
256
+ overrides: ctx.gasOverrides
257
+ }),
258
+ { ctx: { chainIdL2: ctx.chainIdL2 } }
259
+ );
260
+ }
207
261
  async function quoteL1Gas2(input) {
208
262
  const { ctx, tx, overrides, fallbackGasLimit } = input;
209
263
  const estimator = viemToGasEstimator(ctx.client.l1);
@@ -228,6 +282,26 @@ async function quoteL2Gas3(input) {
228
282
  stateOverrides: input.stateOverrides
229
283
  });
230
284
  }
285
+ async function determineBaseL2GasLimit(input) {
286
+ const { ctx } = input;
287
+ if (ctx.l2GasLimit != null) return ctx.l2GasLimit;
288
+ const [pricing, from] = await Promise.all([
289
+ readChainPricing(ctx),
290
+ resolvePriorityTxL2Sender(ctx)
291
+ ]);
292
+ if (pricing && !pricing.zksyncOS) return input.priorityFloorGasLimit;
293
+ return resolveBaseTokenPriorityL2GasLimit({
294
+ priorityFloorGasLimit: input.priorityFloorGasLimit,
295
+ gasPerPubdata: ctx.gasPerPubdata,
296
+ chargesPubdata: pricing?.chargesPubdata ?? true,
297
+ nodeEstimate: await estimatePriorityTxL2Gas(ctx, {
298
+ from,
299
+ to: input.l2Contract,
300
+ data: input.l2Calldata,
301
+ value: input.l2Value
302
+ })
303
+ });
304
+ }
231
305
  async function determineNonBaseL2Gas(input) {
232
306
  const { ctx, l1Token, route } = input;
233
307
  const fallbackQuote = () => quoteL2Gas3({
@@ -306,13 +380,10 @@ async function determineEthNonBaseL2Gas(input) {
306
380
  }
307
381
 
308
382
  // src/adapters/viem/resources/deposits/services/fee.ts
309
- var { wrapAs } = createErrorHandlers("deposits");
383
+ var { wrapAs: wrapAs2 } = createErrorHandlers("deposits");
310
384
  async function quoteL2BaseCost(input) {
311
- const { ctx, l2GasLimit } = input;
312
- const estimator = viemToGasEstimator(ctx.client.l1);
313
- const fees = await estimator.estimateFeesPerGas();
314
- const gasPrice = fees.maxFeePerGas ?? fees.gasPrice ?? await estimator.getGasPrice();
315
- return wrapAs(
385
+ const { ctx, l2GasLimit, l1GasPrice } = input;
386
+ return wrapAs2(
316
387
  "RPC",
317
388
  "deposits.fees.l2BaseCost",
318
389
  async () => {
@@ -320,7 +391,7 @@ async function quoteL2BaseCost(input) {
320
391
  address: ctx.bridgehub,
321
392
  abi: IBridgehub_default,
322
393
  functionName: "l2TransactionBaseCost",
323
- args: [ctx.chainIdL2, gasPrice, l2GasLimit, ctx.gasPerPubdata]
394
+ args: [ctx.chainIdL2, l1GasPrice, l2GasLimit, ctx.gasPerPubdata]
324
395
  });
325
396
  },
326
397
  { ctx: { chainIdL2: ctx.chainIdL2 } }
@@ -387,7 +458,7 @@ function getPriorityTxGasBreakdown(input) {
387
458
  }
388
459
 
389
460
  // src/adapters/viem/resources/deposits/routes/eth.ts
390
- var { wrapAs: wrapAs2 } = createErrorHandlers("deposits");
461
+ var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
391
462
  var EMPTY_BYTES2 = "0x";
392
463
  function routeEthDirect() {
393
464
  return {
@@ -402,13 +473,19 @@ function routeEthDirect() {
402
473
  l2Calldata,
403
474
  gasPerPubdata: ctx.gasPerPubdata
404
475
  });
405
- const quotedL2GasLimit = ctx.l2GasLimit ?? clampPriorityL2GasLimit({
406
- gasLimit: applyPriorityL2GasLimitBuffer({
407
- chainIdL2: ctx.chainIdL2,
408
- gasLimit: priorityFloorBreakdown.derivedL2GasLimit
409
- }),
476
+ const quotedL2GasLimit = await determineBaseL2GasLimit({
477
+ ctx,
478
+ l2Contract,
479
+ l2Value,
410
480
  l2Calldata,
411
- gasPerPubdata: ctx.gasPerPubdata
481
+ priorityFloorGasLimit: clampPriorityL2GasLimit({
482
+ gasLimit: applyPriorityL2GasLimitBuffer({
483
+ chainIdL2: ctx.chainIdL2,
484
+ gasLimit: priorityFloorBreakdown.derivedL2GasLimit
485
+ }),
486
+ l2Calldata,
487
+ gasPerPubdata: ctx.gasPerPubdata
488
+ })
412
489
  });
413
490
  const l2GasParams = await quoteL2Gas3({
414
491
  ctx,
@@ -418,7 +495,12 @@ function routeEthDirect() {
418
495
  if (!l2GasParams) {
419
496
  throw new Error("Failed to estimate L2 gas for deposit.");
420
497
  }
421
- const baseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2GasParams.gasLimit });
498
+ const l1Fees = await quoteL1Fees2({ ctx });
499
+ const baseCost = await quoteL2BaseCost({
500
+ ctx,
501
+ l2GasLimit: l2GasParams.gasLimit,
502
+ l1GasPrice: l1Fees.maxFeePerGas
503
+ });
422
504
  const mintValue = baseCost + ctx.operatorTip + l2Value;
423
505
  const req = buildDirectRequestStruct({
424
506
  chainId: ctx.chainIdL2,
@@ -429,7 +511,7 @@ function routeEthDirect() {
429
511
  l2Contract,
430
512
  l2Value
431
513
  });
432
- const sim = await wrapAs2(
514
+ const sim = await wrapAs3(
433
515
  "RPC",
434
516
  OP_DEPOSITS.eth.estGas,
435
517
  () => ctx.client.l1.simulateContract({
@@ -455,22 +537,19 @@ function routeEthDirect() {
455
537
  data,
456
538
  value: mintValue,
457
539
  from: ctx.sender,
458
- ...ctx.gasOverrides
540
+ ...ctx.gasOverrides,
541
+ ...l1Fees
459
542
  };
460
543
  const l1Gas = await quoteL1Gas2({
461
544
  ctx,
462
545
  tx: l1TxCandidate,
463
546
  overrides: ctx.gasOverrides
464
547
  });
465
- let bridgeTx = { ...sim.request };
466
- if (l1Gas) {
467
- bridgeTx = {
468
- ...bridgeTx,
469
- gas: l1Gas.gasLimit,
470
- maxFeePerGas: l1Gas.maxFeePerGas,
471
- maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
472
- };
473
- }
548
+ const bridgeTx = {
549
+ ...sim.request,
550
+ ...l1Fees,
551
+ ...l1Gas ? { gas: l1Gas.gasLimit } : {}
552
+ };
474
553
  const steps = [
475
554
  {
476
555
  key: "bridgehub:direct",
@@ -544,7 +623,7 @@ async function buildApprovalRequest({
544
623
  }
545
624
 
546
625
  // src/adapters/viem/resources/deposits/routes/erc20-nonbase.ts
547
- var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
626
+ var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
548
627
  var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
549
628
  var ntvCodec = createNTVCodec({
550
629
  encode: (types, values) => encodeAbiParameters(
@@ -635,7 +714,7 @@ function routeErc20NonBase() {
635
714
  return {
636
715
  // TODO: do we even need these validations?
637
716
  async preflight(p, ctx) {
638
- await wrapAs3(
717
+ await wrapAs4(
639
718
  "VALIDATION",
640
719
  OP_DEPOSITS.nonbase.assertNotEthAsset,
641
720
  () => {
@@ -646,7 +725,7 @@ function routeErc20NonBase() {
646
725
  { ctx: { token: p.token } }
647
726
  );
648
727
  const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
649
- await wrapAs3(
728
+ await wrapAs4(
650
729
  "VALIDATION",
651
730
  OP_DEPOSITS.nonbase.assertNonBaseToken,
652
731
  () => {
@@ -663,7 +742,7 @@ function routeErc20NonBase() {
663
742
  const assetRouter = ctx.l1AssetRouter;
664
743
  const nativeTokenVault = ctx.l1NativeTokenVault;
665
744
  const receiver = p.to ?? ctx.sender;
666
- const secondBridgeCalldata = await wrapAs3(
745
+ const secondBridgeCalldata = await wrapAs4(
667
746
  "INTERNAL",
668
747
  OP_DEPOSITS.nonbase.encodeCalldata,
669
748
  () => encodeSecondBridgeErc20DepositCalldata({
@@ -701,11 +780,16 @@ function routeErc20NonBase() {
701
780
  }
702
781
  });
703
782
  if (!l2Gas) throw new Error("Failed to establish L2 gas parameters.");
704
- const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
783
+ const l1Fees = await quoteL1Fees2({ ctx });
784
+ const l2BaseCost = await quoteL2BaseCost({
785
+ ctx,
786
+ l2GasLimit: l2Gas.gasLimit,
787
+ l1GasPrice: l1Fees.maxFeePerGas
788
+ });
705
789
  const mintValue = l2BaseCost + ctx.operatorTip;
706
790
  const approvals = [];
707
791
  const steps = [];
708
- const depositAllowance = await wrapAs3(
792
+ const depositAllowance = await wrapAs4(
709
793
  "CONTRACT",
710
794
  OP_DEPOSITS.nonbase.allowanceToken,
711
795
  () => ctx.client.l1.readContract({
@@ -720,7 +804,7 @@ function routeErc20NonBase() {
720
804
  }
721
805
  );
722
806
  if (depositAllowance < p.amount) {
723
- const approveTx = await wrapAs3(
807
+ const approveTx = await wrapAs4(
724
808
  "CONTRACT",
725
809
  OP_DEPOSITS.nonbase.estGas,
726
810
  () => buildApprovalRequest({
@@ -743,7 +827,7 @@ function routeErc20NonBase() {
743
827
  });
744
828
  }
745
829
  if (!baseIsEth) {
746
- const baseAllowance = await wrapAs3(
830
+ const baseAllowance = await wrapAs4(
747
831
  "CONTRACT",
748
832
  OP_DEPOSITS.nonbase.allowanceBase,
749
833
  () => ctx.client.l1.readContract({
@@ -758,7 +842,7 @@ function routeErc20NonBase() {
758
842
  }
759
843
  );
760
844
  if (baseAllowance < mintValue) {
761
- const approveBaseTx = await wrapAs3(
845
+ const approveBaseTx = await wrapAs4(
762
846
  "CONTRACT",
763
847
  OP_DEPOSITS.nonbase.estGas,
764
848
  () => buildApprovalRequest({
@@ -803,7 +887,8 @@ function routeErc20NonBase() {
803
887
  data: calldata,
804
888
  value: msgValue,
805
889
  from: ctx.sender,
806
- ...ctx.gasOverrides
890
+ ...ctx.gasOverrides,
891
+ ...l1Fees
807
892
  };
808
893
  const l1Gas = await quoteL1Gas2({
809
894
  ctx,
@@ -823,7 +908,7 @@ function routeErc20NonBase() {
823
908
  account: ctx.client.account
824
909
  };
825
910
  } else {
826
- const sim = await wrapAs3(
911
+ const sim = await wrapAs4(
827
912
  "CONTRACT",
828
913
  OP_DEPOSITS.nonbase.estGas,
829
914
  () => ctx.client.l1.simulateContract({
@@ -841,14 +926,11 @@ function routeErc20NonBase() {
841
926
  );
842
927
  bridgeTx = { ...sim.request };
843
928
  }
844
- if (l1Gas) {
845
- bridgeTx = {
846
- ...bridgeTx,
847
- gas: l1Gas.gasLimit,
848
- maxFeePerGas: l1Gas.maxFeePerGas,
849
- maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
850
- };
851
- }
929
+ bridgeTx = {
930
+ ...bridgeTx,
931
+ ...l1Fees,
932
+ ...l1Gas ? { gas: l1Gas.gasLimit } : {}
933
+ };
852
934
  steps.push({
853
935
  key: "bridgehub:two-bridges:erc20-nonbase",
854
936
  kind: "bridgehub:two-bridges",
@@ -871,7 +953,7 @@ function routeErc20NonBase() {
871
953
  }
872
954
  };
873
955
  }
874
- var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
956
+ var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
875
957
  var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
876
958
  var ntvCodec2 = createNTVCodec({
877
959
  encode: (types, values) => encodeAbiParameters(
@@ -955,7 +1037,7 @@ function routeEthNonBase() {
955
1037
  return {
956
1038
  // TODO: do we even need these validations?
957
1039
  async preflight(p, ctx) {
958
- await wrapAs4(
1040
+ await wrapAs5(
959
1041
  "VALIDATION",
960
1042
  OP_DEPOSITS.ethNonBase.assertEthAsset,
961
1043
  () => {
@@ -965,7 +1047,7 @@ function routeEthNonBase() {
965
1047
  },
966
1048
  { ctx: { token: p.token } }
967
1049
  );
968
- await wrapAs4(
1050
+ await wrapAs5(
969
1051
  "VALIDATION",
970
1052
  OP_DEPOSITS.ethNonBase.assertNonEthBase,
971
1053
  () => {
@@ -975,7 +1057,7 @@ function routeEthNonBase() {
975
1057
  },
976
1058
  { ctx: { baseIsEth: ctx.baseIsEth, chainIdL2: ctx.chainIdL2 } }
977
1059
  );
978
- const ethBal = await wrapAs4(
1060
+ const ethBal = await wrapAs5(
979
1061
  "RPC",
980
1062
  OP_DEPOSITS.ethNonBase.ethBalance,
981
1063
  () => ctx.client.l1.getBalance({ address: ctx.sender }),
@@ -984,7 +1066,7 @@ function routeEthNonBase() {
984
1066
  message: "Failed to read L1 ETH balance."
985
1067
  }
986
1068
  );
987
- await wrapAs4(
1069
+ await wrapAs5(
988
1070
  "VALIDATION",
989
1071
  OP_DEPOSITS.ethNonBase.assertEthBalance,
990
1072
  () => {
@@ -1017,11 +1099,16 @@ function routeEthNonBase() {
1017
1099
  undeployedGasLimit: priorityGasModel.undeployedGasLimit
1018
1100
  });
1019
1101
  if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
1020
- const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
1102
+ const l1Fees = await quoteL1Fees2({ ctx });
1103
+ const l2BaseCost = await quoteL2BaseCost({
1104
+ ctx,
1105
+ l2GasLimit: l2Gas.gasLimit,
1106
+ l1GasPrice: l1Fees.maxFeePerGas
1107
+ });
1021
1108
  const mintValue = l2BaseCost + ctx.operatorTip;
1022
1109
  const approvals = [];
1023
1110
  const steps = [];
1024
- const allowance = await wrapAs4(
1111
+ const allowance = await wrapAs5(
1025
1112
  "CONTRACT",
1026
1113
  OP_DEPOSITS.ethNonBase.allowanceBase,
1027
1114
  () => ctx.client.l1.readContract({
@@ -1037,7 +1124,7 @@ function routeEthNonBase() {
1037
1124
  );
1038
1125
  const needsApprove = allowance < mintValue;
1039
1126
  if (needsApprove) {
1040
- const approveTx = await wrapAs4(
1127
+ const approveTx = await wrapAs5(
1041
1128
  "CONTRACT",
1042
1129
  OP_DEPOSITS.ethNonBase.estGas,
1043
1130
  () => buildApprovalRequest({
@@ -1059,7 +1146,7 @@ function routeEthNonBase() {
1059
1146
  tx: approveTx
1060
1147
  });
1061
1148
  }
1062
- const secondBridgeCalldata = await wrapAs4(
1149
+ const secondBridgeCalldata = await wrapAs5(
1063
1150
  "INTERNAL",
1064
1151
  OP_DEPOSITS.ethNonBase.encodeCalldata,
1065
1152
  () => encodeSecondBridgeEthDepositCalldata({ ctx, amount: p.amount, receiver }),
@@ -1101,7 +1188,7 @@ function routeEthNonBase() {
1101
1188
  args: [requestStruct]
1102
1189
  });
1103
1190
  } else {
1104
- const sim = await wrapAs4(
1191
+ const sim = await wrapAs5(
1105
1192
  "CONTRACT",
1106
1193
  OP_DEPOSITS.ethNonBase.estGas,
1107
1194
  () => ctx.client.l1.simulateContract({
@@ -1129,7 +1216,8 @@ function routeEthNonBase() {
1129
1216
  data: calldata,
1130
1217
  value: bridgehubValue,
1131
1218
  from: ctx.sender,
1132
- ...ctx.gasOverrides
1219
+ ...ctx.gasOverrides,
1220
+ ...l1Fees
1133
1221
  };
1134
1222
  const l1Gas = await quoteL1Gas2({
1135
1223
  ctx,
@@ -1137,14 +1225,11 @@ function routeEthNonBase() {
1137
1225
  overrides: ctx.gasOverrides,
1138
1226
  fallbackGasLimit: SAFE_L1_BRIDGE_GAS
1139
1227
  });
1140
- if (l1Gas) {
1141
- bridgeTx = {
1142
- ...bridgeTx,
1143
- gas: l1Gas.gasLimit,
1144
- maxFeePerGas: l1Gas.maxFeePerGas,
1145
- maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
1146
- };
1147
- }
1228
+ bridgeTx = {
1229
+ ...bridgeTx,
1230
+ ...l1Fees,
1231
+ ...l1Gas ? { gas: l1Gas.gasLimit } : {}
1232
+ };
1148
1233
  steps.push({
1149
1234
  key: "bridgehub:two-bridges:eth-nonbase",
1150
1235
  kind: "bridgehub:two-bridges",
@@ -1167,12 +1252,12 @@ function routeEthNonBase() {
1167
1252
  }
1168
1253
  };
1169
1254
  }
1170
- var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
1255
+ var { wrapAs: wrapAs6 } = createErrorHandlers("deposits");
1171
1256
  var EMPTY_BYTES3 = "0x";
1172
1257
  function routeErc20Base() {
1173
1258
  return {
1174
1259
  async preflight(p, ctx) {
1175
- await wrapAs5(
1260
+ await wrapAs6(
1176
1261
  "VALIDATION",
1177
1262
  OP_DEPOSITS.base.assertErc20Asset,
1178
1263
  () => {
@@ -1183,7 +1268,7 @@ function routeErc20Base() {
1183
1268
  { ctx: { token: p.token } }
1184
1269
  );
1185
1270
  const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
1186
- await wrapAs5(
1271
+ await wrapAs6(
1187
1272
  "VALIDATION",
1188
1273
  OP_DEPOSITS.base.assertMatchesBase,
1189
1274
  () => {
@@ -1206,13 +1291,19 @@ function routeErc20Base() {
1206
1291
  l2Calldata,
1207
1292
  gasPerPubdata: ctx.gasPerPubdata
1208
1293
  });
1209
- const quotedL2GasLimit = ctx.l2GasLimit ?? clampPriorityL2GasLimit({
1210
- gasLimit: applyPriorityL2GasLimitBuffer({
1211
- chainIdL2: ctx.chainIdL2,
1212
- gasLimit: priorityFloorBreakdown.derivedL2GasLimit
1213
- }),
1294
+ const quotedL2GasLimit = await determineBaseL2GasLimit({
1295
+ ctx,
1296
+ l2Contract,
1297
+ l2Value,
1214
1298
  l2Calldata,
1215
- gasPerPubdata: ctx.gasPerPubdata
1299
+ priorityFloorGasLimit: clampPriorityL2GasLimit({
1300
+ gasLimit: applyPriorityL2GasLimitBuffer({
1301
+ chainIdL2: ctx.chainIdL2,
1302
+ gasLimit: priorityFloorBreakdown.derivedL2GasLimit
1303
+ }),
1304
+ l2Calldata,
1305
+ gasPerPubdata: ctx.gasPerPubdata
1306
+ })
1216
1307
  });
1217
1308
  const l2Gas = await quoteL2Gas3({
1218
1309
  ctx,
@@ -1220,11 +1311,16 @@ function routeErc20Base() {
1220
1311
  overrideGasLimit: quotedL2GasLimit
1221
1312
  });
1222
1313
  if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
1223
- const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
1314
+ const l1Fees = await quoteL1Fees2({ ctx });
1315
+ const l2BaseCost = await quoteL2BaseCost({
1316
+ ctx,
1317
+ l2GasLimit: l2Gas.gasLimit,
1318
+ l1GasPrice: l1Fees.maxFeePerGas
1319
+ });
1224
1320
  const mintValue = l2BaseCost + ctx.operatorTip + p.amount;
1225
1321
  const approvals = [];
1226
1322
  const steps = [];
1227
- const allowance = await wrapAs5(
1323
+ const allowance = await wrapAs6(
1228
1324
  "CONTRACT",
1229
1325
  OP_DEPOSITS.base.allowance,
1230
1326
  () => ctx.client.l1.readContract({
@@ -1240,7 +1336,7 @@ function routeErc20Base() {
1240
1336
  );
1241
1337
  const needsApprove = allowance < mintValue;
1242
1338
  if (needsApprove) {
1243
- const approveTx = await wrapAs5(
1339
+ const approveTx = await wrapAs6(
1244
1340
  "CONTRACT",
1245
1341
  OP_DEPOSITS.base.estGas,
1246
1342
  () => buildApprovalRequest({
@@ -1289,7 +1385,7 @@ function routeErc20Base() {
1289
1385
  args: [req]
1290
1386
  });
1291
1387
  } else {
1292
- const sim = await wrapAs5(
1388
+ const sim = await wrapAs6(
1293
1389
  "RPC",
1294
1390
  OP_DEPOSITS.base.estGas,
1295
1391
  () => ctx.client.l1.simulateContract({
@@ -1317,7 +1413,8 @@ function routeErc20Base() {
1317
1413
  data: calldata,
1318
1414
  value: 0n,
1319
1415
  from: ctx.sender,
1320
- ...ctx.gasOverrides
1416
+ ...ctx.gasOverrides,
1417
+ ...l1Fees
1321
1418
  };
1322
1419
  const l1Gas = await quoteL1Gas2({
1323
1420
  ctx,
@@ -1325,14 +1422,11 @@ function routeErc20Base() {
1325
1422
  overrides: ctx.gasOverrides,
1326
1423
  fallbackGasLimit: SAFE_L1_BRIDGE_GAS
1327
1424
  });
1328
- if (l1Gas) {
1329
- bridgeTx = {
1330
- ...bridgeTx,
1331
- gas: l1Gas.gasLimit,
1332
- maxFeePerGas: l1Gas.maxFeePerGas,
1333
- maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
1334
- };
1335
- }
1425
+ bridgeTx = {
1426
+ ...bridgeTx,
1427
+ ...l1Fees,
1428
+ ...l1Gas ? { gas: l1Gas.gasLimit } : {}
1429
+ };
1336
1430
  steps.push({
1337
1431
  key: "bridgehub:direct:erc20-base",
1338
1432
  kind: "bridgehub:direct",
@@ -1430,7 +1524,7 @@ async function waitForL2ExecutionFromL1Tx(l1, l2, l1TxHash) {
1430
1524
  }
1431
1525
  return { l2Receipt, l2TxHash };
1432
1526
  }
1433
- var { wrapAs: wrapAs6 } = createErrorHandlers("tokens");
1527
+ var { wrapAs: wrapAs7 } = createErrorHandlers("tokens");
1434
1528
  var ntvCodec3 = createNTVCodec({
1435
1529
  encode: (types, values) => encodeAbiParameters(
1436
1530
  types.map((t, i) => ({ type: t, name: `arg${i}` })),
@@ -1445,7 +1539,7 @@ function createTokensResource(client) {
1445
1539
  let wethL2Promise = null;
1446
1540
  async function getL1ChainId() {
1447
1541
  if (!l2NtvL1ChainIdPromise) {
1448
- l2NtvL1ChainIdPromise = wrapAs6("INTERNAL", "getL1ChainId", async () => {
1542
+ l2NtvL1ChainIdPromise = wrapAs7("INTERNAL", "getL1ChainId", async () => {
1449
1543
  const { l2NativeTokenVault } = await client.contracts();
1450
1544
  return await l2NativeTokenVault.read.L1_CHAIN_ID();
1451
1545
  });
@@ -1454,7 +1548,7 @@ function createTokensResource(client) {
1454
1548
  }
1455
1549
  async function getBaseTokenAssetId() {
1456
1550
  if (!baseTokenAssetIdPromise) {
1457
- baseTokenAssetIdPromise = wrapAs6("INTERNAL", "baseTokenAssetId", async () => {
1551
+ baseTokenAssetIdPromise = wrapAs7("INTERNAL", "baseTokenAssetId", async () => {
1458
1552
  const { l2NativeTokenVault } = await client.contracts();
1459
1553
  const assetId = await l2NativeTokenVault.read.BASE_TOKEN_ASSET_ID();
1460
1554
  return assetId;
@@ -1464,7 +1558,7 @@ function createTokensResource(client) {
1464
1558
  }
1465
1559
  async function getWethL1() {
1466
1560
  if (!wethL1Promise) {
1467
- wethL1Promise = wrapAs6("INTERNAL", "wethL1", async () => {
1561
+ wethL1Promise = wrapAs7("INTERNAL", "wethL1", async () => {
1468
1562
  const { l1NativeTokenVault } = await client.contracts();
1469
1563
  const weth = await l1NativeTokenVault.read.WETH_TOKEN();
1470
1564
  return weth;
@@ -1474,7 +1568,7 @@ function createTokensResource(client) {
1474
1568
  }
1475
1569
  async function getWethL2() {
1476
1570
  if (!wethL2Promise) {
1477
- wethL2Promise = wrapAs6("INTERNAL", "wethL2", async () => {
1571
+ wethL2Promise = wrapAs7("INTERNAL", "wethL2", async () => {
1478
1572
  const { l2NativeTokenVault } = await client.contracts();
1479
1573
  const weth = await l2NativeTokenVault.read.WETH_TOKEN();
1480
1574
  return weth;
@@ -1483,7 +1577,7 @@ function createTokensResource(client) {
1483
1577
  return wethL2Promise;
1484
1578
  }
1485
1579
  async function toL2Address(l1Token) {
1486
- return wrapAs6("CONTRACT", "tokens.toL2Address", async () => {
1580
+ return wrapAs7("CONTRACT", "tokens.toL2Address", async () => {
1487
1581
  const normalized = normalizeL1Token(l1Token);
1488
1582
  const chainId = BigInt(await client.l2.getChainId());
1489
1583
  const baseToken = await client.baseToken(chainId);
@@ -1496,7 +1590,7 @@ function createTokensResource(client) {
1496
1590
  });
1497
1591
  }
1498
1592
  async function toL1Address(l2Token) {
1499
- return wrapAs6("CONTRACT", "tokens.toL1Address", async () => {
1593
+ return wrapAs7("CONTRACT", "tokens.toL1Address", async () => {
1500
1594
  if (isAddressEq(l2Token, ETH_ADDRESS)) return ETH_ADDRESS;
1501
1595
  if (isAddressEq(l2Token, L2_BASE_TOKEN_ADDRESS)) {
1502
1596
  const chainId = BigInt(await client.l2.getChainId());
@@ -1517,32 +1611,32 @@ function createTokensResource(client) {
1517
1611
  });
1518
1612
  }
1519
1613
  async function assetIdOfL1(l1Token) {
1520
- return wrapAs6("CONTRACT", "tokens.assetIdOfL1", async () => {
1614
+ return wrapAs7("CONTRACT", "tokens.assetIdOfL1", async () => {
1521
1615
  const normalized = normalizeL1Token(l1Token);
1522
1616
  const { l1NativeTokenVault } = await client.contracts();
1523
1617
  return await l1NativeTokenVault.read.assetId([normalized]);
1524
1618
  });
1525
1619
  }
1526
1620
  async function assetIdOfL2(l2Token) {
1527
- return wrapAs6("CONTRACT", "tokens.assetIdOfL2", async () => {
1621
+ return wrapAs7("CONTRACT", "tokens.assetIdOfL2", async () => {
1528
1622
  const { l2NativeTokenVault } = await client.contracts();
1529
1623
  return await l2NativeTokenVault.read.assetId([l2Token]);
1530
1624
  });
1531
1625
  }
1532
1626
  async function l2TokenFromAssetId(assetId) {
1533
- return wrapAs6("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
1627
+ return wrapAs7("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
1534
1628
  const { l2NativeTokenVault } = await client.contracts();
1535
1629
  return await l2NativeTokenVault.read.tokenAddress([assetId]);
1536
1630
  });
1537
1631
  }
1538
1632
  async function l1TokenFromAssetId(assetId) {
1539
- return wrapAs6("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
1633
+ return wrapAs7("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
1540
1634
  const { l1NativeTokenVault } = await client.contracts();
1541
1635
  return await l1NativeTokenVault.read.tokenAddress([assetId]);
1542
1636
  });
1543
1637
  }
1544
1638
  async function originChainId(assetId) {
1545
- return wrapAs6("CONTRACT", "tokens.originChainId", async () => {
1639
+ return wrapAs7("CONTRACT", "tokens.originChainId", async () => {
1546
1640
  const { l2NativeTokenVault } = await client.contracts();
1547
1641
  return await l2NativeTokenVault.read.originChainId([assetId]);
1548
1642
  });
@@ -1551,7 +1645,7 @@ function createTokensResource(client) {
1551
1645
  return getBaseTokenAssetId();
1552
1646
  }
1553
1647
  async function isChainEthBased() {
1554
- return wrapAs6("CONTRACT", "tokens.isChainEthBased", async () => {
1648
+ return wrapAs7("CONTRACT", "tokens.isChainEthBased", async () => {
1555
1649
  const baseAssetId = await getBaseTokenAssetId();
1556
1650
  const l1ChainId = await getL1ChainId();
1557
1651
  const ethAssetId = ntvCodec3.encodeAssetId(
@@ -1569,7 +1663,7 @@ function createTokensResource(client) {
1569
1663
  return getWethL2();
1570
1664
  }
1571
1665
  async function computeL2BridgedAddress(args) {
1572
- return wrapAs6("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
1666
+ return wrapAs7("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
1573
1667
  const normalized = normalizeL1Token(args.l1Token);
1574
1668
  const { l2NativeTokenVault } = await client.contracts();
1575
1669
  const predicted = await l2NativeTokenVault.read.calculateCreate2TokenAddress([
@@ -1580,7 +1674,7 @@ function createTokensResource(client) {
1580
1674
  });
1581
1675
  }
1582
1676
  async function resolve(ref, opts) {
1583
- return wrapAs6("CONTRACT", "tokens.resolve", async () => {
1677
+ return wrapAs7("CONTRACT", "tokens.resolve", async () => {
1584
1678
  let chain;
1585
1679
  let address;
1586
1680
  if (typeof ref === "string") {
@@ -2094,12 +2188,12 @@ function buildFeeBreakdown2(p) {
2094
2188
  }
2095
2189
 
2096
2190
  // src/adapters/viem/resources/withdrawals/routes/eth.ts
2097
- var { wrapAs: wrapAs7 } = createErrorHandlers("withdrawals");
2191
+ var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
2098
2192
  function routeEthBase() {
2099
2193
  return {
2100
2194
  async build(p, ctx) {
2101
2195
  const steps = [];
2102
- const data = await wrapAs7(
2196
+ const data = await wrapAs8(
2103
2197
  "INTERNAL",
2104
2198
  OP_WITHDRAWALS.eth.encodeWithdraw,
2105
2199
  () => Promise.resolve(
@@ -2149,14 +2243,14 @@ function routeEthBase() {
2149
2243
  }
2150
2244
  };
2151
2245
  }
2152
- var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
2246
+ var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
2153
2247
  function routeErc20NonBase2() {
2154
2248
  return {
2155
2249
  // TODO: add preflight validations here
2156
2250
  async build(p, ctx) {
2157
2251
  const steps = [];
2158
2252
  const approvals = [];
2159
- const current = await wrapAs8(
2253
+ const current = await wrapAs9(
2160
2254
  "CONTRACT",
2161
2255
  OP_WITHDRAWALS.erc20.allowance,
2162
2256
  () => ctx.client.l2.readContract({
@@ -2195,7 +2289,7 @@ function routeErc20NonBase2() {
2195
2289
  approveTxCandidate.maxFeePerGas = approveGas.maxFeePerGas;
2196
2290
  approveTxCandidate.maxPriorityFeePerGas = approveGas.maxPriorityFeePerGas;
2197
2291
  }
2198
- const approveSim = await wrapAs8(
2292
+ const approveSim = await wrapAs9(
2199
2293
  "CONTRACT",
2200
2294
  OP_WITHDRAWALS.erc20.estGas,
2201
2295
  () => ctx.client.l2.simulateContract({
@@ -2222,7 +2316,7 @@ function routeErc20NonBase2() {
2222
2316
  tx: approveTx
2223
2317
  });
2224
2318
  }
2225
- const assetId = (await wrapAs8(
2319
+ const assetId = (await wrapAs9(
2226
2320
  "CONTRACT",
2227
2321
  OP_WITHDRAWALS.erc20.ensureRegistered,
2228
2322
  () => ctx.client.l2.simulateContract({
@@ -2273,7 +2367,7 @@ function routeErc20NonBase2() {
2273
2367
  ...withdrawGas
2274
2368
  };
2275
2369
  } else {
2276
- const sim = await wrapAs8(
2370
+ const sim = await wrapAs9(
2277
2371
  "CONTRACT",
2278
2372
  OP_WITHDRAWALS.erc20.estGas,
2279
2373
  () => ctx.client.l2.simulateContract({
@@ -2368,7 +2462,7 @@ function createViemAttributesResource() {
2368
2462
  }
2369
2463
 
2370
2464
  // src/adapters/viem/resources/withdrawals/routes/interop-bundle.ts
2371
- var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
2465
+ var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
2372
2466
  var attributes = createViemAttributesResource();
2373
2467
  function saltFor(sender, nonce) {
2374
2468
  return keccak256(
@@ -2393,7 +2487,7 @@ function routeInteropBundle() {
2393
2487
  if (isBaseToken) {
2394
2488
  assetId = ctx.baseTokenAssetId;
2395
2489
  } else {
2396
- assetId = (await wrapAs9(
2490
+ assetId = (await wrapAs10(
2397
2491
  "CONTRACT",
2398
2492
  OP_WITHDRAWALS.erc20.ensureRegistered,
2399
2493
  () => ctx.client.l2.simulateContract({
@@ -2408,7 +2502,7 @@ function routeInteropBundle() {
2408
2502
  message: "Failed to ensure token is registered in L2NativeTokenVault."
2409
2503
  }
2410
2504
  )).result;
2411
- const current = await wrapAs9(
2505
+ const current = await wrapAs10(
2412
2506
  "CONTRACT",
2413
2507
  OP_WITHDRAWALS.erc20.allowance,
2414
2508
  () => ctx.client.l2.readContract({
@@ -2457,7 +2551,7 @@ function routeInteropBundle() {
2457
2551
  });
2458
2552
  }
2459
2553
  }
2460
- const nonce = await wrapAs9(
2554
+ const nonce = await wrapAs10(
2461
2555
  "RPC",
2462
2556
  OP_WITHDRAWALS.prepare,
2463
2557
  () => ctx.client.l2.getTransactionCount({ address: ctx.sender, blockTag: "pending" }),
@@ -2563,7 +2657,7 @@ function createWithdrawalProtocolService(client, override) {
2563
2657
  }
2564
2658
  };
2565
2659
  }
2566
- var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
2660
+ var { wrapAs: wrapAs11 } = createErrorHandlers("withdrawals");
2567
2661
  var IL1NullifierMini = [
2568
2662
  {
2569
2663
  type: "function",
@@ -2581,7 +2675,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2581
2675
  async function finalizationTarget(protocol) {
2582
2676
  const { l1Nullifier } = await client.ensureAddresses();
2583
2677
  if (protocol === "legacy-withdrawal") return l1Nullifier;
2584
- return await wrapAs10(
2678
+ return await wrapAs11(
2585
2679
  "CONTRACT",
2586
2680
  OP_WITHDRAWALS.finalize.fetchParams.receipt,
2587
2681
  () => client.l1.readContract({
@@ -2596,7 +2690,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2596
2690
  );
2597
2691
  }
2598
2692
  async function fetchMessageAndProof(l2TxHash) {
2599
- const raw = await wrapAs10(
2693
+ const raw = await wrapAs11(
2600
2694
  "RPC",
2601
2695
  OP_WITHDRAWALS.finalize.fetchParams.receipt,
2602
2696
  () => client.zks.getReceiptWithL2ToL1(l2TxHash),
@@ -2613,7 +2707,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2613
2707
  context: { l2TxHash }
2614
2708
  });
2615
2709
  }
2616
- const ev = await wrapAs10(
2710
+ const ev = await wrapAs11(
2617
2711
  "INTERNAL",
2618
2712
  OP_WITHDRAWALS.finalize.fetchParams.findMessage,
2619
2713
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
@@ -2623,7 +2717,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2623
2717
  message: "Failed to locate L1MessageSent event in L2 receipt."
2624
2718
  }
2625
2719
  );
2626
- const message = await wrapAs10(
2720
+ const message = await wrapAs11(
2627
2721
  "INTERNAL",
2628
2722
  OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
2629
2723
  () => {
@@ -2635,7 +2729,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2635
2729
  message: "Failed to decode withdrawal message."
2636
2730
  }
2637
2731
  );
2638
- const idx = await wrapAs10(
2732
+ const idx = await wrapAs11(
2639
2733
  "INTERNAL",
2640
2734
  OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
2641
2735
  () => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
@@ -2644,7 +2738,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2644
2738
  message: "Failed to derive messenger log index."
2645
2739
  }
2646
2740
  );
2647
- const proof = await wrapAs10(
2741
+ const proof = await wrapAs11(
2648
2742
  "RPC",
2649
2743
  OP_WITHDRAWALS.finalize.fetchParams.proof,
2650
2744
  () => client.zks.getL2ToL1LogProof(l2TxHash, idx),
@@ -2653,7 +2747,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2653
2747
  message: "Failed to fetch L2\u2192L1 log proof."
2654
2748
  }
2655
2749
  );
2656
- const chainId = await wrapAs10(
2750
+ const chainId = await wrapAs11(
2657
2751
  "RPC",
2658
2752
  OP_WITHDRAWALS.finalize.fetchParams.network,
2659
2753
  () => client.l2.getChainId(),
@@ -2711,7 +2805,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2711
2805
  async function withdrawalOutcome(finalization) {
2712
2806
  const target = await finalizationTarget(finalization.protocol);
2713
2807
  if (finalization.protocol === "legacy-withdrawal") {
2714
- const done = await wrapAs10(
2808
+ const done = await wrapAs11(
2715
2809
  "RPC",
2716
2810
  OP_WITHDRAWALS.finalize.isFinalized,
2717
2811
  () => client.l1.readContract({
@@ -2733,7 +2827,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2733
2827
  }
2734
2828
  const { bundleHash } = finalization.params;
2735
2829
  const status = Number(
2736
- await wrapAs10(
2830
+ await wrapAs11(
2737
2831
  "RPC",
2738
2832
  OP_WITHDRAWALS.finalize.isFinalized,
2739
2833
  () => client.l1.readContract({
@@ -2750,7 +2844,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2750
2844
  );
2751
2845
  if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
2752
2846
  const callStatus = Number(
2753
- await wrapAs10(
2847
+ await wrapAs11(
2754
2848
  "RPC",
2755
2849
  OP_WITHDRAWALS.finalize.isFinalized,
2756
2850
  () => client.l1.readContract({
@@ -2821,7 +2915,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2821
2915
  },
2822
2916
  async estimateFinalization(finalization) {
2823
2917
  const target = await finalizationTarget(finalization.protocol);
2824
- const gasLimit = await wrapAs10(
2918
+ const gasLimit = await wrapAs11(
2825
2919
  "RPC",
2826
2920
  OP_WITHDRAWALS.finalize.estimate,
2827
2921
  () => finalization.protocol === "legacy-withdrawal" ? client.l1.estimateContractGas({
@@ -2849,7 +2943,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2849
2943
  let maxFeePerGas;
2850
2944
  let maxPriorityFeePerGas;
2851
2945
  try {
2852
- const fee = await wrapAs10(
2946
+ const fee = await wrapAs11(
2853
2947
  "RPC",
2854
2948
  OP_WITHDRAWALS.finalize.estimate,
2855
2949
  () => client.l1.estimateFeesPerGas(),
@@ -2868,7 +2962,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
2868
2962
  })();
2869
2963
  maxPriorityFeePerGas = fee.maxPriorityFeePerGas ?? 0n;
2870
2964
  } catch {
2871
- const gasPrice = await wrapAs10(
2965
+ const gasPrice = await wrapAs11(
2872
2966
  "RPC",
2873
2967
  OP_WITHDRAWALS.finalize.estimate,
2874
2968
  () => client.l1.getGasPrice(),