Skip to content

Commit 20f1652

Browse files
benesjansirasistant
authored andcommitted
feat!: updated note hash and nullifier macro (#3777)
Fixes #3669
1 parent d144743 commit 20f1652

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

aztec_macros/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,15 @@ fn check_for_storage_definition(module: &SortedModule) -> bool {
252252
module.types.iter().any(|r#struct| r#struct.name.0.contents == "Storage")
253253
}
254254

255-
// Check if "compute_note_hash_and_nullifier(Field,Field,Field,[Field; N]) -> [Field; 4]" is defined
255+
// Check if "compute_note_hash_and_nullifier(AztecAddress,Field,Field,[Field; N]) -> [Field; 4]" is defined
256256
fn check_for_compute_note_hash_and_nullifier_definition(module: &SortedModule) -> bool {
257257
module.functions.iter().any(|func| {
258258
func.def.name.0.contents == "compute_note_hash_and_nullifier"
259259
&& func.def.parameters.len() == 4
260-
&& func.def.parameters[0].typ.typ == UnresolvedTypeData::FieldElement
260+
&& match &func.def.parameters[0].typ.typ {
261+
UnresolvedTypeData::Named(path, _) => path.segments.last().unwrap().0.contents == "AztecAddress",
262+
_ => false,
263+
}
261264
&& func.def.parameters[1].typ.typ == UnresolvedTypeData::FieldElement
262265
&& func.def.parameters[2].typ.typ == UnresolvedTypeData::FieldElement
263266
// checks if the 4th parameter is an array and the Box<UnresolvedType> in

tooling/nargo_fmt/tests/expected/contract.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ contract Benchmarking {
7171
}
7272

7373
unconstrained fn compute_note_hash_and_nullifier(
74-
contract_address: Field,
74+
contract_address: AztecAddress,
7575
nonce: Field,
7676
storage_slot: Field,
7777
preimage: [Field; VALUE_NOTE_LEN]

tooling/nargo_fmt/tests/input/contract.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ contract Benchmarking {
6666
emit_unencrypted_log(&mut context, storage.balances.at(owner).read());
6767
}
6868

69-
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] {
69+
unconstrained fn compute_note_hash_and_nullifier(contract_address: AztecAddress, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] {
7070
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
7171
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, preimage)
7272
}

0 commit comments

Comments
 (0)