@aztec/stdlib 0.0.1-commit.ffe5b04ea → 0.0.1-commit.fff30aa

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 (265) hide show
  1. package/dest/abi/abi.d.ts +57 -85
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +55 -6
  4. package/dest/abi/buffer.d.ts +14 -4
  5. package/dest/abi/buffer.d.ts.map +1 -1
  6. package/dest/abi/buffer.js +25 -4
  7. package/dest/abi/decoder.d.ts +5 -44
  8. package/dest/abi/decoder.d.ts.map +1 -1
  9. package/dest/abi/decoder.js +12 -67
  10. package/dest/abi/function_selector.js +1 -1
  11. package/dest/abi/function_signature_decoder.d.ts +43 -0
  12. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  13. package/dest/abi/function_signature_decoder.js +66 -0
  14. package/dest/abi/index.d.ts +2 -1
  15. package/dest/abi/index.d.ts.map +1 -1
  16. package/dest/abi/index.js +1 -0
  17. package/dest/abi/selector.d.ts +2 -2
  18. package/dest/abi/selector.d.ts.map +1 -1
  19. package/dest/abi/selector.js +1 -1
  20. package/dest/avm/avm_accumulated_data.js +2 -2
  21. package/dest/avm/avm_circuit_public_inputs.js +2 -2
  22. package/dest/avm/revert_code.d.ts +8 -18
  23. package/dest/avm/revert_code.d.ts.map +1 -1
  24. package/dest/avm/revert_code.js +15 -30
  25. package/dest/block/l2_block_source.d.ts +11 -8
  26. package/dest/block/l2_block_source.d.ts.map +1 -1
  27. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  28. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  29. package/dest/checkpoint/validate.js +2 -2
  30. package/dest/config/sequencer-config.d.ts +1 -3
  31. package/dest/config/sequencer-config.d.ts.map +1 -1
  32. package/dest/config/sequencer-config.js +0 -1
  33. package/dest/epoch-helpers/index.d.ts +9 -1
  34. package/dest/epoch-helpers/index.d.ts.map +1 -1
  35. package/dest/epoch-helpers/index.js +13 -2
  36. package/dest/gas/gas_settings.d.ts +40 -3
  37. package/dest/gas/gas_settings.d.ts.map +1 -1
  38. package/dest/gas/gas_settings.js +50 -6
  39. package/dest/hash/hash.d.ts +19 -1
  40. package/dest/hash/hash.d.ts.map +1 -1
  41. package/dest/hash/hash.js +29 -0
  42. package/dest/interfaces/archiver.js +2 -2
  43. package/dest/interfaces/aztec-node-admin.d.ts +10 -13
  44. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  45. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  46. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  47. package/dest/interfaces/aztec-node-debug.js +18 -0
  48. package/dest/interfaces/aztec-node.d.ts +3 -2
  49. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  50. package/dest/interfaces/aztec-node.js +2 -0
  51. package/dest/interfaces/block-builder.d.ts +32 -11
  52. package/dest/interfaces/block-builder.d.ts.map +1 -1
  53. package/dest/interfaces/block-builder.js +6 -4
  54. package/dest/interfaces/client.d.ts +2 -1
  55. package/dest/interfaces/client.d.ts.map +1 -1
  56. package/dest/interfaces/client.js +1 -0
  57. package/dest/interfaces/configs.d.ts +7 -2
  58. package/dest/interfaces/configs.d.ts.map +1 -1
  59. package/dest/interfaces/configs.js +1 -0
  60. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  61. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  62. package/dest/interfaces/prover-client.d.ts +6 -1
  63. package/dest/interfaces/prover-client.d.ts.map +1 -1
  64. package/dest/interfaces/prover-client.js +7 -1
  65. package/dest/interfaces/validator.d.ts +17 -37
  66. package/dest/interfaces/validator.d.ts.map +1 -1
  67. package/dest/interfaces/validator.js +2 -2
  68. package/dest/interfaces/world_state.d.ts +5 -4
  69. package/dest/interfaces/world_state.d.ts.map +1 -1
  70. package/dest/kernel/claimed_length_array.js +1 -1
  71. package/dest/kernel/hints/private_kernel_reset_hints.d.ts +1 -1
  72. package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
  73. package/dest/kernel/padded_side_effects.js +1 -1
  74. package/dest/kernel/private_to_avm_accumulated_data.js +2 -2
  75. package/dest/kernel/private_to_public_accumulated_data.js +2 -2
  76. package/dest/kernel/private_to_rollup_accumulated_data.js +1 -1
  77. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  78. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  79. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  80. package/dest/logs/index.d.ts +2 -1
  81. package/dest/logs/index.d.ts.map +1 -1
  82. package/dest/logs/index.js +1 -0
  83. package/dest/logs/log_filter.d.ts +4 -1
  84. package/dest/logs/log_filter.d.ts.map +1 -1
  85. package/dest/logs/log_filter.js +2 -1
  86. package/dest/logs/message_context.d.ts +4 -7
  87. package/dest/logs/message_context.d.ts.map +1 -1
  88. package/dest/logs/message_context.js +23 -9
  89. package/dest/logs/pending_tagged_log.d.ts +2 -3
  90. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  91. package/dest/logs/pending_tagged_log.js +2 -2
  92. package/dest/logs/private_log.js +1 -1
  93. package/dest/logs/public_log.d.ts +1 -1
  94. package/dest/logs/public_log.d.ts.map +1 -1
  95. package/dest/logs/public_log.js +7 -1
  96. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  97. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  98. package/dest/logs/shared_secret_derivation.js +15 -9
  99. package/dest/logs/siloed_tag.d.ts +4 -1
  100. package/dest/logs/siloed_tag.d.ts.map +1 -1
  101. package/dest/logs/siloed_tag.js +7 -3
  102. package/dest/logs/tagging_index_range.d.ts +40 -0
  103. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  104. package/dest/logs/tagging_index_range.js +8 -0
  105. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  106. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  107. package/dest/logs/tx_scoped_l2_log.js +7 -0
  108. package/dest/messaging/l1_to_l2_message.d.ts +3 -2
  109. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  110. package/dest/messaging/l1_to_l2_message.js +11 -13
  111. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  112. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  113. package/dest/messaging/l2_to_l1_membership.js +69 -26
  114. package/dest/noir/index.d.ts +3 -3
  115. package/dest/noir/index.d.ts.map +1 -1
  116. package/dest/note/note_dao.d.ts +1 -1
  117. package/dest/note/note_dao.d.ts.map +1 -1
  118. package/dest/note/note_dao.js +1 -4
  119. package/dest/p2p/block_proposal.d.ts +2 -2
  120. package/dest/p2p/block_proposal.d.ts.map +1 -1
  121. package/dest/p2p/block_proposal.js +1 -1
  122. package/dest/p2p/checkpoint_proposal.d.ts +2 -2
  123. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  124. package/dest/p2p/checkpoint_proposal.js +14 -12
  125. package/dest/parity/parity_base_private_inputs.js +1 -1
  126. package/dest/proofs/chonk_proof.d.ts +1 -1
  127. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  128. package/dest/proofs/chonk_proof.js +7 -1
  129. package/dest/rollup/base_rollup_hints.js +2 -2
  130. package/dest/rollup/block_root_rollup_private_inputs.js +5 -5
  131. package/dest/rollup/checkpoint_rollup_public_inputs.js +1 -1
  132. package/dest/rollup/checkpoint_root_rollup_private_inputs.js +3 -3
  133. package/dest/rollup/root_rollup_public_inputs.js +1 -1
  134. package/dest/rollup/tree_snapshot_diff_hints.js +2 -2
  135. package/dest/tests/factories.js +1 -1
  136. package/dest/tests/mocks.d.ts +1 -1
  137. package/dest/tests/mocks.d.ts.map +1 -1
  138. package/dest/tests/mocks.js +2 -2
  139. package/dest/tx/capsule.d.ts +6 -2
  140. package/dest/tx/capsule.d.ts.map +1 -1
  141. package/dest/tx/capsule.js +9 -3
  142. package/dest/tx/private_execution_result.d.ts +6 -6
  143. package/dest/tx/private_execution_result.d.ts.map +1 -1
  144. package/dest/tx/private_execution_result.js +6 -6
  145. package/dest/tx/profiling.d.ts +14 -2
  146. package/dest/tx/profiling.d.ts.map +1 -1
  147. package/dest/tx/profiling.js +13 -3
  148. package/dest/tx/protocol_contracts.js +2 -2
  149. package/dest/tx/simulated_tx.d.ts +59 -76
  150. package/dest/tx/simulated_tx.d.ts.map +1 -1
  151. package/dest/tx/simulated_tx.js +3 -3
  152. package/dest/tx/tx_receipt.d.ts +14 -5
  153. package/dest/tx/tx_receipt.d.ts.map +1 -1
  154. package/dest/tx/tx_receipt.js +14 -18
  155. package/dest/tx/validator/error_texts.d.ts +5 -1
  156. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  157. package/dest/tx/validator/error_texts.js +6 -0
  158. package/dest/update-checker/package_version.d.ts +2 -2
  159. package/dest/update-checker/package_version.d.ts.map +1 -1
  160. package/dest/update-checker/package_version.js +16 -3
  161. package/dest/validators/errors.d.ts +6 -1
  162. package/dest/validators/errors.d.ts.map +1 -1
  163. package/dest/validators/errors.js +7 -0
  164. package/dest/versioning/versioning.d.ts +4 -2
  165. package/dest/versioning/versioning.d.ts.map +1 -1
  166. package/dest/versioning/versioning.js +4 -1
  167. package/dest/vks/vk_data.js +1 -1
  168. package/package.json +10 -11
  169. package/src/abi/abi.ts +78 -2
  170. package/src/abi/buffer.ts +25 -4
  171. package/src/abi/decoder.ts +23 -78
  172. package/src/abi/function_selector.ts +1 -1
  173. package/src/abi/function_signature_decoder.ts +77 -0
  174. package/src/abi/index.ts +1 -0
  175. package/src/abi/selector.ts +1 -1
  176. package/src/avm/avm_accumulated_data.ts +6 -6
  177. package/src/avm/avm_circuit_public_inputs.ts +4 -4
  178. package/src/avm/revert_code.ts +25 -39
  179. package/src/block/l2_block_source.ts +10 -7
  180. package/src/block/l2_block_stream/interfaces.ts +6 -2
  181. package/src/checkpoint/validate.ts +2 -2
  182. package/src/config/sequencer-config.ts +0 -3
  183. package/src/epoch-helpers/index.ts +22 -0
  184. package/src/gas/README.md +123 -0
  185. package/src/gas/gas_settings.ts +65 -12
  186. package/src/hash/hash.ts +34 -0
  187. package/src/interfaces/archiver.ts +2 -2
  188. package/src/interfaces/aztec-node-debug.ts +40 -0
  189. package/src/interfaces/aztec-node.ts +10 -1
  190. package/src/interfaces/block-builder.ts +39 -13
  191. package/src/interfaces/client.ts +1 -0
  192. package/src/interfaces/configs.ts +4 -1
  193. package/src/interfaces/merkle_tree_operations.ts +8 -18
  194. package/src/interfaces/prover-client.ts +8 -0
  195. package/src/interfaces/validator.ts +34 -40
  196. package/src/interfaces/world_state.ts +4 -3
  197. package/src/kernel/claimed_length_array.ts +2 -2
  198. package/src/kernel/hints/private_kernel_reset_hints.ts +5 -2
  199. package/src/kernel/hints/read_request_hints.ts +3 -3
  200. package/src/kernel/padded_side_effects.ts +3 -3
  201. package/src/kernel/private_to_avm_accumulated_data.ts +4 -4
  202. package/src/kernel/private_to_public_accumulated_data.ts +10 -10
  203. package/src/kernel/private_to_rollup_accumulated_data.ts +5 -5
  204. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  205. package/src/logs/index.ts +1 -0
  206. package/src/logs/log_filter.ts +5 -0
  207. package/src/logs/message_context.ts +17 -7
  208. package/src/logs/pending_tagged_log.ts +1 -3
  209. package/src/logs/private_log.ts +1 -1
  210. package/src/logs/public_log.ts +11 -1
  211. package/src/logs/shared_secret_derivation.ts +21 -10
  212. package/src/logs/siloed_tag.ts +7 -2
  213. package/src/logs/tagging_index_range.ts +24 -0
  214. package/src/logs/tx_scoped_l2_log.ts +16 -0
  215. package/src/messaging/l1_to_l2_message.ts +12 -9
  216. package/src/messaging/l2_to_l1_membership.ts +98 -33
  217. package/src/noir/index.ts +2 -2
  218. package/src/note/note_dao.ts +1 -4
  219. package/src/p2p/block_proposal.ts +1 -1
  220. package/src/p2p/checkpoint_proposal.ts +24 -21
  221. package/src/parity/parity_base_private_inputs.ts +1 -1
  222. package/src/proofs/chonk_proof.ts +9 -1
  223. package/src/rollup/base_rollup_hints.ts +2 -2
  224. package/src/rollup/block_root_rollup_private_inputs.ts +8 -8
  225. package/src/rollup/checkpoint_rollup_public_inputs.ts +2 -2
  226. package/src/rollup/checkpoint_root_rollup_private_inputs.ts +4 -4
  227. package/src/rollup/root_rollup_public_inputs.ts +2 -2
  228. package/src/rollup/tree_snapshot_diff_hints.ts +5 -5
  229. package/src/tests/factories.ts +1 -1
  230. package/src/tests/mocks.ts +2 -2
  231. package/src/tx/capsule.ts +10 -2
  232. package/src/tx/private_execution_result.ts +5 -5
  233. package/src/tx/profiling.ts +11 -2
  234. package/src/tx/protocol_contracts.ts +2 -2
  235. package/src/tx/simulated_tx.ts +6 -2
  236. package/src/tx/tx_receipt.ts +18 -16
  237. package/src/tx/validator/error_texts.ts +8 -0
  238. package/src/update-checker/package_version.ts +19 -6
  239. package/src/validators/errors.ts +9 -0
  240. package/src/versioning/versioning.ts +4 -1
  241. package/src/vks/vk_data.ts +1 -1
  242. package/dest/ha-signing/config.d.ts +0 -136
  243. package/dest/ha-signing/config.d.ts.map +0 -1
  244. package/dest/ha-signing/config.js +0 -97
  245. package/dest/ha-signing/index.d.ts +0 -4
  246. package/dest/ha-signing/index.d.ts.map +0 -1
  247. package/dest/ha-signing/index.js +0 -3
  248. package/dest/ha-signing/local_config.d.ts +0 -63
  249. package/dest/ha-signing/local_config.d.ts.map +0 -1
  250. package/dest/ha-signing/local_config.js +0 -24
  251. package/dest/ha-signing/types.d.ts +0 -85
  252. package/dest/ha-signing/types.d.ts.map +0 -1
  253. package/dest/ha-signing/types.js +0 -32
  254. package/dest/kv-store/config.d.ts +0 -17
  255. package/dest/kv-store/config.d.ts.map +0 -1
  256. package/dest/kv-store/config.js +0 -26
  257. package/dest/kv-store/index.d.ts +0 -2
  258. package/dest/kv-store/index.d.ts.map +0 -1
  259. package/dest/kv-store/index.js +0 -1
  260. package/src/ha-signing/config.ts +0 -156
  261. package/src/ha-signing/index.ts +0 -27
  262. package/src/ha-signing/local_config.ts +0 -46
  263. package/src/ha-signing/types.ts +0 -112
  264. package/src/kv-store/config.ts +0 -36
  265. package/src/kv-store/index.ts +0 -1
@@ -22,11 +22,13 @@ export declare function checkCompressedComponentVersion(compressed: string, expe
22
22
  /** Checks that two component versions match. Undefined fields are ignored. */
23
23
  export declare function validatePartialComponentVersionsMatch(expected: Partial<ComponentsVersions>, actual: Partial<ComponentsVersions>): void;
24
24
  /** Returns a Koa middleware that injects the versioning info as headers. */
25
- export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions>): (ctx: Koa.Context, next: () => Promise<void>) => Promise<void>;
25
+ export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: {
26
+ packageVersion?: string;
27
+ }): (ctx: Koa.Context, next: () => Promise<void>) => Promise<void>;
26
28
  /** Returns a json rpc client handler that rejects responses with mismatching versions. */
27
29
  export declare function getVersioningResponseHandler(versions: Partial<ComponentsVersions>): ({ headers }: {
28
30
  headers: {
29
31
  get: (header: string) => string | null | undefined;
30
32
  };
31
33
  }) => Promise<void>;
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbmluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ZlcnNpb25pbmcvdmVyc2lvbmluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssR0FBRyxNQUFNLEtBQUssQ0FBQztBQUUzQixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU3RCw4SUFBOEk7QUFDOUksTUFBTSxNQUFNLGtCQUFrQixHQUFHO0lBQy9CLFNBQVMsRUFBR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UAAU,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,qDAAqD;AACrD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,WAAW,EACnB,uBAAuB,EAAE,MAAM,GAAG,EAAE,EACpC,oBAAoB,EAAE,MAAM,GAAG,EAAE,GAChC,kBAAkB,CAQpB;AAED,qGAAqG;AACrG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAiB9E;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAGvD;CACF;AAED,iGAAiG;AACjG,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,QA6B/F;AAED,8EAA8E;AAC9E,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,EACrC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,QAiBpC;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,kEAkBhH;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;;;;oBAajF"}
@@ -65,7 +65,7 @@ export class ComponentsVersionsError extends Error {
65
65
  }
66
66
  }
67
67
  }
68
- /** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions) {
68
+ /** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions, opts) {
69
69
  return async (ctx, next)=>{
70
70
  try {
71
71
  await next();
@@ -78,6 +78,9 @@ export class ComponentsVersionsError extends Error {
78
78
  ctx.set(`x-aztec-${key}`, value.toString());
79
79
  }
80
80
  }
81
+ if (opts?.packageVersion) {
82
+ ctx.set('x-aztec-packageVersion', opts.packageVersion);
83
+ }
81
84
  }
82
85
  };
83
86
  }
@@ -22,7 +22,7 @@ export class VkData {
22
22
  }
23
23
  static fromBuffer(buffer) {
24
24
  const reader = BufferReader.asReader(buffer);
25
- return new VkData(reader.readObject(VerificationKeyData), reader.readNumber(), reader.readArray(VK_TREE_HEIGHT, Fr));
25
+ return new VkData(reader.readObject(VerificationKeyData), reader.readNumber(), reader.readTuple(VK_TREE_HEIGHT, Fr));
26
26
  }
27
27
  toBuffer() {
28
28
  return serializeToBuffer(this.vk, this.leafIndex, this.siblingPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "0.0.1-commit.ffe5b04ea",
3
+ "version": "0.0.1-commit.fff30aa",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -55,7 +55,6 @@
55
55
  "./database-version/version": "./dest/database-version/database_version.js",
56
56
  "./database-version/manager": "./dest/database-version/version_manager.js",
57
57
  "./validators": "./dest/validators/index.js",
58
- "./ha-signing": "./dest/ha-signing/index.js",
59
58
  "./file-store": "./dest/file-store/index.js",
60
59
  "./snapshots": "./dest/snapshots/index.js",
61
60
  "./update-checker": "./dest/update-checker/index.js",
@@ -63,8 +62,7 @@
63
62
  "./slashing": "./dest/slashing/index.js",
64
63
  "./l1-contracts": "./dest/l1-contracts/index.js",
65
64
  "./world-state": "./dest/world-state/index.js",
66
- "./timetable": "./dest/timetable/index.js",
67
- "./kv-store": "./dest/kv-store/index.js"
65
+ "./timetable": "./dest/timetable/index.js"
68
66
  },
69
67
  "typedocOptions": {
70
68
  "entryPoints": [
@@ -92,13 +90,14 @@
92
90
  },
93
91
  "dependencies": {
94
92
  "@aws-sdk/client-s3": "^3.892.0",
95
- "@aztec/bb.js": "0.0.1-commit.ffe5b04ea",
96
- "@aztec/blob-lib": "0.0.1-commit.ffe5b04ea",
97
- "@aztec/constants": "0.0.1-commit.ffe5b04ea",
98
- "@aztec/ethereum": "0.0.1-commit.ffe5b04ea",
99
- "@aztec/foundation": "0.0.1-commit.ffe5b04ea",
100
- "@aztec/l1-artifacts": "0.0.1-commit.ffe5b04ea",
101
- "@aztec/noir-noirc_abi": "0.0.1-commit.ffe5b04ea",
93
+ "@aztec/bb.js": "0.0.1-commit.fff30aa",
94
+ "@aztec/blob-lib": "0.0.1-commit.fff30aa",
95
+ "@aztec/constants": "0.0.1-commit.fff30aa",
96
+ "@aztec/ethereum": "0.0.1-commit.fff30aa",
97
+ "@aztec/foundation": "0.0.1-commit.fff30aa",
98
+ "@aztec/l1-artifacts": "0.0.1-commit.fff30aa",
99
+ "@aztec/noir-noirc_abi": "0.0.1-commit.fff30aa",
100
+ "@aztec/validator-ha-signer": "0.0.1-commit.fff30aa",
102
101
  "@google-cloud/storage": "^7.15.0",
103
102
  "axios": "^1.13.5",
104
103
  "json-stringify-deterministic": "1.0.12",
package/src/abi/abi.ts CHANGED
@@ -224,7 +224,20 @@ export const FunctionDebugMetadataSchema = z.object({
224
224
  acir_locations: z.record(z.number()),
225
225
  brillig_locations: z.record(z.record(z.number())),
226
226
  }),
227
- files: z.record(z.object({ source: z.string(), path: z.string() })),
227
+ // `function_locations` is required in the static `DebugFileMap` type (noir-types compat), but legacy v4-next
228
+ // artifacts were compiled before this field existed — see {@link fillMissingFunctionLocations} for the full
229
+ // rationale. The preprocessor injects `[]` for missing entries so parsing succeeds; the cast restores the
230
+ // output type since `z.preprocess` widens the schema's input type to `unknown`.
231
+ files: z.preprocess(
232
+ fillMissingFunctionLocations,
233
+ z.record(
234
+ z.object({
235
+ source: z.string(),
236
+ path: z.string(),
237
+ function_locations: z.array(z.object({ start: z.number(), name: z.string() })),
238
+ }),
239
+ ),
240
+ ) as z.ZodType<DebugFileMap>,
228
241
  }) satisfies z.ZodType<FunctionDebugMetadata>;
229
242
 
230
243
  /** The artifact entry of a function. */
@@ -305,6 +318,14 @@ export interface ProgramDebugInfo {
305
318
  debug_infos: Array<DebugInfo>;
306
319
  }
307
320
 
321
+ /** The range a function occupies in a file. */
322
+ export type FunctionLocation = {
323
+ /** The byte where the function starts. */
324
+ start: number;
325
+ /** The name of the function. */
326
+ name: string;
327
+ };
328
+
308
329
  /** Maps a file ID to its metadata for debugging purposes. */
309
330
  export type DebugFileMap = Record<
310
331
  FileId,
@@ -313,9 +334,50 @@ export type DebugFileMap = Record<
313
334
  source: string;
314
335
  /** The path of the file. */
315
336
  path: string;
337
+ /** The range each function occupies in the file. */
338
+ function_locations: FunctionLocation[];
316
339
  }
317
340
  >;
318
341
 
342
+ /**
343
+ * Preprocessor for {@link FunctionDebugMetadataSchema} / {@link ContractArtifactSchema} that injects an empty
344
+ * `function_locations` array on any file map entry missing it. Invoked via `z.preprocess(...)` before the strict
345
+ * object schema runs, so legacy inputs do not fail validation.
346
+ *
347
+ * Why this exists on v4-next (and not on `next` / v5):
348
+ *
349
+ * - The Noir submodule on `next` was bumped past nightly-2026-03-19, which added `function_locations` to the
350
+ * debug file map in the Noir `@aztec/noir-types` package and to every freshly-compiled artifact's `file_map`
351
+ * entries. The matching stdlib change (making `DebugFileMap.function_locations` required) was done in one
352
+ * go on `next`, so there `function_locations` is always present both at compile time and at runtime.
353
+ *
354
+ * - On v4-next we had to cherry-pick the Noir bump (chore: Update Noir to nightly-2026-04-10 (#22393)) without
355
+ * re-running the full noir-projects compilation pipeline, so the on-disk contract and protocol-circuit
356
+ * artifacts (e.g. `yarn-project/protocol-contracts/artifacts/AuthRegistry.json`) still carry the pre-update
357
+ * `file_map` shape with only `source` + `path`. Separately, `ivc-integration` compares our `DebugFileMap`
358
+ * against the Noir-types `DebugFileMap`, which *does* require `function_locations`, so we cannot simply make
359
+ * our own field optional — that would break the structural compatibility check.
360
+ *
361
+ * - To satisfy both constraints at once we keep `function_locations` required in the static TypeScript type
362
+ * (so `ivc-integration` keeps compiling) but relax the runtime input shape via this preprocessor (so legacy
363
+ * artifacts keep parsing). Once all v4-next artifacts get regenerated with the new Noir compiler, this
364
+ * helper — and both `z.preprocess(...)` wrappers — can be removed.
365
+ */
366
+ function fillMissingFunctionLocations(val: unknown): unknown {
367
+ if (val && typeof val === 'object') {
368
+ for (const entry of Object.values(val as Record<string, unknown>)) {
369
+ if (
370
+ entry &&
371
+ typeof entry === 'object' &&
372
+ (entry as { function_locations?: unknown }).function_locations === undefined
373
+ ) {
374
+ (entry as { function_locations: FunctionLocation[] }).function_locations = [];
375
+ }
376
+ }
377
+ }
378
+ return val;
379
+ }
380
+
319
381
  /** Type representing a field layout in the storage of a contract. */
320
382
  export type FieldLayout = {
321
383
  /** Slot in which the field is stored. */
@@ -367,7 +429,21 @@ export const ContractArtifactSchema = zodFor<ContractArtifact>()(
367
429
  globals: z.record(z.array(AbiValueSchema)),
368
430
  }),
369
431
  storageLayout: z.record(z.object({ slot: schemas.Fr })),
370
- fileMap: z.record(z.coerce.number(), z.object({ source: z.string(), path: z.string() })),
432
+ // Legacy v4-next contract artifacts (e.g. `protocol-contracts/artifacts/AuthRegistry.json`) were emitted
433
+ // before Noir started including `function_locations` in their `file_map` entries — see
434
+ // {@link fillMissingFunctionLocations} for the full rationale. The preprocessor injects `[]` for missing
435
+ // entries so parsing succeeds without weakening the static `DebugFileMap` type.
436
+ fileMap: z.preprocess(
437
+ fillMissingFunctionLocations,
438
+ z.record(
439
+ z.coerce.number(),
440
+ z.object({
441
+ source: z.string(),
442
+ path: z.string(),
443
+ function_locations: z.array(z.object({ start: z.number(), name: z.string() })),
444
+ }),
445
+ ),
446
+ ),
371
447
  }),
372
448
  );
373
449
 
package/src/abi/buffer.ts CHANGED
@@ -26,11 +26,32 @@ export function bufferAsFields(input: Buffer, targetLength: number): Fr[] {
26
26
  }
27
27
 
28
28
  /**
29
- * Recovers a buffer from an array of fields.
30
- * @param fields - An output from bufferAsFields.
31
- * @returns The recovered buffer.
29
+ * Recovers a buffer from an array of fields previously encoded with bufferAsFields.
30
+ *
31
+ * The first field encodes the byte length of the original buffer. The remaining fields
32
+ * each carry 31 bytes of payload (the leading byte of each 32-byte field element is skipped).
33
+ *
34
+ * If the declared byte length exceeds the bytes available from the payload fields, the result
35
+ * is zero-padded to the full declared length. This is important for correctness when the field
36
+ * array has been truncated (e.g. contract class logs reconstructed from blobs using a short
37
+ * emittedLength): without padding, the resulting buffer would be shorter than declared, causing
38
+ * bytecode commitment computations to diverge from what the circuit produced.
39
+ *
40
+ * @param fields - An output from bufferAsFields: [byteLength, ...payloadFields].
41
+ * @returns A buffer of exactly `byteLength` bytes.
32
42
  */
33
43
  export function bufferFromFields(fields: Fr[]): Buffer {
34
44
  const [length, ...payload] = fields;
35
- return Buffer.concat(payload.map(f => f.toBuffer().subarray(1))).subarray(0, length.toNumber());
45
+ const byteLength = length.toNumber();
46
+ const raw = Buffer.concat(payload.map(f => f.toBuffer().subarray(1)));
47
+ if (raw.length >= byteLength) {
48
+ return raw.subarray(0, byteLength);
49
+ }
50
+ // Pad with zeros if the declared length exceeds the available payload bytes.
51
+ // This ensures the returned buffer always matches the declared length, so that
52
+ // downstream bytecode commitment computations are consistent even when the
53
+ // source field array was truncated (e.g. reconstructed from blob with a short emittedLength).
54
+ const result = Buffer.alloc(byteLength);
55
+ raw.copy(result);
56
+ return result;
36
57
  }
@@ -1,8 +1,17 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
3
 
3
4
  import { AztecAddress } from '../aztec-address/index.js';
4
- import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
5
- import { isAztecAddressStruct, isOptionStruct, parseSignedInt } from './utils.js';
5
+ import type { AbiType } from './abi.js';
6
+ import { FunctionSelector } from './function_selector.js';
7
+ import {
8
+ isAztecAddressStruct,
9
+ isEthAddressStruct,
10
+ isFunctionSelectorStruct,
11
+ isOptionStruct,
12
+ isWrappedFieldStruct,
13
+ parseSignedInt,
14
+ } from './utils.js';
6
15
 
7
16
  /**
8
17
  * The type of our decoded ABI.
@@ -12,6 +21,9 @@ export type AbiDecoded =
12
21
  | boolean
13
22
  | string
14
23
  | AztecAddress
24
+ | EthAddress
25
+ | FunctionSelector
26
+ | Fr
15
27
  | AbiDecoded[]
16
28
  | { [key: string]: AbiDecoded }
17
29
  | undefined;
@@ -58,6 +70,15 @@ class AbiDecoder {
58
70
  if (isAztecAddressStruct(abiType)) {
59
71
  return new AztecAddress(this.getNextField().toBuffer());
60
72
  }
73
+ if (isEthAddressStruct(abiType)) {
74
+ return EthAddress.fromField(this.getNextField());
75
+ }
76
+ if (isFunctionSelectorStruct(abiType)) {
77
+ return FunctionSelector.fromField(this.getNextField());
78
+ }
79
+ if (isWrappedFieldStruct(abiType)) {
80
+ return this.getNextField();
81
+ }
61
82
  if (isOptionStruct(abiType)) {
62
83
  const isSome = this.decodeNext(abiType.fields[0].type);
63
84
  const value = this.decodeNext(abiType.fields[1].type);
@@ -123,79 +144,3 @@ class AbiDecoder {
123
144
  export function decodeFromAbi(typ: AbiType[], buffer: Fr[]) {
124
145
  return new AbiDecoder(typ, buffer.slice()).decode();
125
146
  }
126
-
127
- /**
128
- * Decodes the signature of a function from the name and parameters.
129
- */
130
- export class FunctionSignatureDecoder {
131
- private separator: string;
132
- constructor(
133
- private name: string,
134
- private parameters: ABIParameter[],
135
- private includeNames = false,
136
- ) {
137
- this.separator = includeNames ? ', ' : ',';
138
- }
139
-
140
- /**
141
- * Decodes a single function parameter type for the function signature.
142
- * @param param - The parameter type to decode.
143
- * @returns A string representing the parameter type.
144
- */
145
- private getParameterType(param: AbiType): string {
146
- switch (param.kind) {
147
- case 'field':
148
- return 'Field';
149
- case 'integer':
150
- return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
151
- case 'boolean':
152
- return 'bool';
153
- case 'array':
154
- return `[${this.getParameterType(param.type)};${param.length}]`;
155
- case 'string':
156
- return `str<${param.length}>`;
157
- case 'struct':
158
- return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
159
- default:
160
- throw new Error(`Unsupported type: ${param.kind}`);
161
- }
162
- }
163
-
164
- /**
165
- * Decodes a single function parameter for the function signature.
166
- * @param param - The parameter to decode.
167
- * @returns A string representing the parameter type and optionally its name.
168
- */
169
- private decodeParameter(param: ABIVariable): string {
170
- const type = this.getParameterType(param.type);
171
- return this.includeNames ? `${param.name}: ${type}` : type;
172
- }
173
-
174
- /**
175
- * Decodes all the parameters and build the function signature
176
- * @returns The function signature.
177
- */
178
- public decode(): string {
179
- return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
180
- }
181
- }
182
-
183
- /**
184
- * Decodes a function signature from the name and parameters.
185
- * @param name - The name of the function.
186
- * @param parameters - The parameters of the function.
187
- * @returns - The function signature.
188
- */
189
- export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
190
- return new FunctionSignatureDecoder(name, parameters).decode();
191
- }
192
-
193
- /**
194
- * Decodes a function signature from the name and parameters including parameter names.
195
- * @param name - The name of the function.
196
- * @param parameters - The parameters of the function.
197
- * @returns - The user-friendly function signature.
198
- */
199
- export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
200
- return new FunctionSignatureDecoder(name, parameters, true).decode();
201
- }
@@ -6,7 +6,7 @@ import { type ZodFor, hexSchemaFor } from '@aztec/foundation/schemas';
6
6
  import { BufferReader, FieldReader, TypeRegistry } from '@aztec/foundation/serialize';
7
7
 
8
8
  import type { ABIParameter } from './abi.js';
9
- import { decodeFunctionSignature } from './decoder.js';
9
+ import { decodeFunctionSignature } from './function_signature_decoder.js';
10
10
  import { Selector } from './selector.js';
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
@@ -0,0 +1,77 @@
1
+ import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
2
+
3
+ /**
4
+ * Decodes the signature of a function from the name and parameters.
5
+ */
6
+ export class FunctionSignatureDecoder {
7
+ private separator: string;
8
+ constructor(
9
+ private name: string,
10
+ private parameters: ABIParameter[],
11
+ private includeNames = false,
12
+ ) {
13
+ this.separator = includeNames ? ', ' : ',';
14
+ }
15
+
16
+ /**
17
+ * Decodes a single function parameter type for the function signature.
18
+ * @param param - The parameter type to decode.
19
+ * @returns A string representing the parameter type.
20
+ */
21
+ private getParameterType(param: AbiType): string {
22
+ switch (param.kind) {
23
+ case 'field':
24
+ return 'Field';
25
+ case 'integer':
26
+ return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
27
+ case 'boolean':
28
+ return 'bool';
29
+ case 'array':
30
+ return `[${this.getParameterType(param.type)};${param.length}]`;
31
+ case 'string':
32
+ return `str<${param.length}>`;
33
+ case 'struct':
34
+ return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
35
+ default:
36
+ throw new Error(`Unsupported type: ${param.kind}`);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Decodes a single function parameter for the function signature.
42
+ * @param param - The parameter to decode.
43
+ * @returns A string representing the parameter type and optionally its name.
44
+ */
45
+ private decodeParameter(param: ABIVariable): string {
46
+ const type = this.getParameterType(param.type);
47
+ return this.includeNames ? `${param.name}: ${type}` : type;
48
+ }
49
+
50
+ /**
51
+ * Decodes all the parameters and build the function signature
52
+ * @returns The function signature.
53
+ */
54
+ public decode(): string {
55
+ return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Decodes a function signature from the name and parameters.
61
+ * @param name - The name of the function.
62
+ * @param parameters - The parameters of the function.
63
+ * @returns - The function signature.
64
+ */
65
+ export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
66
+ return new FunctionSignatureDecoder(name, parameters).decode();
67
+ }
68
+
69
+ /**
70
+ * Decodes a function signature from the name and parameters including parameter names.
71
+ * @param name - The name of the function.
72
+ * @param parameters - The parameters of the function.
73
+ * @returns - The user-friendly function signature.
74
+ */
75
+ export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
76
+ return new FunctionSignatureDecoder(name, parameters, true).decode();
77
+ }
package/src/abi/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abi.js';
2
2
  export * from './buffer.js';
3
3
  export * from './decoder.js';
4
+ export * from './function_signature_decoder.js';
4
5
  export * from './encoder.js';
5
6
  export * from './authorization_selector.js';
6
7
  export * from './event_metadata_definition.js';
@@ -4,7 +4,7 @@ import { bufferToHex } from '@aztec/foundation/string';
4
4
 
5
5
  import { inspect } from 'util';
6
6
 
7
- /** A selector is the first 4 bytes of the hash of a signature. */
7
+ /** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
8
8
  export abstract class Selector {
9
9
  /** The size of the selector in bytes. */
10
10
  public static SIZE = 4;
@@ -88,11 +88,11 @@ export class AvmAccumulatedData {
88
88
  static fromBuffer(buffer: Buffer | BufferReader) {
89
89
  const reader = BufferReader.asReader(buffer);
90
90
  return new this(
91
- reader.readArray(MAX_NOTE_HASHES_PER_TX, Fr),
92
- reader.readArray(MAX_NULLIFIERS_PER_TX, Fr),
93
- reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
91
+ reader.readTuple(MAX_NOTE_HASHES_PER_TX, Fr),
92
+ reader.readTuple(MAX_NULLIFIERS_PER_TX, Fr),
93
+ reader.readTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
94
94
  reader.readObject(FlatPublicLogs),
95
- reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
95
+ reader.readTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
96
96
  );
97
97
  }
98
98
 
@@ -115,9 +115,9 @@ export class AvmAccumulatedData {
115
115
  return new this(
116
116
  reader.readFieldArray(MAX_NOTE_HASHES_PER_TX),
117
117
  reader.readFieldArray(MAX_NULLIFIERS_PER_TX),
118
- reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
118
+ reader.readTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
119
119
  reader.readObject(FlatPublicLogs),
120
- reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
120
+ reader.readTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
121
121
  );
122
122
  }
123
123
 
@@ -143,8 +143,8 @@ export class AvmCircuitPublicInputs {
143
143
  reader.readObject(AztecAddress),
144
144
  reader.readObject(Fr),
145
145
  reader.readObject(PublicCallRequestArrayLengths),
146
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
147
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
146
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
147
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
148
148
  reader.readObject(PublicCallRequest),
149
149
  reader.readObject(PrivateToAvmAccumulatedDataArrayLengths),
150
150
  reader.readObject(PrivateToAvmAccumulatedDataArrayLengths),
@@ -206,8 +206,8 @@ export class AvmCircuitPublicInputs {
206
206
  AztecAddress.fromFields(reader),
207
207
  reader.readField(),
208
208
  PublicCallRequestArrayLengths.fromFields(reader),
209
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
210
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
209
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
210
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
211
211
  PublicCallRequest.fromFields(reader),
212
212
  PrivateToAvmAccumulatedDataArrayLengths.fromFields(reader),
213
213
  PrivateToAvmAccumulatedDataArrayLengths.fromFields(reader),
@@ -5,35 +5,17 @@ import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
5
5
  import { inspect } from 'util';
6
6
  import { z } from 'zod';
7
7
 
8
- /**
9
- * Tracks which revertible phases of a transaction's public execution reverted.
10
- *
11
- * A transaction executes in three sequential phases:
12
- * 1. SETUP – non-revertible; if this fails the entire transaction is rejected.
13
- * 2. APP_LOGIC – revertible; its state changes are rolled back on failure.
14
- * 3. TEARDOWN – revertible; always runs (even after app-logic revert) so the fee-payment contract can clean up.
15
- *
16
- * Only APP_LOGIC and TEARDOWN can produce a revert code. SETUP failures throw instead and discard the transaction
17
- * entirely.
18
- */
8
+ /** Whether a transaction's public execution reverted. */
19
9
  export enum RevertCodeEnum {
20
10
  /** All phases completed successfully; no state was rolled back. */
21
11
  OK = 0,
22
- /** APP_LOGIC reverted; its state changes were discarded. If present, TEARDOWN still ran and succeeded. */
23
- APP_LOGIC_REVERTED = 1,
24
- /** TEARDOWN reverted; its state changes were discarded. APP_LOGIC succeeded. */
25
- TEARDOWN_REVERTED = 2,
26
- /** Both APP_LOGIC and TEARDOWN reverted; only SETUP effects are kept. */
27
- BOTH_REVERTED = 3,
12
+ /** One or more revertible phases reverted; their state changes were discarded. */
13
+ REVERTED = 1,
28
14
  }
29
15
 
30
- function isRevertCodeEnum(value: number): value is RevertCodeEnum {
31
- return (
32
- (value as RevertCodeEnum) === RevertCodeEnum.OK ||
33
- (value as RevertCodeEnum) === RevertCodeEnum.APP_LOGIC_REVERTED ||
34
- (value as RevertCodeEnum) === RevertCodeEnum.TEARDOWN_REVERTED ||
35
- (value as RevertCodeEnum) === RevertCodeEnum.BOTH_REVERTED
36
- );
16
+ /** Returns a valid RevertCodeEnum, coercing any value >= 1 to REVERTED. */
17
+ function toRevertCodeEnum(value: number): RevertCodeEnum {
18
+ return value >= 1 ? RevertCodeEnum.REVERTED : RevertCodeEnum.OK;
37
19
  }
38
20
 
39
21
  /**
@@ -45,9 +27,13 @@ export class RevertCode {
45
27
  this.code = e.valueOf();
46
28
  }
47
29
  static readonly OK: RevertCode = new RevertCode(RevertCodeEnum.OK);
48
- static readonly APP_LOGIC_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.APP_LOGIC_REVERTED);
49
- static readonly TEARDOWN_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.TEARDOWN_REVERTED);
50
- static readonly BOTH_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.BOTH_REVERTED);
30
+ static readonly REVERTED: RevertCode = new RevertCode(RevertCodeEnum.REVERTED);
31
+ /** @deprecated Use REVERTED instead. */
32
+ static readonly APP_LOGIC_REVERTED: RevertCode = RevertCode.REVERTED;
33
+ /** @deprecated Use REVERTED instead. */
34
+ static readonly TEARDOWN_REVERTED: RevertCode = RevertCode.REVERTED;
35
+ /** @deprecated Use REVERTED instead. */
36
+ static readonly BOTH_REVERTED: RevertCode = RevertCode.REVERTED;
51
37
 
52
38
  public getCode(): RevertCodeEnum {
53
39
  return this.code;
@@ -65,12 +51,8 @@ export class RevertCode {
65
51
  switch (this.code as RevertCodeEnum) {
66
52
  case RevertCodeEnum.OK:
67
53
  return 'OK';
68
- case RevertCodeEnum.APP_LOGIC_REVERTED:
69
- return 'Application logic reverted';
70
- case RevertCodeEnum.TEARDOWN_REVERTED:
71
- return 'Teardown reverted';
72
- case RevertCodeEnum.BOTH_REVERTED:
73
- return 'Both reverted';
54
+ case RevertCodeEnum.REVERTED:
55
+ return 'Reverted';
74
56
  default:
75
57
  return `Unknown RevertCode: ${this.code}`;
76
58
  }
@@ -81,7 +63,11 @@ export class RevertCode {
81
63
  }
82
64
 
83
65
  static get schema(): ZodFor<RevertCode> {
84
- return z.nativeEnum(RevertCodeEnum).transform(value => new RevertCode(value));
66
+ return z
67
+ .number()
68
+ .int()
69
+ .min(0)
70
+ .transform(value => new RevertCode(toRevertCodeEnum(value)));
85
71
  }
86
72
 
87
73
  /**
@@ -96,10 +82,10 @@ export class RevertCode {
96
82
  return obj;
97
83
  }
98
84
  const code = typeof obj === 'number' ? obj : (obj.code ?? obj);
99
- if (!isRevertCodeEnum(code)) {
85
+ if (typeof code !== 'number' || code < 0) {
100
86
  throw new Error(`Invalid RevertCode: ${code}`);
101
87
  }
102
- return new RevertCode(code);
88
+ return new RevertCode(toRevertCodeEnum(code));
103
89
  }
104
90
 
105
91
  /**
@@ -131,10 +117,10 @@ export class RevertCode {
131
117
  }
132
118
 
133
119
  public static fromNumber(code: number): RevertCode {
134
- if (!isRevertCodeEnum(code)) {
120
+ if (code < 0) {
135
121
  throw new Error(`Invalid RevertCode: ${code}`);
136
122
  }
137
- return new RevertCode(code);
123
+ return new RevertCode(toRevertCodeEnum(code));
138
124
  }
139
125
 
140
126
  public static fromField(field: Fr): RevertCode {
@@ -152,7 +138,7 @@ export class RevertCode {
152
138
  return RevertCode.fromNumber(code);
153
139
  }
154
140
 
155
- private static readonly NUM_OPTIONS = 4;
141
+ private static readonly NUM_OPTIONS = 2;
156
142
  static random(): RevertCode {
157
143
  return new RevertCode(Math.floor(Math.random() * RevertCode.NUM_OPTIONS));
158
144
  }