From 20dccfc3b808d4cd4aa9bb3f8c9de933c3a718cd Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Aug 2024 10:42:26 +0000 Subject: [PATCH] cleanup and fix --- docs/docs/migration_notes.md | 2 +- .../smart_contract_reference/storage/private_state.md | 2 +- .../noir-contracts/contracts/card_game_contract/src/cards.nr | 1 - .../noir-contracts/contracts/test_contract/src/main.nr | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 919fa6ca365..72e496b90f6 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -51,7 +51,7 @@ Token contract diff: +} +assert(minuend >= subtrahend, "Balance too low"); -Note that the notes are not ensured to be obtained and removed so you have the place checks on the returned notes (e.g. in the example above by checking a sum of balances or by checking that returned note length assert(notes.len() == expected_num_notes)). +Note that the notes are not ensured to be obtained and removed so you have the place checks on the returned notes (e.g. in the example above by checking a sum of balances or by checking the returned notes length assert(notes.len() == expected_num_notes)). diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md b/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md index 0e424943cb6..95fcdebc159 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md +++ b/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md @@ -214,7 +214,7 @@ The usage is similar to using the `insert` method with the difference that this ### `pop_notes` -This function pops (gets, removes and returns) the notes the account has access to based on the providing filter. +This function pops (gets, removes and returns) the notes the account has access to based on the provided filter. The kernel circuits are constrained to a maximum number of notes this function can return at a time. Check [here (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr) and look for `MAX_NOTE_HASH_READ_REQUESTS_PER_CALL` for the up-to-date number. diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index bb9dca96a6b..871332ae601 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -121,7 +121,6 @@ impl Deck<&mut PrivateContext> { } pub fn remove_cards(&mut self, cards: [Card; N]) { - // TODO(benesjan): try to simplify this func let options = NoteGetterOptions::with_filter(filter_cards, cards); let notes = self.set.pop_notes(options); diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 8d2205e5005..27a2f6cd6b8 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -474,7 +474,8 @@ contract Test { let secret_hash = compute_secret_hash(secret); let mut options = NoteGetterOptions::new(); options = options.select(TestNote::properties().value, secret_hash, Option::none()).set_limit(1); - notes_set.pop_notes(options); + let notes = notes_set.pop_notes(options); + assert(notes.len() == 1, "note not popped"); } unconstrained fn get_constant() -> pub Field {