@matterlabs/zksync-js 0.0.21 → 0.0.23

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 (77) hide show
  1. package/dist/adapters/ethers/client.cjs +31 -8
  2. package/dist/adapters/ethers/client.cjs.map +1 -1
  3. package/dist/adapters/ethers/client.d.ts +11 -0
  4. package/dist/adapters/ethers/client.js +6 -5
  5. package/dist/adapters/ethers/index.cjs +1194 -364
  6. package/dist/adapters/ethers/index.cjs.map +1 -1
  7. package/dist/adapters/ethers/index.d.ts +2 -1
  8. package/dist/adapters/ethers/index.js +10 -8
  9. package/dist/adapters/ethers/resources/deposits/context.d.ts +2 -0
  10. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +3 -0
  11. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
  12. package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
  13. package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  14. package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
  15. package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
  16. package/dist/adapters/ethers/sdk.cjs +1166 -370
  17. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  18. package/dist/adapters/ethers/sdk.d.ts +3 -1
  19. package/dist/adapters/ethers/sdk.js +8 -7
  20. package/dist/adapters/viem/client.cjs +44 -7
  21. package/dist/adapters/viem/client.cjs.map +1 -1
  22. package/dist/adapters/viem/client.d.ts +11 -0
  23. package/dist/adapters/viem/client.js +6 -5
  24. package/dist/adapters/viem/index.cjs +1237 -383
  25. package/dist/adapters/viem/index.cjs.map +1 -1
  26. package/dist/adapters/viem/index.d.ts +2 -1
  27. package/dist/adapters/viem/index.js +10 -8
  28. package/dist/adapters/viem/resources/deposits/context.d.ts +2 -0
  29. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +3 -0
  30. package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
  31. package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
  32. package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  33. package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
  34. package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
  35. package/dist/adapters/viem/sdk.cjs +1191 -385
  36. package/dist/adapters/viem/sdk.cjs.map +1 -1
  37. package/dist/adapters/viem/sdk.d.ts +3 -1
  38. package/dist/adapters/viem/sdk.js +8 -7
  39. package/dist/{chunk-UEKFQAOS.js → chunk-2DDJFHHD.js} +304 -9
  40. package/dist/{chunk-MT4X5FEO.js → chunk-3IPSDGHO.js} +19 -1
  41. package/dist/{chunk-JSBMIT4S.js → chunk-4GPIHYVF.js} +1 -1
  42. package/dist/{chunk-SBGBYZJM.js → chunk-4M7VNYGC.js} +2 -2
  43. package/dist/{chunk-CK5UFAZK.js → chunk-6WIAMFIW.js} +37 -3
  44. package/dist/chunk-JJ523MOL.js +157 -0
  45. package/dist/{chunk-7GZDTLHX.js → chunk-NVOFHV3A.js} +666 -304
  46. package/dist/{chunk-LGTYM5XP.js → chunk-OEUDZFXH.js} +1 -1
  47. package/dist/{chunk-NJK325XV.js → chunk-TUN6NH5D.js} +2 -2
  48. package/dist/chunk-UMPAKZCQ.js +19 -0
  49. package/dist/{chunk-24TE2NNJ.js → chunk-URHDNDFN.js} +24 -4
  50. package/dist/{chunk-2CGBLD5H.js → chunk-V2TDNGI5.js} +642 -288
  51. package/dist/{chunk-IDXSGCGF.js → chunk-WPCZNITC.js} +63 -50
  52. package/dist/{chunk-TYYUG5GA.js → chunk-X2JJDQ4O.js} +1 -1
  53. package/dist/core/abi.d.ts +1 -0
  54. package/dist/core/adapters/interfaces.d.ts +2 -0
  55. package/dist/core/constants.cjs +18 -0
  56. package/dist/core/constants.cjs.map +1 -1
  57. package/dist/core/constants.d.ts +17 -0
  58. package/dist/core/constants.js +1 -1
  59. package/dist/core/index.cjs +504 -7
  60. package/dist/core/index.cjs.map +1 -1
  61. package/dist/core/index.d.ts +6 -1
  62. package/dist/core/index.js +6 -4
  63. package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
  64. package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
  65. package/dist/core/internal/abis/IL2AssetRouter.d.ts +0 -14
  66. package/dist/core/resources/deposits/priority.d.ts +30 -0
  67. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  68. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  69. package/dist/core/resources/protocol/semver.d.ts +18 -0
  70. package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
  71. package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
  72. package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
  73. package/dist/core/types/flows/withdrawals.d.ts +30 -0
  74. package/dist/index.cjs +320 -7
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.js +4 -4
  77. package/package.json +1 -1
@@ -3356,13 +3356,6 @@ var IL2AssetRouterABI = [
3356
3356
  outputs: [{ name: "", type: "address", internalType: "address" }],
3357
3357
  stateMutability: "view"
3358
3358
  },
3359
- {
3360
- type: "function",
3361
- name: "l1TokenAddress",
3362
- inputs: [{ name: "_l2Token", type: "address", internalType: "address" }],
3363
- outputs: [{ name: "", type: "address", internalType: "address" }],
3364
- stateMutability: "view"
3365
- },
3366
3359
  {
3367
3360
  type: "function",
3368
3361
  name: "l2TokenAddress",
@@ -7271,10 +7264,24 @@ function decodeRevert(e) {
7271
7264
  // src/adapters/ethers/errors/error-ops.ts
7272
7265
  var { createErrorHandlers } = createErrorOps(decodeRevert);
7273
7266
 
7267
+ // src/core/resources/protocol/semver.ts
7268
+ var SEMVER_MINOR_OFFSET = 32n;
7269
+ var SEMVER_MAJOR_OFFSET = 64n;
7270
+ var U32_MASK = 0xffffffffn;
7271
+ function unpackSemver(packed) {
7272
+ const patch = Number(packed & U32_MASK);
7273
+ const minor = Number(packed >> SEMVER_MINOR_OFFSET & U32_MASK);
7274
+ const major = Number(packed >> SEMVER_MAJOR_OFFSET & U32_MASK);
7275
+ return [major, minor, patch];
7276
+ }
7277
+
7274
7278
  // src/adapters/ethers/client.ts
7275
7279
  var { wrapAs, wrap } = createErrorHandlers("client");
7276
7280
  var ChainTypeManagerABI = [
7277
- "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)"
7281
+ "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)",
7282
+ // Per-chain version. `getSemverProtocolVersion` reports the CTM's own (latest) version, which
7283
+ // runs ahead of individual chains mid-upgrade — so capability gating must use this one.
7284
+ "function getProtocolVersion(uint256 _chainId) view returns (uint256)"
7278
7285
  ];
7279
7286
  function createEthersClient(args) {
7280
7287
  const { l1, l2, signer } = args;
@@ -7433,6 +7440,21 @@ function createEthersClient(args) {
7433
7440
  );
7434
7441
  return semver;
7435
7442
  }
7443
+ async function getChainProtocolVersion(chainId) {
7444
+ try {
7445
+ const targetChainId = chainId ?? (await l2.getNetwork()).chainId;
7446
+ const { bridgehub } = await ensureAddresses();
7447
+ const bh = new ethers.Contract(bridgehub, IBridgehub_default, l1);
7448
+ const chainTypeManager = await bh.chainTypeManager(targetChainId);
7449
+ if (chainTypeManager.toLowerCase() === FORMAL_ETH_ADDRESS) return void 0;
7450
+ const ctm = new ethers.Contract(chainTypeManager, ChainTypeManagerABI, l1);
7451
+ const packed = await ctm.getProtocolVersion(targetChainId);
7452
+ if (packed === 0n) return void 0;
7453
+ return unpackSemver(packed);
7454
+ } catch {
7455
+ return void 0;
7456
+ }
7457
+ }
7436
7458
  function signerFor(target) {
7437
7459
  if (target === "l1") {
7438
7460
  return boundSigner.provider === l1 ? boundSigner : boundSigner.connect(l1);
@@ -7457,6 +7479,7 @@ function createEthersClient(args) {
7457
7479
  refresh,
7458
7480
  baseToken,
7459
7481
  getProtocolVersion,
7482
+ getChainProtocolVersion,
7460
7483
  signerFor
7461
7484
  };
7462
7485
  return client;