@aztec/pxe 5.0.0-rc.2 → 5.0.1

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 (229) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  4. package/dest/contract/contract_class_service.d.ts +31 -0
  5. package/dest/contract/contract_class_service.d.ts.map +1 -0
  6. package/dest/contract/contract_class_service.js +68 -0
  7. package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
  8. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  9. package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
  10. package/dest/contract/helpers.d.ts +7 -0
  11. package/dest/contract/helpers.d.ts.map +1 -0
  12. package/dest/contract/helpers.js +20 -0
  13. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  14. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  15. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  16. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  17. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  19. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/contract_function_simulator.js +31 -14
  22. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  23. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  25. package/dest/contract_function_simulator/index.d.ts +4 -2
  26. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/index.js +2 -1
  28. package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
  29. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
  31. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
  32. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  37. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  39. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
  40. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -1
  42. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
  43. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
  45. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
  46. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
  48. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  49. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  51. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +11 -7
  52. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  53. package/dest/contract_function_simulator/oracle/oracle_registry.js +50 -10
  54. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
  55. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  56. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -16
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +105 -60
  63. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  64. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  65. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  66. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  67. package/dest/entrypoints/client/bundle/index.js +1 -0
  68. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  69. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  70. package/dest/entrypoints/client/bundle/utils.js +11 -5
  71. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  72. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  73. package/dest/entrypoints/client/lazy/index.js +1 -0
  74. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  75. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  76. package/dest/entrypoints/client/lazy/utils.js +11 -5
  77. package/dest/entrypoints/client/store.d.ts +14 -0
  78. package/dest/entrypoints/client/store.d.ts.map +1 -0
  79. package/dest/entrypoints/client/store.js +28 -0
  80. package/dest/entrypoints/server/index.d.ts +6 -2
  81. package/dest/entrypoints/server/index.d.ts.map +1 -1
  82. package/dest/entrypoints/server/index.js +4 -1
  83. package/dest/entrypoints/server/store.d.ts +18 -0
  84. package/dest/entrypoints/server/store.d.ts.map +1 -0
  85. package/dest/entrypoints/server/store.js +28 -0
  86. package/dest/entrypoints/server/utils.d.ts +1 -1
  87. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  88. package/dest/entrypoints/server/utils.js +8 -2
  89. package/dest/error_enriching.d.ts +5 -3
  90. package/dest/error_enriching.d.ts.map +1 -1
  91. package/dest/error_enriching.js +12 -10
  92. package/dest/hooks/execution_hooks.d.ts +15 -4
  93. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  94. package/dest/hooks/index.d.ts +3 -2
  95. package/dest/hooks/index.d.ts.map +1 -1
  96. package/dest/hooks/index.js +1 -0
  97. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  98. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  99. package/dest/hooks/resolve_custom_request.js +3 -0
  100. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
  101. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
  102. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
  103. package/dest/logs/log_service.d.ts +5 -3
  104. package/dest/logs/log_service.d.ts.map +1 -1
  105. package/dest/logs/log_service.js +38 -17
  106. package/dest/notes/note_service.d.ts +1 -1
  107. package/dest/notes/note_service.js +1 -1
  108. package/dest/oracle_version.d.ts +2 -2
  109. package/dest/oracle_version.js +2 -2
  110. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  111. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  112. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  113. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  114. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  115. package/dest/private_kernel/private_kernel_execution_prover.js +17 -36
  116. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  117. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  118. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  119. package/dest/pxe.d.ts +81 -46
  120. package/dest/pxe.d.ts.map +1 -1
  121. package/dest/pxe.js +138 -104
  122. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  123. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  124. package/dest/storage/backwards_compatibility_tests/schema_tests.js +31 -7
  125. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  126. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  127. package/dest/storage/contract_store/contract_store.js +63 -74
  128. package/dest/storage/fact_store/fact_service.d.ts +6 -4
  129. package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
  130. package/dest/storage/fact_store/fact_service.js +19 -4
  131. package/dest/storage/fact_store/fact_store.d.ts +1 -1
  132. package/dest/storage/fact_store/fact_store.js +1 -1
  133. package/dest/storage/fact_store/index.d.ts +2 -1
  134. package/dest/storage/fact_store/index.d.ts.map +1 -1
  135. package/dest/storage/fact_store/index.js +1 -0
  136. package/dest/storage/fact_store/origin_state.d.ts +57 -0
  137. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  138. package/dest/storage/fact_store/origin_state.js +53 -0
  139. package/dest/storage/metadata.d.ts +2 -2
  140. package/dest/storage/metadata.d.ts.map +1 -1
  141. package/dest/storage/metadata.js +1 -1
  142. package/dest/storage/store_identity.d.ts +35 -0
  143. package/dest/storage/store_identity.d.ts.map +1 -0
  144. package/dest/storage/store_identity.js +44 -0
  145. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
  146. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  147. package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
  148. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
  149. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
  150. package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
  151. package/dest/tagging/constants.d.ts +2 -2
  152. package/dest/tagging/constants.d.ts.map +1 -1
  153. package/dest/tagging/constants.js +18 -9
  154. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
  155. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
  156. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  157. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +6 -2
  158. package/package.json +17 -17
  159. package/src/block_synchronizer/block_synchronizer.ts +9 -1
  160. package/src/contract/contract_class_service.ts +83 -0
  161. package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
  162. package/src/contract/helpers.ts +35 -0
  163. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  164. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  165. package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
  166. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  167. package/src/contract_function_simulator/index.ts +7 -1
  168. package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
  169. package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
  170. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
  171. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  172. package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
  173. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
  174. package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
  175. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  176. package/src/contract_function_simulator/oracle/oracle_registry.ts +37 -7
  177. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
  178. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
  179. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +149 -71
  180. package/src/debug/pxe_debug_utils.ts +1 -1
  181. package/src/entrypoints/client/bundle/index.ts +1 -0
  182. package/src/entrypoints/client/bundle/utils.ts +16 -4
  183. package/src/entrypoints/client/lazy/index.ts +1 -0
  184. package/src/entrypoints/client/lazy/utils.ts +16 -4
  185. package/src/entrypoints/client/store.ts +38 -0
  186. package/src/entrypoints/server/index.ts +6 -1
  187. package/src/entrypoints/server/store.ts +47 -0
  188. package/src/entrypoints/server/utils.ts +21 -7
  189. package/src/error_enriching.ts +26 -10
  190. package/src/hooks/execution_hooks.ts +14 -3
  191. package/src/hooks/index.ts +2 -0
  192. package/src/hooks/resolve_custom_request.ts +24 -0
  193. package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
  194. package/src/logs/log_service.ts +35 -11
  195. package/src/notes/note_service.ts +1 -1
  196. package/src/oracle_version.ts +2 -2
  197. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  198. package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
  199. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  200. package/src/pxe.ts +212 -143
  201. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  202. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  203. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  204. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  205. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  206. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
  207. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
  208. package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
  209. package/src/storage/contract_store/contract_store.ts +85 -92
  210. package/src/storage/fact_store/fact_service.ts +29 -5
  211. package/src/storage/fact_store/fact_store.ts +1 -1
  212. package/src/storage/fact_store/index.ts +10 -0
  213. package/src/storage/fact_store/origin_state.ts +75 -0
  214. package/src/storage/metadata.ts +1 -1
  215. package/src/storage/store_identity.ts +72 -0
  216. package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
  217. package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
  218. package/src/tagging/constants.ts +19 -9
  219. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
  220. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
  221. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  222. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  223. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  224. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  225. package/dest/contract_sync/helpers.d.ts +0 -28
  226. package/dest/contract_sync/helpers.d.ts.map +0 -1
  227. package/dest/contract_sync/helpers.js +0 -48
  228. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  229. package/src/contract_sync/helpers.ts +0 -79
@@ -2,21 +2,21 @@
2
2
  "complete_addresses": [
3
3
  {
4
4
  "index": 0,
5
- "value": "0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea313ad6965d11a533a663d07507319f74ac3305325f6f72423c0b24aa1193268bb19e95c05f09cb86d1a6257572f9082ca15d4a02373c4d8c9cee23dc61a4c2a882f9017d51bca6616102d8a1d4dba89e4ce12881a2414576f01d2fec9492814a22a1b054e998835d166711839b515d434b1fbc207ad4fdb5b2b43d6ac6b400871019f5bb255e87523d43da83ebc9fa95169b653d4abef902e011e9eac620fc45b14a5d4bde495b8c3a9ba4aed0d4870526e46fdff22d341a2f689ac5a50d103560f124f07811eebfaaa6d31316a2cc5bf255fa118f720e8ff1f2fc0d4aa46d4960000000000000000000000000000000000000000000000000000000000000003"
5
+ "value": "2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce4413ad6965d11a533a663d07507319f74ac3305325f6f72423c0b24aa1193268bb19e95c05f09cb86d1a6257572f9082ca15d4a02373c4d8c9cee23dc61a4c2a882f9017d51bca6616102d8a1d4dba89e4ce12881a2414576f01d2fec9492814a22a1b054e998835d166711839b515d434b1fbc207ad4fdb5b2b43d6ac6b400871019f5bb255e87523d43da83ebc9fa95169b653d4abef902e011e9eac620fc45b1006a921250e1395ef3cfc24c0e57d8f6745e7660ff70a28150f569bf66b8d5b28f331bfc59268b3f8b708104b95ed3a8065805cac8a0bdb622ce038631584c00000000000000000000000000000000000000000000000000000000000000003"
6
6
  },
7
7
  {
8
8
  "index": 1,
9
- "value": "2cf4c6a79bcb041923c0cf1cfbb6c7407e082824e29588dbcf9cc6c1d6e8b01f17c2df1b7355bb4c4494aa4ec85d15ff8881cea1b34691f0cc558e8aef3f3f4c267e526a2e6e9adf6a026989be005bd50d1aea76d20816b9843bc95557696f9f16c3eb259ba3e3eb27b7fe3abc36e87923990bf5c265cb0d57790eda2a4432f105a5449624125d37f10cd4c68ffd57b0dc0cdaa916cb37840be1db9bf88e3c5f0e81754454e3b12035b13448a9fe3b980bf31a9808cb93e146628fb06fa1b46f14a5d4bde495b8c3a9ba4aed0d4870526e46fdff22d341a2f689ac5a50d103560f124f07811eebfaaa6d31316a2cc5bf255fa118f720e8ff1f2fc0d4aa46d4960000000000000000000000000000000000000000000000000000000000000007"
9
+ "value": "1fc97e4d0bb6609f25973d986a7b4787cdbad4fb98c8823591c67e7cd744ba6317c2df1b7355bb4c4494aa4ec85d15ff8881cea1b34691f0cc558e8aef3f3f4c267e526a2e6e9adf6a026989be005bd50d1aea76d20816b9843bc95557696f9f16c3eb259ba3e3eb27b7fe3abc36e87923990bf5c265cb0d57790eda2a4432f105a5449624125d37f10cd4c68ffd57b0dc0cdaa916cb37840be1db9bf88e3c5f0e81754454e3b12035b13448a9fe3b980bf31a9808cb93e146628fb06fa1b46f1694840b143402ffa76cba23e6a9be64b4db084fa804f61940e2d10cf41d273e2475eeff188767ebed988e7d9997d9ed9fe667ff68df9b7143bc663c242929260000000000000000000000000000000000000000000000000000000000000007"
10
10
  }
11
11
  ],
12
12
  "complete_address_index": [
13
13
  {
14
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3",
15
- "value": "num:0"
14
+ "key": "utf8:0x1fc97e4d0bb6609f25973d986a7b4787cdbad4fb98c8823591c67e7cd744ba63",
15
+ "value": "num:1"
16
16
  },
17
17
  {
18
- "key": "utf8:0x2cf4c6a79bcb041923c0cf1cfbb6c7407e082824e29588dbcf9cc6c1d6e8b01f",
19
- "value": "num:1"
18
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44",
19
+ "value": "num:0"
20
20
  }
21
21
  ]
22
22
  }
@@ -22,7 +22,7 @@
22
22
  "contracts_instances": [
23
23
  {
24
24
  "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000065",
25
- "value": "020000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000004f00000000000000000000000000000000000000000000000000000000000000530000000000000000000000000000000000000000000000000000000000000059000000000000000000000000000000000000000000000000000000000000006100000000000000000000000000000000000000000000000000000000000000670000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000035000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000470000000000000000000000000000000000000000000000000000000000000049"
25
+ "value": "020000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000004f0000000000000000000000000000000000000000000000000000000000000059000000000000000000000000000000000000000000000000000000000000006100000000000000000000000000000000000000000000000000000000000000670000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000035000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000470000000000000000000000000000000000000000000000000000000000000049"
26
26
  }
27
27
  ]
28
28
  }
@@ -1,51 +1,51 @@
1
1
  {
2
2
  "key_store": [
3
3
  {
4
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ivpk_m",
4
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ivpk_m",
5
5
  "value": "19e95c05f09cb86d1a6257572f9082ca15d4a02373c4d8c9cee23dc61a4c2a882f9017d51bca6616102d8a1d4dba89e4ce12881a2414576f01d2fec9492814a2"
6
6
  },
7
7
  {
8
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ivpk_m_hash",
8
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ivpk_m_hash",
9
9
  "value": "1fd17152d394f6a43b527c531590888d610d1bcb9aa71a02498ce820bbf4dc62"
10
10
  },
11
11
  {
12
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ivsk_m",
12
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ivsk_m",
13
13
  "value": "1fb01c42d1aaa2662041b899c77cb19e08192193acc5a94405f1b43c974eba7a"
14
14
  },
15
15
  {
16
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-nhk_m",
16
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-nhk_m",
17
17
  "value": "2dd30220767969b10044b1322585bb4c4df4e0c5d9b4d7b3045a879a8e3e91d2"
18
18
  },
19
19
  {
20
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-npk_m",
20
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-npk_m",
21
21
  "value": "214c7a24ddf501afc8734c7379ee502296289eb24cd8cd03cd435e128c06be0000987721e0963b4a5bd81ee862e2740d8849fd90537569064d3d3a4640e858d2"
22
22
  },
23
23
  {
24
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-npk_m_hash",
24
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-npk_m_hash",
25
25
  "value": "13ad6965d11a533a663d07507319f74ac3305325f6f72423c0b24aa1193268bb"
26
26
  },
27
27
  {
28
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ovpk_m",
28
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ovpk_m",
29
29
  "value": "2c19ff0b089b07da436e6f7be6b26cdc17b9cee504a528c071ef6a416299683d0b369479d6e50504702d0b56bb56e4e8e0e77171429896651d0c11621e82ebc3"
30
30
  },
31
31
  {
32
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ovpk_m_hash",
32
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ovpk_m_hash",
33
33
  "value": "2a1b054e998835d166711839b515d434b1fbc207ad4fdb5b2b43d6ac6b400871"
34
34
  },
35
35
  {
36
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-ovsk_m",
36
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-ovsk_m",
37
37
  "value": "279fe6ef7dd2477b919327b1ebab7497c41b9a7ccfa9d5d52e32698e3b85293b"
38
38
  },
39
39
  {
40
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-tpk_m",
40
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-tpk_m",
41
41
  "value": "2fcdd0d194adafd753dc0ed279f5cfb54ddcce1dd581d4631cf343ba9ee6c1ab2858abca6c00da3def156b1f12a6464384e326d5fa724c2fc2ff2b7f3fc8ad5f"
42
42
  },
43
43
  {
44
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-tpk_m_hash",
44
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-tpk_m_hash",
45
45
  "value": "019f5bb255e87523d43da83ebc9fa95169b653d4abef902e011e9eac620fc45b"
46
46
  },
47
47
  {
48
- "key": "utf8:0x0b3683ee9df3ed6ed7027145bd6093f783b0bb4d8354501d906db7bb8cb58ea3-tsk_m",
48
+ "key": "utf8:0x2369ead09116908cedc1642d5e0c714ef288ecbc838e4d434f800a408914ce44-tsk_m",
49
49
  "value": "183cb61099458d1564aa57c90c7091ac623a14092ab314150c9cfbb416810320"
50
50
  }
51
51
  ]
@@ -1,17 +1,25 @@
1
1
  {
2
2
  "highest_aged_index": [
3
3
  {
4
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
4
+ "key": "utf8:constrained:0x0000000000000000000000000000000000000000000000000000000000000013:0x0000000000000000000000000000000000000000000000000000000000000017",
5
+ "value": "num:13"
6
+ },
7
+ {
8
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
5
9
  "value": "num:13"
6
10
  }
7
11
  ],
8
12
  "highest_finalized_index": [
9
13
  {
10
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
14
+ "key": "utf8:constrained:0x0000000000000000000000000000000000000000000000000000000000000013:0x0000000000000000000000000000000000000000000000000000000000000017",
15
+ "value": "num:11"
16
+ },
17
+ {
18
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
11
19
  "value": "num:11"
12
20
  },
13
21
  {
14
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000005:0x0000000000000000000000000000000000000000000000000000000000000007",
22
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000005:0x0000000000000000000000000000000000000000000000000000000000000007",
15
23
  "value": "num:17"
16
24
  }
17
25
  ]
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "pending_indexes": [
3
3
  {
4
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
4
+ "key": "utf8:constrained:0x0000000000000000000000000000000000000000000000000000000000000013:0x0000000000000000000000000000000000000000000000000000000000000017",
5
+ "value": "[{\"lowestIndex\":4,\"highestIndex\":7,\"txHash\":\"0x0000000000000000000000000000000000000000000000000000000000000025\"}]"
6
+ },
7
+ {
8
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
5
9
  "value": "[{\"lowestIndex\":4,\"highestIndex\":7,\"txHash\":\"0x0000000000000000000000000000000000000000000000000000000000000013\"},{\"lowestIndex\":8,\"highestIndex\":11,\"txHash\":\"0x0000000000000000000000000000000000000000000000000000000000000017\"}]"
6
10
  },
7
11
  {
8
- "key": "utf8:0x000000000000000000000000000000000000000000000000000000000000000b:0x000000000000000000000000000000000000000000000000000000000000000d",
12
+ "key": "utf8:unconstrained:0x000000000000000000000000000000000000000000000000000000000000000b:0x000000000000000000000000000000000000000000000000000000000000000d",
9
13
  "value": "[{\"lowestIndex\":1,\"highestIndex\":9,\"txHash\":\"0x000000000000000000000000000000000000000000000000000000000000001d\"}]"
10
14
  }
11
15
  ],
12
16
  "last_finalized_indexes": [
13
17
  {
14
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
18
+ "key": "utf8:constrained:0x0000000000000000000000000000000000000000000000000000000000000013:0x0000000000000000000000000000000000000000000000000000000000000017",
19
+ "value": "num:3"
20
+ },
21
+ {
22
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000002:0x0000000000000000000000000000000000000000000000000000000000000003",
15
23
  "value": "num:3"
16
24
  },
17
25
  {
18
- "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000005:0x0000000000000000000000000000000000000000000000000000000000000007",
26
+ "key": "utf8:unconstrained:0x0000000000000000000000000000000000000000000000000000000000000005:0x0000000000000000000000000000000000000000000000000000000000000007",
19
27
  "value": "num:5"
20
28
  }
21
29
  ]
@@ -16,15 +16,15 @@
16
16
  "recipient_shared_secrets": [
17
17
  {
18
18
  "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000007",
19
- "value": "utf8:0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
19
+ "value": "{\"kind\":\"arbitrary-secret\",\"secret\":\"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003\"}"
20
20
  },
21
21
  {
22
22
  "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000007",
23
- "value": "utf8:0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000007"
23
+ "value": "{\"kind\":\"handshake\",\"secret\":\"0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000007\"}"
24
24
  },
25
25
  {
26
26
  "key": "utf8:0x000000000000000000000000000000000000000000000000000000000000000b",
27
- "value": "utf8:0x000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011"
27
+ "value": "{\"kind\":\"arbitrary-secret\",\"secret\":\"0x000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011\"}"
28
28
  }
29
29
  ]
30
30
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 9,
2
+ "schemaVersion": 13,
3
3
  "stores": [
4
4
  {
5
5
  "name": "capsules",
@@ -15,9 +15,10 @@ import { BlockHash, Body, GENESIS_BLOCK_HEADER_HASH, L2Block } from '@aztec/stdl
15
15
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
16
16
  import { CompleteAddress, SerializableContractInstance } from '@aztec/stdlib/contract';
17
17
  import { GasFees } from '@aztec/stdlib/gas';
18
- import { PublicKey, PublicKeys } from '@aztec/stdlib/keys';
18
+ import { PublicKey, PublicKeys, deriveKeys } from '@aztec/stdlib/keys';
19
19
  import {
20
20
  AppTaggingSecret,
21
+ AppTaggingSecretKind,
21
22
  ContractClassLog,
22
23
  ContractClassLogFields,
23
24
  PrivateLog,
@@ -255,7 +256,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
255
256
  name: 'KeyStore',
256
257
  writeToStore: async kvStore => {
257
258
  const keyStore = new KeyStore(kvStore);
258
- await keyStore.addAccount(new Fr(2n), new Fr(3n));
259
+ await keyStore.addAccount(await deriveKeys(new Fr(2n)), new Fr(3n));
259
260
  },
260
261
  snapshotStore: async kvStore => ({
261
262
  key_store: await snapshotMap(kvStore.openMap<string, Buffer>('key_store')),
@@ -530,10 +531,18 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
530
531
  const jobId = 'fixture-job';
531
532
  const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
532
533
  const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
534
+ // A constrained secret keys under the `constrained:` prefix, so the snapshot pins both kinds side by side.
535
+ const secretConstrained = new AppTaggingSecret(
536
+ new Fr(19n),
537
+ AztecAddress.fromBigIntUnsafe(23n),
538
+ AppTaggingSecretKind.CONSTRAINED,
539
+ );
533
540
 
534
541
  await recipientTaggingStore.updateHighestFinalizedIndex(secretA, 11, jobId);
535
542
  await recipientTaggingStore.updateHighestAgedIndex(secretA, 13, jobId);
536
543
  await recipientTaggingStore.updateHighestFinalizedIndex(secretB, 17, jobId);
544
+ await recipientTaggingStore.updateHighestFinalizedIndex(secretConstrained, 11, jobId);
545
+ await recipientTaggingStore.updateHighestAgedIndex(secretConstrained, 13, jobId);
537
546
  await kvStore.transactionAsync(() => recipientTaggingStore.commit(jobId));
538
547
  },
539
548
  snapshotStore: async kvStore => ({
@@ -553,20 +562,25 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
553
562
 
554
563
  await taggingSecretSourcesStore.addSharedSecret(
555
564
  AztecAddress.fromBigIntUnsafe(7n),
565
+ 'arbitrary-secret',
556
566
  new Point(new Fr(2n), new Fr(3n)),
557
567
  );
558
568
  await taggingSecretSourcesStore.addSharedSecret(
559
569
  AztecAddress.fromBigIntUnsafe(7n),
570
+ 'handshake',
560
571
  new Point(new Fr(5n), new Fr(7n)),
561
572
  );
562
573
  await taggingSecretSourcesStore.addSharedSecret(
563
574
  AztecAddress.fromBigIntUnsafe(11n),
575
+ 'arbitrary-secret',
564
576
  new Point(new Fr(13n), new Fr(17n)),
565
577
  );
566
578
  },
567
579
  snapshotStore: async kvStore => ({
568
580
  senders: await snapshotMap(kvStore.openMap<string, true>('senders')),
569
- recipient_shared_secrets: await snapshotMap(kvStore.openMultiMap<string, string>('recipient_shared_secrets')),
581
+ recipient_shared_secrets: await snapshotMap(
582
+ kvStore.openMultiMap<string, { kind: string; secret: string }>('recipient_shared_secrets'),
583
+ ),
570
584
  }),
571
585
  },
572
586
 
@@ -579,10 +593,17 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
579
593
  const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
580
594
  const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
581
595
  const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.fromBigIntUnsafe(13n));
596
+ const secretConstrained = new AppTaggingSecret(
597
+ new Fr(19n),
598
+ AztecAddress.fromBigIntUnsafe(23n),
599
+ AppTaggingSecretKind.CONSTRAINED,
600
+ );
582
601
  const txHashA = TxHash.fromBigInt(17n);
583
602
  const txHashB = TxHash.fromBigInt(19n);
584
603
  const txHashC = TxHash.fromBigInt(23n);
585
604
  const txHashD = TxHash.fromBigInt(29n);
605
+ const txHashE = TxHash.fromBigInt(31n);
606
+ const txHashF = TxHash.fromBigInt(37n);
586
607
 
587
608
  // secretA receives three pending ranges (one per tx); secretB receives one. After finalizing txHashA below,
588
609
  // secretA's array shrinks to two elements (the txHashB and txHashC ranges, both with highestIndex > 3) which
@@ -621,7 +642,20 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
621
642
  jobId,
622
643
  );
623
644
 
624
- await senderTaggingStore.finalizePendingIndexes([txHashA], jobId);
645
+ // secretConstrained gets a finalized range (txHashE) plus a surviving higher pending range (txHashF), so the
646
+ // `constrained:` key lands in both pending_indexes and last_finalized_indexes.
647
+ await senderTaggingStore.storePendingIndexes(
648
+ [{ extendedSecret: secretConstrained, lowestIndex: 1, highestIndex: 3 }],
649
+ txHashE,
650
+ jobId,
651
+ );
652
+ await senderTaggingStore.storePendingIndexes(
653
+ [{ extendedSecret: secretConstrained, lowestIndex: 4, highestIndex: 7 }],
654
+ txHashF,
655
+ jobId,
656
+ );
657
+
658
+ await senderTaggingStore.finalizePendingIndexes([txHashA, txHashE], jobId);
625
659
 
626
660
  await kvStore.transactionAsync(() => senderTaggingStore.commit(jobId));
627
661
  },
@@ -6,7 +6,6 @@ import type { MembershipWitness } from '@aztec/foundation/trees';
6
6
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
7
7
  import {
8
8
  type ContractArtifact,
9
- type FunctionAbi,
10
9
  type FunctionArtifactWithContractName,
11
10
  FunctionCall,
12
11
  type FunctionDebugMetadata,
@@ -23,8 +22,8 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
22
  import {
24
23
  type ContractClassIdPreimage,
25
24
  type ContractClassWithId,
26
- type ContractInstanceWithAddress,
27
- SerializableContractInstance,
25
+ type ContractInstancePreimageWithAddress,
26
+ SerializableContractInstancePreimage,
28
27
  getContractClassFromArtifact,
29
28
  } from '@aztec/stdlib/contract';
30
29
 
@@ -112,9 +111,6 @@ export class ContractStore {
112
111
  // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
113
112
  #contractArtifactCache: Map<string, ContractArtifact> = new Map();
114
113
 
115
- /** Map from contract address to contract class id (avoids KV round-trip on hot path). */
116
- #contractClassIdMap: Map<string, Fr> = new Map();
117
-
118
114
  #store: AztecAsyncKVStore;
119
115
  #contractArtifacts: AztecAsyncMap<string, Buffer>;
120
116
  #contractClassData: AztecAsyncMap<string, Buffer>;
@@ -131,9 +127,10 @@ export class ContractStore {
131
127
 
132
128
  /**
133
129
  * Registers a new contract artifact and its corresponding class data.
134
- * IMPORTANT: This method does not verify that the provided artifact matches the class data or that the class id matches the artifact.
135
- * It is the caller's responsibility to ensure the consistency and correctness of the provided data.
136
- * This is done to avoid redundant, expensive contract class computations
130
+ *
131
+ * IMPORTANT: This method does not verify that the provided artifact matches the class data or that the class id
132
+ * matches the artifact. It is the caller's responsibility to ensure the consistency and correctness of the provided
133
+ * data. This is done to avoid redundant, expensive contract class computations.
137
134
  */
138
135
  public async addContractArtifact(
139
136
  contract: ContractArtifact,
@@ -168,31 +165,17 @@ export class ContractStore {
168
165
  return contractClass.id;
169
166
  }
170
167
 
171
- async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
168
+ async addContractInstance(contract: ContractInstancePreimageWithAddress): Promise<void> {
172
169
  await this.#store.transactionAsync(async () => {
173
170
  await this.#contractInstances.set(
174
171
  contract.address.toString(),
175
- new SerializableContractInstance(contract).toBuffer(),
172
+ new SerializableContractInstancePreimage(contract).toBuffer(),
176
173
  );
177
174
  });
178
-
179
- this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
180
175
  }
181
176
 
182
177
  // Private getters
183
178
 
184
- async #getContractClassId(contractAddress: AztecAddress): Promise<Fr | undefined> {
185
- const key = contractAddress.toString();
186
- if (!this.#contractClassIdMap.has(key)) {
187
- const instance = await this.getContractInstance(contractAddress);
188
- if (!instance) {
189
- return;
190
- }
191
- this.#contractClassIdMap.set(key, instance.currentContractClassId);
192
- }
193
- return this.#contractClassIdMap.get(key);
194
- }
195
-
196
179
  async #getPrivateFunctionTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree | undefined> {
197
180
  if (!this.#privateFunctionTrees.has(classId.toString())) {
198
181
  const artifact = await this.getContractArtifact(classId);
@@ -205,11 +188,6 @@ export class ContractStore {
205
188
  return this.#privateFunctionTrees.get(classId.toString())!;
206
189
  }
207
190
 
208
- async #getArtifactByAddress(contractAddress: AztecAddress): Promise<ContractArtifact | undefined> {
209
- const classId = await this.#getContractClassId(contractAddress);
210
- return classId && this.getContractArtifact(classId);
211
- }
212
-
213
191
  // Public getters
214
192
 
215
193
  getContractsAddresses(): Promise<AztecAddress[]> {
@@ -219,11 +197,11 @@ export class ContractStore {
219
197
  });
220
198
  }
221
199
 
222
- /** Returns a contract instance for a given address. */
223
- public getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
200
+ /** Returns the address preimage of a given address. */
201
+ public getContractInstance(contractAddress: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
224
202
  return this.#store.transactionAsync(async () => {
225
203
  const contract = await this.#contractInstances.getAsync(contractAddress.toString());
226
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
204
+ return contract && SerializableContractInstancePreimage.fromBuffer(contract).withAddress(contractAddress);
227
205
  });
228
206
  }
229
207
 
@@ -262,82 +240,69 @@ export class ContractStore {
262
240
  return { ...classData, packedBytecode };
263
241
  }
264
242
 
265
- public async getContract(
266
- address: AztecAddress,
267
- ): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
268
- const instance = await this.getContractInstance(address);
269
- if (!instance) {
270
- return;
271
- }
272
- const artifact = await this.getContractArtifact(instance.currentContractClassId);
273
- if (!artifact) {
274
- return;
275
- }
276
- return { ...instance, ...artifact };
277
- }
278
-
279
243
  /**
280
- * Retrieves the artifact of a specified function within a given contract.
244
+ * Retrieves the artifact of a specified function within a given contract class.
281
245
  *
282
- * @param contractAddress - The AztecAddress representing the contract containing the function.
246
+ * @param contractClassId - The id of the contract class containing the function.
283
247
  * @param selector - The function selector.
284
- * @returns The corresponding function's artifact as an object.
248
+ * @returns The corresponding function's artifact as an object, or `undefined` if the class is not registered.
285
249
  */
286
250
  public async getFunctionArtifact(
287
- contractAddress: AztecAddress,
251
+ contractClassId: Fr,
288
252
  selector: FunctionSelector,
289
253
  ): Promise<FunctionArtifactWithContractName | undefined> {
290
- const artifact = await this.#getArtifactByAddress(contractAddress);
254
+ const artifact = await this.getContractArtifact(contractClassId);
291
255
  if (!artifact) {
292
256
  return undefined;
293
257
  }
294
- const fn = await findFunctionArtifactBySelector(artifact, selector);
295
- return fn && { ...fn, contractName: artifact.name };
258
+ const fn = assertSelectorInArtifact(artifact, await findFunctionArtifactBySelector(artifact, selector), {
259
+ contractClassId,
260
+ selector,
261
+ });
262
+ return { ...fn, contractName: artifact.name };
296
263
  }
297
264
 
265
+ /**
266
+ * Same as {@link getFunctionArtifact} but with debug metadata attached. Returns `undefined` when the class artifact
267
+ * is not registered.
268
+ */
298
269
  public async getFunctionArtifactWithDebugMetadata(
299
- contractAddress: AztecAddress,
270
+ contractClassId: Fr,
300
271
  selector: FunctionSelector,
301
- ): Promise<FunctionArtifactWithContractName> {
302
- const artifact = await this.getFunctionArtifact(contractAddress, selector);
272
+ ): Promise<FunctionArtifactWithContractName | undefined> {
273
+ const artifact = await this.getContractArtifact(contractClassId);
303
274
  if (!artifact) {
304
- throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
275
+ return undefined;
305
276
  }
306
- const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
277
+ const fn = assertSelectorInArtifact(artifact, await findFunctionArtifactBySelector(artifact, selector), {
278
+ contractClassId,
279
+ selector,
280
+ });
307
281
  return {
308
- ...artifact,
309
- debug,
282
+ ...fn,
283
+ contractName: artifact.name,
284
+ debug: getFunctionDebugMetadata(artifact, fn),
310
285
  };
311
286
  }
312
287
 
313
- public async getPublicFunctionArtifact(
314
- contractAddress: AztecAddress,
315
- ): Promise<FunctionArtifactWithContractName | undefined> {
316
- const artifact = await this.#getArtifactByAddress(contractAddress);
288
+ public async getPublicFunctionArtifact(contractClassId: Fr): Promise<FunctionArtifactWithContractName | undefined> {
289
+ const artifact = await this.getContractArtifact(contractClassId);
317
290
  const fn = artifact && artifact.functions.find(f => f.functionType === FunctionType.PUBLIC);
318
291
  return fn && { ...fn, contractName: artifact.name };
319
292
  }
320
293
 
321
- public async getFunctionAbi(
322
- contractAddress: AztecAddress,
323
- selector: FunctionSelector,
324
- ): Promise<FunctionAbi | undefined> {
325
- const artifact = await this.#getArtifactByAddress(contractAddress);
326
- return artifact && (await findFunctionAbiBySelector(artifact, selector));
327
- }
328
-
329
294
  /**
330
- * Retrieves the debug metadata of a specified function within a given contract.
295
+ * Retrieves the debug metadata of a specified function within a given contract class.
331
296
  *
332
- * @param contractAddress - The AztecAddress representing the contract containing the function.
297
+ * @param contractClassId - The id of the contract class containing the function.
333
298
  * @param selector - The function selector.
334
299
  * @returns The corresponding function's debug metadata, or undefined.
335
300
  */
336
301
  public async getFunctionDebugMetadata(
337
- contractAddress: AztecAddress,
302
+ contractClassId: Fr,
338
303
  selector: FunctionSelector,
339
304
  ): Promise<FunctionDebugMetadata | undefined> {
340
- const artifact = await this.#getArtifactByAddress(contractAddress);
305
+ const artifact = await this.getContractArtifact(contractClassId);
341
306
  if (!artifact) {
342
307
  return undefined;
343
308
  }
@@ -345,10 +310,8 @@ export class ContractStore {
345
310
  return fn && getFunctionDebugMetadata(artifact, fn);
346
311
  }
347
312
 
348
- public async getPublicFunctionDebugMetadata(
349
- contractAddress: AztecAddress,
350
- ): Promise<FunctionDebugMetadata | undefined> {
351
- const artifact = await this.#getArtifactByAddress(contractAddress);
313
+ public async getPublicFunctionDebugMetadata(contractClassId: Fr): Promise<FunctionDebugMetadata | undefined> {
314
+ const artifact = await this.getContractArtifact(contractClassId);
352
315
  const fn = artifact && artifact.functions.find(f => f.functionType === FunctionType.PUBLIC);
353
316
  return fn && getFunctionDebugMetadata(artifact, fn);
354
317
  }
@@ -368,28 +331,34 @@ export class ContractStore {
368
331
  return tree?.getFunctionMembershipWitness(selector);
369
332
  }
370
333
 
371
- public async getDebugContractName(contractAddress: AztecAddress) {
372
- const artifact = await this.#getArtifactByAddress(contractAddress);
334
+ public async getDebugContractName(contractClassId: Fr) {
335
+ const artifact = await this.getContractArtifact(contractClassId);
373
336
  return artifact?.name;
374
337
  }
375
338
 
376
- public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
377
- const artifact = await this.#getArtifactByAddress(contractAddress);
339
+ public async getDebugFunctionName(contractClassId: Fr, selector: FunctionSelector) {
340
+ const artifact = await this.getContractArtifact(contractClassId);
378
341
  const fn = artifact && (await findFunctionAbiBySelector(artifact, selector));
379
- return `${artifact?.name ?? contractAddress}:${fn?.name ?? selector}`;
342
+ return `${artifact?.name ?? contractClassId}:${fn?.name ?? selector}`;
380
343
  }
381
344
 
382
- public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
383
- const contract = await this.getContract(to);
384
- if (!contract) {
345
+ public async getFunctionCall(
346
+ functionName: string,
347
+ args: any[],
348
+ to: AztecAddress,
349
+ contractClassId: Fr,
350
+ ): Promise<FunctionCall> {
351
+ const artifact = await this.getContractArtifact(contractClassId);
352
+ if (!artifact) {
385
353
  throw new Error(
386
- `Unknown contract ${to}: register it by calling wallet.registerContract(...).\nSee docs for context: https://docs.aztec.network/errors/14`,
354
+ `No artifact registered for contract class ${contractClassId} (contract ${to}): register it by calling ` +
355
+ `wallet.registerContract(...).\nSee docs for context: https://docs.aztec.network/errors/14`,
387
356
  );
388
357
  }
389
358
 
390
- const functionDao = contract.functions.find(f => f.name === functionName);
359
+ const functionDao = artifact.functions.find(f => f.name === functionName);
391
360
  if (!functionDao) {
392
- throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
361
+ throw new Error(`Unknown function ${functionName} in contract ${artifact.name}.`);
393
362
  }
394
363
 
395
364
  const selector = await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters);
@@ -406,3 +375,27 @@ export class ContractStore {
406
375
  });
407
376
  }
408
377
  }
378
+
379
+ /**
380
+ * Narrows the result of a selector lookup against a registered artifact. A missing class artifact is reported as
381
+ * `undefined` by the callers (an absence they can handle), but a selector that is absent from an artifact we *do* have
382
+ * is exceptional and throws rather than returning undefined. We cannot tell from here why the selector is missing: it
383
+ * may be that no such function exists in the contract (a wrong selector), or that the registered artifact does not
384
+ * correspond to the resolved class id (registration performs no validation, so a mismatched artifact is possible). The
385
+ * error names both possibilities.
386
+ */
387
+ function assertSelectorInArtifact<T>(
388
+ artifact: ContractArtifact,
389
+ fn: T | undefined,
390
+ context: { contractClassId: Fr; selector: FunctionSelector },
391
+ ): T {
392
+ if (!fn) {
393
+ throw new Error(
394
+ `Function with selector ${context.selector} not found in the registered artifact for contract class ` +
395
+ `${context.contractClassId} (${artifact.name}). Either no function with this selector exists in the ` +
396
+ `contract, or the registered artifact does not match the class id (re-register it via ` +
397
+ `wallet.registerContract(...)).`,
398
+ );
399
+ }
400
+ return fn;
401
+ }