Skip to content

Commit

Permalink
feat: adding unencrypted events to Token contract
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 17, 2023
1 parent 472465b commit 1c17487
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ contract Token {

use dep::safe_math::SafeU120;

// docs:start:unencrypted_import
use dep::aztec::log::emit_unencrypted_log;
// docs:end:unencrypted_import

use dep::aztec::{
note::{
note_getter_options::NoteGetterOptions,
Expand Down Expand Up @@ -135,6 +139,8 @@ contract Token {
// docs:start:write_admin
storage.admin.write(new_admin);
// docs:end:write_admin

emit_unencrypted_log(&mut context, "Admin set");
}
// docs:end:set_admin

Expand All @@ -150,6 +156,8 @@ contract Token {
// docs:start:write_minter
storage.minters.at(minter.address).write(approve);
// docs:end:write_minter

emit_unencrypted_log(&mut context, "Minter set");
}
// docs:end:set_minter

Expand All @@ -168,6 +176,11 @@ contract Token {

storage.public_balances.at(to.address).write(new_balance);
storage.total_supply.write(supply);

// docs:start:unencrypted_log
emit_unencrypted_log(&mut context, "Public tokens minted");
// docs:end:unencrypted_log

1
}
// docs:end:mint_public
Expand All @@ -187,6 +200,8 @@ contract Token {
// docs:start:insert_from_public
pending_shields.insert_from_public(&mut note);
// docs:end:insert_from_public

emit_unencrypted_log(&mut context, "Private tokens minted");
1
}
// docs:end:mint_private
Expand Down Expand Up @@ -214,6 +229,9 @@ contract Token {

storage.public_balances.at(from.address).write(from_balance);
pending_shields.insert_from_public(&mut note);

emit_unencrypted_log(&mut context, "Tokens shielded");

1
}
// docs:end:shield
Expand All @@ -239,6 +257,8 @@ contract Token {
let to_balance = storage.public_balances.at(to.address).read().add(amount);
storage.public_balances.at(to.address).write(to_balance);

emit_unencrypted_log(&mut context, "Public tokens transferred");

1
}
// docs:end:transfer_public
Expand All @@ -263,6 +283,8 @@ contract Token {
let new_supply = storage.total_supply.read().sub(amount);
storage.total_supply.write(new_supply);

emit_unencrypted_log(&mut context, "Public tokens burned");

1
}
// docs:end:burn_public
Expand Down

0 comments on commit 1c17487

Please sign in to comment.