Skip to content

Commit

Permalink
updated events definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunkar committed Dec 9, 2024
1 parent 535f905 commit 011d2cf
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 17 deletions.
1 change: 0 additions & 1 deletion avm-transpiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/macros/events/mod.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::utils::compute_event_selector;
use protocol_types::meta::flatten_to_fields;
use std::meta::typ::fresh_type_variable;

comptime fn generate_event_interface(s: StructDefinition) -> Quoted {
let name = s.name();
Expand All @@ -13,7 +14,6 @@ comptime fn generate_event_interface(s: StructDefinition) -> Quoted {
impl aztec::event::event_interface::EventInterface<$content_len> for $name {
fn to_be_bytes(self) -> [u8; $content_len * 32 + 32] {
let mut buffer: [u8; $content_len * 32 + 32] = [0; $content_len * 32 + 32];

let event_type_id_bytes: [u8; 32] = $name::get_event_type_id().to_field().to_be_bytes();

for i in 0..32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ contract ContractInstanceDeployer {
};
use std::meta::derive;

#[event]
#[derive(Serialize)]
#[event]
struct ContractInstanceDeployed {
DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE: Field,
address: AztecAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ contract Crowdfunding {
use token::Token;
// docs:end:all-deps

#[event]
#[derive(Serialize)]
#[event]
struct WithdrawalProcessed {
who: AztecAddress,
amount: u64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ contract NFT {
utils::comparison::Comparator,
};
use dep::compressed_string::FieldCompressedString;
use std::{embedded_curve_ops::EmbeddedCurvePoint, meta::derive};
use std::meta::derive;

// TODO(#8467): Rename this to Transfer - calling this NFTTransfer to avoid export conflict with the Transfer event
// in the Token contract.
#[event]
#[derive(Serialize)]
#[event]
struct NFTTransfer {
from: AztecAddress,
to: AztecAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ contract Test {
get_mint_to_private_content_hash, get_mint_to_public_content_hash,
};
use dep::value_note::value_note::ValueNote;
// TODO investigate why the macros require EmbeddedCurvePoint and EmbeddedCurveScalar
use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar};
use std::meta::derive;

use crate::test_note::TestNote;

#[event]
#[derive(Serialize)]
#[event]
struct ExampleEvent {
value0: Field,
value1: Field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ contract TestLog {
use dep::value_note::value_note::ValueNote;
use std::meta::derive;

use std::embedded_curve_ops::EmbeddedCurveScalar;

#[event]
#[derive(Serialize)]
#[event]
struct ExampleEvent0 {
value0: Field,
value1: Field,
}

#[event]
#[derive(Serialize)]
#[event]
struct ExampleEvent1 {
value2: AztecAddress,
value3: u8,
Expand All @@ -32,9 +30,6 @@ contract TestLog {
example_set: PrivateSet<ValueNote, Context>,
}

// EXAMPLE_EVENT_0_BYTES_LEN + 16
global EXAMPLE_EVENT_0_CIPHERTEXT_BYTES_LEN: Field = 144;

#[private]
fn emit_encrypted_events(other: AztecAddress, preimages: [Field; 4]) {
let event0 = ExampleEvent0 { value0: preimages[0], value1: preimages[1] };
Expand Down

0 comments on commit 011d2cf

Please sign in to comment.