@aztec/pxe 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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.
- package/dest/bin/check_oracle_version.js +5 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts +16 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +91 -22
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +12 -2
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +230 -89
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +3 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -7
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +9 -11
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -8
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +7 -12
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +67 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +327 -119
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +59 -76
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +125 -90
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +140 -73
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +347 -162
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +44 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +116 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +60 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +23 -9
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +24 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +5 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +30 -11
- package/dest/events/event_service.d.ts +7 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +33 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +20 -6
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +11 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +52 -64
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +9 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +45 -40
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -9
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +140 -73
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -16
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +91 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +163 -145
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -2
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +25 -10
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +143 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -85
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +229 -111
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +43 -32
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +300 -122
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +4 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -26
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +18 -12
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +23 -16
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +8 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +44 -27
- package/package.json +27 -18
- package/src/bin/check_oracle_version.ts +5 -4
- package/src/block_synchronizer/block_synchronizer.ts +113 -35
- package/src/config/index.ts +9 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +392 -154
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +2 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -10
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +5 -11
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +97 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +422 -166
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +169 -185
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +578 -193
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +176 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +18 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +19 -18
- package/src/entrypoints/pxe_creation_options.ts +9 -1
- package/src/entrypoints/server/index.ts +4 -1
- package/src/entrypoints/server/utils.ts +24 -29
- package/src/events/event_service.ts +31 -26
- package/src/events/private_event_filter_validator.ts +23 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +94 -104
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +54 -48
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -9
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +195 -136
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +25 -20
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +297 -223
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +183 -29
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -101
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +323 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +296 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +366 -134
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +3 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +27 -29
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +31 -15
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +42 -29
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -4,9 +4,11 @@ import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
|
4
4
|
import { arrayOfArraysToBoundedVecOfArrays, bufferToBoundedVec, fromUintArray, fromUintBoundedVec, toACVMField } from '@aztec/simulator/client';
|
|
5
5
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
7
8
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
10
|
+
import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
|
|
11
|
+
import { packAsHintedNote } from './note_packing_utils.js';
|
|
10
12
|
export class UnavailableOracleError extends Error {
|
|
11
13
|
constructor(oracleName){
|
|
12
14
|
super(`${oracleName} oracles not available with the current handler`);
|
|
@@ -14,6 +16,25 @@ export class UnavailableOracleError extends Error {
|
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* A data source that has all the apis required by Aztec.nr.
|
|
19
|
+
*
|
|
20
|
+
* ## Oracle naming conventions
|
|
21
|
+
*
|
|
22
|
+
* We try to keep oracle naming consistent, please see below the conventions we adhere to.
|
|
23
|
+
*
|
|
24
|
+
* Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
|
|
25
|
+
*
|
|
26
|
+
* - **Scope prefix** indicates the execution context required:
|
|
27
|
+
* - `aztec_prv_` — available only during private function execution.
|
|
28
|
+
* - `aztec_utl_` — available during both utility and private execution.
|
|
29
|
+
*
|
|
30
|
+
* - **Verb** signals the operation's semantics (verb-first, then object):
|
|
31
|
+
* - `get` — read / lookup / get data from oracle into contract.
|
|
32
|
+
* - `does`/`is`/`has` — predicate (returns boolean).
|
|
33
|
+
* - `emit`/`notify` — propagate data from contract to oracle.
|
|
34
|
+
* - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
|
|
35
|
+
* - `call` — trigger nested execution (control flow).
|
|
36
|
+
* - `assert` — validate a condition, throw on failure.
|
|
37
|
+
* - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
|
|
17
38
|
*/ export class Oracle {
|
|
18
39
|
handler;
|
|
19
40
|
constructor(handler){
|
|
@@ -48,11 +69,11 @@ export class UnavailableOracleError extends Error {
|
|
|
48
69
|
];
|
|
49
70
|
// Get all the oracle function names
|
|
50
71
|
const oracleNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name));
|
|
51
|
-
// Validate oracle names - these must be prefixed with either "
|
|
72
|
+
// Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
|
|
52
73
|
// and must correspond to a function on the Oracle class.
|
|
53
74
|
oracleNames.forEach((name)=>{
|
|
54
|
-
if (!name.startsWith('
|
|
55
|
-
throw new Error(`Oracle function "${name}" must be prefixed with either "
|
|
75
|
+
if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
|
|
76
|
+
throw new Error(`Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`);
|
|
56
77
|
}
|
|
57
78
|
const method = this[name];
|
|
58
79
|
if (typeof method !== 'function') {
|
|
@@ -60,42 +81,78 @@ export class UnavailableOracleError extends Error {
|
|
|
60
81
|
}
|
|
61
82
|
});
|
|
62
83
|
// Build callback object and return it
|
|
63
|
-
|
|
84
|
+
const callback = oracleNames.reduce((acc, name)=>{
|
|
64
85
|
const method = this[name];
|
|
65
86
|
acc[name] = method.bind(this);
|
|
66
87
|
return acc;
|
|
67
88
|
}, {});
|
|
89
|
+
const allCallbacks = {
|
|
90
|
+
...callback,
|
|
91
|
+
...buildLegacyOracleCallbacks(this)
|
|
92
|
+
};
|
|
93
|
+
// Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
|
|
94
|
+
// contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
|
|
95
|
+
// minor version).
|
|
96
|
+
const handler = this.handler;
|
|
97
|
+
return new Proxy(allCallbacks, {
|
|
98
|
+
get (target, prop) {
|
|
99
|
+
if (prop in target) {
|
|
100
|
+
return target[prop];
|
|
101
|
+
}
|
|
102
|
+
// Return a function that throws with an enhanced error message if applicable
|
|
103
|
+
return ()=>{
|
|
104
|
+
let contractVersion = undefined;
|
|
105
|
+
if ('nonOracleFunctionGetContractOracleVersion' in handler) {
|
|
106
|
+
contractVersion = handler.nonOracleFunctionGetContractOracleVersion();
|
|
107
|
+
}
|
|
108
|
+
if (!contractVersion) {
|
|
109
|
+
throw new Error(`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` + `was not called before '${prop}'). This usually means the contract was not compiled with the ` + `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` + `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` + `is called before any other oracle calls. See https://docs.aztec.network/errors/8`);
|
|
110
|
+
} else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
|
|
111
|
+
throw new Error(`Oracle '${prop}' not found.` + ` This usually means the contract requires a newer private execution environment than you have.` + ` Upgrade your private execution environment to a compatible version. The contract was compiled with` + ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` + ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` + ` See https://docs.aztec.network/errors/8`);
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error(`Oracle '${prop}' not found.` + ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` + ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` + ` standard oracles should be available. This could mean the contract was compiled against a modified` + ` version of Aztec.nr, or that it references an oracle that does not exist.` + ` See https://docs.aztec.network/errors/8`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
68
118
|
}
|
|
69
|
-
|
|
70
|
-
|
|
119
|
+
// eslint-disable-next-line camelcase
|
|
120
|
+
aztec_utl_assertCompatibleOracleVersionV2([major], [minor]) {
|
|
121
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(major).toNumber(), Fr.fromString(minor).toNumber());
|
|
71
122
|
return Promise.resolve([]);
|
|
72
123
|
}
|
|
73
|
-
|
|
74
|
-
|
|
124
|
+
// eslint-disable-next-line camelcase
|
|
125
|
+
aztec_utl_getRandomField() {
|
|
126
|
+
const val = this.handlerAsMisc().getRandomField();
|
|
75
127
|
return Promise.resolve([
|
|
76
128
|
toACVMField(val)
|
|
77
129
|
]);
|
|
78
130
|
}
|
|
79
|
-
|
|
80
|
-
|
|
131
|
+
// eslint-disable-next-line camelcase
|
|
132
|
+
aztec_prv_setHashPreimage(values, [hash]) {
|
|
133
|
+
this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
|
|
81
134
|
return Promise.resolve([]);
|
|
82
135
|
}
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
// eslint-disable-next-line camelcase
|
|
137
|
+
async aztec_prv_getHashPreimage([returnsHash]) {
|
|
138
|
+
const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
|
|
85
139
|
return [
|
|
86
140
|
values.map(toACVMField)
|
|
87
141
|
];
|
|
88
142
|
}
|
|
89
|
-
|
|
90
|
-
|
|
143
|
+
// eslint-disable-next-line camelcase
|
|
144
|
+
aztec_utl_getUtilityContext() {
|
|
145
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
91
146
|
return Promise.resolve(context.toNoirRepresentation());
|
|
92
147
|
}
|
|
93
|
-
|
|
94
|
-
|
|
148
|
+
// eslint-disable-next-line camelcase
|
|
149
|
+
async aztec_utl_getKeyValidationRequest([pkMHash]) {
|
|
150
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
|
|
95
151
|
return keyValidationRequest.toFields().map(toACVMField);
|
|
96
152
|
}
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
// eslint-disable-next-line camelcase
|
|
154
|
+
async aztec_utl_getContractInstance([address]) {
|
|
155
|
+
const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
|
|
99
156
|
return [
|
|
100
157
|
instance.salt,
|
|
101
158
|
instance.deployer,
|
|
@@ -104,57 +161,69 @@ export class UnavailableOracleError extends Error {
|
|
|
104
161
|
...instance.publicKeys.toFields()
|
|
105
162
|
].map(toACVMField);
|
|
106
163
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const witness = await this.handlerAsUtility().
|
|
164
|
+
// eslint-disable-next-line camelcase
|
|
165
|
+
async aztec_utl_getNoteHashMembershipWitness([anchorBlockHash], [noteHash]) {
|
|
166
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
167
|
+
const parsedNoteHash = Fr.fromString(noteHash);
|
|
168
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
112
169
|
if (!witness) {
|
|
113
|
-
throw new Error(`
|
|
170
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`);
|
|
114
171
|
}
|
|
115
|
-
return
|
|
116
|
-
toACVMField(witness[0]),
|
|
117
|
-
witness.slice(1).map(toACVMField)
|
|
118
|
-
];
|
|
172
|
+
return witness.toNoirRepresentation();
|
|
119
173
|
}
|
|
120
|
-
|
|
121
|
-
|
|
174
|
+
// eslint-disable-next-line camelcase
|
|
175
|
+
async aztec_utl_getBlockHashMembershipWitness([anchorBlockHash], [blockHash]) {
|
|
176
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
177
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
178
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
179
|
+
if (!witness) {
|
|
180
|
+
throw new Error(`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`);
|
|
181
|
+
}
|
|
182
|
+
return witness.toNoirRepresentation();
|
|
183
|
+
}
|
|
184
|
+
// eslint-disable-next-line camelcase
|
|
185
|
+
async aztec_utl_getNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
186
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
122
187
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
123
|
-
const witness = await this.handlerAsUtility().
|
|
188
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
124
189
|
if (!witness) {
|
|
125
|
-
throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block ${
|
|
190
|
+
throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
126
191
|
}
|
|
127
192
|
return witness.toNoirRepresentation();
|
|
128
193
|
}
|
|
129
|
-
|
|
130
|
-
|
|
194
|
+
// eslint-disable-next-line camelcase
|
|
195
|
+
async aztec_utl_getLowNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
196
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
131
197
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
132
|
-
const witness = await this.handlerAsUtility().
|
|
198
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
133
199
|
if (!witness) {
|
|
134
|
-
throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block ${
|
|
200
|
+
throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
135
201
|
}
|
|
136
202
|
return witness.toNoirRepresentation();
|
|
137
203
|
}
|
|
138
|
-
|
|
139
|
-
|
|
204
|
+
// eslint-disable-next-line camelcase
|
|
205
|
+
async aztec_utl_getPublicDataWitness([blockHash], [leafSlot]) {
|
|
206
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
140
207
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
141
|
-
const witness = await this.handlerAsUtility().
|
|
208
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
142
209
|
if (!witness) {
|
|
143
|
-
throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block ${
|
|
210
|
+
throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`);
|
|
144
211
|
}
|
|
145
212
|
return witness.toNoirRepresentation();
|
|
146
213
|
}
|
|
147
|
-
|
|
214
|
+
// eslint-disable-next-line camelcase
|
|
215
|
+
async aztec_utl_getBlockHeader([blockNumber]) {
|
|
148
216
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
149
|
-
const header = await this.handlerAsUtility().
|
|
217
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
150
218
|
if (!header) {
|
|
151
219
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
152
220
|
}
|
|
153
221
|
return header.toFields().map(toACVMField);
|
|
154
222
|
}
|
|
155
|
-
|
|
223
|
+
// eslint-disable-next-line camelcase
|
|
224
|
+
async aztec_utl_getAuthWitness([messageHash]) {
|
|
156
225
|
const messageHashField = Fr.fromString(messageHash);
|
|
157
|
-
const witness = await this.handlerAsUtility().
|
|
226
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
158
227
|
if (!witness) {
|
|
159
228
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
160
229
|
}
|
|
@@ -162,79 +231,109 @@ export class UnavailableOracleError extends Error {
|
|
|
162
231
|
witness.map(toACVMField)
|
|
163
232
|
];
|
|
164
233
|
}
|
|
165
|
-
|
|
234
|
+
// eslint-disable-next-line camelcase
|
|
235
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]) {
|
|
166
236
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
167
|
-
const
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
237
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
238
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
239
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
240
|
+
if (result === undefined) {
|
|
241
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
242
|
+
return [
|
|
243
|
+
toACVMField(0),
|
|
244
|
+
Array(13).fill(toACVMField(0))
|
|
245
|
+
];
|
|
246
|
+
} else {
|
|
247
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
248
|
+
return [
|
|
249
|
+
toACVMField(1),
|
|
250
|
+
[
|
|
251
|
+
...result.publicKeys.toFields(),
|
|
252
|
+
result.partialAddress
|
|
253
|
+
].map(toACVMField)
|
|
254
|
+
];
|
|
255
|
+
}
|
|
174
256
|
}
|
|
175
|
-
|
|
257
|
+
// eslint-disable-next-line camelcase
|
|
258
|
+
async aztec_utl_getNotes([ownerSome], [ownerValue], [storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedHintedNoteLength]) {
|
|
176
259
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
177
260
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
178
|
-
const noteDatas = await this.handlerAsUtility().
|
|
179
|
-
const
|
|
261
|
+
const noteDatas = await this.handlerAsUtility().getNotes(owner, Fr.fromString(storageSlot), +numSelects, selectByIndexes.map((s)=>+s), selectByOffsets.map((s)=>+s), selectByLengths.map((s)=>+s), selectValues.map(Fr.fromString), selectComparators.map((s)=>+s), sortByIndexes.map((s)=>+s), sortByOffsets.map((s)=>+s), sortByLengths.map((s)=>+s), sortOrder.map((s)=>+s), +limit, +offset, +status);
|
|
262
|
+
const returnDataAsArrayOfPackedHintedNotes = noteDatas.map((noteData)=>packAsHintedNote({
|
|
180
263
|
contractAddress: noteData.contractAddress,
|
|
181
264
|
owner: noteData.owner,
|
|
182
265
|
randomness: noteData.randomness,
|
|
183
266
|
storageSlot: noteData.storageSlot,
|
|
184
267
|
noteNonce: noteData.noteNonce,
|
|
185
|
-
|
|
268
|
+
isPending: noteData.isPending,
|
|
186
269
|
note: noteData.note
|
|
187
270
|
}));
|
|
188
271
|
// Now we convert each sub-array to an array of ACVMField
|
|
189
|
-
const returnDataAsArrayOfACVMFieldArrays =
|
|
272
|
+
const returnDataAsArrayOfACVMFieldArrays = returnDataAsArrayOfPackedHintedNotes.map((subArray)=>subArray.map(toACVMField));
|
|
190
273
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
191
|
-
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +
|
|
274
|
+
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
192
275
|
}
|
|
193
|
-
|
|
194
|
-
|
|
276
|
+
// eslint-disable-next-line camelcase
|
|
277
|
+
aztec_prv_notifyCreatedNote([owner], [storageSlot], [randomness], [noteTypeId], note, [noteHash], [counter]) {
|
|
278
|
+
this.handlerAsPrivate().notifyCreatedNote(AztecAddress.fromString(owner), Fr.fromString(storageSlot), Fr.fromString(randomness), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
|
|
195
279
|
return Promise.resolve([]);
|
|
196
280
|
}
|
|
197
|
-
|
|
198
|
-
|
|
281
|
+
// eslint-disable-next-line camelcase
|
|
282
|
+
async aztec_prv_notifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
|
|
283
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
199
284
|
return [];
|
|
200
285
|
}
|
|
201
|
-
|
|
202
|
-
|
|
286
|
+
// eslint-disable-next-line camelcase
|
|
287
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]) {
|
|
288
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
203
289
|
return [];
|
|
204
290
|
}
|
|
205
|
-
|
|
206
|
-
|
|
291
|
+
// eslint-disable-next-line camelcase
|
|
292
|
+
async aztec_prv_isNullifierPending([innerNullifier], [contractAddress]) {
|
|
293
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(Fr.fromString(innerNullifier), AztecAddress.fromString(contractAddress));
|
|
294
|
+
return [
|
|
295
|
+
toACVMField(isPending)
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
// eslint-disable-next-line camelcase
|
|
299
|
+
async aztec_utl_doesNullifierExist([innerNullifier]) {
|
|
300
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
207
301
|
return [
|
|
208
302
|
toACVMField(exists)
|
|
209
303
|
];
|
|
210
304
|
}
|
|
211
|
-
|
|
212
|
-
|
|
305
|
+
// eslint-disable-next-line camelcase
|
|
306
|
+
async aztec_utl_getL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
|
|
307
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
|
|
213
308
|
return message.toNoirRepresentation();
|
|
214
309
|
}
|
|
215
|
-
|
|
216
|
-
|
|
310
|
+
// eslint-disable-next-line camelcase
|
|
311
|
+
async aztec_utl_getFromPublicStorage([blockHash], [contractAddress], [startStorageSlot], [numberOfElements]) {
|
|
312
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(BlockHash.fromString(blockHash), new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +numberOfElements);
|
|
217
313
|
return [
|
|
218
314
|
values.map(toACVMField)
|
|
219
315
|
];
|
|
220
316
|
}
|
|
221
|
-
|
|
317
|
+
// eslint-disable-next-line camelcase
|
|
318
|
+
aztec_prv_notifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
|
|
222
319
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
223
320
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
224
|
-
this.handlerAsPrivate().
|
|
321
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
225
322
|
return Promise.resolve([]);
|
|
226
323
|
}
|
|
227
|
-
|
|
324
|
+
// eslint-disable-next-line camelcase
|
|
325
|
+
async aztec_utl_log(level, message, _ignoredFieldsSize, fields) {
|
|
228
326
|
const levelFr = Fr.fromString(level[0]);
|
|
229
327
|
const messageStr = message.map((acvmField)=>String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
230
328
|
const fieldsFr = fields.map(Fr.fromString);
|
|
231
|
-
this.handlerAsMisc().
|
|
232
|
-
return
|
|
329
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
330
|
+
return [];
|
|
233
331
|
}
|
|
234
332
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
235
333
|
// change the name here.
|
|
236
|
-
|
|
237
|
-
|
|
334
|
+
// eslint-disable-next-line camelcase
|
|
335
|
+
async aztec_prv_callPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
|
|
336
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
238
337
|
return [
|
|
239
338
|
[
|
|
240
339
|
endSideEffectCounter,
|
|
@@ -242,48 +341,84 @@ export class UnavailableOracleError extends Error {
|
|
|
242
341
|
].map(toACVMField)
|
|
243
342
|
];
|
|
244
343
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
async privateNotifySetPublicTeardownFunctionCall([contractAddress], [calldataHash], [sideEffectCounter], [isStaticCall]) {
|
|
250
|
-
await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(AztecAddress.fromString(contractAddress), Fr.fromString(calldataHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
344
|
+
// eslint-disable-next-line camelcase
|
|
345
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]) {
|
|
346
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
251
347
|
return [];
|
|
252
348
|
}
|
|
253
|
-
|
|
254
|
-
|
|
349
|
+
// eslint-disable-next-line camelcase
|
|
350
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]) {
|
|
351
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
255
352
|
return Promise.resolve([]);
|
|
256
353
|
}
|
|
257
|
-
|
|
258
|
-
|
|
354
|
+
// eslint-disable-next-line camelcase
|
|
355
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]) {
|
|
356
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(Fr.fromString(sideEffectCounter).toNumber());
|
|
259
357
|
return Promise.resolve([
|
|
260
358
|
toACVMField(isRevertible)
|
|
261
359
|
]);
|
|
262
360
|
}
|
|
263
|
-
|
|
264
|
-
|
|
361
|
+
// eslint-disable-next-line camelcase
|
|
362
|
+
async aztec_prv_getNextAppTagAsSender([sender], [recipient]) {
|
|
363
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
|
|
265
364
|
return [
|
|
266
365
|
toACVMField(tag.value)
|
|
267
366
|
];
|
|
268
367
|
}
|
|
269
|
-
|
|
270
|
-
|
|
368
|
+
// eslint-disable-next-line camelcase
|
|
369
|
+
async aztec_utl_getPendingTaggedLogs([pendingTaggedLogArrayBaseSlot], [scope]) {
|
|
370
|
+
await this.handlerAsUtility().getPendingTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot), AztecAddress.fromString(scope));
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
// eslint-disable-next-line camelcase
|
|
374
|
+
async aztec_utl_getPendingTaggedLogs_v2([scope]) {
|
|
375
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
|
|
376
|
+
return [
|
|
377
|
+
toACVMField(slot)
|
|
378
|
+
];
|
|
379
|
+
}
|
|
380
|
+
// eslint-disable-next-line camelcase
|
|
381
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
382
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
271
383
|
return [];
|
|
272
384
|
}
|
|
273
|
-
|
|
274
|
-
|
|
385
|
+
// eslint-disable-next-line camelcase
|
|
386
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2([noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
387
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
275
388
|
return [];
|
|
276
389
|
}
|
|
277
|
-
|
|
278
|
-
|
|
390
|
+
// eslint-disable-next-line camelcase
|
|
391
|
+
async aztec_utl_getLogsByTag([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot], [scope]) {
|
|
392
|
+
await this.handlerAsUtility().getLogsByTag(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
279
393
|
return [];
|
|
280
394
|
}
|
|
281
|
-
|
|
282
|
-
|
|
395
|
+
// eslint-disable-next-line camelcase
|
|
396
|
+
async aztec_utl_getMessageContextsByTxHash([contractAddress], [messageContextRequestsArrayBaseSlot], [messageContextResponsesArrayBaseSlot], [scope]) {
|
|
397
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(AztecAddress.fromString(contractAddress), Fr.fromString(messageContextRequestsArrayBaseSlot), Fr.fromString(messageContextResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
283
398
|
return [];
|
|
284
399
|
}
|
|
285
|
-
|
|
286
|
-
|
|
400
|
+
// eslint-disable-next-line camelcase
|
|
401
|
+
async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]) {
|
|
402
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
|
|
403
|
+
return [
|
|
404
|
+
toACVMField(responseSlot)
|
|
405
|
+
];
|
|
406
|
+
}
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]) {
|
|
409
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(Fr.fromString(requestArrayBaseSlot));
|
|
410
|
+
return [
|
|
411
|
+
toACVMField(responseSlot)
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
// eslint-disable-next-line camelcase
|
|
415
|
+
aztec_utl_setCapsule([contractAddress], [slot], capsule, [scope]) {
|
|
416
|
+
this.handlerAsUtility().setCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString), AztecAddress.fromField(Fr.fromString(scope)));
|
|
417
|
+
return Promise.resolve([]);
|
|
418
|
+
}
|
|
419
|
+
// eslint-disable-next-line camelcase
|
|
420
|
+
async aztec_utl_getCapsule([contractAddress], [slot], [tSize], [scope]) {
|
|
421
|
+
const values = await this.handlerAsUtility().getCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
287
422
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
288
423
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
289
424
|
if (values === null) {
|
|
@@ -300,35 +435,107 @@ export class UnavailableOracleError extends Error {
|
|
|
300
435
|
];
|
|
301
436
|
}
|
|
302
437
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
438
|
+
// eslint-disable-next-line camelcase
|
|
439
|
+
aztec_utl_deleteCapsule([contractAddress], [slot], [scope]) {
|
|
440
|
+
this.handlerAsUtility().deleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
441
|
+
return Promise.resolve([]);
|
|
306
442
|
}
|
|
307
|
-
|
|
308
|
-
|
|
443
|
+
// eslint-disable-next-line camelcase
|
|
444
|
+
async aztec_utl_copyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries], [scope]) {
|
|
445
|
+
await this.handlerAsUtility().copyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber(), AztecAddress.fromField(Fr.fromString(scope)));
|
|
309
446
|
return [];
|
|
310
447
|
}
|
|
311
|
-
|
|
448
|
+
// eslint-disable-next-line camelcase
|
|
449
|
+
aztec_utl_pushEphemeral([slot], elements) {
|
|
450
|
+
const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
|
|
451
|
+
return Promise.resolve([
|
|
452
|
+
toACVMField(newLen)
|
|
453
|
+
]);
|
|
454
|
+
}
|
|
455
|
+
// eslint-disable-next-line camelcase
|
|
456
|
+
aztec_utl_popEphemeral([slot]) {
|
|
457
|
+
const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
|
|
458
|
+
return Promise.resolve([
|
|
459
|
+
element.map(toACVMField)
|
|
460
|
+
]);
|
|
461
|
+
}
|
|
462
|
+
// eslint-disable-next-line camelcase
|
|
463
|
+
aztec_utl_getEphemeral([slot], [index]) {
|
|
464
|
+
const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
465
|
+
return Promise.resolve([
|
|
466
|
+
element.map(toACVMField)
|
|
467
|
+
]);
|
|
468
|
+
}
|
|
469
|
+
// eslint-disable-next-line camelcase
|
|
470
|
+
aztec_utl_setEphemeral([slot], [index], elements) {
|
|
471
|
+
this.handlerAsUtility().setEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber(), elements.map(Fr.fromString));
|
|
472
|
+
return Promise.resolve([]);
|
|
473
|
+
}
|
|
474
|
+
// eslint-disable-next-line camelcase
|
|
475
|
+
aztec_utl_getEphemeralLen([slot]) {
|
|
476
|
+
const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
|
|
477
|
+
return Promise.resolve([
|
|
478
|
+
toACVMField(len)
|
|
479
|
+
]);
|
|
480
|
+
}
|
|
481
|
+
// eslint-disable-next-line camelcase
|
|
482
|
+
aztec_utl_removeEphemeral([slot], [index]) {
|
|
483
|
+
this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
484
|
+
return Promise.resolve([]);
|
|
485
|
+
}
|
|
486
|
+
// eslint-disable-next-line camelcase
|
|
487
|
+
aztec_utl_clearEphemeral([slot]) {
|
|
488
|
+
this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
|
|
489
|
+
return Promise.resolve([]);
|
|
490
|
+
}
|
|
491
|
+
// eslint-disable-next-line camelcase
|
|
492
|
+
async aztec_utl_decryptAes128(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
|
|
312
493
|
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
313
494
|
const ivBuffer = fromUintArray(iv, 8);
|
|
314
495
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
315
|
-
|
|
316
|
-
|
|
496
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
497
|
+
try {
|
|
498
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
499
|
+
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
500
|
+
return [
|
|
501
|
+
toACVMField(1),
|
|
502
|
+
storage,
|
|
503
|
+
length
|
|
504
|
+
];
|
|
505
|
+
} catch {
|
|
506
|
+
const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
|
|
507
|
+
return [
|
|
508
|
+
toACVMField(0),
|
|
509
|
+
zeroStorage,
|
|
510
|
+
toACVMField(0)
|
|
511
|
+
];
|
|
512
|
+
}
|
|
317
513
|
}
|
|
318
|
-
|
|
319
|
-
|
|
514
|
+
// eslint-disable-next-line camelcase
|
|
515
|
+
async aztec_utl_getSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2], [contractAddress]) {
|
|
516
|
+
const secret = await this.handlerAsUtility().getSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
|
|
320
517
|
ephPKField0,
|
|
321
518
|
ephPKField1,
|
|
322
519
|
ephPKField2
|
|
323
|
-
].map(Fr.fromString)));
|
|
324
|
-
return
|
|
520
|
+
].map(Fr.fromString)), AztecAddress.fromField(Fr.fromString(contractAddress)));
|
|
521
|
+
return [
|
|
522
|
+
toACVMField(secret)
|
|
523
|
+
];
|
|
524
|
+
}
|
|
525
|
+
// eslint-disable-next-line camelcase
|
|
526
|
+
aztec_utl_setContractSyncCacheInvalid([contractAddress], scopes, [scopeCount]) {
|
|
527
|
+
const scopeAddresses = scopes.slice(0, +scopeCount).map((s)=>AztecAddress.fromField(Fr.fromString(s)));
|
|
528
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(AztecAddress.fromField(Fr.fromString(contractAddress)), scopeAddresses);
|
|
529
|
+
return Promise.resolve([]);
|
|
325
530
|
}
|
|
326
|
-
|
|
327
|
-
|
|
531
|
+
// eslint-disable-next-line camelcase
|
|
532
|
+
async aztec_utl_emitOffchainEffect(data) {
|
|
533
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
328
534
|
return [];
|
|
329
535
|
}
|
|
330
|
-
|
|
331
|
-
|
|
536
|
+
// eslint-disable-next-line camelcase
|
|
537
|
+
async aztec_prv_getSenderForTags() {
|
|
538
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
332
539
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
333
540
|
return sender ? [
|
|
334
541
|
toACVMField(1n),
|
|
@@ -338,8 +545,9 @@ export class UnavailableOracleError extends Error {
|
|
|
338
545
|
toACVMField(0n)
|
|
339
546
|
];
|
|
340
547
|
}
|
|
341
|
-
|
|
342
|
-
|
|
548
|
+
// eslint-disable-next-line camelcase
|
|
549
|
+
async aztec_prv_setSenderForTags([senderForTags]) {
|
|
550
|
+
await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
343
551
|
return [];
|
|
344
552
|
}
|
|
345
553
|
}
|