@matterlabs/zksync-js 0.0.8 → 0.0.10

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 (75) hide show
  1. package/dist/adapters/ethers/client.cjs +1640 -236
  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 +5 -5
  5. package/dist/adapters/ethers/index.cjs +4395 -1525
  6. package/dist/adapters/ethers/index.cjs.map +1 -1
  7. package/dist/adapters/ethers/index.d.ts +4 -0
  8. package/dist/adapters/ethers/index.js +8 -8
  9. package/dist/adapters/ethers/resources/contracts/types.d.ts +15 -0
  10. package/dist/adapters/ethers/resources/deposits/context.d.ts +3 -3
  11. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +2 -2
  12. package/dist/adapters/ethers/resources/deposits/services/verification.d.ts +1 -1
  13. package/dist/adapters/ethers/resources/interop/address.d.ts +18 -0
  14. package/dist/adapters/ethers/resources/interop/attributes/resource.d.ts +9 -0
  15. package/dist/adapters/ethers/resources/interop/context.d.ts +36 -0
  16. package/dist/adapters/ethers/resources/interop/index.d.ts +63 -0
  17. package/dist/adapters/ethers/resources/interop/resolvers.d.ts +9 -0
  18. package/dist/adapters/ethers/resources/interop/routes/direct.d.ts +2 -0
  19. package/dist/adapters/ethers/resources/interop/routes/indirect.d.ts +2 -0
  20. package/dist/adapters/ethers/resources/interop/routes/types.d.ts +13 -0
  21. package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +15 -0
  22. package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +15 -0
  23. package/dist/adapters/ethers/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
  24. package/dist/adapters/ethers/resources/interop/services/finalization/decoders.d.ts +12 -0
  25. package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +13 -0
  26. package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +7 -0
  27. package/dist/adapters/ethers/resources/interop/services/finalization/status.d.ts +5 -0
  28. package/dist/adapters/ethers/resources/interop/services/finalization/topics.d.ts +6 -0
  29. package/dist/adapters/ethers/resources/interop/services/starter-data.d.ts +6 -0
  30. package/dist/adapters/ethers/resources/interop/types.d.ts +16 -0
  31. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +2 -2
  32. package/dist/adapters/ethers/sdk.cjs +3357 -917
  33. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  34. package/dist/adapters/ethers/sdk.d.ts +10 -8
  35. package/dist/adapters/ethers/sdk.js +6 -6
  36. package/dist/adapters/viem/client.cjs +684 -31
  37. package/dist/adapters/viem/client.cjs.map +1 -1
  38. package/dist/adapters/viem/client.js +5 -3
  39. package/dist/adapters/viem/index.cjs +267 -273
  40. package/dist/adapters/viem/index.cjs.map +1 -1
  41. package/dist/adapters/viem/index.d.ts +1 -0
  42. package/dist/adapters/viem/index.js +8 -7
  43. package/dist/adapters/viem/resources/deposits/context.d.ts +3 -3
  44. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +2 -2
  45. package/dist/adapters/viem/resources/deposits/services/verification.d.ts +1 -1
  46. package/dist/adapters/viem/resources/withdrawals/context.d.ts +2 -2
  47. package/dist/adapters/viem/sdk.cjs +39 -58
  48. package/dist/adapters/viem/sdk.cjs.map +1 -1
  49. package/dist/adapters/viem/sdk.js +6 -5
  50. package/dist/{chunk-NODVRI3E.js → chunk-AIFHAPJC.js} +8 -2
  51. package/dist/{chunk-3GFCAGGI.js → chunk-FBKBF7YM.js} +1533 -1434
  52. package/dist/chunk-HOZTREW6.js +209 -0
  53. package/dist/{chunk-L343N56B.js → chunk-IYEDEUXG.js} +1 -1
  54. package/dist/{chunk-63DNJXS3.js → chunk-MBEMIFYS.js} +1375 -75
  55. package/dist/chunk-N3FVEFOK.js +113 -0
  56. package/dist/{chunk-NVULC4JB.js → chunk-QDJOEVGJ.js} +2 -2
  57. package/dist/{chunk-5V2JRM5J.js → chunk-SRPKTXIF.js} +1 -1
  58. package/dist/{chunk-SHQQI3UD.js → chunk-UIXU35ZU.js} +1 -1
  59. package/dist/{chunk-ODMBZ2VX.js → chunk-VKUTFNZA.js} +42 -31
  60. package/dist/{chunk-LNIEQ7AN.js → chunk-ZBGQQ63V.js} +36 -167
  61. package/dist/{chunk-QZVYN3YA.js → chunk-ZVHFVUDE.js} +2 -37
  62. package/dist/core/index.cjs +3 -2
  63. package/dist/core/index.cjs.map +1 -1
  64. package/dist/core/index.js +4 -4
  65. package/dist/core/resources/interop/attributes/types.d.ts +0 -2
  66. package/dist/core/resources/interop/finalization.d.ts +0 -1
  67. package/dist/core/types/errors.d.ts +15 -5
  68. package/dist/core/types/fees.d.ts +9 -0
  69. package/dist/core/types/flows/interop.d.ts +12 -36
  70. package/dist/core/types/primitives.d.ts +1 -0
  71. package/dist/index.cjs +3 -2
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.js +4 -4
  74. package/package.json +1 -1
  75. package/dist/chunk-FGXRG2JS.js +0 -142
@@ -1,5 +1,5 @@
1
- export { pickDepositRoute } from '../chunk-L343N56B.js';
2
- export { findL1MessageSentLog, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, isL1MessageSentLog, messengerLogIndex, normalizeAddrEq, normalizeL1Token, pickWithdrawRoute } from '../chunk-QZVYN3YA.js';
3
- export { makeTransportFromEthers, makeTransportFromViem, zks_exports as zksRpc } from '../chunk-SHQQI3UD.js';
4
- export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty } from '../chunk-3GFCAGGI.js';
1
+ export { pickDepositRoute } from '../chunk-IYEDEUXG.js';
2
+ export { findL1MessageSentLog, isL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from '../chunk-ZVHFVUDE.js';
3
+ export { makeTransportFromEthers, makeTransportFromViem, zks_exports as zksRpc } from '../chunk-UIXU35ZU.js';
4
+ export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token } from '../chunk-FBKBF7YM.js';
5
5
  export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS } from '../chunk-C3AGOEHR.js';
@@ -1,6 +1,4 @@
1
1
  import type { Hex } from '../../../types/primitives';
2
- import type { DecodedAttribute } from '../../../types/flows/interop';
3
2
  export interface AttributesCodec {
4
3
  encode(fn: string, args: readonly unknown[]): Hex;
5
- decode(attr: Hex): DecodedAttribute;
6
4
  }
@@ -16,7 +16,6 @@ export declare const DEFAULT_TIMEOUT_MS = 300000;
16
16
  interface ResolvedInteropIds {
17
17
  l2SrcTxHash?: Hex;
18
18
  bundleHash?: Hex;
19
- dstChainId?: bigint;
20
19
  dstExecTxHash?: Hex;
21
20
  }
22
21
  export declare function resolveIdsFromWaitable(input: InteropWaitable): ResolvedInteropIds;
@@ -66,7 +66,12 @@ export declare class ZKsyncError extends Error {
66
66
  name: string;
67
67
  };
68
68
  }
69
- export declare function isZKsyncError(e: unknown): e is ZKsyncError;
69
+ export declare function isZKsyncError(e: unknown, opts?: {
70
+ type?: ErrorType;
71
+ resource?: Resource;
72
+ operation?: string;
73
+ messageIncludes?: string;
74
+ }): e is ZKsyncError;
70
75
  export declare function isReceiptNotFound(e: unknown): boolean;
71
76
  export type TryResult<T> = {
72
77
  ok: true;
@@ -75,6 +80,10 @@ export type TryResult<T> = {
75
80
  ok: false;
76
81
  error: ZKsyncError;
77
82
  };
83
+ export declare const OP_CLIENT: {
84
+ readonly ensureAddresses: "client.ensureAddresses";
85
+ readonly getSemverProtocolVersion: "client.getSemverProtocolVersion";
86
+ };
78
87
  export declare const OP_DEPOSITS: {
79
88
  readonly quote: "deposits.quote";
80
89
  readonly tryQuote: "deposits.tryQuote";
@@ -162,10 +171,8 @@ export declare const OP_WITHDRAWALS: {
162
171
  readonly messengerIndex: "withdrawals.finalize.fetchParams:messengerIndex";
163
172
  readonly proof: "withdrawals.finalize.fetchParams:proof";
164
173
  readonly network: "withdrawals.finalize.fetchParams:network";
165
- readonly ensureAddresses: "withdrawals.finalize.fetchParams:ensureAddresses";
166
174
  };
167
175
  readonly readiness: {
168
- readonly ensureAddresses: "withdrawals.finalize.readiness:ensureAddresses";
169
176
  readonly isFinalized: "withdrawals.finalize.readiness:isWithdrawalFinalized";
170
177
  readonly simulate: "withdrawals.finalize.readiness:simulate";
171
178
  };
@@ -187,6 +194,10 @@ export declare const OP_INTEROP: {
187
194
  readonly tryWait: "interop.tryWait";
188
195
  readonly finalize: "interop.finalize";
189
196
  readonly tryFinalize: "interop.tryFinalize";
197
+ readonly context: {
198
+ readonly chainTypeManager: "interop.chainTypeManager";
199
+ readonly protocolVersion: "interop.protocolVersion";
200
+ };
190
201
  readonly routes: {
191
202
  readonly direct: {
192
203
  readonly preflight: "interop.routes.direct:preflight";
@@ -204,11 +215,10 @@ export declare const OP_INTEROP: {
204
215
  readonly svc: {
205
216
  readonly status: {
206
217
  readonly sourceReceipt: "interop.svc.status:sourceReceipt";
207
- readonly ensureAddresses: "interop.svc.status:ensureAddresses";
208
218
  readonly parseSentLog: "interop.svc.status:parseSentLog";
209
- readonly requireDstProvider: "interop.svc.status:requireDstProvider";
210
219
  readonly dstLogs: "interop.svc.status:dstLogs";
211
220
  readonly derive: "interop.svc.status:derive";
221
+ readonly getRoot: "interop.svc.status:getRoot";
212
222
  };
213
223
  readonly wait: {
214
224
  readonly poll: "interop.svc.wait:poll";
@@ -37,4 +37,13 @@ export type TxOverrides = {
37
37
  gasLimit: bigint;
38
38
  maxFeePerGas: bigint;
39
39
  maxPriorityFeePerGas?: bigint;
40
+ /** Optional nonce override.
41
+ * - number: use as the starting nonce directly (skip getTransactionCount). If there are multiple transactions,
42
+ * the specified number will be used as a starting nonce and incremented for each transaction.
43
+ * - 'latest' | 'pending': call getTransactionCount with the given block tag.
44
+ */
45
+ nonce?: number | 'latest' | 'pending';
40
46
  };
47
+ /** TxOverrides without the nonce field. */
48
+ export type TxGasOverrides = Omit<TxOverrides, 'nonce'>;
49
+ export declare function toGasOverrides(overrides: TxOverrides): TxGasOverrides;
@@ -1,31 +1,6 @@
1
1
  import type { Address, Hex } from '../primitives';
2
2
  import type { ApprovalNeed, Plan, Handle } from './base';
3
- /** Encoded call attributes for interop */
4
- export type EncodedCallAttributes = readonly Hex[];
5
- /** Encoded bundle attributes for interop */
6
- export type EncodedBundleAttributes = readonly Hex[];
7
- /**
8
- * A decoded interop attribute with its function selector and arguments.
9
- */
10
- export interface DecodedAttribute {
11
- /** Function selector (0x + 8 hex chars, representing 4 bytes) */
12
- selector: Hex;
13
- /** Name of the attribute function */
14
- name: string;
15
- /** Full function signature (e.g. "interopCallValue(uint256)") when ABI is known */
16
- signature?: string;
17
- /** Decoded arguments array (types vary based on function) */
18
- args: unknown[];
19
- }
20
- /**
21
- * Summary of all decoded attributes for both call-level and bundle-level attributes.
22
- */
23
- export interface DecodedAttributesSummary {
24
- /** Attributes that apply to individual interop calls */
25
- call: DecodedAttribute[];
26
- /** Attributes that apply to the entire interop bundle */
27
- bundle: DecodedAttribute[];
28
- }
3
+ import type { TxOverrides } from '../fees';
29
4
  /**
30
5
  * The routing mechanism for interop execution.
31
6
  */
@@ -58,12 +33,8 @@ export type InteropAction =
58
33
  * Input parameters for initiating an interop operation.
59
34
  */
60
35
  export interface InteropParams {
61
- /** Destination chain ID (EIP-155 format) */
62
- dstChainId: bigint;
63
36
  /** Ordered list of actions to execute on destination chain */
64
37
  actions: InteropAction[];
65
- /** Optional: Override default sender address for the operation */
66
- sender?: Address;
67
38
  /** Optional: Restrict execution to a specific address on destination */
68
39
  execution?: {
69
40
  only: Address;
@@ -72,6 +43,8 @@ export interface InteropParams {
72
43
  unbundling?: {
73
44
  by: Address;
74
45
  };
46
+ /** Optional: Gas overrides for L2 transaction */
47
+ txOverrides?: TxOverrides;
75
48
  }
76
49
  /**
77
50
  * Cost and approval quote for an interop operation before execution.
@@ -91,6 +64,15 @@ export interface InteropQuote {
91
64
  /** Optional: Estimated L2 fee */
92
65
  l2Fee?: bigint;
93
66
  }
67
+ /**
68
+ * Quote add-ons a route can compute
69
+ */
70
+ export interface QuoteExtras {
71
+ /** Sum of msg.value across actions (sendNative + call.value). */
72
+ totalActionValue: bigint;
73
+ /** Sum of ERC-20 amounts across actions (for approvals/bridging). */
74
+ bridgedTokenTotal: bigint;
75
+ }
94
76
  /**
95
77
  * Execution plan for an interop operation.
96
78
  * Contains transaction details, routing, and quote before submission.
@@ -109,8 +91,6 @@ export interface InteropHandle<Tx> extends Handle<Record<string, Hex>, InteropRo
109
91
  l1MsgHash?: Hex;
110
92
  /** Interop bundle hash */
111
93
  bundleHash?: Hex;
112
- /** Destination chain ID (EIP-155 format) */
113
- dstChainId?: bigint;
114
94
  /** Transaction hash of execution on destination chain (once executed) */
115
95
  dstExecTxHash?: Hex;
116
96
  }
@@ -150,8 +130,6 @@ export interface InteropStatus {
150
130
  bundleHash?: Hex;
151
131
  /** Destination chain execution transaction hash */
152
132
  dstExecTxHash?: Hex;
153
- /** Destination chain ID (EIP-155 format) */
154
- dstChainId?: bigint;
155
133
  }
156
134
  /**
157
135
  * Interop expected root data.
@@ -224,8 +202,6 @@ export declare function isInteropFinalizationInfo(obj: unknown): obj is InteropF
224
202
  export interface InteropFinalizationResult {
225
203
  /** Interop bundle hash that was finalized */
226
204
  bundleHash: Hex;
227
- /** Destination chain ID */
228
- dstChainId: bigint;
229
205
  /** Transaction hash of the successful execution on destination */
230
206
  dstExecTxHash: Hex;
231
207
  }
@@ -1,3 +1,4 @@
1
1
  export type Address = `0x${string}`;
2
2
  export type Hex = `0x${string}`;
3
3
  export type Hash = Hex;
4
+ export declare const ZERO_HASH: Hash;
package/dist/index.cjs CHANGED
@@ -6166,12 +6166,13 @@ if (kInspect) {
6166
6166
  enumerable: false
6167
6167
  });
6168
6168
  }
6169
- function isZKsyncError(e) {
6169
+ function isZKsyncError(e, opts) {
6170
6170
  if (!e || typeof e !== "object") return false;
6171
6171
  const maybe = e;
6172
6172
  if (!("envelope" in maybe)) return false;
6173
6173
  const envelope = maybe.envelope;
6174
- return typeof envelope?.type === "string" && typeof envelope?.message === "string";
6174
+ if (typeof envelope?.type !== "string" || typeof envelope?.message !== "string") return false;
6175
+ return true;
6175
6176
  }
6176
6177
 
6177
6178
  // src/core/errors/factory.ts