@matterlabs/zksync-js 0.0.20 → 0.0.22

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 (72) hide show
  1. package/dist/adapters/ethers/client.cjs +31 -1
  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 +1057 -290
  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/withdrawals/context.d.ts +12 -1
  10. package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
  11. package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  12. package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
  13. package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
  14. package/dist/adapters/ethers/sdk.cjs +1010 -274
  15. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  16. package/dist/adapters/ethers/sdk.d.ts +3 -1
  17. package/dist/adapters/ethers/sdk.js +8 -7
  18. package/dist/adapters/viem/client.cjs +44 -0
  19. package/dist/adapters/viem/client.cjs.map +1 -1
  20. package/dist/adapters/viem/client.d.ts +11 -0
  21. package/dist/adapters/viem/client.js +6 -5
  22. package/dist/adapters/viem/index.cjs +1094 -296
  23. package/dist/adapters/viem/index.cjs.map +1 -1
  24. package/dist/adapters/viem/index.d.ts +2 -1
  25. package/dist/adapters/viem/index.js +10 -8
  26. package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
  27. package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
  28. package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  29. package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
  30. package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
  31. package/dist/adapters/viem/sdk.cjs +1048 -295
  32. package/dist/adapters/viem/sdk.cjs.map +1 -1
  33. package/dist/adapters/viem/sdk.d.ts +3 -1
  34. package/dist/adapters/viem/sdk.js +8 -7
  35. package/dist/{chunk-SBGBYZJM.js → chunk-2D3FBCZC.js} +2 -2
  36. package/dist/{chunk-3HHUZXSV.js → chunk-32N6TI6K.js} +10 -2
  37. package/dist/{chunk-6LYAENO6.js → chunk-3SPDWWRD.js} +6 -4
  38. package/dist/{chunk-3T5V4HKS.js → chunk-4K4LOCQJ.js} +569 -259
  39. package/dist/{chunk-UEKFQAOS.js → chunk-AMRHBZIY.js} +304 -2
  40. package/dist/{chunk-E2XKJCI5.js → chunk-CP4SQ5PM.js} +537 -242
  41. package/dist/{chunk-NJK325XV.js → chunk-CPNHKNI4.js} +2 -2
  42. package/dist/{chunk-TYYUG5GA.js → chunk-CUBUD4J4.js} +1 -1
  43. package/dist/{chunk-CK5UFAZK.js → chunk-JXBLQQEN.js} +37 -3
  44. package/dist/{chunk-JSBMIT4S.js → chunk-KL6ZCPWJ.js} +1 -1
  45. package/dist/{chunk-MT4X5FEO.js → chunk-NQRYXL3K.js} +3 -1
  46. package/dist/{chunk-24TE2NNJ.js → chunk-PI4PF6WT.js} +24 -4
  47. package/dist/chunk-QUAPG3ZR.js +157 -0
  48. package/dist/chunk-UMPAKZCQ.js +19 -0
  49. package/dist/core/abi.d.ts +1 -0
  50. package/dist/core/constants.cjs +2 -0
  51. package/dist/core/constants.cjs.map +1 -1
  52. package/dist/core/constants.d.ts +9 -0
  53. package/dist/core/constants.js +1 -1
  54. package/dist/core/index.cjs +513 -0
  55. package/dist/core/index.cjs.map +1 -1
  56. package/dist/core/index.d.ts +6 -1
  57. package/dist/core/index.js +6 -4
  58. package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
  59. package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
  60. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  61. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  62. package/dist/core/resources/protocol/semver.d.ts +18 -0
  63. package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
  64. package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
  65. package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
  66. package/dist/core/resources/withdrawals/status.d.ts +5 -0
  67. package/dist/core/types/flows/withdrawals.d.ts +32 -2
  68. package/dist/core/utils/events.d.ts +2 -0
  69. package/dist/index.cjs +313 -0
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.js +4 -4
  72. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { EthersClient } from './client';
2
2
  import { type DepositsResource } from './resources/deposits/index';
3
- import { type WithdrawalsResource } from './resources/withdrawals/index';
3
+ import { type WithdrawalsResource, type WithdrawalsResourceOptions } from './resources/withdrawals/index';
4
4
  import { type InteropResource } from './resources/interop/index';
5
5
  import type { TokensResource } from '../../core/types/flows/token';
6
6
  import type { ContractsResource } from './resources/contracts/index';
@@ -8,6 +8,8 @@ import type { InteropConfig } from './resources/interop/types';
8
8
  export interface EthersSdkOptions {
9
9
  /** Configuration required for interop operations. */
10
10
  interop?: InteropConfig;
11
+ /** Options for the withdrawals resource, e.g. forcing the withdrawal protocol. */
12
+ withdrawals?: WithdrawalsResourceOptions;
11
13
  }
12
14
  export interface EthersSdk {
13
15
  deposits: DepositsResource;
@@ -1,7 +1,8 @@
1
- export { createEthersSdk } from '../../chunk-E2XKJCI5.js';
2
- import '../../chunk-NJK325XV.js';
3
- import '../../chunk-6LYAENO6.js';
4
- import '../../chunk-3HHUZXSV.js';
5
- import '../../chunk-JSBMIT4S.js';
6
- import '../../chunk-UEKFQAOS.js';
7
- import '../../chunk-MT4X5FEO.js';
1
+ export { createEthersSdk } from '../../chunk-CP4SQ5PM.js';
2
+ import '../../chunk-CPNHKNI4.js';
3
+ import '../../chunk-3SPDWWRD.js';
4
+ import '../../chunk-QUAPG3ZR.js';
5
+ import '../../chunk-32N6TI6K.js';
6
+ import '../../chunk-KL6ZCPWJ.js';
7
+ import '../../chunk-AMRHBZIY.js';
8
+ import '../../chunk-NQRYXL3K.js';
@@ -5949,6 +5949,17 @@ function decodeRevert(e) {
5949
5949
  // src/adapters/viem/errors/error-ops.ts
5950
5950
  var { createErrorHandlers } = createErrorOps(decodeRevert);
5951
5951
 
5952
+ // src/core/resources/protocol/semver.ts
5953
+ var SEMVER_MINOR_OFFSET = 32n;
5954
+ var SEMVER_MAJOR_OFFSET = 64n;
5955
+ var U32_MASK = 0xffffffffn;
5956
+ function unpackSemver(packed) {
5957
+ const patch = Number(packed & U32_MASK);
5958
+ const minor = Number(packed >> SEMVER_MINOR_OFFSET & U32_MASK);
5959
+ const major = Number(packed >> SEMVER_MAJOR_OFFSET & U32_MASK);
5960
+ return [major, minor, patch];
5961
+ }
5962
+
5952
5963
  // src/adapters/viem/client.ts
5953
5964
  var { wrap } = createErrorHandlers("client");
5954
5965
  var ChainTypeManagerABI = [
@@ -5958,6 +5969,15 @@ var ChainTypeManagerABI = [
5958
5969
  inputs: [],
5959
5970
  outputs: [{ type: "uint32" }, { type: "uint32" }, { type: "uint32" }],
5960
5971
  stateMutability: "view"
5972
+ },
5973
+ {
5974
+ // Per-chain version. `getSemverProtocolVersion` reports the CTM's own (latest) version, which
5975
+ // runs ahead of individual chains mid-upgrade — so capability gating must use this one.
5976
+ type: "function",
5977
+ name: "getProtocolVersion",
5978
+ inputs: [{ name: "_chainId", type: "uint256" }],
5979
+ outputs: [{ type: "uint256" }],
5980
+ stateMutability: "view"
5961
5981
  }
5962
5982
  ];
5963
5983
  function createViemClient(args) {
@@ -6098,6 +6118,29 @@ function createViemClient(args) {
6098
6118
  );
6099
6119
  return semver;
6100
6120
  }
6121
+ async function getChainProtocolVersion(chainId) {
6122
+ try {
6123
+ const targetChainId = chainId ?? BigInt(await l2.getChainId());
6124
+ const { bridgehub } = await ensureAddresses();
6125
+ const chainTypeManager = await l1.readContract({
6126
+ address: bridgehub,
6127
+ abi: IBridgehub_default,
6128
+ functionName: "chainTypeManager",
6129
+ args: [targetChainId]
6130
+ });
6131
+ if (chainTypeManager.toLowerCase() === FORMAL_ETH_ADDRESS.toLowerCase()) return void 0;
6132
+ const packed = await l1.readContract({
6133
+ address: chainTypeManager,
6134
+ abi: ChainTypeManagerABI,
6135
+ functionName: "getProtocolVersion",
6136
+ args: [targetChainId]
6137
+ });
6138
+ if (packed === 0n) return void 0;
6139
+ return unpackSemver(packed);
6140
+ } catch {
6141
+ return void 0;
6142
+ }
6143
+ }
6101
6144
  let lazyL2;
6102
6145
  function getL2Wallet() {
6103
6146
  if (l2Wallet) return l2Wallet;
@@ -6122,6 +6165,7 @@ function createViemClient(args) {
6122
6165
  refresh,
6123
6166
  baseToken,
6124
6167
  getProtocolVersion,
6168
+ getChainProtocolVersion,
6125
6169
  getL2Wallet
6126
6170
  };
6127
6171
  }