@matterlabs/zksync-js 0.0.15 → 0.0.16

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 (32) hide show
  1. package/dist/adapters/ethers/client.js +4 -4
  2. package/dist/adapters/ethers/index.cjs +83 -4
  3. package/dist/adapters/ethers/index.cjs.map +1 -1
  4. package/dist/adapters/ethers/index.js +6 -6
  5. package/dist/adapters/ethers/resources/interop/index.d.ts +4 -1
  6. package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +4 -0
  7. package/dist/adapters/ethers/sdk.cjs +83 -4
  8. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  9. package/dist/adapters/ethers/sdk.js +5 -5
  10. package/dist/adapters/viem/client.js +4 -4
  11. package/dist/adapters/viem/index.cjs +93 -6
  12. package/dist/adapters/viem/index.cjs.map +1 -1
  13. package/dist/adapters/viem/index.js +6 -6
  14. package/dist/adapters/viem/resources/interop/index.d.ts +4 -1
  15. package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +4 -0
  16. package/dist/adapters/viem/sdk.cjs +93 -6
  17. package/dist/adapters/viem/sdk.cjs.map +1 -1
  18. package/dist/adapters/viem/sdk.js +5 -5
  19. package/dist/{chunk-MZBKM3GH.js → chunk-24TE2NNJ.js} +2 -2
  20. package/dist/{chunk-4PZCNTQ3.js → chunk-3KH5PCD6.js} +96 -10
  21. package/dist/{chunk-HGB3DOV2.js → chunk-5HG2DUYW.js} +86 -8
  22. package/dist/{chunk-JHRYNLZG.js → chunk-CK5UFAZK.js} +2 -2
  23. package/dist/{chunk-MDPX5LNW.js → chunk-JSBMIT4S.js} +1 -1
  24. package/dist/{chunk-65HAYKVL.js → chunk-NJK325XV.js} +2 -2
  25. package/dist/{chunk-K2UVKMLN.js → chunk-NLUCYVMX.js} +1 -1
  26. package/dist/{chunk-YIWXIP2M.js → chunk-SBGBYZJM.js} +2 -2
  27. package/dist/{chunk-HVHMLAYH.js → chunk-TYYUG5GA.js} +1 -1
  28. package/dist/{chunk-JXR5V5YK.js → chunk-UEKFQAOS.js} +1 -0
  29. package/dist/core/index.js +2 -2
  30. package/dist/core/types/errors.d.ts +1 -0
  31. package/dist/index.js +2 -2
  32. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- export { createEthersClient } from '../../chunk-MZBKM3GH.js';
2
- import '../../chunk-65HAYKVL.js';
1
+ export { createEthersClient } from '../../chunk-24TE2NNJ.js';
2
+ import '../../chunk-NJK325XV.js';
3
3
  import '../../chunk-BWKWWLY4.js';
4
- import '../../chunk-MDPX5LNW.js';
5
- import '../../chunk-JXR5V5YK.js';
4
+ import '../../chunk-JSBMIT4S.js';
5
+ import '../../chunk-UEKFQAOS.js';
6
6
  import '../../chunk-MT4X5FEO.js';
@@ -389,6 +389,7 @@ var OP_INTEROP = {
389
389
  tryWait: "interop.tryWait",
390
390
  finalize: "interop.finalize",
391
391
  tryFinalize: "interop.tryFinalize",
392
+ verify: "interop.verify",
392
393
  context: {
393
394
  chainTypeManager: "interop.chainTypeManager",
394
395
  protocolVersion: "interop.protocolVersion"
@@ -8944,7 +8945,7 @@ function routeEthNonBase() {
8944
8945
  const requestStruct = {
8945
8946
  chainId: ctx.chainIdL2,
8946
8947
  mintValue,
8947
- l2Value: p.amount,
8948
+ l2Value: 0n,
8948
8949
  l2GasLimit: l2GasParams.gasLimit,
8949
8950
  l2GasPerPubdataByteLimit: ctx.gasPerPubdata,
8950
8951
  refundRecipient: ctx.refundRecipient,
@@ -8952,6 +8953,7 @@ function routeEthNonBase() {
8952
8953
  secondBridgeValue: p.amount,
8953
8954
  secondBridgeCalldata
8954
8955
  };
8956
+ const bridgehubValue = p.amount;
8955
8957
  const bridgehub = await ctx.contracts.bridgehub();
8956
8958
  const data = bridgehub.interface.encodeFunctionData("requestL2TransactionTwoBridges", [
8957
8959
  requestStruct
@@ -8959,8 +8961,7 @@ function routeEthNonBase() {
8959
8961
  const l1TxCandidate = {
8960
8962
  to: ctx.bridgehub,
8961
8963
  data,
8962
- value: p.amount,
8963
- // base ≠ ETH ⇒ msg.value == secondBridgeValue
8964
+ value: bridgehubValue,
8964
8965
  from: ctx.sender,
8965
8966
  ...ctx.gasOverrides
8966
8967
  };
@@ -11407,6 +11408,60 @@ async function executeBundle(client, dstProvider, info, opts) {
11407
11408
  );
11408
11409
  }
11409
11410
  }
11411
+ async function verifyBundle(client, dstProvider, info) {
11412
+ const signer = await wrap5(OP_INTEROP.verify, () => client.signerFor(dstProvider), {
11413
+ message: "Failed to resolve destination signer for verifyBundle."
11414
+ });
11415
+ const { interopHandler } = await client.ensureAddresses();
11416
+ const handler = new ethers.Contract(interopHandler, IInteropHandler_default, signer);
11417
+ try {
11418
+ const txResponse = await handler.verifyBundle(
11419
+ info.encodedData,
11420
+ info.proof
11421
+ );
11422
+ const hash = txResponse.hash;
11423
+ return {
11424
+ hash,
11425
+ wait: async () => {
11426
+ try {
11427
+ const receipt = await txResponse.wait();
11428
+ if (!receipt || receipt.status !== 1) {
11429
+ throw createError("EXECUTION", {
11430
+ resource: "interop",
11431
+ operation: OP_INTEROP.verify,
11432
+ message: "Interop bundle verification reverted on destination.",
11433
+ context: { txHash: hash }
11434
+ });
11435
+ }
11436
+ return receipt;
11437
+ } catch (e) {
11438
+ if (isZKsyncError(e)) throw e;
11439
+ throw toZKsyncError(
11440
+ "EXECUTION",
11441
+ {
11442
+ resource: "interop",
11443
+ operation: OP_INTEROP.verify,
11444
+ message: "Failed while waiting for verifyBundle transaction on destination.",
11445
+ context: { txHash: hash }
11446
+ },
11447
+ e
11448
+ );
11449
+ }
11450
+ }
11451
+ };
11452
+ } catch (e) {
11453
+ if (isZKsyncError(e)) throw e;
11454
+ throw toZKsyncError(
11455
+ "EXECUTION",
11456
+ {
11457
+ resource: "interop",
11458
+ operation: OP_INTEROP.verify,
11459
+ message: "Failed to send verifyBundle transaction on destination chain."
11460
+ },
11461
+ e
11462
+ );
11463
+ }
11464
+ }
11410
11465
 
11411
11466
  // src/core/resources/interop/finalization.ts
11412
11467
  var DEFAULT_POLL_MS = 1e3;
@@ -11985,6 +12040,28 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
11985
12040
  }
11986
12041
  );
11987
12042
  const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
12043
+ const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap7(
12044
+ OP_INTEROP.svc.status.getRoot,
12045
+ () => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
12046
+ {
12047
+ message: "Failed to get interop root from the destination chain.",
12048
+ ctx: { where: "interop.getInteropRoot" }
12049
+ }
12050
+ );
12051
+ const verifyBundle2 = (dstChain, h) => wrap7(
12052
+ OP_INTEROP.verify,
12053
+ async () => {
12054
+ const dstProvider = resolveChainRef(dstChain);
12055
+ const info = isInteropFinalizationInfo(h) ? h : await svc.wait(dstProvider, getGwProvider(), h);
12056
+ const result = await verifyBundle(client, dstProvider, info);
12057
+ await result.wait();
12058
+ return { bundleHash: info.bundleHash, dstExecTxHash: result.hash };
12059
+ },
12060
+ {
12061
+ message: "Failed to verify interop bundle on destination.",
12062
+ ctx: { where: "interop.verifyBundle" }
12063
+ }
12064
+ );
11988
12065
  return {
11989
12066
  quote,
11990
12067
  tryQuote,
@@ -11996,7 +12073,9 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
11996
12073
  wait,
11997
12074
  tryWait,
11998
12075
  finalize,
11999
- tryFinalize
12076
+ tryFinalize,
12077
+ getInteropRoot: interopGetRoot,
12078
+ verifyBundle: verifyBundle2
12000
12079
  };
12001
12080
  }
12002
12081