@aztec/pxe 5.0.0-rc.1 → 5.0.0-rc.2
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_stream_source.d.ts +5 -5
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
- package/dest/block_synchronizer/block_stream_source.js +4 -29
- package/dest/block_synchronizer/block_synchronizer.d.ts +13 -11
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +43 -15
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +11 -16
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +22 -18
- package/dest/contract_function_simulator/index.d.ts +15 -9
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +3 -7
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +4 -8
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/option.js +18 -13
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +5 -8
- 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 -14
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +33 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +81 -6
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +128 -9
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +80 -36
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +926 -264
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -8
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +80 -11
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +46 -20
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +119 -55
- package/dest/contract_sync/helpers.d.ts +7 -6
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +11 -16
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +1 -0
- package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +1 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +0 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +3 -1
- package/dest/error_enriching.js +1 -1
- package/dest/hooks/execution_hooks.d.ts +16 -7
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/execution_hooks.js +3 -3
- package/dest/hooks/index.d.ts +3 -3
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +62 -28
- package/dest/messages/tx_resolver_service.d.ts +17 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/{message_context_service.js → tx_resolver_service.js} +8 -8
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/test_utils.js +1 -1
- package/dest/pxe.d.ts +46 -19
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +104 -52
- package/dest/storage/allowed_scopes.d.ts +6 -0
- package/dest/storage/allowed_scopes.d.ts.map +1 -0
- package/dest/storage/allowed_scopes.js +7 -0
- 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 +86 -33
- package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_service.js +6 -9
- package/dest/storage/contract_store/contract_store.js +2 -2
- package/dest/storage/fact_store/fact_service.d.ts +20 -0
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_service.js +30 -0
- package/dest/storage/fact_store/fact_store.d.ts +95 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +408 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store_keys.js +50 -0
- package/dest/storage/fact_store/index.d.ts +5 -0
- package/dest/storage/fact_store/index.d.ts.map +1 -0
- package/dest/storage/fact_store/index.js +3 -0
- package/dest/storage/fact_store/stored_fact.d.ts +32 -0
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
- package/dest/storage/fact_store/stored_fact.js +64 -0
- package/dest/storage/index.d.ts +2 -1
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/open_pxe_stores.d.ts +5 -3
- package/dest/storage/open_pxe_stores.d.ts.map +1 -1
- package/dest/storage/open_pxe_stores.js +5 -3
- package/dest/storage/tagging_store/index.d.ts +2 -2
- package/dest/storage/tagging_store/index.d.ts.map +1 -1
- package/dest/storage/tagging_store/index.js +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +92 -0
- package/package.json +17 -17
- package/src/block_synchronizer/block_stream_source.ts +6 -45
- package/src/block_synchronizer/block_synchronizer.ts +56 -23
- package/src/config/index.ts +1 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +32 -31
- package/src/contract_function_simulator/index.ts +17 -8
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
- package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
- package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +7 -60
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/option.ts +17 -11
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +3 -14
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/oracle_registry.ts +87 -79
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +641 -247
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +94 -14
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +206 -66
- package/src/contract_sync/helpers.ts +11 -18
- package/src/entrypoints/client/bundle/utils.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +1 -0
- package/src/entrypoints/pxe_creation_options.ts +7 -1
- package/src/entrypoints/server/index.ts +0 -1
- package/src/entrypoints/server/utils.ts +3 -1
- package/src/error_enriching.ts +1 -1
- package/src/hooks/execution_hooks.ts +17 -8
- package/src/hooks/index.ts +6 -2
- package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
- package/src/logs/log_service.ts +71 -37
- package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/test_utils.ts +1 -1
- package/src/pxe.ts +150 -54
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +21 -5
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +88 -33
- package/src/storage/capsule_store/capsule_service.ts +8 -13
- package/src/storage/contract_store/contract_store.ts +2 -2
- package/src/storage/fact_store/fact_service.ts +45 -0
- package/src/storage/fact_store/fact_store.ts +487 -0
- package/src/storage/fact_store/fact_store_keys.ts +75 -0
- package/src/storage/fact_store/index.ts +4 -0
- package/src/storage/fact_store/stored_fact.ts +80 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/open_pxe_stores.ts +6 -3
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
- package/dest/messages/message_context_service.d.ts +0 -17
- package/dest/messages/message_context_service.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
|
@@ -1,66 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { range } from '@aztec/foundation/array';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
2
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
5
3
|
|
|
6
|
-
const MAX_LOG_CONTENT_LEN = PRIVATE_LOG_CIPHERTEXT_LEN;
|
|
7
|
-
|
|
8
4
|
/**
|
|
9
5
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
|
|
10
6
|
* type in a `EphemeralArray`.
|
|
11
7
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
toFields(): Fr[] {
|
|
21
|
-
return [
|
|
22
|
-
// We need to trim the payload since public logs can be larger than MAX_LOG_CONTENT_LEN.
|
|
23
|
-
// This is currently not a problem since this class is only used with public logs for note completion.
|
|
24
|
-
...serializeBoundedVec(this.logPayload.slice(0, MAX_LOG_CONTENT_LEN), MAX_LOG_CONTENT_LEN),
|
|
25
|
-
this.txHash.hash,
|
|
26
|
-
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
27
|
-
this.firstNullifierInTx,
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static toEmptyFields(): Fr[] {
|
|
32
|
-
const serializationLen =
|
|
33
|
-
MAX_LOG_CONTENT_LEN +
|
|
34
|
-
1 /* logPayload BVec */ +
|
|
35
|
-
1 /* txHash */ +
|
|
36
|
-
MAX_NOTE_HASHES_PER_TX +
|
|
37
|
-
1 /* uniqueNoteHashesInTx BVec */ +
|
|
38
|
-
1; /* firstNullifierInTx */
|
|
39
|
-
return range(serializationLen).map(_ => Fr.zero());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static toSerializedOption(response: LogRetrievalResponse | null): Fr[] {
|
|
43
|
-
if (response) {
|
|
44
|
-
return [new Fr(1), ...response.toFields()];
|
|
45
|
-
} else {
|
|
46
|
-
return [new Fr(0), ...LogRetrievalResponse.toEmptyFields()];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Helper function to serialize a bounded vector according to Noir's BoundedVec format
|
|
53
|
-
* @param values - The values to serialize
|
|
54
|
-
* @param maxLength - The maximum length of the bounded vector
|
|
55
|
-
* @returns The serialized bounded vector as Fr[]
|
|
56
|
-
*/
|
|
57
|
-
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
58
|
-
if (values.length > maxLength) {
|
|
59
|
-
throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const lengthDiff = maxLength - values.length;
|
|
63
|
-
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
64
|
-
const storage = values.concat(zeroPaddingArray);
|
|
65
|
-
return [...storage, new Fr(values.length)];
|
|
66
|
-
}
|
|
8
|
+
export type LogRetrievalResponse = {
|
|
9
|
+
logPayload: Fr[];
|
|
10
|
+
txHash: TxHash;
|
|
11
|
+
uniqueNoteHashesInTx: Fr[];
|
|
12
|
+
firstNullifierInTx: Fr;
|
|
13
|
+
};
|
|
@@ -23,8 +23,8 @@ export class NoteValidationRequest {
|
|
|
23
23
|
static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest {
|
|
24
24
|
const reader = FieldReader.asReader(fields);
|
|
25
25
|
|
|
26
|
-
const contractAddress = AztecAddress.
|
|
27
|
-
const owner = AztecAddress.
|
|
26
|
+
const contractAddress = AztecAddress.fromFieldUnsafe(reader.readField());
|
|
27
|
+
const owner = AztecAddress.fromFieldUnsafe(reader.readField());
|
|
28
28
|
const storageSlot = reader.readField();
|
|
29
29
|
const randomness = reader.readField();
|
|
30
30
|
const noteNonce = reader.readField();
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
export class Option<T> {
|
|
9
9
|
private constructor(
|
|
10
10
|
public readonly value: T | undefined,
|
|
11
|
-
|
|
11
|
+
// `unknown` (not the descriptor shape) keeps this generic Option decoupled from the serialization layer's
|
|
12
|
+
// `{ length }`/`{ maxLength }` size descriptors; only the None-serialization path inspects it.
|
|
13
|
+
public readonly size: unknown,
|
|
12
14
|
) {}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -26,25 +28,22 @@ export class Option<T> {
|
|
|
26
28
|
/**
|
|
27
29
|
* Construct an absent Option.
|
|
28
30
|
*
|
|
29
|
-
* When serialized back to ACVM, the `None` case must produce the same number of fields as `Some`.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* re-serialized (e.g. deserialized input params).
|
|
33
|
-
*
|
|
34
|
-
* @param template - A representative empty `T` whose serialization determines the zero-filled wire format.
|
|
31
|
+
* When serialized back to ACVM, the `None` case must produce the same number of fields as `Some`. For an inner type whose
|
|
32
|
+
* wire size varies per call site (`BoundedVec`, an array), pass a `size` descriptor so the inner type's shape can
|
|
33
|
+
* resolve how many zero fields to emit; fixed-size inners take no argument.
|
|
35
34
|
*
|
|
36
35
|
* @example None for a fixed-size type:
|
|
37
36
|
* ```ts
|
|
38
|
-
* return Option.none(
|
|
37
|
+
* return Option.none();
|
|
39
38
|
* ```
|
|
40
39
|
*
|
|
41
40
|
* @example None for a dynamic-size type:
|
|
42
41
|
* ```ts
|
|
43
|
-
* return Option.none(
|
|
42
|
+
* return Option.none({ maxLength: ciphertext.maxLength });
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
static none<T>(
|
|
47
|
-
return new Option<T>(undefined,
|
|
45
|
+
static none<T>(size?: unknown): Option<T> {
|
|
46
|
+
return new Option<T>(undefined, size);
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
/**
|
|
@@ -66,4 +65,11 @@ export class Option<T> {
|
|
|
66
65
|
isNone(): this is Option<T> & { value: undefined } {
|
|
67
66
|
return this.value === undefined;
|
|
68
67
|
}
|
|
68
|
+
|
|
69
|
+
equals(other: Option<T>, innerEquals: (a: T, b: T) => boolean): boolean {
|
|
70
|
+
if (this.isSome() && other.isSome()) {
|
|
71
|
+
return innerEquals(this.value, other.value);
|
|
72
|
+
}
|
|
73
|
+
return this.isNone() && other.isNone();
|
|
74
|
+
}
|
|
69
75
|
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import {
|
|
3
|
-
import { AppTaggingSecretKind, appTaggingSecretKindFromDeliveryMode } from '@aztec/stdlib/logs';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AppTaggingSecretKind } from '@aztec/stdlib/logs';
|
|
4
3
|
|
|
5
4
|
/** A tagging secret an app supplies explicitly to `getPendingTaggedLogs` when PXE cannot derive it internally. */
|
|
6
|
-
export
|
|
7
|
-
constructor(
|
|
8
|
-
public secret: Fr,
|
|
9
|
-
public mode: AppTaggingSecretKind,
|
|
10
|
-
) {}
|
|
11
|
-
|
|
12
|
-
static fromFields(fields: Fr[] | FieldReader): ProvidedSecret {
|
|
13
|
-
const reader = FieldReader.asReader(fields);
|
|
14
|
-
return new ProvidedSecret(reader.readField(), appTaggingSecretKindFromDeliveryMode(reader.readField().toNumber()));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
5
|
+
export type ProvidedSecret = { secret: Fr; mode: AppTaggingSecretKind };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
|
|
3
|
+
// Keep in sync with aztec::messages::delivery::ResolvedTaggingStrategy
|
|
4
|
+
const NON_INTERACTIVE_HANDSHAKE = 1;
|
|
5
|
+
const UNCONSTRAINED_SECRET = 2;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The tagging secret PXE hands to the contract after applying the wallet's {@link TaggingSecretStrategy} choice
|
|
9
|
+
* (and app-siloing). The contract uses it directly to derive the message tag, so it never sees raw key material.
|
|
10
|
+
*/
|
|
11
|
+
export type ResolvedTaggingStrategy =
|
|
12
|
+
| {
|
|
13
|
+
/** A non-interactive handshake: the recipient re-derives the secret from the onchain handshake registry. */
|
|
14
|
+
type: 'non-interactive-handshake';
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
/**
|
|
18
|
+
* An app-siloed, recipient-directional secret, ready to use. Only sound for unconstrained delivery.
|
|
19
|
+
*/
|
|
20
|
+
type: 'unconstrained-secret';
|
|
21
|
+
/** The app-siloed directional tagging secret. */
|
|
22
|
+
secret: Fr;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Serializes a {@link ResolvedTaggingStrategy} to its Noir `[kind, secret]` field layout, zero-filling absent fields. */
|
|
26
|
+
export function resolvedTaggingStrategyToFields(resolved: ResolvedTaggingStrategy): Fr[] {
|
|
27
|
+
switch (resolved.type) {
|
|
28
|
+
case 'non-interactive-handshake':
|
|
29
|
+
return [new Fr(NON_INTERACTIVE_HANDSHAKE), Fr.ZERO];
|
|
30
|
+
case 'unconstrained-secret':
|
|
31
|
+
return [new Fr(UNCONSTRAINED_SECRET), resolved.secret];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Deserializes a {@link ResolvedTaggingStrategy} from its `kind` discriminant and `secret` field. */
|
|
36
|
+
export function resolvedTaggingStrategyFromFields(kind: number, secret: Fr): ResolvedTaggingStrategy {
|
|
37
|
+
switch (kind) {
|
|
38
|
+
case NON_INTERACTIVE_HANDSHAKE:
|
|
39
|
+
return { type: 'non-interactive-handshake' };
|
|
40
|
+
case UNCONSTRAINED_SECRET:
|
|
41
|
+
return { type: 'unconstrained-secret', secret };
|
|
42
|
+
default:
|
|
43
|
+
throw new Error(`Unrecognized resolved tagging strategy kind: ${kind}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The resolved on-chain context of a transaction.
|
|
8
|
+
*
|
|
9
|
+
* Carries the note hashes and first nullifier needed to discover notes that originated from the transaction, plus the
|
|
10
|
+
* number and hash of the block in which it was mined.
|
|
11
|
+
*
|
|
12
|
+
* A TS version of the `ResolvedTx` struct in `oracle/tx_resolution.nr`.
|
|
13
|
+
*/
|
|
14
|
+
export class ResolvedTx {
|
|
15
|
+
constructor(
|
|
16
|
+
public txHash: TxHash,
|
|
17
|
+
public uniqueNoteHashesInTx: Fr[],
|
|
18
|
+
public firstNullifierInTx: Fr,
|
|
19
|
+
public blockNumber: number,
|
|
20
|
+
public blockHash: Fr,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
toFields(): Fr[] {
|
|
24
|
+
return [
|
|
25
|
+
this.txHash.hash,
|
|
26
|
+
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
27
|
+
this.firstNullifierInTx,
|
|
28
|
+
new Fr(this.blockNumber),
|
|
29
|
+
this.blockHash,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static empty(): ResolvedTx {
|
|
34
|
+
return new ResolvedTx(TxHash.zero(), [], Fr.ZERO, 0, Fr.ZERO);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to serialize a bounded vector according to Noir's BoundedVec format: the storage array padded to
|
|
40
|
+
* `maxLength`, followed by the actual length.
|
|
41
|
+
* @param values - The values to serialize
|
|
42
|
+
* @param maxLength - The maximum length of the bounded vector
|
|
43
|
+
* @returns The serialized bounded vector as Fr[]
|
|
44
|
+
*/
|
|
45
|
+
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
46
|
+
const storage = padArrayEnd(
|
|
47
|
+
values,
|
|
48
|
+
Fr.ZERO,
|
|
49
|
+
maxLength,
|
|
50
|
+
`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`,
|
|
51
|
+
);
|
|
52
|
+
return [...storage, new Fr(values.length)];
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
+
import type { FlatPublicLogs } from '@aztec/stdlib/logs';
|
|
3
|
+
import type { TxEffect } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import type { ContractClassLogData } from './contract_class_log_data.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wire form of a {@link TxEffect} as the `getTxEffect` oracle returns it: identical to the domain type except its logs
|
|
9
|
+
* are flattened to their Noir layout. Keeping the conversion in the handler lets the `TX_EFFECT` mapping stay purely
|
|
10
|
+
* structural.
|
|
11
|
+
*/
|
|
12
|
+
export type TxEffectData = Omit<FieldsOf<TxEffect>, 'publicLogs' | 'contractClassLogs'> & {
|
|
13
|
+
publicLogs: FlatPublicLogs;
|
|
14
|
+
contractClassLogs: ContractClassLogData[];
|
|
15
|
+
};
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import { toACVMField } from '@aztec/simulator/client';
|
|
2
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Returns a representation of the utility context as expected by intrinsic Noir deserialization.
|
|
16
|
-
* The order of the fields has to be the same as the order of the fields in the utility_context.nr.
|
|
17
|
-
*/
|
|
18
|
-
public toNoirRepresentation(): (string | string[])[] {
|
|
19
|
-
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
20
|
-
const blockHeaderFields = this.blockHeader.toFields().map(toACVMField);
|
|
21
|
-
return [...blockHeaderFields, this.contractAddress.toString() as string];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
7
|
+
export type UtilityContext = {
|
|
8
|
+
blockHeader: BlockHeader;
|
|
9
|
+
contractAddress: AztecAddress;
|
|
10
|
+
msgSender: AztecAddress;
|
|
11
|
+
};
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
) {}
|
|
11
|
-
|
|
12
|
-
toFields(): Fr[] {
|
|
13
|
-
return [new Fr(this.index), ...this.siblingPath.toFields()];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Returns a representation of the public data witness as expected by intrinsic Noir deserialization.
|
|
18
|
-
*/
|
|
19
|
-
public toNoirRepresentation(): (string | string[])[] {
|
|
20
|
-
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
21
|
-
return [new Fr(this.index).toString() as string, this.siblingPath.toFields().map(fr => fr.toString()) as string[]];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
3
|
+
export type MessageLoadOracleInputs<N extends number> = {
|
|
4
|
+
/** The index of the message commitment in the merkle tree. */
|
|
5
|
+
index: bigint;
|
|
6
|
+
/** The path in the merkle tree to the message. */
|
|
7
|
+
siblingPath: SiblingPath<N>;
|
|
8
|
+
};
|
|
@@ -15,11 +15,12 @@ import {
|
|
|
15
15
|
BUFFER,
|
|
16
16
|
BYTE,
|
|
17
17
|
CALL_PRIVATE_RESULT,
|
|
18
|
-
|
|
18
|
+
CONTRACT_CLASS_LOG,
|
|
19
19
|
CONTRACT_INSTANCE,
|
|
20
20
|
DELIVERY_MODE,
|
|
21
21
|
EPHEMERAL_ARRAY,
|
|
22
22
|
EVENT_VALIDATION_REQUEST,
|
|
23
|
+
FACT_COLLECTION,
|
|
23
24
|
FIELD,
|
|
24
25
|
FUNCTION_SELECTOR,
|
|
25
26
|
type InputSlot,
|
|
@@ -27,7 +28,6 @@ import {
|
|
|
27
28
|
LOG_RETRIEVAL_REQUEST,
|
|
28
29
|
LOG_RETRIEVAL_RESPONSE,
|
|
29
30
|
MEMBERSHIP_WITNESS,
|
|
30
|
-
MESSAGE_CONTEXT,
|
|
31
31
|
MESSAGE_LOAD_ORACLE_INPUTS,
|
|
32
32
|
type MaybePromise,
|
|
33
33
|
NOTE,
|
|
@@ -35,12 +35,15 @@ import {
|
|
|
35
35
|
NOTE_VALIDATION_REQUEST,
|
|
36
36
|
NULLIFIER_MEMBERSHIP_WITNESS,
|
|
37
37
|
OPTION,
|
|
38
|
+
ORIGIN_BLOCK,
|
|
38
39
|
type OutputSlot,
|
|
39
40
|
PENDING_TAGGED_LOG,
|
|
40
41
|
POINT,
|
|
41
42
|
PROVIDED_SECRET,
|
|
42
43
|
PUBLIC_DATA_WITNESS,
|
|
43
44
|
PUBLIC_KEYS_AND_PARTIAL_ADDRESS,
|
|
45
|
+
RESOLVED_TAGGING_STRATEGY,
|
|
46
|
+
RESOLVED_TX,
|
|
44
47
|
STR,
|
|
45
48
|
TX_EFFECT,
|
|
46
49
|
TX_HASH,
|
|
@@ -48,6 +51,7 @@ import {
|
|
|
48
51
|
U32,
|
|
49
52
|
UTILITY_CONTEXT,
|
|
50
53
|
assertReadersConsumed,
|
|
54
|
+
slotsOf,
|
|
51
55
|
} from './oracle_type_mappings.js';
|
|
52
56
|
|
|
53
57
|
export {
|
|
@@ -59,7 +63,9 @@ export {
|
|
|
59
63
|
BOUNDED_VEC,
|
|
60
64
|
BUFFER,
|
|
61
65
|
BYTE,
|
|
66
|
+
CONTRACT_CLASS_LOG,
|
|
62
67
|
DELIVERY_MODE,
|
|
68
|
+
RESOLVED_TAGGING_STRATEGY,
|
|
63
69
|
EPHEMERAL_ARRAY,
|
|
64
70
|
EVENT_VALIDATION_REQUEST,
|
|
65
71
|
FIELD,
|
|
@@ -67,85 +73,23 @@ export {
|
|
|
67
73
|
LOG_RETRIEVAL_REQUEST,
|
|
68
74
|
LOG_RETRIEVAL_RESPONSE,
|
|
69
75
|
MEMBERSHIP_WITNESS,
|
|
70
|
-
MESSAGE_CONTEXT,
|
|
71
76
|
NOTE_VALIDATION_REQUEST,
|
|
72
77
|
OPTION,
|
|
73
78
|
PENDING_TAGGED_LOG,
|
|
74
79
|
POINT,
|
|
75
80
|
PROVIDED_SECRET,
|
|
81
|
+
RESOLVED_TX,
|
|
76
82
|
STR,
|
|
77
83
|
U32,
|
|
84
|
+
slotsOf,
|
|
78
85
|
type InputSlot,
|
|
79
86
|
type MaybePromise,
|
|
80
87
|
type OutputSlot,
|
|
88
|
+
type SlotShape,
|
|
81
89
|
type TypeMapping,
|
|
82
90
|
} from './oracle_type_mappings.js';
|
|
83
91
|
|
|
84
|
-
|
|
85
|
-
| 'aztec_misc_assertCompatibleOracleVersion'
|
|
86
|
-
| 'aztec_misc_getRandomField'
|
|
87
|
-
| 'aztec_misc_log'
|
|
88
|
-
| 'aztec_utl_getUtilityContext'
|
|
89
|
-
| 'aztec_utl_getKeyValidationRequest'
|
|
90
|
-
| 'aztec_utl_getContractInstance'
|
|
91
|
-
| 'aztec_utl_getNoteHashMembershipWitness'
|
|
92
|
-
| 'aztec_utl_getBlockHashMembershipWitness'
|
|
93
|
-
| 'aztec_utl_getNullifierMembershipWitness'
|
|
94
|
-
| 'aztec_utl_getLowNullifierMembershipWitness'
|
|
95
|
-
| 'aztec_utl_getPublicDataWitness'
|
|
96
|
-
| 'aztec_utl_getBlockHeader'
|
|
97
|
-
| 'aztec_utl_getAuthWitness'
|
|
98
|
-
| 'aztec_utl_getPublicKeysAndPartialAddress'
|
|
99
|
-
| 'aztec_utl_doesNullifierExist'
|
|
100
|
-
| 'aztec_utl_getL1ToL2MembershipWitness'
|
|
101
|
-
| 'aztec_utl_getFromPublicStorage'
|
|
102
|
-
| 'aztec_utl_getNotes'
|
|
103
|
-
| 'aztec_utl_getPendingTaggedLogs'
|
|
104
|
-
| 'aztec_utl_validateAndStoreEnqueuedNotesAndEvents'
|
|
105
|
-
| 'aztec_utl_getLogsByTag'
|
|
106
|
-
| 'aztec_utl_getMessageContextsByTxHash'
|
|
107
|
-
| 'aztec_utl_getTxEffect'
|
|
108
|
-
| 'aztec_utl_setCapsule'
|
|
109
|
-
| 'aztec_utl_getCapsule'
|
|
110
|
-
| 'aztec_utl_deleteCapsule'
|
|
111
|
-
| 'aztec_utl_copyCapsule'
|
|
112
|
-
| 'aztec_utl_decryptAes128'
|
|
113
|
-
| 'aztec_utl_getSharedSecrets'
|
|
114
|
-
| 'aztec_utl_setContractSyncCacheInvalid'
|
|
115
|
-
| 'aztec_utl_emitOffchainEffect'
|
|
116
|
-
| 'aztec_utl_callUtilityFunction'
|
|
117
|
-
| 'aztec_utl_pushEphemeral'
|
|
118
|
-
| 'aztec_utl_popEphemeral'
|
|
119
|
-
| 'aztec_utl_getEphemeral'
|
|
120
|
-
| 'aztec_utl_setEphemeral'
|
|
121
|
-
| 'aztec_utl_getEphemeralLen'
|
|
122
|
-
| 'aztec_utl_removeEphemeral'
|
|
123
|
-
| 'aztec_utl_clearEphemeral'
|
|
124
|
-
| 'aztec_utl_pushTransient'
|
|
125
|
-
| 'aztec_utl_popTransient'
|
|
126
|
-
| 'aztec_utl_getTransient'
|
|
127
|
-
| 'aztec_utl_setTransient'
|
|
128
|
-
| 'aztec_utl_getTransientLen'
|
|
129
|
-
| 'aztec_utl_removeTransient'
|
|
130
|
-
| 'aztec_utl_clearTransient'
|
|
131
|
-
| 'aztec_prv_setHashPreimage'
|
|
132
|
-
| 'aztec_prv_getHashPreimage'
|
|
133
|
-
| 'aztec_prv_notifyCreatedNote'
|
|
134
|
-
| 'aztec_prv_notifyNullifiedNote'
|
|
135
|
-
| 'aztec_prv_notifyCreatedNullifier'
|
|
136
|
-
| 'aztec_prv_isNullifierPending'
|
|
137
|
-
| 'aztec_prv_notifyCreatedContractClassLog'
|
|
138
|
-
| 'aztec_prv_callPrivateFunction'
|
|
139
|
-
| 'aztec_prv_assertValidPublicCalldata'
|
|
140
|
-
| 'aztec_prv_notifyRevertiblePhaseStart'
|
|
141
|
-
| 'aztec_prv_isExecutionInRevertiblePhase'
|
|
142
|
-
| 'aztec_prv_getAppTaggingSecret'
|
|
143
|
-
| 'aztec_prv_getNextTaggingIndex'
|
|
144
|
-
| 'aztec_prv_getSenderForTags';
|
|
145
|
-
|
|
146
|
-
type OracleRegistry = Record<OracleRegistryName, OracleRegistryEntry>;
|
|
147
|
-
|
|
148
|
-
export const ORACLE_REGISTRY: OracleRegistry = {
|
|
92
|
+
export const ORACLE_REGISTRY = {
|
|
149
93
|
aztec_misc_assertCompatibleOracleVersion: makeEntry({
|
|
150
94
|
params: [
|
|
151
95
|
{ name: 'major', type: U32 },
|
|
@@ -167,7 +111,10 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
167
111
|
aztec_utl_getUtilityContext: makeEntry({ returnType: UTILITY_CONTEXT }),
|
|
168
112
|
|
|
169
113
|
aztec_utl_getKeyValidationRequest: makeEntry({
|
|
170
|
-
params: [
|
|
114
|
+
params: [
|
|
115
|
+
{ name: 'pkMHash', type: FIELD },
|
|
116
|
+
{ name: 'keyIndex', type: FIELD },
|
|
117
|
+
],
|
|
171
118
|
returnType: KEY_VALIDATION_REQUEST,
|
|
172
119
|
}),
|
|
173
120
|
|
|
@@ -299,9 +246,9 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
299
246
|
returnType: EPHEMERAL_ARRAY(EPHEMERAL_ARRAY(LOG_RETRIEVAL_RESPONSE)),
|
|
300
247
|
}),
|
|
301
248
|
|
|
302
|
-
|
|
249
|
+
aztec_utl_getResolvedTxs: makeEntry({
|
|
303
250
|
params: [{ name: 'requests', type: EPHEMERAL_ARRAY(FIELD) }],
|
|
304
|
-
returnType: EPHEMERAL_ARRAY(OPTION(
|
|
251
|
+
returnType: EPHEMERAL_ARRAY(OPTION(RESOLVED_TX)),
|
|
305
252
|
}),
|
|
306
253
|
|
|
307
254
|
aztec_utl_getTxEffect: makeEntry({
|
|
@@ -349,8 +296,8 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
349
296
|
aztec_utl_decryptAes128: makeEntry({
|
|
350
297
|
params: [
|
|
351
298
|
{ name: 'ciphertext', type: BOUNDED_VEC(BYTE) },
|
|
352
|
-
{ name: 'iv', type: BUFFER(8) },
|
|
353
|
-
{ name: 'symKey', type: BUFFER(8) },
|
|
299
|
+
{ name: 'iv', type: BUFFER(8, 16) },
|
|
300
|
+
{ name: 'symKey', type: BUFFER(8, 16) },
|
|
354
301
|
],
|
|
355
302
|
returnType: OPTION(BOUNDED_VEC(BYTE)),
|
|
356
303
|
}),
|
|
@@ -375,6 +322,46 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
375
322
|
params: [{ name: 'data', type: ARRAY(FIELD) }],
|
|
376
323
|
}),
|
|
377
324
|
|
|
325
|
+
aztec_utl_recordFact: makeEntry({
|
|
326
|
+
params: [
|
|
327
|
+
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
328
|
+
{ name: 'scope', type: AZTEC_ADDRESS },
|
|
329
|
+
{ name: 'factCollectionTypeId', type: FIELD },
|
|
330
|
+
{ name: 'factCollectionId', type: FIELD },
|
|
331
|
+
{ name: 'factTypeId', type: FIELD },
|
|
332
|
+
{ name: 'payload', type: EPHEMERAL_ARRAY(FIELD) },
|
|
333
|
+
{ name: 'originBlock', type: OPTION(ORIGIN_BLOCK) },
|
|
334
|
+
],
|
|
335
|
+
}),
|
|
336
|
+
|
|
337
|
+
aztec_utl_deleteFactCollection: makeEntry({
|
|
338
|
+
params: [
|
|
339
|
+
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
340
|
+
{ name: 'scope', type: AZTEC_ADDRESS },
|
|
341
|
+
{ name: 'factCollectionTypeId', type: FIELD },
|
|
342
|
+
{ name: 'factCollectionId', type: FIELD },
|
|
343
|
+
],
|
|
344
|
+
}),
|
|
345
|
+
|
|
346
|
+
aztec_utl_getFactCollection: makeEntry({
|
|
347
|
+
params: [
|
|
348
|
+
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
349
|
+
{ name: 'scope', type: AZTEC_ADDRESS },
|
|
350
|
+
{ name: 'factCollectionTypeId', type: FIELD },
|
|
351
|
+
{ name: 'factCollectionId', type: FIELD },
|
|
352
|
+
],
|
|
353
|
+
returnType: OPTION(FACT_COLLECTION),
|
|
354
|
+
}),
|
|
355
|
+
|
|
356
|
+
aztec_utl_getFactCollectionsByType: makeEntry({
|
|
357
|
+
params: [
|
|
358
|
+
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
359
|
+
{ name: 'scope', type: AZTEC_ADDRESS },
|
|
360
|
+
{ name: 'factCollectionTypeId', type: FIELD },
|
|
361
|
+
],
|
|
362
|
+
returnType: EPHEMERAL_ARRAY(FACT_COLLECTION),
|
|
363
|
+
}),
|
|
364
|
+
|
|
378
365
|
aztec_utl_callUtilityFunction: makeEntry({
|
|
379
366
|
params: [
|
|
380
367
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
@@ -520,7 +507,7 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
520
507
|
|
|
521
508
|
aztec_prv_notifyCreatedContractClassLog: makeEntry({
|
|
522
509
|
params: [
|
|
523
|
-
{ name: 'log', type:
|
|
510
|
+
{ name: 'log', type: CONTRACT_CLASS_LOG },
|
|
524
511
|
{ name: 'counter', type: U32 },
|
|
525
512
|
],
|
|
526
513
|
}),
|
|
@@ -566,7 +553,16 @@ export const ORACLE_REGISTRY: OracleRegistry = {
|
|
|
566
553
|
}),
|
|
567
554
|
|
|
568
555
|
aztec_prv_getSenderForTags: makeEntry({ returnType: OPTION(AZTEC_ADDRESS) }),
|
|
569
|
-
|
|
556
|
+
|
|
557
|
+
aztec_prv_resolveTaggingStrategy: makeEntry({
|
|
558
|
+
params: [
|
|
559
|
+
{ name: 'sender', type: AZTEC_ADDRESS },
|
|
560
|
+
{ name: 'recipient', type: AZTEC_ADDRESS },
|
|
561
|
+
{ name: 'deliveryMode', type: DELIVERY_MODE },
|
|
562
|
+
],
|
|
563
|
+
returnType: RESOLVED_TAGGING_STRATEGY,
|
|
564
|
+
}),
|
|
565
|
+
} satisfies Record<string, OracleRegistryEntry>;
|
|
570
566
|
|
|
571
567
|
// ─── Registry Infrastructure ─────────────────────────────────────────────────
|
|
572
568
|
|
|
@@ -584,6 +580,10 @@ export interface OracleRegistryEntry<
|
|
|
584
580
|
deserializeParams(inputs: InputSlot[]): TDeserializedParams;
|
|
585
581
|
/** Serialize a handler return value into ACVM output slots. */
|
|
586
582
|
serializeReturn(result: TReturnValue): OutputSlot[];
|
|
583
|
+
/** The ordered named parameters with their {@link TypeMapping}s. Lets callers introspect the oracle's wire ABI. */
|
|
584
|
+
readonly params: readonly RegistryParam[];
|
|
585
|
+
/** The return {@link TypeMapping}, or `undefined` for oracles that return nothing. */
|
|
586
|
+
readonly returnType?: TypeMapping<TReturnValue>;
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
export function makeEntry<const TParams extends RegistryParam[] = [], TReturnValue = void>({
|
|
@@ -594,16 +594,18 @@ export function makeEntry<const TParams extends RegistryParam[] = [], TReturnVal
|
|
|
594
594
|
returnType?: TypeMapping<TReturnValue>;
|
|
595
595
|
} = {}): OracleRegistryEntry<InferDeserializedParams<TParams>, TReturnValue> {
|
|
596
596
|
return {
|
|
597
|
+
params: params ?? [],
|
|
598
|
+
returnType,
|
|
597
599
|
deserializeParams(inputs: InputSlot[]): InferDeserializedParams<TParams> {
|
|
598
600
|
const resolvedParams: RegistryParam[] = params ?? [];
|
|
599
601
|
// Walk the input slots left-to-right, advancing by each param's slot count.
|
|
600
602
|
let offset = 0;
|
|
601
|
-
|
|
603
|
+
const named = resolvedParams.map(param => {
|
|
602
604
|
if (!param.type.deserialization) {
|
|
603
605
|
throw new Error(`Param '${param.name}' has no deserialization defined`);
|
|
604
606
|
}
|
|
605
607
|
// Collect the slots for this param and wrap each in a FieldReader.
|
|
606
|
-
const slotCount = param.type
|
|
608
|
+
const slotCount = slotsOf(param.type);
|
|
607
609
|
const readers = inputs
|
|
608
610
|
.slice(offset, offset + slotCount)
|
|
609
611
|
.map(slot => new FieldReader(slot.map(hex => Fr.fromString(hex))));
|
|
@@ -613,7 +615,13 @@ export function makeEntry<const TParams extends RegistryParam[] = [], TReturnVal
|
|
|
613
615
|
const value = param.type.deserialization.fn(readers);
|
|
614
616
|
assertReadersConsumed(readers);
|
|
615
617
|
return { name: param.name, value };
|
|
616
|
-
})
|
|
618
|
+
});
|
|
619
|
+
// Every input slot must be specified by a param: oracles whose Noir decl passes an extra field must declare it
|
|
620
|
+
// (the handler can ignore it). Otherwise an under-declared shape would silently drop a field into nothing.
|
|
621
|
+
if (offset !== inputs.length) {
|
|
622
|
+
throw new Error(`Oracle received ${inputs.length} input slot(s) but the registry specifies ${offset}`);
|
|
623
|
+
}
|
|
624
|
+
return named as unknown as InferDeserializedParams<TParams>;
|
|
617
625
|
},
|
|
618
626
|
serializeReturn(result: TReturnValue): OutputSlot[] {
|
|
619
627
|
if (returnType?.serialization === undefined) {
|
|
@@ -660,7 +668,7 @@ type InferDeserializedParams<T extends RegistryParam[]> = {
|
|
|
660
668
|
// ─── Derived Handler Interfaces ─────────────────────────────────────────────
|
|
661
669
|
|
|
662
670
|
/** Strips the `aztec_{scope}_` prefix from an oracle key to get the handler method name. */
|
|
663
|
-
|
|
671
|
+
type StripOraclePrefix<K extends string> = K extends `aztec_${string}_${infer M}` ? M : never;
|
|
664
672
|
|
|
665
673
|
/** Derives the handler function signature from a registry entry's deserialization/serialization types. */
|
|
666
674
|
type HandlerFn<E extends OracleRegistryEntry> = (
|