Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Unify name for Child oriented events #36

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions contracts/rmrk/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub mod rmrk_contract {
#[ink(event)]
pub struct ChildAdded {
Copy link
Member

Choose a reason for hiding this comment

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

It was not changed here but seems a good opportunity to improve. We name this ChildProposed on EVM, because it must be accepted. So "Added" might be confusing.

#[ink(topic)]
to: Id,
parent: Id,
Copy link
Member

Choose a reason for hiding this comment

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

We call this tokenId since the context is the current collection and event is named Child so this token being the parent can be implied. I'd prefer consistency but parent also makes it more explicit so I'm fine with either.

I have mixed thoughts about whether to include "Id" in the names, in general. Here it seems obvious since type is Id, but when calling it, it might not be so obvious. Again, no strong position here, up for discussion.

#[ink(topic)]
collection: AccountId,
#[ink(topic)]
Expand All @@ -93,9 +93,9 @@ pub mod rmrk_contract {
#[ink(topic)]
Copy link
Member

Choose a reason for hiding this comment

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

This event is probably legacy. "Removing" a child became "Transferring" a child so event should be ChildTransferred. Since it can happen from pending (rejecting) or active (removing). Maybe we need an issue for this change, I haven't checked nesting lego yet 😞

parent: Id,
#[ink(topic)]
child_collection: AccountId,
collection: AccountId,
#[ink(topic)]
child_token_id: Id,
child: Id,
}

/// Event emitted when a child is rejected.
Expand All @@ -104,9 +104,9 @@ pub mod rmrk_contract {
#[ink(topic)]
parent: Id,
#[ink(topic)]
child_collection: AccountId,
collection: AccountId,
Copy link
Member

Choose a reason for hiding this comment

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

I would definitely keep child_collection in the name, here you can't know if this collections is about the parent or the child, both present on the event.

#[ink(topic)]
child_token_id: Id,
child: Id,
}

/// Event emitted when new asset is set for the collection.
Expand Down Expand Up @@ -302,7 +302,7 @@ pub mod rmrk_contract {
/// Emit ChildAdded event
fn _emit_added_child_event(&self, to: &Id, collection: &AccountId, child: &Id) {
self.env().emit_event(ChildAdded {
to: to.clone(),
parent: to.clone(),
collection: *collection,
child: child.clone(),
});
Expand All @@ -326,8 +326,8 @@ pub mod rmrk_contract {
) {
self.env().emit_event(ChildRemoved {
parent: parent.clone(),
child_collection: *child_collection,
child_token_id: child_token_id.clone(),
collection: *child_collection,
child: child_token_id.clone(),
});
}

Expand All @@ -340,8 +340,8 @@ pub mod rmrk_contract {
) {
self.env().emit_event(ChildRejected {
parent: parent.clone(),
child_collection: *child_collection,
child_token_id: child_token_id.clone(),
collection: *child_collection,
child: child_token_id.clone(),
});
}
}
Expand Down