Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 13, 2024
1 parent aa78db8 commit f719697
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions noir-projects/noir-contracts/contracts/nft_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ contract NFT {
);
}

/// Prepares a transfer to a private balance of `to`. The transfer then needs to be
/// finalized by calling `finalize_transfer_to_private`. Returns a hiding point slot.
/// Prepares an increase of private balance of `to` (partial note). The increase needs to be finalized by calling
/// `finalize_transfer_to_private. Returns a hiding point slot.
#[private]
fn prepare_transfer_to_private(to: AztecAddress) -> Field {
fn prepare_private_balance_increase(to: AztecAddress) -> Field {
_prepare_private_balance_increase(to, &mut context, storage)
}

/// This function exists separately from `prepare_transfer_to_private` solely as an optimization as it allows
/// This function exists separately from `prepare_private_balance_increase` solely as an optimization as it allows
/// us to have it inlined in the `transfer_to_private` function which results in one less kernel iteration.
///
/// TODO(#9180): Consider adding macro support for functions callable both as an entrypoint and as an internal
Expand Down Expand Up @@ -235,7 +235,7 @@ contract NFT {
}

/// Finalizes a transfer of NFT with `token_id` from public balance of `from` to a private balance of `to`.
/// The transfer must be prepared by calling `prepare_transfer_to_private` first and the resulting
/// The transfer must be prepared by calling `prepare_private_balance_increase` first and the resulting
/// `hiding_point_slot` must be passed as an argument to this function.
#[public]
fn finalize_transfer_to_private(token_id: Field, hiding_point_slot: Field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dep::aztec::{
};
use std::test::OracleMock;

/// Internal orchestration means that the calls to `prepare_transfer_to_private`
/// Internal orchestration means that the calls to `prepare_private_balance_increase`
/// and `finalize_transfer_to_private` are done by the NFT contract itself.
/// In this test's case this is done by the `NFT::transfer_to_private(...)` function called
/// in `utils::setup_mint_and_transfer_to_private`.
Expand Down Expand Up @@ -40,7 +40,7 @@ unconstrained fn transfer_to_private_external_orchestration() {

// We prepare the transfer
let hiding_point_slot: Field = NFT::at(nft_contract_address)
.prepare_transfer_to_private(recipient)
.prepare_private_balance_increase(recipient)
.call(&mut env.private());

// Finalize the transfer of the NFT (message sender owns the NFT in public)
Expand Down Expand Up @@ -96,7 +96,7 @@ unconstrained fn transfer_to_private_failure_not_an_owner() {
// as the NFT owner check is before we use the value but that would made the test less robust against changes
// in the contract.)
let hiding_point_slot: Field = NFT::at(nft_contract_address)
.prepare_transfer_to_private(not_owner)
.prepare_private_balance_increase(not_owner)
.call(&mut env.private());

// Try transferring someone else's public NFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,16 @@ contract Token {
}
// docs:end:transfer_to_private

/// Prepares a transfer to a private balance of `to`. The transfer then needs to be
/// finalized by calling `finalize_transfer_to_private`. Returns a hiding point slot.
/// Prepares an increase of private balance of `to` (partial note). The increase needs to be finalized by calling
/// some of the finalization functions (`finalize_transfer_to_private`, `finalize_mint_to_private`).
/// Returns a hiding point slot.
#[private]
fn prepare_transfer_to_private(to: AztecAddress) -> Field {
fn prepare_private_balance_increase(to: AztecAddress) -> Field {
let from = context.msg_sender();
_prepare_private_balance_increase(from, to, &mut context, storage)
}

/// This function exists separately from `prepare_transfer_to_private` solely as an optimization as it allows
/// This function exists separately from `prepare_private_balance_increase` solely as an optimization as it allows
/// us to have it inlined in the `transfer_to_private` function which results in one less kernel iteration.
///
/// TODO(#9180): Consider adding macro support for functions callable both as an entrypoint and as an internal
Expand Down Expand Up @@ -504,7 +505,7 @@ contract Token {
}

/// Finalizes a transfer of token `amount` from public balance of `from` to a private balance of `to`.
/// The transfer must be prepared by calling `prepare_transfer_to_private` first and the resulting
/// The transfer must be prepared by calling `prepare_private_balance_increase` first and the resulting
/// `hiding_point_slot` must be passed as an argument to this function.
#[public]
fn finalize_transfer_to_private(amount: Field, hiding_point_slot: Field) {
Expand Down Expand Up @@ -569,7 +570,7 @@ contract Token {
// docs:end:mint_to_private

/// Finalizes a mint of token `amount` to a private balance of `to`. The mint must be prepared by calling
/// `prepare_transfer_to_private` first and the resulting
/// `prepare_private_balance_increase` first and the resulting
/// `hiding_point_slot` must be passed as an argument to this function.
///
/// Note: This function is only an optimization as it could be replaced by a combination of `mint_to_public`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{test::utils, Token};
use dep::aztec::oracle::random::random;
use std::test::OracleMock;

/// Internal orchestration means that the calls to `prepare_transfer_to_private`
/// Internal orchestration means that the calls to `prepare_private_balance_increase`
/// and `finalize_transfer_to_private` are done by the TOKEN contract itself.
/// In this test's case this is done by the `Token::transfer_to_private(...)` function called
/// in `utils::setup_mint_and_transfer_to_private`.
Expand Down Expand Up @@ -33,7 +33,7 @@ unconstrained fn transfer_to_private_external_orchestration() {

// We prepare the transfer
let hiding_point_slot: Field = Token::at(token_contract_address)
.prepare_transfer_to_private(recipient)
.prepare_private_balance_increase(recipient)
.call(&mut env.private());

// Finalize the transfer of the tokens (message sender owns the tokens in public)
Expand Down Expand Up @@ -79,7 +79,7 @@ unconstrained fn transfer_to_private_failure_not_an_owner() {
// as the token balance check is before we use the value but that would made the test less robust against changes
// in the contract.)
let hiding_point_slot: Field = Token::at(token_contract_address)
.prepare_transfer_to_private(not_owner)
.prepare_private_balance_increase(not_owner)
.call(&mut env.private());

// Try transferring someone else's token balance
Expand Down

0 comments on commit f719697

Please sign in to comment.