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