@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.b655e406

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 (309) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +2 -0
  3. package/dest/bin/check_oracle_version.d.ts.map +1 -0
  4. package/dest/bin/check_oracle_version.js +39 -0
  5. package/dest/config/index.d.ts +10 -15
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +11 -20
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  17. package/dest/contract_function_simulator/execution_note_cache.js +183 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  24. package/dest/contract_function_simulator/index.d.ts +14 -0
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/index.js +12 -0
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  42. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/oracle/index.js +2 -0
  45. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
  54. package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/oracle/oracle.js +328 -0
  57. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  66. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/pick_notes.js +51 -0
  69. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  72. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  74. package/dest/contract_function_simulator/proxied_node.js +27 -0
  75. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +3 -2
  81. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  82. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/bundle/utils.js +18 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +3 -2
  87. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  88. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  89. package/dest/entrypoints/client/lazy/utils.js +17 -11
  90. package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  92. package/dest/entrypoints/server/index.d.ts +5 -3
  93. package/dest/entrypoints/server/index.d.ts.map +1 -1
  94. package/dest/entrypoints/server/index.js +4 -3
  95. package/dest/entrypoints/server/utils.d.ts +7 -15
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +34 -28
  98. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  101. package/dest/oracle_version.d.ts +3 -0
  102. package/dest/oracle_version.d.ts.map +1 -0
  103. package/dest/oracle_version.js +10 -0
  104. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  109. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  110. package/dest/private_kernel/hints/index.d.ts +3 -0
  111. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  112. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  113. package/dest/private_kernel/index.d.ts +3 -0
  114. package/dest/private_kernel/index.d.ts.map +1 -0
  115. package/dest/private_kernel/index.js +2 -0
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  117. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  118. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  119. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  120. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  121. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  122. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
  123. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  124. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  125. package/dest/pxe.d.ts +233 -0
  126. package/dest/pxe.d.ts.map +1 -0
  127. package/dest/pxe.js +789 -0
  128. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  129. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  130. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  131. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
  132. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  133. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  134. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
  135. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  136. package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
  137. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  138. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  139. package/dest/storage/contract_data_provider/index.js +0 -1
  140. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  141. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  143. package/dest/storage/index.d.ts +2 -3
  144. package/dest/storage/index.d.ts.map +1 -1
  145. package/dest/storage/index.js +2 -3
  146. package/dest/storage/metadata.d.ts +2 -0
  147. package/dest/storage/metadata.d.ts.map +1 -0
  148. package/dest/storage/metadata.js +1 -0
  149. package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
  150. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  151. package/dest/storage/note_data_provider/note_dao.js +16 -20
  152. package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
  153. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  154. package/dest/storage/note_data_provider/note_data_provider.js +133 -74
  155. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
  156. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  157. package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
  158. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
  159. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  160. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  161. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  162. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  163. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  164. package/dest/synchronizer/synchronizer.d.ts +7 -9
  165. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  166. package/dest/synchronizer/synchronizer.js +17 -19
  167. package/dest/tagging/constants.d.ts +2 -0
  168. package/dest/tagging/constants.d.ts.map +1 -0
  169. package/dest/tagging/constants.js +2 -0
  170. package/dest/tagging/index.d.ts +7 -0
  171. package/dest/tagging/index.d.ts.map +1 -0
  172. package/dest/tagging/index.js +5 -0
  173. package/dest/tagging/siloed_tag.d.ts +14 -0
  174. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  175. package/dest/tagging/siloed_tag.js +20 -0
  176. package/dest/tagging/tag.d.ts +12 -0
  177. package/dest/tagging/tag.d.ts.map +1 -0
  178. package/dest/tagging/tag.js +17 -0
  179. package/dest/tagging/utils.d.ts +18 -0
  180. package/dest/tagging/utils.d.ts.map +1 -0
  181. package/dest/tagging/utils.js +24 -0
  182. package/package.json +34 -32
  183. package/src/bin/check_oracle_version.ts +50 -0
  184. package/src/config/index.ts +20 -33
  185. package/src/config/package_info.ts +1 -1
  186. package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
  187. package/src/contract_function_simulator/execution_data_provider.ts +343 -0
  188. package/src/contract_function_simulator/execution_note_cache.ts +222 -0
  189. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  190. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  191. package/src/contract_function_simulator/index.ts +13 -0
  192. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  193. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  194. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  195. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
  196. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  197. package/src/contract_function_simulator/oracle/index.ts +16 -0
  198. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  199. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  200. package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
  201. package/src/contract_function_simulator/oracle/oracle.ts +575 -0
  202. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  203. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
  204. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  205. package/src/contract_function_simulator/pick_notes.ts +141 -0
  206. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  207. package/src/contract_function_simulator/proxied_node.ts +33 -0
  208. package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
  209. package/src/entrypoints/client/bundle/index.ts +4 -2
  210. package/src/entrypoints/client/bundle/utils.ts +36 -36
  211. package/src/entrypoints/client/lazy/index.ts +4 -2
  212. package/src/entrypoints/client/lazy/utils.ts +36 -31
  213. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  214. package/src/entrypoints/server/index.ts +5 -3
  215. package/src/entrypoints/server/utils.ts +69 -47
  216. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  217. package/src/oracle_version.ts +11 -0
  218. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
  219. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  220. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  221. package/src/private_kernel/index.ts +2 -0
  222. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  223. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  224. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  225. package/src/pxe.ts +1113 -0
  226. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  227. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  228. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
  229. package/src/storage/contract_data_provider/index.ts +0 -1
  230. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  231. package/src/storage/index.ts +2 -4
  232. package/src/storage/metadata.ts +1 -0
  233. package/src/storage/note_data_provider/note_dao.ts +19 -27
  234. package/src/storage/note_data_provider/note_data_provider.ts +161 -113
  235. package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
  236. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  237. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  238. package/src/synchronizer/synchronizer.ts +21 -22
  239. package/src/tagging/constants.ts +2 -0
  240. package/src/tagging/index.ts +6 -0
  241. package/src/tagging/siloed_tag.ts +22 -0
  242. package/src/tagging/tag.ts +16 -0
  243. package/src/tagging/utils.ts +31 -0
  244. package/dest/bin/index.d.ts +0 -3
  245. package/dest/bin/index.d.ts.map +0 -1
  246. package/dest/bin/index.js +0 -28
  247. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  248. package/dest/kernel_oracle/index.d.ts.map +0 -1
  249. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  250. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  251. package/dest/kernel_prover/hints/index.d.ts +0 -2
  252. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  253. package/dest/kernel_prover/index.d.ts +0 -3
  254. package/dest/kernel_prover/index.d.ts.map +0 -1
  255. package/dest/kernel_prover/index.js +0 -2
  256. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  257. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  258. package/dest/kernel_prover/kernel_prover.js +0 -217
  259. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  260. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  261. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  262. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  263. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  264. package/dest/pxe_http/index.d.ts +0 -2
  265. package/dest/pxe_http/index.d.ts.map +0 -1
  266. package/dest/pxe_http/index.js +0 -1
  267. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  268. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  269. package/dest/pxe_http/pxe_http_server.js +0 -27
  270. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  271. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  272. package/dest/pxe_oracle_interface/index.js +0 -692
  273. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  274. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  275. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  276. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  277. package/dest/pxe_service/index.d.ts +0 -3
  278. package/dest/pxe_service/index.d.ts.map +0 -1
  279. package/dest/pxe_service/index.js +0 -2
  280. package/dest/pxe_service/pxe_service.d.ts +0 -111
  281. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  282. package/dest/pxe_service/pxe_service.js +0 -664
  283. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  284. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  285. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  286. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  287. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  289. package/dest/storage/data_provider.d.ts +0 -4
  290. package/dest/storage/data_provider.d.ts.map +0 -1
  291. package/dest/storage/data_provider.js +0 -1
  292. package/dest/test/pxe_test_suite.d.ts +0 -3
  293. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  294. package/dest/test/pxe_test_suite.js +0 -97
  295. package/src/bin/index.ts +0 -38
  296. package/src/kernel_prover/index.ts +0 -2
  297. package/src/kernel_prover/kernel_prover.ts +0 -351
  298. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  299. package/src/pxe_http/index.ts +0 -1
  300. package/src/pxe_http/pxe_http_server.ts +0 -29
  301. package/src/pxe_oracle_interface/index.ts +0 -925
  302. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  303. package/src/pxe_service/index.ts +0 -2
  304. package/src/pxe_service/pxe_service.ts +0 -949
  305. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  306. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  307. package/src/storage/data_provider.ts +0 -3
  308. package/src/test/pxe_test_suite.ts +0 -111
  309. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -3,9 +3,7 @@ import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/k
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { CompleteAddress } from '@aztec/stdlib/contract';
5
5
 
6
- import type { DataProvider } from '../data_provider.js';
7
-
8
- export class AddressDataProvider implements DataProvider {
6
+ export class AddressDataProvider {
9
7
  #store: AztecAsyncKVStore;
10
8
  #completeAddresses: AztecAsyncArray<Buffer>;
11
9
  #completeAddressIndex: AztecAsyncMap<string, number>;
@@ -64,8 +62,4 @@ export class AddressDataProvider implements DataProvider {
64
62
  (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
65
63
  );
66
64
  }
67
-
68
- async getSize(): Promise<number> {
69
- return (await this.#completeAddresses.lengthAsync()) * CompleteAddress.SIZE_IN_BYTES;
70
- }
71
65
  }
@@ -1,25 +1,22 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
- import { type LogFn, createDebugOnlyLogger } from '@aztec/foundation/log';
2
+ import { type Logger, createLogger } from '@aztec/foundation/log';
4
3
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
5
 
7
- import type { DataProvider } from '../data_provider.js';
8
-
9
- export class CapsuleDataProvider implements DataProvider {
6
+ export class CapsuleDataProvider {
10
7
  #store: AztecAsyncKVStore;
11
8
 
12
9
  // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
13
10
  #capsules: AztecAsyncMap<string, Buffer>;
14
11
 
15
- debug: LogFn;
12
+ logger: Logger;
16
13
 
17
14
  constructor(store: AztecAsyncKVStore) {
18
15
  this.#store = store;
19
16
 
20
17
  this.#capsules = this.#store.openMap('capsules');
21
18
 
22
- this.debug = createDebugOnlyLogger('pxe:capsule-data-provider');
19
+ this.logger = createLogger('pxe:capsule-data-provider');
23
20
  }
24
21
 
25
22
  async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
@@ -29,7 +26,7 @@ export class CapsuleDataProvider implements DataProvider {
29
26
  async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
30
27
  const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
31
28
  if (!dataBuffer) {
32
- this.debug(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
29
+ this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
33
30
  return null;
34
31
  }
35
32
  const capsule: Fr[] = [];
@@ -43,38 +40,108 @@ export class CapsuleDataProvider implements DataProvider {
43
40
  await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
44
41
  }
45
42
 
46
- async copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
47
- // In order to support overlapping source and destination regions, we need to check the relative positions of source
48
- // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
49
- // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
50
- // indexes to avoid reading elements that've been overwritten.
43
+ copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
44
+ return this.#store.transactionAsync(async () => {
45
+ // In order to support overlapping source and destination regions, we need to check the relative positions of source
46
+ // and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
47
+ // indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
48
+ // indexes to avoid reading elements that've been overwritten.
51
49
 
52
- const indexes = Array.from(Array(numEntries).keys());
53
- if (srcSlot.lt(dstSlot)) {
54
- indexes.reverse();
55
- }
50
+ const indexes = Array.from(Array(numEntries).keys());
51
+ if (srcSlot.lt(dstSlot)) {
52
+ indexes.reverse();
53
+ }
56
54
 
57
- for (const i of indexes) {
58
- const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
59
- const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
55
+ for (const i of indexes) {
56
+ const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
57
+ const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
60
58
 
61
- const toCopy = await this.#capsules.getAsync(currentSrcSlot);
62
- if (!toCopy) {
63
- throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
59
+ const toCopy = await this.#capsules.getAsync(currentSrcSlot);
60
+ if (!toCopy) {
61
+ throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
62
+ }
63
+
64
+ await this.#capsules.set(currentDstSlot, toCopy);
64
65
  }
66
+ });
67
+ }
65
68
 
66
- await this.#capsules.set(currentDstSlot, toCopy);
67
- }
69
+ /**
70
+ * Appends multiple capsules to a capsule array stored at the base slot.
71
+ * The array length is stored at the base slot, and elements are stored in consecutive slots after it.
72
+ * All operations are performed in a single transaction.
73
+ * @param contractAddress - The contract address that owns the capsule array
74
+ * @param baseSlot - The slot where the array length is stored
75
+ * @param content - Array of capsule data to append
76
+ */
77
+ appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void> {
78
+ return this.#store.transactionAsync(async () => {
79
+ // Load current length, defaulting to 0 if not found
80
+ const lengthData = await this.loadCapsule(contractAddress, baseSlot);
81
+ const currentLength = lengthData ? lengthData[0].toNumber() : 0;
82
+
83
+ // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
84
+ for (let i = 0; i < content.length; i++) {
85
+ const nextSlot = arraySlot(baseSlot, currentLength + i);
86
+ await this.storeCapsule(contractAddress, nextSlot, content[i]);
87
+ }
88
+
89
+ // Update length to include all new capsules
90
+ const newLength = currentLength + content.length;
91
+ await this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)]);
92
+ });
93
+ }
94
+
95
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]> {
96
+ return this.#store.transactionAsync(async () => {
97
+ // Load length, defaulting to 0 if not found
98
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
99
+ const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
100
+
101
+ const values: Fr[][] = [];
102
+
103
+ // Read each capsule at consecutive slots after baseSlot
104
+ for (let i = 0; i < length; i++) {
105
+ const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
106
+ if (currentValue == undefined) {
107
+ throw new Error(
108
+ `Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
109
+ );
110
+ }
111
+
112
+ values.push(currentValue);
113
+ }
114
+
115
+ return values;
116
+ });
68
117
  }
69
118
 
70
- public async getSize() {
71
- return (await toArray(this.#capsules.valuesAsync())).reduce(
72
- (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES,
73
- 0,
74
- );
119
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]) {
120
+ return this.#store.transactionAsync(async () => {
121
+ // Load current length, defaulting to 0 if not found
122
+ const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
123
+ const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
124
+
125
+ // Set the new length
126
+ await this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)]);
127
+
128
+ // Store the new content, possibly overwriting existing values
129
+ for (let i = 0; i < content.length; i++) {
130
+ await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
131
+ }
132
+
133
+ // Clear any stragglers
134
+ for (let i = content.length; i < originalLength; i++) {
135
+ await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
136
+ }
137
+ });
75
138
  }
76
139
  }
77
140
 
78
141
  function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
79
142
  return `${contractAddress.toString()}:${slot.toString()}`;
80
143
  }
144
+
145
+ function arraySlot(baseSlot: Fr, index: number) {
146
+ return baseSlot.add(new Fr(1)).add(new Fr(index));
147
+ }
@@ -1,11 +1,13 @@
1
+ import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
1
2
  import type { Fr } from '@aztec/foundation/fields';
2
3
  import { toArray } from '@aztec/foundation/iterable';
3
4
  import type { MembershipWitness } from '@aztec/foundation/trees';
4
5
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
- import { ContractClassNotFoundError, ContractNotFoundError } from '@aztec/simulator/client';
6
6
  import {
7
7
  type ContractArtifact,
8
+ type FunctionAbi,
8
9
  type FunctionArtifact,
10
+ type FunctionArtifactWithContractName,
9
11
  type FunctionDebugMetadata,
10
12
  FunctionSelector,
11
13
  FunctionType,
@@ -18,9 +20,9 @@ import {
18
20
  type ContractClass,
19
21
  type ContractInstanceWithAddress,
20
22
  SerializableContractInstance,
23
+ getContractClassFromArtifact,
21
24
  } from '@aztec/stdlib/contract';
22
25
 
23
- import type { DataProvider } from '../data_provider.js';
24
26
  import { PrivateFunctionsTree } from './private_functions_tree.js';
25
27
 
26
28
  /**
@@ -30,9 +32,13 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
30
32
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
31
33
  * the required information and facilitate cryptographic proof generation.
32
34
  */
33
- export class ContractDataProvider implements DataProvider {
35
+ export class ContractDataProvider {
34
36
  /** Map from contract class id to private function tree. */
35
- private contractClassesCache: Map<string, PrivateFunctionsTree> = new Map();
37
+ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
38
+ #privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
39
+
40
+ /** Map from contract address to contract class id */
41
+ #contractClassIdMap: Map<string, Fr> = new Map();
36
42
 
37
43
  #contractArtifacts: AztecAsyncMap<string, Buffer>;
38
44
  #contractInstances: AztecAsyncMap<string, Buffer>;
@@ -65,6 +71,8 @@ export class ContractDataProvider implements DataProvider {
65
71
  }
66
72
 
67
73
  async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
74
+ this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
75
+
68
76
  await this.#contractInstances.set(
69
77
  contract.address.toString(),
70
78
  new SerializableContractInstance(contract).toBuffer(),
@@ -73,15 +81,15 @@ export class ContractDataProvider implements DataProvider {
73
81
 
74
82
  // Private getters
75
83
 
76
- async #getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
77
- const contract = await this.#contractInstances.getAsync(address.toString());
78
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(address);
79
- }
80
-
81
- async #getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
82
- const contract = await this.#contractArtifacts.getAsync(id.toString());
83
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
84
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
84
+ async #getContractClassId(contractAddress: AztecAddress): Promise<Fr | undefined> {
85
+ if (!this.#contractClassIdMap.has(contractAddress.toString())) {
86
+ const instance = await this.getContractInstance(contractAddress);
87
+ if (!instance) {
88
+ return;
89
+ }
90
+ this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
91
+ }
92
+ return this.#contractClassIdMap.get(contractAddress.toString());
85
93
  }
86
94
 
87
95
  /**
@@ -94,31 +102,21 @@ export class ContractDataProvider implements DataProvider {
94
102
  * @returns A ContractTree instance associated with the specified contract address.
95
103
  * @throws An Error if the contract is not found in the ContractDatabase.
96
104
  */
97
- private async getTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree> {
98
- if (!this.contractClassesCache.has(classId.toString())) {
99
- const artifact = await this.#getContractArtifact(classId);
105
+ async #getPrivateFunctionTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree | undefined> {
106
+ if (!this.#privateFunctionTrees.has(classId.toString())) {
107
+ const artifact = await this.getContractArtifact(classId);
100
108
  if (!artifact) {
101
- throw new ContractClassNotFoundError(classId.toString());
109
+ return;
102
110
  }
103
111
  const tree = await PrivateFunctionsTree.create(artifact);
104
- this.contractClassesCache.set(classId.toString(), tree);
112
+ this.#privateFunctionTrees.set(classId.toString(), tree);
105
113
  }
106
- return this.contractClassesCache.get(classId.toString())!;
114
+ return this.#privateFunctionTrees.get(classId.toString())!;
107
115
  }
108
116
 
109
- /**
110
- * Retrieve or create a ContractTree instance based on the provided AztecAddress.
111
- * If an existing tree with the same contract address is found in the cache, it will be returned.
112
- * Otherwise, a new ContractTree instance will be created using the contract data from the database
113
- * and added to the cache before returning.
114
- *
115
- * @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
116
- * @returns A ContractTree instance associated with the specified contract address.
117
- * @throws An Error if the contract is not found in the ContractDatabase.
118
- */
119
- private async getTreeForAddress(contractAddress: AztecAddress): Promise<PrivateFunctionsTree> {
120
- const instance = await this.getContractInstance(contractAddress);
121
- return this.getTreeForClassId(instance.currentContractClassId);
117
+ async #getContractArtifactByAddress(contractAddress: AztecAddress): Promise<ContractArtifact | undefined> {
118
+ const contractClassId = await this.#getContractClassId(contractAddress);
119
+ return contractClassId && this.getContractArtifact(contractClassId);
122
120
  }
123
121
 
124
122
  // Public getters
@@ -129,32 +127,33 @@ export class ContractDataProvider implements DataProvider {
129
127
  }
130
128
 
131
129
  /** Returns a contract instance for a given address. Throws if not found. */
132
- public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress> {
133
- const instance = await this.#getContractInstance(contractAddress);
134
- if (!instance) {
135
- throw new ContractNotFoundError(contractAddress.toString());
136
- }
137
- return instance;
130
+ public async getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
131
+ const contract = await this.#contractInstances.getAsync(contractAddress.toString());
132
+ return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
138
133
  }
139
134
 
140
- public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact> {
141
- const tree = await this.getTreeForClassId(contractClassId);
142
- return tree.getArtifact();
135
+ public async getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
136
+ const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
137
+ // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
138
+ return contract && contractArtifactFromBuffer(Buffer.from(contract));
143
139
  }
144
140
 
145
141
  /** Returns a contract class for a given class id. Throws if not found. */
146
- public async getContractClass(contractClassId: Fr): Promise<ContractClass> {
147
- const tree = await this.getTreeForClassId(contractClassId);
148
- return tree.getContractClass();
142
+ public async getContractClass(contractClassId: Fr): Promise<ContractClass | undefined> {
143
+ const artifact = await this.getContractArtifact(contractClassId);
144
+ return artifact && getContractClassFromArtifact(artifact);
149
145
  }
150
146
 
151
147
  public async getContract(
152
148
  address: AztecAddress,
153
149
  ): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
154
150
  const instance = await this.getContractInstance(address);
155
- const artifact = instance && (await this.getContractArtifact(instance?.currentContractClassId));
156
- if (!instance || !artifact) {
157
- return undefined;
151
+ if (!instance) {
152
+ return;
153
+ }
154
+ const artifact = await this.getContractArtifact(instance.currentContractClassId);
155
+ if (!artifact) {
156
+ return;
158
157
  }
159
158
  return { ...instance, ...artifact };
160
159
  }
@@ -168,9 +167,21 @@ export class ContractDataProvider implements DataProvider {
168
167
  * @param selector - The function selector.
169
168
  * @returns The corresponding function's artifact as an object.
170
169
  */
171
- public async getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector) {
172
- const tree = await this.getTreeForAddress(contractAddress);
173
- return tree.getFunctionArtifact(selector);
170
+ public async getFunctionArtifact(
171
+ contractAddress: AztecAddress,
172
+ selector: FunctionSelector,
173
+ ): Promise<FunctionArtifactWithContractName | undefined> {
174
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
175
+ const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
176
+ return fnArtifact && { ...fnArtifact, contractName: artifact.name };
177
+ }
178
+
179
+ public async getPublicFunctionArtifact(
180
+ contractAddress: AztecAddress,
181
+ ): Promise<FunctionArtifactWithContractName | undefined> {
182
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
183
+ const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
184
+ return fnArtifact && { ...fnArtifact, contractName: artifact.name };
174
185
  }
175
186
 
176
187
  /**
@@ -186,8 +197,16 @@ export class ContractDataProvider implements DataProvider {
186
197
  contractAddress: AztecAddress,
187
198
  functionName: string,
188
199
  ): Promise<FunctionArtifact | undefined> {
189
- const tree = await this.getTreeForAddress(contractAddress);
190
- return tree.getArtifact().functions.find(f => f.name === functionName);
200
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
201
+ return artifact?.functions.find(fn => fn.name === functionName);
202
+ }
203
+
204
+ public async getFunctionAbi(
205
+ contractAddress: AztecAddress,
206
+ selector: FunctionSelector,
207
+ ): Promise<FunctionAbi | undefined> {
208
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
209
+ return artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
191
210
  }
192
211
 
193
212
  /**
@@ -204,24 +223,17 @@ export class ContractDataProvider implements DataProvider {
204
223
  contractAddress: AztecAddress,
205
224
  selector: FunctionSelector,
206
225
  ): Promise<FunctionDebugMetadata | undefined> {
207
- const tree = await this.getTreeForAddress(contractAddress);
208
- const artifact = await tree.getFunctionArtifact(selector);
209
- return getFunctionDebugMetadata(tree.getArtifact(), artifact);
226
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
227
+ const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
228
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
210
229
  }
211
230
 
212
- /**
213
- * Retrieve the bytecode of a specific function in a contract at the given address.
214
- * The returned bytecode is required for executing and verifying the function's behavior
215
- * in the Aztec network. Throws an error if the contract or function cannot be found.
216
- *
217
- * @param contractAddress - The contract's address.
218
- * @param selector - The function selector.
219
- * @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
220
- * @throws Error if the contract address is unknown or not found.
221
- */
222
- public async getBytecode(contractAddress: AztecAddress, selector: FunctionSelector) {
223
- const tree = await this.getTreeForAddress(contractAddress);
224
- return tree.getBytecode(selector);
231
+ public async getPublicFunctionDebugMetadata(
232
+ contractAddress: AztecAddress,
233
+ ): Promise<FunctionDebugMetadata | undefined> {
234
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
235
+ const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
236
+ return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
225
237
  }
226
238
 
227
239
  /**
@@ -236,26 +248,47 @@ export class ContractDataProvider implements DataProvider {
236
248
  public async getFunctionMembershipWitness(
237
249
  contractClassId: Fr,
238
250
  selector: FunctionSelector,
239
- ): Promise<MembershipWitness<5>> {
240
- const tree = await this.getTreeForClassId(contractClassId);
241
- return tree.getFunctionMembershipWitness(selector);
251
+ ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined> {
252
+ const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
253
+ return tree?.getFunctionMembershipWitness(selector);
242
254
  }
243
255
 
244
256
  public async getDebugContractName(contractAddress: AztecAddress) {
245
- const tree = await this.getTreeForAddress(contractAddress);
246
- return tree.getArtifact().name;
257
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
258
+ return artifact?.name;
247
259
  }
248
260
 
249
261
  public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
250
- const tree = await this.getTreeForAddress(contractAddress);
251
- const { name: contractName } = tree.getArtifact();
252
- const { name: functionName } = await tree.getFunctionArtifact(selector);
253
- return `${contractName}:${functionName}`;
262
+ const artifact = await this.#getContractArtifactByAddress(contractAddress);
263
+ const fnArtifact = artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
264
+ return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
254
265
  }
255
266
 
256
- public async getSize() {
257
- return (await toArray(this.#contractInstances.valuesAsync()))
258
- .concat(await toArray(this.#contractArtifacts.valuesAsync()))
259
- .reduce((sum, value) => sum + value.length, 0);
267
+ async #findFunctionArtifactBySelector(
268
+ artifact: ContractArtifact,
269
+ selector: FunctionSelector,
270
+ ): Promise<FunctionArtifact | undefined> {
271
+ const functions = artifact.functions;
272
+ for (let i = 0; i < functions.length; i++) {
273
+ const fn = functions[i];
274
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
275
+ if (fnSelector.equals(selector)) {
276
+ return fn;
277
+ }
278
+ }
279
+ }
280
+
281
+ async #findFunctionAbiBySelector(
282
+ artifact: ContractArtifact,
283
+ selector: FunctionSelector,
284
+ ): Promise<FunctionAbi | undefined> {
285
+ const functions = [...artifact.functions, ...(artifact.nonDispatchPublicFunctions ?? [])];
286
+ for (let i = 0; i < functions.length; i++) {
287
+ const fn = functions[i];
288
+ const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
289
+ if (fnSelector.equals(selector)) {
290
+ return fn;
291
+ }
292
+ }
260
293
  }
261
294
  }
@@ -1,2 +1 @@
1
1
  export { ContractDataProvider } from './contract_data_provider.js';
2
- export { PrivateFunctionsTree } from './private_functions_tree.js';
@@ -2,12 +2,12 @@ import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { assertLength } from '@aztec/foundation/serialize';
4
4
  import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
5
- import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
5
+ import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
6
6
  import {
7
- type ContractClassWithId,
7
+ type PrivateFunction,
8
8
  computePrivateFunctionLeaf,
9
9
  computePrivateFunctionsTree,
10
- getContractClassFromArtifact,
10
+ getContractClassPrivateFunctionFromArtifact,
11
11
  } from '@aztec/stdlib/contract';
12
12
 
13
13
  /**
@@ -19,78 +19,15 @@ import {
19
19
  export class PrivateFunctionsTree {
20
20
  private tree?: MerkleTree;
21
21
 
22
- private constructor(private readonly artifact: ContractArtifact, private contractClass: ContractClassWithId) {}
22
+ private constructor(private readonly privateFunctions: PrivateFunction[]) {}
23
23
 
24
24
  static async create(artifact: ContractArtifact) {
25
- const contractClass = await getContractClassFromArtifact(artifact);
26
- return new PrivateFunctionsTree(artifact, contractClass);
27
- }
28
-
29
- /**
30
- * Retrieve the artifact of a given function.
31
- * The function is identified by its selector, which represents a unique identifier for the function's signature.
32
- * Throws an error if the function with the provided selector is not found in the contract.
33
- *
34
- * @param selector - The function selector.
35
- * @returns The artifact object containing relevant information about the targeted function.
36
- */
37
- public async getFunctionArtifact(selector: FunctionSelector) {
38
- const functionsAndSelectors = await Promise.all(
39
- this.artifact.functions.map(async f => ({
40
- f,
41
- selector: await FunctionSelector.fromNameAndParameters(f.name, f.parameters),
42
- })),
25
+ const privateFunctions = await Promise.all(
26
+ artifact.functions
27
+ .filter(fn => fn.functionType === FunctionType.PRIVATE)
28
+ .map(getContractClassPrivateFunctionFromArtifact),
43
29
  );
44
- const artifact = functionsAndSelectors.find(f => selector.equals(f.selector))?.f;
45
- if (!artifact) {
46
- throw new Error(
47
- `Unknown function. Selector ${selector.toString()} not found in the artifact ${
48
- this.artifact.name
49
- } with class ${this.getContractClassId().toString()}.`,
50
- );
51
- }
52
- return artifact;
53
- }
54
-
55
- /**
56
- * Retrieve the bytecode of a function in the contract by its function selector.
57
- * The function selector is a unique identifier for each function in a contract.
58
- * Throws an error if the function with the given selector is not found in the contract.
59
- *
60
- * @param selector - The selector of a function to get bytecode for.
61
- * @returns The bytecode of the function as a string.
62
- */
63
- public async getBytecode(selector: FunctionSelector) {
64
- const artifact = await this.getFunctionArtifact(selector);
65
- return artifact.bytecode;
66
- }
67
-
68
- /**
69
- * Calculate and return the root of the function tree for the current contract.
70
- * This root is a cryptographic commitment to the set of constrained functions within the contract,
71
- * which is used in the Aztec node's proof system. The root will be cached after the first call.
72
- *
73
- * @returns A promise that resolves to the Fr (finite field element) representation of the function tree root.
74
- */
75
- public getFunctionTreeRoot() {
76
- return this.getTree();
77
- }
78
-
79
- /** Returns the contract class object. */
80
- public getContractClass() {
81
- return this.contractClass;
82
- }
83
-
84
- /** Returns the contract artifact. */
85
- public getArtifact() {
86
- return this.artifact;
87
- }
88
-
89
- /**
90
- * Returns the contract class identifier for the given artifact.
91
- */
92
- public getContractClassId() {
93
- return this.getContractClass().id;
30
+ return new PrivateFunctionsTree(privateFunctions);
94
31
  }
95
32
 
96
33
  /**
@@ -105,7 +42,7 @@ export class PrivateFunctionsTree {
105
42
  public async getFunctionMembershipWitness(
106
43
  selector: FunctionSelector,
107
44
  ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
108
- const fn = this.getContractClass().privateFunctions.find(f => f.selector.equals(selector));
45
+ const fn = this.privateFunctions.find(f => f.selector.equals(selector));
109
46
  if (!fn) {
110
47
  throw new Error(`Private function with selector ${selector.toString()} not found in contract class.`);
111
48
  }
@@ -123,8 +60,7 @@ export class PrivateFunctionsTree {
123
60
 
124
61
  private async getTree() {
125
62
  if (!this.tree) {
126
- const fns = this.getContractClass().privateFunctions;
127
- this.tree = await computePrivateFunctionsTree(fns);
63
+ this.tree = await computePrivateFunctionsTree(this.privateFunctions);
128
64
  }
129
65
  return this.tree;
130
66
  }
@@ -1,10 +1,8 @@
1
1
  export * from './address_data_provider/index.js';
2
- export * from './auth_witness_data_provider/index.js';
3
2
  export * from './capsule_data_provider/index.js';
4
3
  export * from './contract_data_provider/index.js';
5
4
  export * from './note_data_provider/index.js';
6
5
  export * from './sync_data_provider/index.js';
7
6
  export * from './tagging_data_provider/index.js';
8
- export * from './data_provider.js';
9
-
10
- export const PXE_DATA_SCHEMA_VERSION = 2;
7
+ export * from './metadata.js';
8
+ export * from './private_event_data_provider/private_event_data_provider.js';
@@ -0,0 +1 @@
1
+ export const PXE_DATA_SCHEMA_VERSION = 2;