@matterlabs/zksync-js 0.0.13 → 0.0.15

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 (96) hide show
  1. package/dist/adapters/ethers/client.cjs +13 -4
  2. package/dist/adapters/ethers/client.cjs.map +1 -1
  3. package/dist/adapters/ethers/client.d.ts +1 -2
  4. package/dist/adapters/ethers/client.js +6 -6
  5. package/dist/adapters/ethers/index.cjs +607 -259
  6. package/dist/adapters/ethers/index.cjs.map +1 -1
  7. package/dist/adapters/ethers/index.js +9 -9
  8. package/dist/adapters/ethers/resources/deposits/routes/priority.d.ts +12 -0
  9. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +4 -0
  10. package/dist/adapters/ethers/resources/interop/index.d.ts +14 -14
  11. package/dist/adapters/ethers/resources/interop/resolvers.d.ts +3 -8
  12. package/dist/adapters/ethers/resources/interop/routes/types.d.ts +2 -1
  13. package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +10 -0
  14. package/dist/adapters/ethers/resources/interop/services/fee.d.ts +12 -0
  15. package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +1 -1
  16. package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +1 -1
  17. package/dist/adapters/ethers/resources/interop/services/gas.d.ts +12 -0
  18. package/dist/adapters/ethers/resources/interop/types.d.ts +6 -14
  19. package/dist/adapters/ethers/sdk.cjs +1008 -259
  20. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  21. package/dist/adapters/ethers/sdk.d.ts +6 -1
  22. package/dist/adapters/ethers/sdk.js +7 -7
  23. package/dist/adapters/viem/client.cjs +795 -7
  24. package/dist/adapters/viem/client.cjs.map +1 -1
  25. package/dist/adapters/viem/client.d.ts +6 -1
  26. package/dist/adapters/viem/client.js +6 -6
  27. package/dist/adapters/viem/index.cjs +6490 -2799
  28. package/dist/adapters/viem/index.cjs.map +1 -1
  29. package/dist/adapters/viem/index.d.ts +5 -0
  30. package/dist/adapters/viem/index.js +9 -9
  31. package/dist/adapters/viem/resources/deposits/routes/priority.d.ts +13 -0
  32. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +4 -0
  33. package/dist/adapters/viem/resources/interop/address.d.ts +18 -0
  34. package/dist/adapters/viem/resources/interop/attributes/resource.d.ts +6 -0
  35. package/dist/adapters/viem/resources/interop/context.d.ts +31 -0
  36. package/dist/adapters/viem/resources/interop/index.d.ts +62 -0
  37. package/dist/adapters/viem/resources/interop/resolvers.d.ts +4 -0
  38. package/dist/adapters/viem/resources/interop/routes/direct.d.ts +2 -0
  39. package/dist/adapters/viem/resources/interop/routes/indirect.d.ts +2 -0
  40. package/dist/adapters/viem/resources/interop/routes/types.d.ts +23 -0
  41. package/dist/adapters/viem/resources/interop/services/erc20.d.ts +25 -0
  42. package/dist/adapters/viem/resources/interop/services/fee.d.ts +12 -0
  43. package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +15 -0
  44. package/dist/adapters/viem/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
  45. package/dist/adapters/viem/resources/interop/services/finalization/decoders.d.ts +11 -0
  46. package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +13 -0
  47. package/dist/adapters/viem/resources/interop/services/finalization/polling.d.ts +7 -0
  48. package/dist/adapters/viem/resources/interop/services/finalization/status.d.ts +5 -0
  49. package/dist/adapters/viem/resources/interop/services/finalization/topics.d.ts +4 -0
  50. package/dist/adapters/viem/resources/interop/services/gas.d.ts +12 -0
  51. package/dist/adapters/viem/resources/interop/services/starter-data.d.ts +6 -0
  52. package/dist/adapters/viem/resources/interop/types.d.ts +8 -0
  53. package/dist/adapters/viem/sdk.cjs +6401 -2758
  54. package/dist/adapters/viem/sdk.cjs.map +1 -1
  55. package/dist/adapters/viem/sdk.d.ts +8 -1
  56. package/dist/adapters/viem/sdk.js +7 -7
  57. package/dist/{chunk-E3KP7XCG.js → chunk-3HHUZXSV.js} +1 -1
  58. package/dist/{chunk-EDWBCPO3.js → chunk-4PZCNTQ3.js} +1387 -71
  59. package/dist/{chunk-UDBRUBEK.js → chunk-65HAYKVL.js} +2 -2
  60. package/dist/chunk-BWKWWLY4.js +9 -0
  61. package/dist/{chunk-JHO2UQ5F.js → chunk-HGB3DOV2.js} +445 -554
  62. package/dist/{chunk-HI64OOAR.js → chunk-HVHMLAYH.js} +1 -1
  63. package/dist/{chunk-2RIARDXZ.js → chunk-JHRYNLZG.js} +65 -7
  64. package/dist/{chunk-RI73VJSH.js → chunk-JXR5V5YK.js} +463 -27
  65. package/dist/chunk-K2UVKMLN.js +658 -0
  66. package/dist/{chunk-53MC5BR2.js → chunk-MDPX5LNW.js} +1 -1
  67. package/dist/{chunk-QQ2OR434.js → chunk-MT4X5FEO.js} +18 -2
  68. package/dist/{chunk-R5WRFPK2.js → chunk-MZBKM3GH.js} +4 -4
  69. package/dist/{chunk-5R7L5NM5.js → chunk-YIWXIP2M.js} +10 -2
  70. package/dist/core/constants.cjs +17 -1
  71. package/dist/core/constants.cjs.map +1 -1
  72. package/dist/core/constants.d.ts +9 -1
  73. package/dist/core/constants.js +1 -1
  74. package/dist/core/index.cjs +52 -24
  75. package/dist/core/index.cjs.map +1 -1
  76. package/dist/core/index.js +5 -5
  77. package/dist/core/internal/abis/IERC7786Attributes.d.ts +21 -11
  78. package/dist/core/internal/abis/IInteropCenter.d.ts +4 -0
  79. package/dist/core/resources/deposits/chains.d.ts +1 -0
  80. package/dist/core/resources/deposits/gas.d.ts +7 -0
  81. package/dist/core/resources/deposits/priority.d.ts +41 -0
  82. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  83. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  84. package/dist/core/resources/interop/plan.d.ts +11 -3
  85. package/dist/core/resources/interop/protocol.d.ts +3 -0
  86. package/dist/core/rpc/types.d.ts +1 -0
  87. package/dist/core/rpc/zks.d.ts +5 -1
  88. package/dist/core/types/errors.d.ts +5 -0
  89. package/dist/core/types/flows/interop.d.ts +11 -20
  90. package/dist/core/types/primitives.d.ts +2 -0
  91. package/dist/index.cjs +69 -25
  92. package/dist/index.cjs.map +1 -1
  93. package/dist/index.js +5 -5
  94. package/package.json +1 -1
  95. package/dist/chunk-4S4XDA4N.js +0 -415
  96. package/dist/chunk-5L6EYUJB.js +0 -237
@@ -10,9 +10,13 @@ var utils = require('@noble/hashes/utils');
10
10
  var isNumber = (x) => typeof x === "number" && Number.isFinite(x);
11
11
  var isBigint = (x) => typeof x === "bigint";
12
12
  var k256hex = (s) => `0x${utils.bytesToHex(sha3.keccak_256(utils.utf8ToBytes(s)))}`.toLowerCase();
13
+ var FORMAL_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
13
14
  var L2_ASSET_ROUTER_ADDRESS = "0x0000000000000000000000000000000000010003";
14
15
  var L2_NATIVE_TOKEN_VAULT_ADDRESS = "0x0000000000000000000000000000000000010004";
15
16
  var L2_BASE_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800A";
17
+ var L2_INTEROP_CENTER_ADDRESS = "0x000000000000000000000000000000000001000d";
18
+ var L2_INTEROP_HANDLER_ADDRESS = "0x000000000000000000000000000000000001000e";
19
+ var L2_MESSAGE_VERIFICATION_ADDRESS = "0x0000000000000000000000000000000000010009";
16
20
  k256hex("L1MessageSent(uint256,bytes32,bytes)");
17
21
  k256hex("L1MessageSent(address,bytes32,bytes)");
18
22
 
@@ -158,7 +162,9 @@ function isZKsyncError(e, opts) {
158
162
  return true;
159
163
  }
160
164
  var OP_CLIENT = {
161
- ensureAddresses: "client.ensureAddresses"};
165
+ ensureAddresses: "client.ensureAddresses",
166
+ getSemverProtocolVersion: "client.getSemverProtocolVersion"
167
+ };
162
168
 
163
169
  // src/core/errors/factory.ts
164
170
  function createError(type, input) {
@@ -224,6 +230,7 @@ function normalizeProof(p) {
224
230
  const raw = p ?? {};
225
231
  const idRaw = raw?.id ?? raw?.index;
226
232
  const bnRaw = raw?.batch_number ?? raw?.batchNumber;
233
+ const gwBlockNumberRaw = raw?.gatewayBlockNumber;
227
234
  if (idRaw == null || bnRaw == null) {
228
235
  throw createError("RPC", {
229
236
  resource: "zksrpc",
@@ -244,7 +251,8 @@ function normalizeProof(p) {
244
251
  id: toBig(idRaw),
245
252
  batchNumber: toBig(bnRaw),
246
253
  proof: toHexArray(raw?.proof),
247
- root: raw.root
254
+ root: raw.root,
255
+ gatewayBlockNumber: gwBlockNumberRaw != null ? toBig(gwBlockNumberRaw) : void 0
248
256
  };
249
257
  } catch (e) {
250
258
  if (isZKsyncError(e)) throw e;
@@ -521,13 +529,15 @@ function createZksRpc(transport) {
521
529
  );
522
530
  },
523
531
  // Fetches a proof for an L2→L1 log emitted in the given transaction.
524
- async getL2ToL1LogProof(txHash, index) {
532
+ async getL2ToL1LogProof(txHash, index, proofTarget) {
525
533
  return withRpcOp(
526
534
  "zksrpc.getL2ToL1LogProof",
527
535
  "Failed to fetch L2\u2192L1 log proof.",
528
- { txHash, index },
536
+ { txHash, index, proofTarget },
529
537
  async () => {
530
- const proof = await transport(METHODS.getL2ToL1LogProof, [txHash, index]);
538
+ const params = [txHash, index];
539
+ if (proofTarget != void 0) params.push(proofTarget);
540
+ const proof = await transport(METHODS.getL2ToL1LogProof, params);
531
541
  if (!proof) {
532
542
  throw createError("STATE", {
533
543
  resource: "zksrpc",
@@ -5085,6 +5095,718 @@ var MailboxABI = [
5085
5095
  ];
5086
5096
  var Mailbox_default = MailboxABI;
5087
5097
 
5098
+ // src/core/internal/abis/IInteropErrors.ts
5099
+ var IInteropErrorsABI = [
5100
+ {
5101
+ type: "error",
5102
+ name: "AttributeAlreadySet",
5103
+ inputs: [
5104
+ {
5105
+ name: "selector",
5106
+ type: "bytes4"
5107
+ }
5108
+ ]
5109
+ },
5110
+ {
5111
+ type: "error",
5112
+ name: "AttributeViolatesRestriction",
5113
+ inputs: [
5114
+ {
5115
+ name: "selector",
5116
+ type: "bytes4"
5117
+ },
5118
+ {
5119
+ name: "restriction",
5120
+ type: "uint256"
5121
+ }
5122
+ ]
5123
+ },
5124
+ {
5125
+ type: "error",
5126
+ name: "BundleAlreadyProcessed",
5127
+ inputs: [
5128
+ {
5129
+ name: "bundleHash",
5130
+ type: "bytes32"
5131
+ }
5132
+ ]
5133
+ },
5134
+ {
5135
+ type: "error",
5136
+ name: "CallAlreadyExecuted",
5137
+ inputs: [
5138
+ {
5139
+ name: "bundleHash",
5140
+ type: "bytes32"
5141
+ },
5142
+ {
5143
+ name: "callIndex",
5144
+ type: "uint256"
5145
+ }
5146
+ ]
5147
+ },
5148
+ {
5149
+ type: "error",
5150
+ name: "CallNotExecutable",
5151
+ inputs: [
5152
+ {
5153
+ name: "bundleHash",
5154
+ type: "bytes32"
5155
+ },
5156
+ {
5157
+ name: "callIndex",
5158
+ type: "uint256"
5159
+ }
5160
+ ]
5161
+ },
5162
+ {
5163
+ type: "error",
5164
+ name: "CanNotUnbundle",
5165
+ inputs: [
5166
+ {
5167
+ name: "bundleHash",
5168
+ type: "bytes32"
5169
+ }
5170
+ ]
5171
+ },
5172
+ {
5173
+ type: "error",
5174
+ name: "DestinationChainNotRegistered",
5175
+ inputs: [
5176
+ {
5177
+ name: "destinationChainId",
5178
+ type: "uint256"
5179
+ }
5180
+ ]
5181
+ },
5182
+ {
5183
+ type: "error",
5184
+ name: "ExecutingNotAllowed",
5185
+ inputs: [
5186
+ {
5187
+ name: "bundleHash",
5188
+ type: "bytes32"
5189
+ },
5190
+ {
5191
+ name: "callerAddress",
5192
+ type: "bytes"
5193
+ },
5194
+ {
5195
+ name: "executionAddress",
5196
+ type: "bytes"
5197
+ }
5198
+ ]
5199
+ },
5200
+ {
5201
+ type: "error",
5202
+ name: "FeeWithdrawalFailed",
5203
+ inputs: []
5204
+ },
5205
+ {
5206
+ type: "error",
5207
+ name: "IndirectCallValueMismatch",
5208
+ inputs: [
5209
+ {
5210
+ name: "expected",
5211
+ type: "uint256"
5212
+ },
5213
+ {
5214
+ name: "actual",
5215
+ type: "uint256"
5216
+ }
5217
+ ]
5218
+ },
5219
+ {
5220
+ type: "error",
5221
+ name: "InteroperableAddressChainReferenceNotEmpty",
5222
+ inputs: [
5223
+ {
5224
+ name: "interoperableAddress",
5225
+ type: "bytes"
5226
+ }
5227
+ ]
5228
+ },
5229
+ {
5230
+ type: "error",
5231
+ name: "InteroperableAddressNotEmpty",
5232
+ inputs: [
5233
+ {
5234
+ name: "interoperableAddress",
5235
+ type: "bytes"
5236
+ }
5237
+ ]
5238
+ },
5239
+ {
5240
+ type: "error",
5241
+ name: "InvalidInteropBundleVersion",
5242
+ inputs: []
5243
+ },
5244
+ {
5245
+ type: "error",
5246
+ name: "InvalidInteropCallVersion",
5247
+ inputs: []
5248
+ },
5249
+ {
5250
+ type: "error",
5251
+ name: "InteropRootAlreadyExists",
5252
+ inputs: []
5253
+ },
5254
+ {
5255
+ type: "error",
5256
+ name: "MessageNotIncluded",
5257
+ inputs: []
5258
+ },
5259
+ {
5260
+ type: "error",
5261
+ name: "SidesLengthNotOne",
5262
+ inputs: []
5263
+ },
5264
+ {
5265
+ type: "error",
5266
+ name: "UnauthorizedMessageSender",
5267
+ inputs: [
5268
+ {
5269
+ name: "expected",
5270
+ type: "address"
5271
+ },
5272
+ {
5273
+ name: "actual",
5274
+ type: "address"
5275
+ }
5276
+ ]
5277
+ },
5278
+ {
5279
+ type: "error",
5280
+ name: "UnbundlingNotAllowed",
5281
+ inputs: [
5282
+ {
5283
+ name: "bundleHash",
5284
+ type: "bytes32"
5285
+ },
5286
+ {
5287
+ name: "callerAddress",
5288
+ type: "bytes"
5289
+ },
5290
+ {
5291
+ name: "unbundlerAddress",
5292
+ type: "bytes"
5293
+ }
5294
+ ]
5295
+ },
5296
+ {
5297
+ type: "error",
5298
+ name: "WrongCallStatusLength",
5299
+ inputs: [
5300
+ {
5301
+ name: "bundleCallsLength",
5302
+ type: "uint256"
5303
+ },
5304
+ {
5305
+ name: "providedCallStatusLength",
5306
+ type: "uint256"
5307
+ }
5308
+ ]
5309
+ },
5310
+ {
5311
+ type: "error",
5312
+ name: "WrongDestinationChainId",
5313
+ inputs: [
5314
+ {
5315
+ name: "bundleHash",
5316
+ type: "bytes32"
5317
+ },
5318
+ {
5319
+ name: "expected",
5320
+ type: "uint256"
5321
+ },
5322
+ {
5323
+ name: "actual",
5324
+ type: "uint256"
5325
+ }
5326
+ ]
5327
+ },
5328
+ {
5329
+ type: "error",
5330
+ name: "WrongDestinationBaseTokenAssetId",
5331
+ inputs: [
5332
+ {
5333
+ name: "bundleHash",
5334
+ type: "bytes32"
5335
+ },
5336
+ {
5337
+ name: "expected",
5338
+ type: "bytes32"
5339
+ },
5340
+ {
5341
+ name: "actual",
5342
+ type: "bytes32"
5343
+ }
5344
+ ]
5345
+ },
5346
+ {
5347
+ type: "error",
5348
+ name: "WrongSourceChainId",
5349
+ inputs: [
5350
+ {
5351
+ name: "bundleHash",
5352
+ type: "bytes32"
5353
+ },
5354
+ {
5355
+ name: "expected",
5356
+ type: "uint256"
5357
+ },
5358
+ {
5359
+ name: "actual",
5360
+ type: "uint256"
5361
+ }
5362
+ ]
5363
+ },
5364
+ {
5365
+ type: "error",
5366
+ name: "ZKTokenNotAvailable",
5367
+ inputs: []
5368
+ }
5369
+ ];
5370
+ var IInteropErrors_default = IInteropErrorsABI;
5371
+
5372
+ // src/core/internal/abis/IL1ContractErrors.ts
5373
+ var IL1ContractErrorsABI = [
5374
+ {
5375
+ type: "error",
5376
+ name: "AccessToFallbackDenied",
5377
+ inputs: [
5378
+ { name: "target", type: "address" },
5379
+ { name: "invoker", type: "address" }
5380
+ ]
5381
+ },
5382
+ {
5383
+ type: "error",
5384
+ name: "AccessToFunctionDenied",
5385
+ inputs: [
5386
+ { name: "target", type: "address" },
5387
+ { name: "selector", type: "bytes4" },
5388
+ { name: "invoker", type: "address" }
5389
+ ]
5390
+ },
5391
+ { type: "error", name: "AddressAlreadySet", inputs: [{ name: "addr", type: "address" }] },
5392
+ { type: "error", name: "AddressHasNoCode", inputs: [{ name: "", type: "address" }] },
5393
+ {
5394
+ type: "error",
5395
+ name: "AddressMismatch",
5396
+ inputs: [
5397
+ { name: "expected", type: "address" },
5398
+ { name: "supplied", type: "address" }
5399
+ ]
5400
+ },
5401
+ { type: "error", name: "AlreadyPermanentRollup", inputs: [] },
5402
+ { type: "error", name: "AlreadyWhitelisted", inputs: [{ name: "", type: "address" }] },
5403
+ { type: "error", name: "AmountMustBeGreaterThanZero", inputs: [] },
5404
+ {
5405
+ type: "error",
5406
+ name: "AssetHandlerDoesNotExist",
5407
+ inputs: [{ name: "assetId", type: "bytes32" }]
5408
+ },
5409
+ {
5410
+ type: "error",
5411
+ name: "AssetHandlerNotRegistered",
5412
+ inputs: [{ name: "assetId", type: "bytes32" }]
5413
+ },
5414
+ { type: "error", name: "AssetIdAlreadyRegistered", inputs: [] },
5415
+ {
5416
+ type: "error",
5417
+ name: "AssetIdMismatch",
5418
+ inputs: [
5419
+ { name: "expected", type: "bytes32" },
5420
+ { name: "supplied", type: "bytes32" }
5421
+ ]
5422
+ },
5423
+ { type: "error", name: "AssetIdNotSupported", inputs: [{ name: "assetId", type: "bytes32" }] },
5424
+ { type: "error", name: "AssetRouterAllowanceNotZero", inputs: [] },
5425
+ { type: "error", name: "BaseTokenGasPriceDenominatorNotSet", inputs: [] },
5426
+ {
5427
+ type: "error",
5428
+ name: "BatchHashMismatch",
5429
+ inputs: [
5430
+ { name: "expected", type: "bytes32" },
5431
+ { name: "actual", type: "bytes32" }
5432
+ ]
5433
+ },
5434
+ { type: "error", name: "BatchNotExecuted", inputs: [{ name: "batchNumber", type: "uint256" }] },
5435
+ {
5436
+ type: "error",
5437
+ name: "BatchNumberMismatch",
5438
+ inputs: [
5439
+ { name: "expectedBatchNumber", type: "uint256" },
5440
+ { name: "providedBatchNumber", type: "uint256" }
5441
+ ]
5442
+ },
5443
+ { type: "error", name: "BridgeHubAlreadyRegistered", inputs: [] },
5444
+ { type: "error", name: "BridgeMintNotImplemented", inputs: [] },
5445
+ { type: "error", name: "BurningNativeWETHNotSupported", inputs: [] },
5446
+ {
5447
+ type: "error",
5448
+ name: "BytecodeAlreadyPublished",
5449
+ inputs: [{ name: "bytecodeHash", type: "bytes32" }]
5450
+ },
5451
+ { type: "error", name: "CallerNotTimerAdmin", inputs: [] },
5452
+ { type: "error", name: "CallNotAllowed", inputs: [{ name: "call", type: "bytes" }] },
5453
+ { type: "error", name: "CanOnlyProcessOneBatch", inputs: [] },
5454
+ { type: "error", name: "CantExecuteUnprovenBatches", inputs: [] },
5455
+ { type: "error", name: "CantRevertExecutedBatch", inputs: [] },
5456
+ { type: "error", name: "ChainAlreadyLive", inputs: [] },
5457
+ { type: "error", name: "ChainIdAlreadyExists", inputs: [] },
5458
+ { type: "error", name: "ChainIdCantBeCurrentChain", inputs: [] },
5459
+ { type: "error", name: "ChainIdMismatch", inputs: [] },
5460
+ { type: "error", name: "ChainIdNotRegistered", inputs: [{ name: "chainId", type: "uint256" }] },
5461
+ { type: "error", name: "ChainIdTooBig", inputs: [] },
5462
+ { type: "error", name: "CTMAlreadyRegistered", inputs: [] },
5463
+ { type: "error", name: "CTMNotRegistered", inputs: [] },
5464
+ { type: "error", name: "DeadlineNotYetPassed", inputs: [] },
5465
+ { type: "error", name: "DefaultAdminTransferNotAllowed", inputs: [] },
5466
+ { type: "error", name: "DelegateCallFailed", inputs: [{ name: "returnData", type: "bytes" }] },
5467
+ { type: "error", name: "DenominatorIsZero", inputs: [] },
5468
+ { type: "error", name: "DeployFailed", inputs: [] },
5469
+ { type: "error", name: "DeployingBridgedTokenForNativeToken", inputs: [] },
5470
+ { type: "error", name: "DepositDoesNotExist", inputs: [] },
5471
+ { type: "error", name: "DepositExists", inputs: [] },
5472
+ { type: "error", name: "DiamondAlreadyFrozen", inputs: [] },
5473
+ { type: "error", name: "DiamondNotFrozen", inputs: [] },
5474
+ { type: "error", name: "EmptyAddress", inputs: [] },
5475
+ { type: "error", name: "EmptyAssetId", inputs: [] },
5476
+ { type: "error", name: "EmptyBytes32", inputs: [] },
5477
+ { type: "error", name: "EmptyData", inputs: [] },
5478
+ { type: "error", name: "EmptyDeposit", inputs: [] },
5479
+ { type: "error", name: "EmptyPrecommitData", inputs: [{ name: "batchNumber", type: "uint256" }] },
5480
+ { type: "error", name: "EmptyProofLength", inputs: [] },
5481
+ { type: "error", name: "ETHDepositNotSupported", inputs: [] },
5482
+ {
5483
+ type: "error",
5484
+ name: "FacetExists",
5485
+ inputs: [
5486
+ { name: "selector", type: "bytes4" },
5487
+ { name: "", type: "address" }
5488
+ ]
5489
+ },
5490
+ { type: "error", name: "GasPerPubdataMismatch", inputs: [] },
5491
+ { type: "error", name: "GenesisBatchCommitmentZero", inputs: [] },
5492
+ { type: "error", name: "GenesisBatchHashZero", inputs: [] },
5493
+ { type: "error", name: "GenesisIndexStorageZero", inputs: [] },
5494
+ { type: "error", name: "GenesisUpgradeZero", inputs: [] },
5495
+ { type: "error", name: "HashedLogIsDefault", inputs: [] },
5496
+ {
5497
+ type: "error",
5498
+ name: "HashMismatch",
5499
+ inputs: [
5500
+ { name: "expected", type: "bytes32" },
5501
+ { name: "actual", type: "bytes32" }
5502
+ ]
5503
+ },
5504
+ {
5505
+ type: "error",
5506
+ name: "IncorrectBatchBounds",
5507
+ inputs: [
5508
+ { name: "processFromExpected", type: "uint256" },
5509
+ { name: "processToExpected", type: "uint256" },
5510
+ { name: "processFromProvided", type: "uint256" },
5511
+ { name: "processToProvided", type: "uint256" }
5512
+ ]
5513
+ },
5514
+ {
5515
+ type: "error",
5516
+ name: "IncorrectBridgeHubAddress",
5517
+ inputs: [{ name: "bridgehub", type: "address" }]
5518
+ },
5519
+ {
5520
+ type: "error",
5521
+ name: "IncorrectTokenAddressFromNTV",
5522
+ inputs: [
5523
+ { name: "assetId", type: "bytes32" },
5524
+ { name: "tokenAddress", type: "address" }
5525
+ ]
5526
+ },
5527
+ { type: "error", name: "InsufficientChainBalance", inputs: [] },
5528
+ {
5529
+ type: "error",
5530
+ name: "InvalidBatchNumber",
5531
+ inputs: [
5532
+ { name: "provided", type: "uint256" },
5533
+ { name: "expected", type: "uint256" }
5534
+ ]
5535
+ },
5536
+ { type: "error", name: "InvalidCaller", inputs: [{ name: "", type: "address" }] },
5537
+ { type: "error", name: "InvalidDAForPermanentRollup", inputs: [] },
5538
+ { type: "error", name: "InvalidDelay", inputs: [] },
5539
+ {
5540
+ type: "error",
5541
+ name: "InvalidLogSender",
5542
+ inputs: [
5543
+ { name: "sender", type: "address" },
5544
+ { name: "logKey", type: "uint256" }
5545
+ ]
5546
+ },
5547
+ {
5548
+ type: "error",
5549
+ name: "InvalidMessageRoot",
5550
+ inputs: [
5551
+ { name: "expectedMessageRoot", type: "bytes32" },
5552
+ { name: "providedMessageRoot", type: "bytes32" }
5553
+ ]
5554
+ },
5555
+ { type: "error", name: "InvalidNTVBurnData", inputs: [] },
5556
+ {
5557
+ type: "error",
5558
+ name: "InvalidNumberOfBlobs",
5559
+ inputs: [
5560
+ { name: "expected", type: "uint256" },
5561
+ { name: "numCommitments", type: "uint256" },
5562
+ { name: "numHashes", type: "uint256" }
5563
+ ]
5564
+ },
5565
+ {
5566
+ type: "error",
5567
+ name: "InvalidPackedPrecommitmentLength",
5568
+ inputs: [{ name: "length", type: "uint256" }]
5569
+ },
5570
+ { type: "error", name: "InvalidProof", inputs: [] },
5571
+ { type: "error", name: "InvalidProofLengthForFinalNode", inputs: [] },
5572
+ { type: "error", name: "InvalidProtocolVersion", inputs: [] },
5573
+ { type: "error", name: "InvalidPubdataPricingMode", inputs: [] },
5574
+ { type: "error", name: "InvalidSelector", inputs: [{ name: "func", type: "bytes4" }] },
5575
+ { type: "error", name: "InvalidSystemLogsLength", inputs: [] },
5576
+ { type: "error", name: "InvalidUpgradeTxn", inputs: [{ name: "", type: "uint8" }] },
5577
+ { type: "error", name: "L2TimestampTooBig", inputs: [] },
5578
+ {
5579
+ type: "error",
5580
+ name: "L2WithdrawalMessageWrongLength",
5581
+ inputs: [{ name: "messageLen", type: "uint256" }]
5582
+ },
5583
+ { type: "error", name: "LegacyBridgeNotSet", inputs: [] },
5584
+ { type: "error", name: "LegacyBridgeUsesNonNativeToken", inputs: [] },
5585
+ { type: "error", name: "LegacyEncodingUsedForNonL1Token", inputs: [] },
5586
+ { type: "error", name: "LegacyMethodForNonL1Token", inputs: [] },
5587
+ {
5588
+ type: "error",
5589
+ name: "LengthIsNotDivisibleBy32",
5590
+ inputs: [{ name: "length", type: "uint256" }]
5591
+ },
5592
+ { type: "error", name: "LogAlreadyProcessed", inputs: [{ name: "", type: "uint8" }] },
5593
+ { type: "error", name: "MalformedBytecode", inputs: [{ name: "", type: "uint8" }] },
5594
+ { type: "error", name: "MerkleIndexOrHeightMismatch", inputs: [] },
5595
+ { type: "error", name: "MerkleIndexOutOfBounds", inputs: [] },
5596
+ { type: "error", name: "MerkleNothingToProve", inputs: [] },
5597
+ { type: "error", name: "MerklePathEmpty", inputs: [] },
5598
+ {
5599
+ type: "error",
5600
+ name: "MerklePathLengthMismatch",
5601
+ inputs: [
5602
+ { name: "pathLength", type: "uint256" },
5603
+ { name: "expectedLength", type: "uint256" }
5604
+ ]
5605
+ },
5606
+ { type: "error", name: "MerklePathOutOfBounds", inputs: [] },
5607
+ {
5608
+ type: "error",
5609
+ name: "MerkleWrongIndex",
5610
+ inputs: [
5611
+ { name: "index", type: "uint256" },
5612
+ { name: "maxNodeNumber", type: "uint256" }
5613
+ ]
5614
+ },
5615
+ {
5616
+ type: "error",
5617
+ name: "MerkleWrongLength",
5618
+ inputs: [
5619
+ { name: "newLeavesLength", type: "uint256" },
5620
+ { name: "leafNumber", type: "uint256" }
5621
+ ]
5622
+ },
5623
+ { type: "error", name: "MigrationPaused", inputs: [] },
5624
+ { type: "error", name: "MigrationsNotPaused", inputs: [] },
5625
+ {
5626
+ type: "error",
5627
+ name: "MissingSystemLogs",
5628
+ inputs: [
5629
+ { name: "expected", type: "uint256" },
5630
+ { name: "actual", type: "uint256" }
5631
+ ]
5632
+ },
5633
+ {
5634
+ type: "error",
5635
+ name: "MsgValueMismatch",
5636
+ inputs: [
5637
+ { name: "expectedMsgValue", type: "uint256" },
5638
+ { name: "providedMsgValue", type: "uint256" }
5639
+ ]
5640
+ },
5641
+ {
5642
+ type: "error",
5643
+ name: "MsgValueTooLow",
5644
+ inputs: [
5645
+ { name: "required", type: "uint256" },
5646
+ { name: "provided", type: "uint256" }
5647
+ ]
5648
+ },
5649
+ { type: "error", name: "NewDeadlineExceedsMaxDeadline", inputs: [] },
5650
+ { type: "error", name: "NewDeadlineNotGreaterThanCurrent", inputs: [] },
5651
+ { type: "error", name: "NoCallsProvided", inputs: [] },
5652
+ { type: "error", name: "NoCTMForAssetId", inputs: [{ name: "assetId", type: "bytes32" }] },
5653
+ { type: "error", name: "NoFunctionsForDiamondCut", inputs: [] },
5654
+ { type: "error", name: "NoFundsTransferred", inputs: [] },
5655
+ { type: "error", name: "NoLegacySharedBridge", inputs: [] },
5656
+ { type: "error", name: "NonEmptyCalldata", inputs: [] },
5657
+ { type: "error", name: "NonEmptyMsgValue", inputs: [] },
5658
+ { type: "error", name: "NonIncreasingTimestamp", inputs: [] },
5659
+ { type: "error", name: "NonSequentialBatch", inputs: [] },
5660
+ { type: "error", name: "NonSequentialVersion", inputs: [] },
5661
+ { type: "error", name: "NotAllowed", inputs: [{ name: "addr", type: "address" }] },
5662
+ { type: "error", name: "NotARestriction", inputs: [{ name: "addr", type: "address" }] },
5663
+ { type: "error", name: "NotAZKChain", inputs: [{ name: "addr", type: "address" }] },
5664
+ { type: "error", name: "NotInitializedReentrancyGuard", inputs: [] },
5665
+ { type: "error", name: "NotWhitelisted", inputs: [{ name: "", type: "address" }] },
5666
+ { type: "error", name: "OnlyEraSupported", inputs: [] },
5667
+ { type: "error", name: "OnlySelfAllowed", inputs: [] },
5668
+ { type: "error", name: "OperationExists", inputs: [] },
5669
+ { type: "error", name: "OperationMustBePending", inputs: [] },
5670
+ { type: "error", name: "OperationMustBeReady", inputs: [] },
5671
+ { type: "error", name: "OriginChainIdNotFound", inputs: [] },
5672
+ {
5673
+ type: "error",
5674
+ name: "PrecommitmentMismatch",
5675
+ inputs: [
5676
+ { name: "batchNumber", type: "uint256" },
5677
+ { name: "expected", type: "bytes32" },
5678
+ { name: "found", type: "bytes32" }
5679
+ ]
5680
+ },
5681
+ { type: "error", name: "PreviousOperationNotExecuted", inputs: [] },
5682
+ { type: "error", name: "PriorityOperationsRollingHashMismatch", inputs: [] },
5683
+ { type: "error", name: "PriorityTxPubdataExceedsMaxPubDataPerBatch", inputs: [] },
5684
+ {
5685
+ type: "error",
5686
+ name: "ProtocolIdMismatch",
5687
+ inputs: [
5688
+ { name: "expectedProtocolVersion", type: "uint256" },
5689
+ { name: "providedProtocolId", type: "uint256" }
5690
+ ]
5691
+ },
5692
+ { type: "error", name: "ProtocolIdNotGreater", inputs: [] },
5693
+ {
5694
+ type: "error",
5695
+ name: "PubdataGreaterThanLimit",
5696
+ inputs: [
5697
+ { name: "limit", type: "uint256" },
5698
+ { name: "length", type: "uint256" }
5699
+ ]
5700
+ },
5701
+ { type: "error", name: "QueueIsEmpty", inputs: [] },
5702
+ { type: "error", name: "Reentrancy", inputs: [] },
5703
+ {
5704
+ type: "error",
5705
+ name: "RemoveFunctionFacetAddressNotZero",
5706
+ inputs: [{ name: "facet", type: "address" }]
5707
+ },
5708
+ { type: "error", name: "RemoveFunctionFacetAddressZero", inputs: [] },
5709
+ { type: "error", name: "RemovingPermanentRestriction", inputs: [] },
5710
+ { type: "error", name: "ReplaceFunctionFacetAddressZero", inputs: [] },
5711
+ {
5712
+ type: "error",
5713
+ name: "RestrictionWasAlreadyPresent",
5714
+ inputs: [{ name: "restriction", type: "address" }]
5715
+ },
5716
+ {
5717
+ type: "error",
5718
+ name: "RestrictionWasNotPresent",
5719
+ inputs: [{ name: "restriction", type: "address" }]
5720
+ },
5721
+ { type: "error", name: "RevertedBatchNotAfterNewLastBatch", inputs: [] },
5722
+ {
5723
+ type: "error",
5724
+ name: "RoleAccessDenied",
5725
+ inputs: [
5726
+ { name: "chainAddress", type: "address" },
5727
+ { name: "role", type: "bytes32" },
5728
+ { name: "account", type: "address" }
5729
+ ]
5730
+ },
5731
+ { type: "error", name: "SelectorsMustAllHaveSameFreezability", inputs: [] },
5732
+ { type: "error", name: "SettlementLayersMustSettleOnL1", inputs: [] },
5733
+ { type: "error", name: "SharedBridgeNotSet", inputs: [] },
5734
+ { type: "error", name: "SharedBridgeValueNotSet", inputs: [{ name: "", type: "uint8" }] },
5735
+ { type: "error", name: "SlotOccupied", inputs: [] },
5736
+ { type: "error", name: "SystemLogsSizeTooBig", inputs: [] },
5737
+ {
5738
+ type: "error",
5739
+ name: "TimeNotReached",
5740
+ inputs: [
5741
+ { name: "expectedTimestamp", type: "uint256" },
5742
+ { name: "actualTimestamp", type: "uint256" }
5743
+ ]
5744
+ },
5745
+ { type: "error", name: "TimerAlreadyStarted", inputs: [] },
5746
+ { type: "error", name: "TimestampError", inputs: [] },
5747
+ { type: "error", name: "TokenIsLegacy", inputs: [] },
5748
+ { type: "error", name: "TokenNotLegacy", inputs: [] },
5749
+ { type: "error", name: "TokenNotSupported", inputs: [{ name: "token", type: "address" }] },
5750
+ { type: "error", name: "TokensWithFeesNotSupported", inputs: [] },
5751
+ { type: "error", name: "TooHighDeploymentNonce", inputs: [] },
5752
+ { type: "error", name: "TooManyFactoryDeps", inputs: [] },
5753
+ { type: "error", name: "TooMuchGas", inputs: [] },
5754
+ { type: "error", name: "TransactionNotAllowed", inputs: [] },
5755
+ { type: "error", name: "TxHashMismatch", inputs: [] },
5756
+ { type: "error", name: "TxnBodyGasLimitNotEnoughGas", inputs: [] },
5757
+ {
5758
+ type: "error",
5759
+ name: "UnallowedImplementation",
5760
+ inputs: [{ name: "implementationHash", type: "bytes32" }]
5761
+ },
5762
+ { type: "error", name: "Unauthorized", inputs: [{ name: "caller", type: "address" }] },
5763
+ { type: "error", name: "UndefinedDiamondCutAction", inputs: [] },
5764
+ { type: "error", name: "UnexpectedSystemLog", inputs: [{ name: "logKey", type: "uint256" }] },
5765
+ { type: "error", name: "UnknownVerifierType", inputs: [] },
5766
+ {
5767
+ type: "error",
5768
+ name: "UnsupportedCommitBatchEncoding",
5769
+ inputs: [{ name: "version", type: "uint8" }]
5770
+ },
5771
+ { type: "error", name: "UnsupportedEncodingVersion", inputs: [] },
5772
+ {
5773
+ type: "error",
5774
+ name: "UnsupportedExecuteBatchEncoding",
5775
+ inputs: [{ name: "version", type: "uint8" }]
5776
+ },
5777
+ {
5778
+ type: "error",
5779
+ name: "UnsupportedProofBatchEncoding",
5780
+ inputs: [{ name: "version", type: "uint8" }]
5781
+ },
5782
+ { type: "error", name: "UpgradeBatchNumberIsNotZero", inputs: [] },
5783
+ { type: "error", name: "ValidateTxnNotEnoughGas", inputs: [] },
5784
+ {
5785
+ type: "error",
5786
+ name: "ValueMismatch",
5787
+ inputs: [
5788
+ { name: "expected", type: "uint256" },
5789
+ { name: "actual", type: "uint256" }
5790
+ ]
5791
+ },
5792
+ { type: "error", name: "VerifiedBatchesExceedsCommittedBatches", inputs: [] },
5793
+ { type: "error", name: "WithdrawalAlreadyFinalized", inputs: [] },
5794
+ { type: "error", name: "WithdrawFailed", inputs: [] },
5795
+ { type: "error", name: "WrappedBaseTokenAlreadyRegistered", inputs: [] },
5796
+ {
5797
+ type: "error",
5798
+ name: "WrongMagicValue",
5799
+ inputs: [
5800
+ { name: "expectedMagicValue", type: "uint256" },
5801
+ { name: "providedMagicValue", type: "uint256" }
5802
+ ]
5803
+ },
5804
+ { type: "error", name: "ZeroAddress", inputs: [] },
5805
+ { type: "error", name: "ZeroChainId", inputs: [] },
5806
+ { type: "error", name: "ZKChainLimitReached", inputs: [] }
5807
+ ];
5808
+ var IL1ContractErrors_default = IL1ContractErrorsABI;
5809
+
5088
5810
  // src/core/errors/error-ops.ts
5089
5811
  function resolveMessage(op, msg) {
5090
5812
  if (!msg) return `Error during ${op}.`;
@@ -5162,6 +5884,14 @@ var ABI_PANIC = [
5162
5884
  ERROR_ABIS.push({ name: "Mailbox", abi: Mailbox_default });
5163
5885
  } catch {
5164
5886
  }
5887
+ try {
5888
+ ERROR_ABIS.push({ name: "IL1ContractErrors", abi: IL1ContractErrors_default });
5889
+ } catch {
5890
+ }
5891
+ try {
5892
+ ERROR_ABIS.push({ name: "IInteropErrors", abi: IInteropErrors_default });
5893
+ } catch {
5894
+ }
5165
5895
  })();
5166
5896
  function extractRevertData(e) {
5167
5897
  const candidates = [
@@ -5221,6 +5951,15 @@ var { createErrorHandlers } = createErrorOps(decodeRevert);
5221
5951
 
5222
5952
  // src/adapters/viem/client.ts
5223
5953
  var { wrap } = createErrorHandlers("client");
5954
+ var ChainTypeManagerABI = [
5955
+ {
5956
+ type: "function",
5957
+ name: "getSemverProtocolVersion",
5958
+ inputs: [],
5959
+ outputs: [{ type: "uint32" }, { type: "uint32" }, { type: "uint32" }],
5960
+ stateMutability: "view"
5961
+ }
5962
+ ];
5224
5963
  function createViemClient(args) {
5225
5964
  const { l1, l2, l1Wallet, l2Wallet } = args;
5226
5965
  if (!l1Wallet.account) {
@@ -5254,6 +5993,9 @@ function createViemClient(args) {
5254
5993
  const l2AssetRouter = args.overrides?.l2AssetRouter ?? L2_ASSET_ROUTER_ADDRESS;
5255
5994
  const l2NativeTokenVault = args.overrides?.l2NativeTokenVault ?? L2_NATIVE_TOKEN_VAULT_ADDRESS;
5256
5995
  const l2BaseTokenSystem = args.overrides?.l2BaseTokenSystem ?? L2_BASE_TOKEN_ADDRESS;
5996
+ const interopCenter = args.overrides?.interopCenter ?? L2_INTEROP_CENTER_ADDRESS;
5997
+ const interopHandler = args.overrides?.interopHandler ?? L2_INTEROP_HANDLER_ADDRESS;
5998
+ const l2MessageVerification = args.overrides?.l2MessageVerification ?? L2_MESSAGE_VERIFICATION_ADDRESS;
5257
5999
  addrCache = {
5258
6000
  bridgehub,
5259
6001
  l1AssetRouter,
@@ -5261,7 +6003,10 @@ function createViemClient(args) {
5261
6003
  l1NativeTokenVault,
5262
6004
  l2AssetRouter,
5263
6005
  l2NativeTokenVault,
5264
- l2BaseTokenSystem
6006
+ l2BaseTokenSystem,
6007
+ interopCenter,
6008
+ interopHandler,
6009
+ l2MessageVerification
5265
6010
  };
5266
6011
  return addrCache;
5267
6012
  },
@@ -5311,13 +6056,55 @@ function createViemClient(args) {
5311
6056
  });
5312
6057
  return token;
5313
6058
  }
6059
+ async function getProtocolVersion(chainId) {
6060
+ const targetChainId = chainId ?? BigInt(await l2.getChainId());
6061
+ const { bridgehub } = await ensureAddresses();
6062
+ const chainTypeManager = await wrap(
6063
+ OP_CLIENT.getSemverProtocolVersion,
6064
+ () => l1.readContract({
6065
+ address: bridgehub,
6066
+ abi: IBridgehub_default,
6067
+ functionName: "chainTypeManager",
6068
+ args: [targetChainId]
6069
+ }),
6070
+ {
6071
+ ctx: { where: "bridgehub.chainTypeManager", bridgehub, chainId: targetChainId },
6072
+ message: "Failed to read chain type manager."
6073
+ }
6074
+ );
6075
+ if (chainTypeManager.toLowerCase() === FORMAL_ETH_ADDRESS.toLowerCase()) {
6076
+ throw createError("STATE", {
6077
+ resource: "client",
6078
+ operation: OP_CLIENT.getSemverProtocolVersion,
6079
+ message: "No registered chain type manager for the chain.",
6080
+ context: { chainId }
6081
+ });
6082
+ }
6083
+ const semver = await wrap(
6084
+ OP_CLIENT.getSemverProtocolVersion,
6085
+ () => l1.readContract({
6086
+ address: chainTypeManager,
6087
+ abi: ChainTypeManagerABI,
6088
+ functionName: "getSemverProtocolVersion"
6089
+ }),
6090
+ {
6091
+ ctx: {
6092
+ where: "chainTypeManager.getSemverProtocolVersion",
6093
+ chainId: targetChainId,
6094
+ chainTypeManager
6095
+ },
6096
+ message: "Failed to read semver protocol version."
6097
+ }
6098
+ );
6099
+ return semver;
6100
+ }
5314
6101
  let lazyL2;
5315
6102
  function getL2Wallet() {
5316
6103
  if (l2Wallet) return l2Wallet;
5317
6104
  if (!lazyL2) {
5318
6105
  lazyL2 = viem.createWalletClient({
5319
6106
  account: l1Wallet.account,
5320
- transport: l2.transport
6107
+ transport: viem.custom(l2.transport)
5321
6108
  });
5322
6109
  }
5323
6110
  return lazyL2;
@@ -5334,6 +6121,7 @@ function createViemClient(args) {
5334
6121
  contracts,
5335
6122
  refresh,
5336
6123
  baseToken,
6124
+ getProtocolVersion,
5337
6125
  getL2Wallet
5338
6126
  };
5339
6127
  }