@matterlabs/zksync-js 0.0.16 → 0.0.18

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.
@@ -8404,8 +8404,8 @@ function buildFeeBreakdown(p) {
8404
8404
 
8405
8405
  // src/core/resources/deposits/priority.ts
8406
8406
  var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
8407
- var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
8408
- var ERAVM_PRIORITY_L2_GAS_BUFFER = 30n;
8407
+ var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
8408
+ var PRIORITY_L2_GAS_BUFFER = 40n;
8409
8409
  var maxBigInt2 = (a, b) => a > b ? a : b;
8410
8410
  var ceilDiv = (a, b) => (a + b - 1n) / b;
8411
8411
  function derivePriorityTxGasBreakdown(input) {
@@ -8433,10 +8433,7 @@ function derivePriorityBodyGasEstimateCap(input) {
8433
8433
  return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
8434
8434
  }
8435
8435
  function applyPriorityL2GasLimitBuffer(input) {
8436
- if (!isEraVmChain(input.chainIdL2)) {
8437
- return input.gasLimit;
8438
- }
8439
- return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
8436
+ return input.gasLimit * (100n + PRIORITY_L2_GAS_BUFFER) / 100n;
8440
8437
  }
8441
8438
  var EMPTY_BYTES = "0x";
8442
8439
  var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
@@ -8562,6 +8559,22 @@ function routeEthDirect() {
8562
8559
  var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
8563
8560
  var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
8564
8561
  var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
8562
+ async function encodeSecondBridgeErc20DepositCalldata(input) {
8563
+ if (!input.ctx.resolvedToken) {
8564
+ return encodeSecondBridgeErc20Args(input.token, input.amount, input.receiver);
8565
+ }
8566
+ const { chainId: l1ChainId } = await input.ctx.client.l1.getNetwork();
8567
+ const isL1Origin = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID || input.ctx.resolvedToken.originChainId === 0n || input.ctx.resolvedToken.originChainId === BigInt(l1ChainId);
8568
+ if (isL1Origin) {
8569
+ return encodeSecondBridgeErc20Args(input.token, input.amount, input.receiver);
8570
+ }
8571
+ const transferData = encodeNativeTokenVaultTransferData(
8572
+ input.amount,
8573
+ input.receiver,
8574
+ input.token
8575
+ );
8576
+ return encodeSecondBridgeDataV1(input.ctx.resolvedToken.assetId, transferData);
8577
+ }
8565
8578
  async function getPriorityGasModel(input) {
8566
8579
  try {
8567
8580
  const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
@@ -8634,9 +8647,14 @@ function routeErc20NonBase() {
8634
8647
  const secondBridgeCalldata = await wrapAs3(
8635
8648
  "INTERNAL",
8636
8649
  OP_DEPOSITS.nonbase.encodeCalldata,
8637
- () => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, receiver)),
8650
+ () => encodeSecondBridgeErc20DepositCalldata({
8651
+ ctx,
8652
+ token: p.token,
8653
+ amount: p.amount,
8654
+ receiver
8655
+ }),
8638
8656
  {
8639
- ctx: { where: "encodeSecondBridgeErc20Args" },
8657
+ ctx: { where: "encodeSecondBridgeErc20DepositCalldata" },
8640
8658
  message: "Failed to encode bridging calldata."
8641
8659
  }
8642
8660
  );
@@ -11091,13 +11109,23 @@ function routeIndirect() {
11091
11109
  // src/adapters/ethers/resources/interop/routes/direct.ts
11092
11110
  function routeDirect() {
11093
11111
  return {
11094
- // eslint-disable-next-line @typescript-eslint/require-await
11095
11112
  async preflight(params, ctx) {
11096
11113
  preflightDirect(params, {
11097
11114
  dstChainId: ctx.dstChainId,
11098
11115
  baseTokens: ctx.baseTokens,
11099
11116
  l2AssetRouter: ctx.l2AssetRouter,
11100
11117
  l2NativeTokenVault: ctx.l2NativeTokenVault});
11118
+ for (const action of params.actions) {
11119
+ const code = await ctx.dstProvider.getCode(action.to);
11120
+ if (!code || code === "0x") {
11121
+ throw createError("VALIDATION", {
11122
+ resource: "interop",
11123
+ operation: OP_INTEROP.routes.direct.preflight,
11124
+ message: `Destination address ${action.to} is not a contract on the destination chain. The receiver must be a contract that implements the IERC7786Recipient interface (receiveMessage).`,
11125
+ context: { to: action.to, action: action.type }
11126
+ });
11127
+ }
11128
+ }
11101
11129
  },
11102
11130
  async build(params, ctx) {
11103
11131
  const steps = [];
@@ -11347,7 +11375,7 @@ async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
11347
11375
  }
11348
11376
  return { phase: "SENT" };
11349
11377
  }
11350
- async function executeBundle(client, dstProvider, info, opts) {
11378
+ async function executeBundle(client, dstProvider, info, opts, txOverrides) {
11351
11379
  const { topics } = getTopics();
11352
11380
  const { bundleHash, encodedData, proof } = info;
11353
11381
  const dstStatus = await getBundleStatus(client, dstProvider, topics, bundleHash, opts);
@@ -11365,7 +11393,11 @@ async function executeBundle(client, dstProvider, info, opts) {
11365
11393
  const { interopHandler } = await client.ensureAddresses();
11366
11394
  const handler = new ethers.Contract(interopHandler, IInteropHandler_default, signer);
11367
11395
  try {
11368
- const txResponse = await handler.executeBundle(encodedData, proof);
11396
+ const txResponse = await handler.executeBundle(
11397
+ encodedData,
11398
+ proof,
11399
+ txOverrides ?? {}
11400
+ );
11369
11401
  const hash = txResponse.hash;
11370
11402
  return {
11371
11403
  hash,
@@ -11813,8 +11845,8 @@ function createInteropFinalizationServices(client) {
11813
11845
  wait(dstProvider, gwProvider, input, opts) {
11814
11846
  return waitForFinalization(client, dstProvider, gwProvider, input, opts);
11815
11847
  },
11816
- async finalize(dstProvider, info, opts) {
11817
- const execResult = await executeBundle(client, dstProvider, info, opts);
11848
+ async finalize(dstProvider, info, opts, txOverrides) {
11849
+ const execResult = await executeBundle(client, dstProvider, info, opts, txOverrides);
11818
11850
  await execResult.wait();
11819
11851
  return {
11820
11852
  bundleHash: info.bundleHash,
@@ -12024,22 +12056,25 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
12024
12056
  ctx: { where: "interop.wait" }
12025
12057
  });
12026
12058
  const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
12027
- const finalize = (dstChain, h, opts) => wrap7(
12059
+ const finalize = (dstChain, h, opts, txOverrides) => wrap7(
12028
12060
  OP_INTEROP.finalize,
12029
12061
  async () => {
12030
12062
  const dstProvider = resolveChainRef(dstChain);
12031
12063
  if (isInteropFinalizationInfo(h)) {
12032
- return svc.finalize(dstProvider, h, opts);
12064
+ return svc.finalize(dstProvider, h, opts, txOverrides);
12033
12065
  }
12034
12066
  const info = await svc.wait(dstProvider, getGwProvider(), h);
12035
- return svc.finalize(dstProvider, info, opts);
12067
+ return svc.finalize(dstProvider, info, opts, txOverrides);
12036
12068
  },
12037
12069
  {
12038
12070
  message: "Failed to finalize/execute interop bundle on destination.",
12039
12071
  ctx: { where: "interop.finalize" }
12040
12072
  }
12041
12073
  );
12042
- const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
12074
+ const tryFinalize = (dstChain, h, opts, txOverrides) => toResult2(
12075
+ OP_INTEROP.tryFinalize,
12076
+ () => finalize(dstChain, h, opts, txOverrides)
12077
+ );
12043
12078
  const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap7(
12044
12079
  OP_INTEROP.svc.status.getRoot,
12045
12080
  () => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),