From d42370ff4d2f72932c6b333e2e37ee840ea2bcb0 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 11 Jul 2024 10:32:43 +0000 Subject: [PATCH] fix --- .../docs_example_contract/src/types/card_note.nr | 10 +++++++++- .../private_token_contract/src/types/balances_map.nr | 2 +- .../token_blacklist_contract/src/types/balances_map.nr | 2 +- .../contracts/token_contract/src/types/balances_map.nr | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index 467457651531..f4a2094051fe 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -1,7 +1,7 @@ use dep::aztec::prelude::{AztecAddress, NoteInterface, NoteHeader, PrivateContext}; use dep::aztec::{ note::{utils::compute_note_hash_for_consumption}, keys::getters::get_nsk_app, - protocol_types::{traits::{Empty, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{traits::{Empty, Eq, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} }; // Shows how to create a custom note @@ -55,3 +55,11 @@ impl Serialize<3> for CardNote { [ self.points.to_field(), self.randomness, self.npk_m_hash.to_field() ] } } + +impl Eq for CardNote { + fn eq(self, other: Self) -> bool { + (self.points == other.points) & + (self.npk_m_hash == other.npk_m_hash) & + (self.randomness == other.randomness) + } +} diff --git a/noir-projects/noir-contracts/contracts/private_token_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/private_token_contract/src/types/balances_map.nr index b1f1837ef70b..d70e62fa91c2 100644 --- a/noir-projects/noir-contracts/contracts/private_token_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/private_token_contract/src/types/balances_map.nr @@ -70,7 +70,7 @@ impl BalancesMap { self: Self, owner_npk_m_hash: Field, addend: U128 - ) -> OuterNoteEmission where T: NoteInterface + OwnedNote { + ) -> OuterNoteEmission where T: NoteInterface + OwnedNote + Eq { let mut addend_note = T::new(addend, owner_npk_m_hash); OuterNoteEmission::new(Option::some(self.map.insert(&mut addend_note))) } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index f97784cd218f..882364d9f655 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -59,7 +59,7 @@ impl BalancesMap { self: Self, owner: AztecAddress, addend: U128 - ) -> OuterNoteEmission where T: NoteInterface + OwnedNote { + ) -> OuterNoteEmission where T: NoteInterface + OwnedNote + Eq { if addend == U128::from_integer(0) { OuterNoteEmission::new(Option::none()) } else { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr index 25e745746bc4..63a0092ea5c9 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr @@ -62,7 +62,7 @@ impl BalancesMap { self: Self, owner: AztecAddress, addend: U128 - ) -> OuterNoteEmission where T: NoteInterface + OwnedNote { + ) -> OuterNoteEmission where T: NoteInterface + OwnedNote + Eq { if addend == U128::from_integer(0) { OuterNoteEmission::new(Option::none()) } else {