@matterlabs/zksync-js 0.0.16 → 0.0.17

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,5 +1,5 @@
1
- export { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-3KH5PCD6.js';
2
- import '../../chunk-NLUCYVMX.js';
1
+ export { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-ONCNOWNC.js';
2
+ import '../../chunk-6LYAENO6.js';
3
3
  import '../../chunk-3HHUZXSV.js';
4
4
  export { createViemClient as createClient, createViemClient } from '../../chunk-CK5UFAZK.js';
5
5
  export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-SBGBYZJM.js';
@@ -8,6 +8,7 @@ import type { InteropRouteStrategy, ViemTransactionRequest } from './routes/type
8
8
  import { createInteropFinalizationServices, type InteropFinalizationServices } from './services/finalization';
9
9
  import { type LogsQueryOptions } from './services/finalization/data-fetchers';
10
10
  import type { ChainRef, InteropConfig } from './types';
11
+ import type { TxGasOverrides } from '../../../../core/types/fees';
11
12
  export declare const ROUTES: Record<InteropRoute, InteropRouteStrategy>;
12
13
  export interface InteropResource {
13
14
  quote(dstChain: ChainRef, params: InteropParams): Promise<InteropQuote>;
@@ -49,8 +50,8 @@ export interface InteropResource {
49
50
  ok: false;
50
51
  error: unknown;
51
52
  }>;
52
- finalize(dstChain: ChainRef, h: InteropWaitable | InteropFinalizationInfo, opts?: LogsQueryOptions): Promise<InteropFinalizationResult>;
53
- tryFinalize(dstChain: ChainRef, h: InteropWaitable | InteropFinalizationInfo, opts?: LogsQueryOptions): Promise<{
53
+ finalize(dstChain: ChainRef, h: InteropWaitable | InteropFinalizationInfo, opts?: LogsQueryOptions, txOverrides?: TxGasOverrides): Promise<InteropFinalizationResult>;
54
+ tryFinalize(dstChain: ChainRef, h: InteropWaitable | InteropFinalizationInfo, opts?: LogsQueryOptions, txOverrides?: TxGasOverrides): Promise<{
54
55
  ok: true;
55
56
  value: InteropFinalizationResult;
56
57
  } | {
@@ -1,6 +1,7 @@
1
1
  import { type PublicClient, type TransactionReceipt } from 'viem';
2
2
  import type { Hex } from '../../../../../../core/types/primitives';
3
3
  import type { InteropFinalizationInfo } from '../../../../../../core/types/flows/interop';
4
+ import type { TxGasOverrides } from '../../../../../../core/types/fees';
4
5
  import type { ViemClient } from '../../../../client';
5
6
  import type { InteropPhase } from '../../../../../../core/types/flows/interop';
6
7
  import type { InteropTopics } from '../../../../../../core/resources/interop/events';
@@ -9,7 +10,7 @@ export declare function getBundleStatus(client: ViemClient, dstProvider: PublicC
9
10
  phase: InteropPhase;
10
11
  dstExecTxHash?: Hex;
11
12
  }>;
12
- export declare function executeBundle(client: ViemClient, dstProvider: PublicClient, info: InteropFinalizationInfo, opts?: LogsQueryOptions): Promise<{
13
+ export declare function executeBundle(client: ViemClient, dstProvider: PublicClient, info: InteropFinalizationInfo, opts?: LogsQueryOptions, txOverrides?: TxGasOverrides): Promise<{
13
14
  hash: Hex;
14
15
  wait: () => Promise<TransactionReceipt>;
15
16
  }>;
@@ -2,12 +2,13 @@ import type { PublicClient } from 'viem';
2
2
  import type { InteropStatus, InteropWaitable, InteropFinalizationInfo, InteropFinalizationResult } from '../../../../../../core/types/flows/interop';
3
3
  import type { ViemClient } from '../../../../client';
4
4
  import type { LogsQueryOptions } from './data-fetchers';
5
+ import type { TxGasOverrides } from '../../../../../../core/types/fees';
5
6
  export interface InteropFinalizationServices {
6
7
  status(dstProvider: PublicClient, input: InteropWaitable, opts?: LogsQueryOptions): Promise<InteropStatus>;
7
8
  wait(dstProvider: PublicClient, gwProvider: PublicClient, input: InteropWaitable, opts?: {
8
9
  pollMs?: number;
9
10
  timeoutMs?: number;
10
11
  }): Promise<InteropFinalizationInfo>;
11
- finalize(dstProvider: PublicClient, info: InteropFinalizationInfo, opts?: LogsQueryOptions): Promise<InteropFinalizationResult>;
12
+ finalize(dstProvider: PublicClient, info: InteropFinalizationInfo, opts?: LogsQueryOptions, txOverrides?: TxGasOverrides): Promise<InteropFinalizationResult>;
12
13
  }
13
14
  export declare function createInteropFinalizationServices(client: ViemClient): InteropFinalizationServices;
@@ -6533,8 +6533,8 @@ function buildFeeBreakdown(p) {
6533
6533
 
6534
6534
  // src/core/resources/deposits/priority.ts
6535
6535
  var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
6536
- var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
6537
- var ERAVM_PRIORITY_L2_GAS_BUFFER = 30n;
6536
+ var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
6537
+ var PRIORITY_L2_GAS_BUFFER = 40n;
6538
6538
  var maxBigInt2 = (a, b) => a > b ? a : b;
6539
6539
  var ceilDiv = (a, b) => (a + b - 1n) / b;
6540
6540
  function derivePriorityTxGasBreakdown(input) {
@@ -6562,10 +6562,7 @@ function derivePriorityBodyGasEstimateCap(input) {
6562
6562
  return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
6563
6563
  }
6564
6564
  function applyPriorityL2GasLimitBuffer(input) {
6565
- if (!isEraVmChain(input.chainIdL2)) {
6566
- return input.gasLimit;
6567
- }
6568
- return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
6565
+ return input.gasLimit * (100n + PRIORITY_L2_GAS_BUFFER) / 100n;
6569
6566
  }
6570
6567
  var EMPTY_BYTES = "0x";
6571
6568
  var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
@@ -9709,13 +9706,23 @@ function routeIndirect() {
9709
9706
  }
9710
9707
  function routeDirect() {
9711
9708
  return {
9712
- // eslint-disable-next-line @typescript-eslint/require-await
9713
9709
  async preflight(params, ctx) {
9714
9710
  preflightDirect(params, {
9715
9711
  dstChainId: ctx.dstChainId,
9716
9712
  baseTokens: ctx.baseTokens,
9717
9713
  l2AssetRouter: ctx.l2AssetRouter,
9718
9714
  l2NativeTokenVault: ctx.l2NativeTokenVault});
9715
+ for (const action of params.actions) {
9716
+ const bytecode = await ctx.dstPublicClient.getCode({ address: action.to });
9717
+ if (!bytecode || bytecode === "0x") {
9718
+ throw createError("VALIDATION", {
9719
+ resource: "interop",
9720
+ operation: OP_INTEROP.routes.direct.preflight,
9721
+ 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).`,
9722
+ context: { to: action.to, action: action.type }
9723
+ });
9724
+ }
9725
+ }
9719
9726
  },
9720
9727
  async build(params, ctx) {
9721
9728
  const steps = [];
@@ -9975,7 +9982,7 @@ async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
9975
9982
  }
9976
9983
  return { phase: "SENT" };
9977
9984
  }
9978
- async function executeBundle(client, dstProvider, info, opts) {
9985
+ async function executeBundle(client, dstProvider, info, opts, txOverrides) {
9979
9986
  const { topics } = getTopics();
9980
9987
  const { bundleHash, encodedData, proof } = info;
9981
9988
  const dstStatus = await getBundleStatus(client, dstProvider, topics, bundleHash, opts);
@@ -10004,7 +10011,10 @@ async function executeBundle(client, dstProvider, info, opts) {
10004
10011
  functionName: "executeBundle",
10005
10012
  args: [encodedData, proof],
10006
10013
  account: client.account,
10007
- chain: dstProvider.chain ?? null
10014
+ chain: dstProvider.chain ?? null,
10015
+ gas: txOverrides?.gasLimit,
10016
+ maxFeePerGas: txOverrides?.maxFeePerGas,
10017
+ maxPriorityFeePerGas: txOverrides?.maxPriorityFeePerGas
10008
10018
  });
10009
10019
  return {
10010
10020
  hash,
@@ -10461,8 +10471,8 @@ function createInteropFinalizationServices(client) {
10461
10471
  wait(dstProvider, gwProvider, input, opts) {
10462
10472
  return waitForFinalization(client, dstProvider, gwProvider, input, opts);
10463
10473
  },
10464
- async finalize(dstProvider, info, opts) {
10465
- const execResult = await executeBundle(client, dstProvider, info, opts);
10474
+ async finalize(dstProvider, info, opts, txOverrides) {
10475
+ const execResult = await executeBundle(client, dstProvider, info, opts, txOverrides);
10466
10476
  await execResult.wait();
10467
10477
  return {
10468
10478
  bundleHash: info.bundleHash,
@@ -10690,22 +10700,25 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
10690
10700
  ctx: { where: "interop.wait" }
10691
10701
  });
10692
10702
  const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
10693
- const finalize = (dstChain, h, opts) => wrap6(
10703
+ const finalize = (dstChain, h, opts, txOverrides) => wrap6(
10694
10704
  OP_INTEROP.finalize,
10695
10705
  async () => {
10696
10706
  const dstProvider = resolveChainRef(dstChain);
10697
10707
  if (isInteropFinalizationInfo(h)) {
10698
- return svc.finalize(dstProvider, h, opts);
10708
+ return svc.finalize(dstProvider, h, opts, txOverrides);
10699
10709
  }
10700
10710
  const info = await svc.wait(dstProvider, getGwProvider(), h);
10701
- return svc.finalize(dstProvider, info, opts);
10711
+ return svc.finalize(dstProvider, info, opts, txOverrides);
10702
10712
  },
10703
10713
  {
10704
10714
  message: "Failed to finalize/execute interop bundle on destination.",
10705
10715
  ctx: { where: "interop.finalize" }
10706
10716
  }
10707
10717
  );
10708
- const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
10718
+ const tryFinalize = (dstChain, h, opts, txOverrides) => toResult2(
10719
+ OP_INTEROP.tryFinalize,
10720
+ () => finalize(dstChain, h, opts, txOverrides)
10721
+ );
10709
10722
  const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap6(
10710
10723
  OP_INTEROP.svc.status.getRoot,
10711
10724
  () => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),