@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.5476d83
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/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +39 -0
- package/dest/config/index.d.ts +11 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -33
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +300 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +265 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_data_provider.js +14 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +94 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +190 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +23 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +48 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +100 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +17 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +50 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +333 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +231 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +428 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +153 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
- package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_node.js +27 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.js +694 -0
- package/dest/entrypoints/client/bundle/index.d.ts +5 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +18 -12
- package/dest/entrypoints/client/lazy/index.d.ts +5 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +14 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +6 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -3
- package/dest/entrypoints/server/utils.d.ts +8 -16
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +30 -35
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
- package/dest/oracle_version.d.ts +3 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +10 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts +3 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.js +48 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +289 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +62 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +45 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
- package/dest/pxe.d.ts +240 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +771 -0
- package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/address_data_provider/index.d.ts +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +15 -6
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
- package/dest/storage/capsule_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +13 -58
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +89 -79
- package/dest/storage/contract_data_provider/index.d.ts +1 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
- package/dest/storage/index.d.ts +3 -4
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -3
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_data_provider/index.d.ts +2 -2
- package/dest/storage/note_data_provider/index.d.ts.map +1 -1
- package/dest/storage/note_data_provider/index.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +73 -10
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +145 -83
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +37 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +105 -0
- package/dest/storage/sync_data_provider/index.d.ts +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +3 -5
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
- package/dest/storage/tagging_data_provider/index.d.ts +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
- package/dest/synchronizer/index.d.ts +1 -1
- package/dest/synchronizer/synchronizer.d.ts +8 -10
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +17 -19
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +37 -34
- package/src/bin/check_oracle_version.ts +50 -0
- package/src/config/index.ts +27 -55
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +553 -0
- package/src/contract_function_simulator/execution_data_provider.ts +333 -0
- package/src/contract_function_simulator/execution_note_cache.ts +229 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +61 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +170 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +54 -0
- package/src/contract_function_simulator/oracle/oracle.ts +583 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +633 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
- package/src/contract_function_simulator/proxied_node.ts +33 -0
- package/src/contract_function_simulator/pxe_oracle_interface.ts +1008 -0
- package/src/entrypoints/client/bundle/index.ts +4 -2
- package/src/entrypoints/client/bundle/utils.ts +36 -36
- package/src/entrypoints/client/lazy/index.ts +4 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -31
- package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
- package/src/entrypoints/server/index.ts +5 -3
- package/src/entrypoints/server/utils.ts +58 -50
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
- package/src/oracle_version.ts +11 -0
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -146
- package/src/private_kernel/hints/compute_side_effect_uniqueness_hints.ts +173 -0
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
- package/src/pxe.ts +1085 -0
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
- package/src/storage/contract_data_provider/contract_data_provider.ts +109 -93
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
- package/src/storage/index.ts +2 -4
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_data_provider/index.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +176 -122
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +143 -0
- package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
- package/src/synchronizer/synchronizer.ts +21 -22
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts +0 -45
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -106
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -38
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/data_provider.ts +0 -3
- package/src/storage/note_data_provider/note_dao.ts +0 -162
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
|
|
5
|
-
export declare class AddressDataProvider implements DataProvider {
|
|
4
|
+
export declare class AddressDataProvider {
|
|
6
5
|
#private;
|
|
7
6
|
constructor(store: AztecAsyncKVStore);
|
|
8
7
|
addCompleteAddress(completeAddress: CompleteAddress): Promise<boolean>;
|
|
9
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
10
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
11
|
-
getSize(): Promise<number>;
|
|
12
10
|
}
|
|
13
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19kYXRhX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9hZGRyZXNzX2RhdGFfcHJvdmlkZXIvYWRkcmVzc19kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFtQixpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RixPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsbUJBQW1COztJQUs5QixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFLbkM7SUFFRCxrQkFBa0IsQ0FBQyxlQUFlLEVBQUUsZUFBZSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0EwQnJFO0lBWUQsa0JBQWtCLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsZUFBZSxHQUFHLFNBQVMsQ0FBQyxDQUU5RTtJQUVLLG9CQUFvQixJQUFJLE9BQU8sQ0FBQyxlQUFlLEVBQUUsQ0FBQyxDQUl2RDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,mBAAmB;;IAK9B,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAYD,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAE9E;IAEK,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAIvD;CACF"}
|
|
@@ -44,7 +44,4 @@ export class AddressDataProvider {
|
|
|
44
44
|
async getCompleteAddresses() {
|
|
45
45
|
return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
|
|
46
46
|
}
|
|
47
|
-
async getSize() {
|
|
48
|
-
return await this.#completeAddresses.lengthAsync() * CompleteAddress.SIZE_IN_BYTES;
|
|
49
|
-
}
|
|
50
47
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AddressDataProvider } from './address_data_provider.js';
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2FkZHJlc3NfZGF0YV9wcm92aWRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQyJ9
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
|
|
6
|
-
export declare class CapsuleDataProvider implements DataProvider {
|
|
5
|
+
export declare class CapsuleDataProvider {
|
|
7
6
|
#private;
|
|
8
|
-
|
|
7
|
+
logger: Logger;
|
|
9
8
|
constructor(store: AztecAsyncKVStore);
|
|
10
9
|
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
|
|
11
10
|
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
|
|
12
11
|
deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
|
|
13
12
|
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
15
|
+
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
16
|
+
* All operations are performed in a single transaction.
|
|
17
|
+
* @param contractAddress - The contract address that owns the capsule array
|
|
18
|
+
* @param baseSlot - The slot where the array length is stored
|
|
19
|
+
* @param content - Array of capsule data to append
|
|
20
|
+
*/
|
|
21
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
22
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]>;
|
|
23
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
15
24
|
}
|
|
16
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9kYXRhX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9jYXBzdWxlX2RhdGFfcHJvdmlkZXIvY2Fwc3VsZV9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUM5QyxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEUscUJBQWEsbUJBQW1COztJQU05QixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBRWYsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBTW5DO0lBRUssWUFBWSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUV4RjtJQUVLLFdBQVcsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsRUFBRSxHQUFHLElBQUksQ0FBQyxDQVcvRTtJQUVLLGFBQWEsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUxRTtJQUVELFdBQVcsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLE9BQU8sRUFBRSxFQUFFLEVBQUUsT0FBTyxFQUFFLEVBQUUsRUFBRSxVQUFVLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0F3QnRHO0lBRUQ7Ozs7Ozs7T0FPRztJQUNILG9CQUFvQixDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBZ0JoRztJQUVELGdCQUFnQixDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsRUFBRSxFQUFFLEVBQUUsQ0FBQyxDQXNCN0U7SUFFRCxlQUFlLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsRUFBRSxFQUFFLE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxpQkFtQjNFO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EA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|
-
import {
|
|
3
|
-
import { createDebugOnlyLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
export class CapsuleDataProvider {
|
|
5
4
|
#store;
|
|
6
5
|
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
7
6
|
#capsules;
|
|
8
|
-
|
|
7
|
+
logger;
|
|
9
8
|
constructor(store){
|
|
10
9
|
this.#store = store;
|
|
11
10
|
this.#capsules = this.#store.openMap('capsules');
|
|
12
|
-
this.
|
|
11
|
+
this.logger = createLogger('pxe:capsule-data-provider');
|
|
13
12
|
}
|
|
14
13
|
async storeCapsule(contractAddress, slot, capsule) {
|
|
15
14
|
await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map((value)=>value.toBuffer())));
|
|
@@ -17,7 +16,7 @@ export class CapsuleDataProvider {
|
|
|
17
16
|
async loadCapsule(contractAddress, slot) {
|
|
18
17
|
const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
|
|
19
18
|
if (!dataBuffer) {
|
|
20
|
-
this.
|
|
19
|
+
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
23
22
|
const capsule = [];
|
|
@@ -29,29 +28,91 @@ export class CapsuleDataProvider {
|
|
|
29
28
|
async deleteCapsule(contractAddress, slot) {
|
|
30
29
|
await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const i of indexes){
|
|
42
|
-
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
43
|
-
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
44
|
-
const toCopy = await this.#capsules.getAsync(currentSrcSlot);
|
|
45
|
-
if (!toCopy) {
|
|
46
|
-
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
31
|
+
copyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
|
|
32
|
+
return this.#store.transactionAsync(async ()=>{
|
|
33
|
+
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
34
|
+
// and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
|
|
35
|
+
// indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
|
|
36
|
+
// indexes to avoid reading elements that've been overwritten.
|
|
37
|
+
const indexes = Array.from(Array(numEntries).keys());
|
|
38
|
+
if (srcSlot.lt(dstSlot)) {
|
|
39
|
+
indexes.reverse();
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
for (const i of indexes){
|
|
42
|
+
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
43
|
+
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
44
|
+
const toCopy = await this.#capsules.getAsync(currentSrcSlot);
|
|
45
|
+
if (!toCopy) {
|
|
46
|
+
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
await this.#capsules.set(currentDstSlot, toCopy);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
54
|
+
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
55
|
+
* All operations are performed in a single transaction.
|
|
56
|
+
* @param contractAddress - The contract address that owns the capsule array
|
|
57
|
+
* @param baseSlot - The slot where the array length is stored
|
|
58
|
+
* @param content - Array of capsule data to append
|
|
59
|
+
*/ appendToCapsuleArray(contractAddress, baseSlot, content) {
|
|
60
|
+
return this.#store.transactionAsync(async ()=>{
|
|
61
|
+
// Load current length, defaulting to 0 if not found
|
|
62
|
+
const lengthData = await this.loadCapsule(contractAddress, baseSlot);
|
|
63
|
+
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
64
|
+
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
65
|
+
for(let i = 0; i < content.length; i++){
|
|
66
|
+
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
67
|
+
await this.storeCapsule(contractAddress, nextSlot, content[i]);
|
|
68
|
+
}
|
|
69
|
+
// Update length to include all new capsules
|
|
70
|
+
const newLength = currentLength + content.length;
|
|
71
|
+
await this.storeCapsule(contractAddress, baseSlot, [
|
|
72
|
+
new Fr(newLength)
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
50
75
|
}
|
|
51
|
-
|
|
52
|
-
return
|
|
76
|
+
readCapsuleArray(contractAddress, baseSlot) {
|
|
77
|
+
return this.#store.transactionAsync(async ()=>{
|
|
78
|
+
// Load length, defaulting to 0 if not found
|
|
79
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
80
|
+
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
81
|
+
const values = [];
|
|
82
|
+
// Read each capsule at consecutive slots after baseSlot
|
|
83
|
+
for(let i = 0; i < length; i++){
|
|
84
|
+
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
85
|
+
if (currentValue == undefined) {
|
|
86
|
+
throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
|
|
87
|
+
}
|
|
88
|
+
values.push(currentValue);
|
|
89
|
+
}
|
|
90
|
+
return values;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
setCapsuleArray(contractAddress, baseSlot, content) {
|
|
94
|
+
return this.#store.transactionAsync(async ()=>{
|
|
95
|
+
// Load current length, defaulting to 0 if not found
|
|
96
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
97
|
+
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
98
|
+
// Set the new length
|
|
99
|
+
await this.storeCapsule(contractAddress, baseSlot, [
|
|
100
|
+
new Fr(content.length)
|
|
101
|
+
]);
|
|
102
|
+
// Store the new content, possibly overwriting existing values
|
|
103
|
+
for(let i = 0; i < content.length; i++){
|
|
104
|
+
await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
|
|
105
|
+
}
|
|
106
|
+
// Clear any stragglers
|
|
107
|
+
for(let i = content.length; i < originalLength; i++){
|
|
108
|
+
await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
53
111
|
}
|
|
54
112
|
}
|
|
55
113
|
function dbSlotToKey(contractAddress, slot) {
|
|
56
114
|
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
57
115
|
}
|
|
116
|
+
function arraySlot(baseSlot, index) {
|
|
117
|
+
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
118
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { CapsuleDataProvider } from './capsule_data_provider.js';
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NhcHN1bGVfZGF0YV9wcm92aWRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQyJ9
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
1
|
+
import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
3
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import { type ContractArtifact, type
|
|
5
|
+
import { type ContractArtifact, type FunctionAbi, type FunctionArtifactWithContractName, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
7
|
import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
9
|
-
import type { DataProvider } from '../data_provider.js';
|
|
10
8
|
/**
|
|
11
9
|
* ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
|
|
12
10
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
@@ -14,41 +12,17 @@ import type { DataProvider } from '../data_provider.js';
|
|
|
14
12
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
15
13
|
* the required information and facilitate cryptographic proof generation.
|
|
16
14
|
*/
|
|
17
|
-
export declare class ContractDataProvider
|
|
15
|
+
export declare class ContractDataProvider {
|
|
18
16
|
#private;
|
|
19
|
-
/** Map from contract class id to private function tree. */
|
|
20
|
-
private contractClassesCache;
|
|
21
17
|
constructor(store: AztecAsyncKVStore);
|
|
22
18
|
addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
|
|
23
19
|
addContractInstance(contract: ContractInstanceWithAddress): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Retrieve or create a ContractTree instance based on the provided class id.
|
|
26
|
-
* If an existing tree with the same class id is found in the cache, it will be returned.
|
|
27
|
-
* Otherwise, a new ContractTree instance will be created using the contract data from the database
|
|
28
|
-
* and added to the cache before returning.
|
|
29
|
-
*
|
|
30
|
-
* @param classId - The class id of the contract for which the ContractTree is required.
|
|
31
|
-
* @returns A ContractTree instance associated with the specified contract address.
|
|
32
|
-
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
33
|
-
*/
|
|
34
|
-
private getTreeForClassId;
|
|
35
|
-
/**
|
|
36
|
-
* Retrieve or create a ContractTree instance based on the provided AztecAddress.
|
|
37
|
-
* If an existing tree with the same contract address is found in the cache, it will be returned.
|
|
38
|
-
* Otherwise, a new ContractTree instance will be created using the contract data from the database
|
|
39
|
-
* and added to the cache before returning.
|
|
40
|
-
*
|
|
41
|
-
* @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
|
|
42
|
-
* @returns A ContractTree instance associated with the specified contract address.
|
|
43
|
-
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
44
|
-
*/
|
|
45
|
-
private getTreeForAddress;
|
|
46
20
|
getContractsAddresses(): Promise<AztecAddress[]>;
|
|
47
21
|
/** Returns a contract instance for a given address. Throws if not found. */
|
|
48
|
-
getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress>;
|
|
49
|
-
getContractArtifact(contractClassId: Fr): Promise<ContractArtifact>;
|
|
22
|
+
getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
23
|
+
getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined>;
|
|
50
24
|
/** Returns a contract class for a given class id. Throws if not found. */
|
|
51
|
-
getContractClass(contractClassId: Fr): Promise<ContractClass>;
|
|
25
|
+
getContractClass(contractClassId: Fr): Promise<ContractClass | undefined>;
|
|
52
26
|
getContract(address: AztecAddress): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined>;
|
|
53
27
|
/**
|
|
54
28
|
* Retrieves the artifact of a specified function within a given contract.
|
|
@@ -59,17 +33,9 @@ export declare class ContractDataProvider implements DataProvider {
|
|
|
59
33
|
* @param selector - The function selector.
|
|
60
34
|
* @returns The corresponding function's artifact as an object.
|
|
61
35
|
*/
|
|
62
|
-
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* The function is identified by its name, which is unique within a contract.
|
|
66
|
-
* Throws if the contract has not been added to the database.
|
|
67
|
-
*
|
|
68
|
-
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
69
|
-
* @param functionName - The name of the function.
|
|
70
|
-
* @returns The corresponding function's artifact as an object
|
|
71
|
-
*/
|
|
72
|
-
getFunctionArtifactByName(contractAddress: AztecAddress, functionName: string): Promise<FunctionArtifact | undefined>;
|
|
36
|
+
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifactWithContractName | undefined>;
|
|
37
|
+
getPublicFunctionArtifact(contractAddress: AztecAddress): Promise<FunctionArtifactWithContractName | undefined>;
|
|
38
|
+
getFunctionAbi(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionAbi | undefined>;
|
|
73
39
|
/**
|
|
74
40
|
* Retrieves the debug metadata of a specified function within a given contract.
|
|
75
41
|
* The function is identified by its selector, which is a unique code generated from the function's signature.
|
|
@@ -81,17 +47,7 @@ export declare class ContractDataProvider implements DataProvider {
|
|
|
81
47
|
* @returns The corresponding function's artifact as an object.
|
|
82
48
|
*/
|
|
83
49
|
getFunctionDebugMetadata(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionDebugMetadata | undefined>;
|
|
84
|
-
|
|
85
|
-
* Retrieve the bytecode of a specific function in a contract at the given address.
|
|
86
|
-
* The returned bytecode is required for executing and verifying the function's behavior
|
|
87
|
-
* in the Aztec network. Throws an error if the contract or function cannot be found.
|
|
88
|
-
*
|
|
89
|
-
* @param contractAddress - The contract's address.
|
|
90
|
-
* @param selector - The function selector.
|
|
91
|
-
* @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
|
|
92
|
-
* @throws Error if the contract address is unknown or not found.
|
|
93
|
-
*/
|
|
94
|
-
getBytecode(contractAddress: AztecAddress, selector: FunctionSelector): Promise<Buffer>;
|
|
50
|
+
getPublicFunctionDebugMetadata(contractAddress: AztecAddress): Promise<FunctionDebugMetadata | undefined>;
|
|
95
51
|
/**
|
|
96
52
|
* Retrieve the function membership witness for the given contract class and function selector.
|
|
97
53
|
* The function membership witness represents a proof that the function belongs to the specified contract.
|
|
@@ -101,9 +57,8 @@ export declare class ContractDataProvider implements DataProvider {
|
|
|
101
57
|
* @param selector - The function selector.
|
|
102
58
|
* @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
|
|
103
59
|
*/
|
|
104
|
-
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<
|
|
105
|
-
getDebugContractName(contractAddress: AztecAddress): Promise<string>;
|
|
60
|
+
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined>;
|
|
61
|
+
getDebugContractName(contractAddress: AztecAddress): Promise<string | undefined>;
|
|
106
62
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
107
|
-
getSize(): Promise<number>;
|
|
108
63
|
}
|
|
109
|
-
//# sourceMappingURL=
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvY29udHJhY3RfZGF0YV9wcm92aWRlci9jb250cmFjdF9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFbkQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEVBQ0wsS0FBSyxnQkFBZ0IsR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kJGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAEhB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAGjC,MAAM,wBAAwB,CAAC;AAIhC;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAW/B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;IAIY,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBlF;IAEK,mBAAmB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9E;IA4CK,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAGrD;IAED,4EAA4E;IAC/D,mBAAmB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGhH;IAEY,mBAAmB,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,gBAAgB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|
|
3
2
|
import { FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
4
|
+
import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
6
5
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
7
6
|
/**
|
|
8
7
|
* ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
|
|
@@ -11,7 +10,9 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
11
10
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
12
11
|
* the required information and facilitate cryptographic proof generation.
|
|
13
12
|
*/ export class ContractDataProvider {
|
|
14
|
-
/** Map from contract class id to private function tree. */
|
|
13
|
+
/** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
14
|
+
#privateFunctionTrees = new Map();
|
|
15
|
+
/** Map from contract address to contract class id */ #contractClassIdMap = new Map();
|
|
15
16
|
#contractArtifacts;
|
|
16
17
|
#contractInstances;
|
|
17
18
|
constructor(store){
|
|
@@ -28,17 +29,19 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
28
29
|
await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
|
|
29
30
|
}
|
|
30
31
|
async addContractInstance(contract) {
|
|
32
|
+
this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
|
|
31
33
|
await this.#contractInstances.set(contract.address.toString(), new SerializableContractInstance(contract).toBuffer());
|
|
32
34
|
}
|
|
33
35
|
// Private getters
|
|
34
|
-
async #
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
async #getContractClassId(contractAddress) {
|
|
37
|
+
if (!this.#contractClassIdMap.has(contractAddress.toString())) {
|
|
38
|
+
const instance = await this.getContractInstance(contractAddress);
|
|
39
|
+
if (!instance) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
|
|
43
|
+
}
|
|
44
|
+
return this.#contractClassIdMap.get(contractAddress.toString());
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* Retrieve or create a ContractTree instance based on the provided class id.
|
|
@@ -49,29 +52,20 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
49
52
|
* @param classId - The class id of the contract for which the ContractTree is required.
|
|
50
53
|
* @returns A ContractTree instance associated with the specified contract address.
|
|
51
54
|
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
52
|
-
*/ async
|
|
53
|
-
if (!this.
|
|
54
|
-
const artifact = await this
|
|
55
|
+
*/ async #getPrivateFunctionTreeForClassId(classId) {
|
|
56
|
+
if (!this.#privateFunctionTrees.has(classId.toString())) {
|
|
57
|
+
const artifact = await this.getContractArtifact(classId);
|
|
55
58
|
if (!artifact) {
|
|
56
|
-
|
|
59
|
+
return;
|
|
57
60
|
}
|
|
58
61
|
const tree = await PrivateFunctionsTree.create(artifact);
|
|
59
|
-
this.
|
|
62
|
+
this.#privateFunctionTrees.set(classId.toString(), tree);
|
|
60
63
|
}
|
|
61
|
-
return this.
|
|
64
|
+
return this.#privateFunctionTrees.get(classId.toString());
|
|
62
65
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* Otherwise, a new ContractTree instance will be created using the contract data from the database
|
|
67
|
-
* and added to the cache before returning.
|
|
68
|
-
*
|
|
69
|
-
* @param contractAddress - The AztecAddress of the contract for which the ContractTree is required.
|
|
70
|
-
* @returns A ContractTree instance associated with the specified contract address.
|
|
71
|
-
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
72
|
-
*/ async getTreeForAddress(contractAddress) {
|
|
73
|
-
const instance = await this.getContractInstance(contractAddress);
|
|
74
|
-
return this.getTreeForClassId(instance.currentContractClassId);
|
|
66
|
+
async #getContractArtifactByAddress(contractAddress) {
|
|
67
|
+
const contractClassId = await this.#getContractClassId(contractAddress);
|
|
68
|
+
return contractClassId && this.getContractArtifact(contractClassId);
|
|
75
69
|
}
|
|
76
70
|
// Public getters
|
|
77
71
|
async getContractsAddresses() {
|
|
@@ -79,25 +73,26 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
79
73
|
return keys.map(AztecAddress.fromString);
|
|
80
74
|
}
|
|
81
75
|
/** Returns a contract instance for a given address. Throws if not found. */ async getContractInstance(contractAddress) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
throw new ContractNotFoundError(contractAddress.toString());
|
|
85
|
-
}
|
|
86
|
-
return instance;
|
|
76
|
+
const contract = await this.#contractInstances.getAsync(contractAddress.toString());
|
|
77
|
+
return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
|
|
87
78
|
}
|
|
88
79
|
async getContractArtifact(contractClassId) {
|
|
89
|
-
const
|
|
90
|
-
|
|
80
|
+
const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
|
|
81
|
+
// TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
|
|
82
|
+
return contract && contractArtifactFromBuffer(Buffer.from(contract));
|
|
91
83
|
}
|
|
92
84
|
/** Returns a contract class for a given class id. Throws if not found. */ async getContractClass(contractClassId) {
|
|
93
|
-
const
|
|
94
|
-
return
|
|
85
|
+
const artifact = await this.getContractArtifact(contractClassId);
|
|
86
|
+
return artifact && getContractClassFromArtifact(artifact);
|
|
95
87
|
}
|
|
96
88
|
async getContract(address) {
|
|
97
89
|
const instance = await this.getContractInstance(address);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
if (!instance) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const artifact = await this.getContractArtifact(instance.currentContractClassId);
|
|
94
|
+
if (!artifact) {
|
|
95
|
+
return;
|
|
101
96
|
}
|
|
102
97
|
return {
|
|
103
98
|
...instance,
|
|
@@ -113,20 +108,24 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
113
108
|
* @param selector - The function selector.
|
|
114
109
|
* @returns The corresponding function's artifact as an object.
|
|
115
110
|
*/ async getFunctionArtifact(contractAddress, selector) {
|
|
116
|
-
const
|
|
117
|
-
|
|
111
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
112
|
+
const fnArtifact = artifact && await this.#findFunctionArtifactBySelector(artifact, selector);
|
|
113
|
+
return fnArtifact && {
|
|
114
|
+
...fnArtifact,
|
|
115
|
+
contractName: artifact.name
|
|
116
|
+
};
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
return
|
|
118
|
+
async getPublicFunctionArtifact(contractAddress) {
|
|
119
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
120
|
+
const fnArtifact = artifact && artifact.functions.find((fn)=>fn.functionType === FunctionType.PUBLIC);
|
|
121
|
+
return fnArtifact && {
|
|
122
|
+
...fnArtifact,
|
|
123
|
+
contractName: artifact.name
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async getFunctionAbi(contractAddress, selector) {
|
|
127
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
128
|
+
return artifact && await this.#findFunctionAbiBySelector(artifact, selector);
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Retrieves the debug metadata of a specified function within a given contract.
|
|
@@ -138,22 +137,14 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
138
137
|
* @param selector - The function selector.
|
|
139
138
|
* @returns The corresponding function's artifact as an object.
|
|
140
139
|
*/ async getFunctionDebugMetadata(contractAddress, selector) {
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
return getFunctionDebugMetadata(
|
|
140
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
141
|
+
const fnArtifact = artifact && await this.#findFunctionArtifactBySelector(artifact, selector);
|
|
142
|
+
return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
*
|
|
150
|
-
* @param contractAddress - The contract's address.
|
|
151
|
-
* @param selector - The function selector.
|
|
152
|
-
* @returns A Promise that resolves to a Buffer containing the bytecode of the specified function.
|
|
153
|
-
* @throws Error if the contract address is unknown or not found.
|
|
154
|
-
*/ async getBytecode(contractAddress, selector) {
|
|
155
|
-
const tree = await this.getTreeForAddress(contractAddress);
|
|
156
|
-
return tree.getBytecode(selector);
|
|
144
|
+
async getPublicFunctionDebugMetadata(contractAddress) {
|
|
145
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
146
|
+
const fnArtifact = artifact && artifact.functions.find((fn)=>fn.functionType === FunctionType.PUBLIC);
|
|
147
|
+
return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
|
|
157
148
|
}
|
|
158
149
|
/**
|
|
159
150
|
* Retrieve the function membership witness for the given contract class and function selector.
|
|
@@ -164,20 +155,39 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
164
155
|
* @param selector - The function selector.
|
|
165
156
|
* @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
|
|
166
157
|
*/ async getFunctionMembershipWitness(contractClassId, selector) {
|
|
167
|
-
const tree = await this
|
|
168
|
-
return tree
|
|
158
|
+
const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
|
|
159
|
+
return tree?.getFunctionMembershipWitness(selector);
|
|
169
160
|
}
|
|
170
161
|
async getDebugContractName(contractAddress) {
|
|
171
|
-
const
|
|
172
|
-
return
|
|
162
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
163
|
+
return artifact?.name;
|
|
173
164
|
}
|
|
174
165
|
async getDebugFunctionName(contractAddress, selector) {
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
167
|
+
const fnArtifact = artifact && await this.#findFunctionAbiBySelector(artifact, selector);
|
|
168
|
+
return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
|
|
169
|
+
}
|
|
170
|
+
async #findFunctionArtifactBySelector(artifact, selector) {
|
|
171
|
+
const functions = artifact.functions;
|
|
172
|
+
for(let i = 0; i < functions.length; i++){
|
|
173
|
+
const fn = functions[i];
|
|
174
|
+
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
175
|
+
if (fnSelector.equals(selector)) {
|
|
176
|
+
return fn;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
179
|
}
|
|
180
|
-
async
|
|
181
|
-
|
|
180
|
+
async #findFunctionAbiBySelector(artifact, selector) {
|
|
181
|
+
const functions = [
|
|
182
|
+
...artifact.functions,
|
|
183
|
+
...artifact.nonDispatchPublicFunctions ?? []
|
|
184
|
+
];
|
|
185
|
+
for(let i = 0; i < functions.length; i++){
|
|
186
|
+
const fn = functions[i];
|
|
187
|
+
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
188
|
+
if (fnSelector.equals(selector)) {
|
|
189
|
+
return fn;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
182
192
|
}
|
|
183
193
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { ContractDataProvider } from './contract_data_provider.js';
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NvbnRyYWN0X2RhdGFfcHJvdmlkZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sNkJBQTZCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|