Skip to content

Comments

improve(events): add static emit function to Event macro#49

Open
scab24 wants to merge 3 commits intor55-eth:mainfrom
scab24:improvement/emit_function_to_Event_macro
Open

improve(events): add static emit function to Event macro#49
scab24 wants to merge 3 commits intor55-eth:mainfrom
scab24:improvement/emit_function_to_Event_macro

Conversation

@scab24
Copy link
Contributor

@scab24 scab24 commented May 2, 2025

  • Add static emit() function to #[derive(Event)] macro
  • Simplify event emission syntax from log::emit(Event::new()) to Event::emit()
  • Update all event emissions in ERC20 contract
  • Update all event emissions in ERC721 contract
  • Add print_event_logs utility function for testing

#48

- Add static emit() function to #[derive(Event)] macro
- Simplify event emission syntax from log::emit(Event::new()) to Event::emit()
- Update all event emissions in ERC20 contract
- Update all event emissions in ERC721 contract
- Add print_event_logs utility function for testing
Copy link
Contributor

@0xrusowsky 0xrusowsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the macro change looks good, but style/lint should be fixed


// Emit event + return
log::emit(Approval::new(owner, spender, amount));
// Emit event + return usando la nueva sintaxis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove spanish comments pls

Copy link
Contributor Author

@scab24 scab24 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted! I tried to automate the comments, but I forgot to review it
Thanks !

14dc969


// Emit event + return
log::emit(Transfer::new(from, to, amount));
// Emit event + return usando la nueva sintaxis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


// Emit event + return
log::emit(Transfer::new(from, to, amount));
// Emit event + return usando la nueva sintaxis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


// Emit event + return
log::emit(OwnershipTransferred::new(from, new_owner));
// Emit event + return usando la nueva sintaxis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Bytes::from_hex(trimmed).expect("Unable to parse file content as bytes")
}

pub fn print_event_logs(logs: &[Log], title: Option<&str>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of the fn if we don't use it?

i'd either adopt it in the tests or remove it

Copy link
Contributor Author

@scab24 scab24 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used it to run some tests to verify that the new implementation was working correctly
I just removed it, thanks !

14dc969

Copy link
Contributor

@0xrusowsky 0xrusowsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but u'll need an approval from @gakonst or @leonardoalt

@scab24
Copy link
Contributor Author

scab24 commented Aug 28, 2025

Hi (@gakonst , @leonardoalt ), I would like to know if this PR is correct
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants