Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 27, 2024
1 parent c5ba475 commit ebc0127
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ type = "contract"

[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
int_note = { path = "../../../aztec-nr/int-note" }
compressed_string = { path = "../../../aztec-nr/compressed-string" }
authwit = { path = "../../../aztec-nr/authwit" }
20 changes: 9 additions & 11 deletions noir-projects/noir-contracts/contracts/token_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod test;
contract Token {
// Libs

use dep::int_note::int_note::{IntNote, IntNoteHidingPoint};
use dep::compressed_string::FieldCompressedString;

use dep::aztec::{
Expand All @@ -32,10 +33,7 @@ contract Token {
use dep::authwit::auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public, compute_authwit_nullifier};
// docs:end:import_authwit

use crate::types::{
transparent_note::TransparentNote,
token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteHidingPoint}, balance_set::BalanceSet
};
use crate::types::{transparent_note::TransparentNote, balance_set::BalanceSet};
// docs:end::imports

// In the first transfer iteration we are computing a lot of additional information (validating inputs, retrieving
Expand Down Expand Up @@ -64,7 +62,7 @@ contract Token {
minters: Map<AztecAddress, PublicMutable<bool>>,
// docs:end:storage_minters
// docs:start:storage_balances
balances: Map<AztecAddress, BalanceSet<TokenNote>>,
balances: Map<AztecAddress, BalanceSet<IntNote>>,
// docs:end:storage_balances
total_supply: PublicMutable<U128>,
// docs:start:storage_pending_shields
Expand Down Expand Up @@ -536,7 +534,7 @@ contract Token {

// 4. We create the partial notes for the fee payer and the user.
// --> Called "partial" because they don't have the amount set yet (that will be done in `complete_refund(...)`).
let fee_payer_partial_note = TokenNote {
let fee_payer_partial_note = IntNote {
header: NoteHeader {
contract_address: AztecAddress::zero(),
nonce: 0,
Expand All @@ -547,7 +545,7 @@ contract Token {
npk_m_hash: fee_payer_npk_m_hash,
randomness: fee_payer_randomness
};
let user_partial_note = TokenNote {
let user_partial_note = IntNote {
header: NoteHeader {
contract_address: AztecAddress::zero(),
nonce: 0,
Expand Down Expand Up @@ -580,10 +578,10 @@ contract Token {
#[aztec(internal)]
fn complete_refund(
// TODO(#7771): the following makes macros crash --> try getting it work once we migrate to metaprogramming
// mut fee_payer_point: TokenNoteHidingPoint,
// mut user_point: TokenNoteHidingPoint,
fee_payer_point_immutable: TokenNoteHidingPoint,
user_point_immutable: TokenNoteHidingPoint,
// mut fee_payer_point: IntNoteHidingPoint,
// mut user_point: IntNoteHidingPoint,
fee_payer_point_immutable: IntNoteHidingPoint,
user_point_immutable: IntNoteHidingPoint,
funded_amount: Field
) {
// TODO(#7771): nuke the following 2 lines once we have mutable args
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{test::utils, Token, types::token_note::TokenNote};
use crate::{test::utils, Token};

use dep::aztec::{
test::helpers::cheatcodes, oracle::unsafe_rand::unsafe_rand, hash::compute_secret_hash,
prelude::NoteHeader, protocol_types::storage::map::derive_storage_slot_in_map,
keys::getters::get_current_public_keys
};
use dep::authwit::cheatcodes as authwit_cheatcodes;
use dep::int_note::int_note::IntNote;

#[test]
unconstrained fn setup_refund_success() {
Expand Down Expand Up @@ -45,7 +46,7 @@ unconstrained fn setup_refund_success() {
// worth `funded_amount - transaction_fee`. We "know" the transaction fee was 1 (it is hardcoded in
// `executePublicFunction` TXE oracle) but we need to notify TXE of the note (preimage).
env.store_note_in_cache(
&mut TokenNote {
&mut IntNote {
amount: U128::from_integer(funded_amount - 1),
npk_m_hash: user_npk_m_hash,
randomness: user_randomness,
Expand All @@ -55,7 +56,7 @@ unconstrained fn setup_refund_success() {
token_contract_address
);
env.store_note_in_cache(
&mut TokenNote {
&mut IntNote {
amount: U128::from_integer(1),
npk_m_hash: fee_payer_npk_m_hash,
randomness: fee_payer_randomness,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dep::aztec::{
oracle::{execution::{get_block_number, get_contract_address}, unsafe_rand::unsafe_rand, storage::storage_read}
};

use crate::{types::{token_note::TokenNote, transparent_note::TransparentNote}, Token};
use crate::{types::{transparent_note::TransparentNote}, Token};

pub fn setup(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress) {
// Setup env, generate keys
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mod transparent_note;
mod balance_set;
mod token_note;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dep::aztec::{
note::{note_getter::view_notes, note_emission::{NoteEmission, OuterNoteEmission}},
keys::{getters::get_current_public_keys, public_keys::NpkM}
};
use crate::types::token_note::OwnedNote;
use dep::int_note::int_note::OwnedNote;

struct BalanceSet<T, Context> {
set: PrivateSet<T, Context>,
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_fees/private_refunds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('e2e_fees/private_refunds', () => {
t.aliceAddress,
token.address,
deriveStorageSlotInMap(TokenContract.storage.balances.slot, t.aliceAddress),
TokenContract.notes.TokenNote.id,
TokenContract.notes.IntNote.id,
txHash,
),
);
Expand All @@ -118,7 +118,7 @@ describe('e2e_fees/private_refunds', () => {
t.bobAddress,
token.address,
deriveStorageSlotInMap(TokenContract.storage.balances.slot, t.bobAddress),
TokenContract.notes.TokenNote.id,
TokenContract.notes.IntNote.id,
txHash,
),
);
Expand Down

0 comments on commit ebc0127

Please sign in to comment.