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

Update events docs #297

Merged
merged 7 commits into from
Jan 18, 2024
Merged

Update events docs #297

merged 7 commits into from
Jan 18, 2024

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Jan 5, 2024

For events 2.0 use-ink/ink#1827

When an event is emitted, 0 or more topics can be associated with it. The event is then indexed
together with other events with the same topic value.

An event's fields can be annotated with `#[ink(topic)]` (see example), which will result in a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
An event's fields can be annotated with `#[ink(topic)]` (see example), which will result in a
An event's field can be annotated with `#[ink(topic)]` (see example), which will result in a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is meant to convey that multiple individual fields can be annotated with the topic.

An event's fields can be annotated with `#[ink(topic)]` (see example), which will result in a
topic derived from the value of that field being emitted together with the event.

Topics are by default a 32 byte array (`[u8; 32]`), although this is configurable on the
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it actually configurable? I thought ink is hardcoded to use blake 256 still

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The type of the resulting topic is configurable yes. So if it is shorter I guess it will be truncated and longer padded.

https://github.com/paritytech/ink/blob/27407b5f59f24233cddc3cea59cc2213ba2c6674/crates/env/src/engine/on_chain/impls.rs#L157

Our way of generating the topic value itself is hardcoded to blake2.

Copy link
Collaborator

@cmichi cmichi left a comment

Choose a reason for hiding this comment

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

Just some style remarks for consistency with existing docs.

docs/basics/events.md Outdated Show resolved Hide resolved
docs/basics/events.md Outdated Show resolved Hide resolved
docs/basics/events.md Outdated Show resolved Hide resolved
@cmichi cmichi merged commit 7e0fc78 into master Jan 18, 2024
4 checks passed
@cmichi cmichi deleted the aj/events branch January 18, 2024 09:28
cmichi added a commit that referenced this pull request Jan 18, 2024
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.

3 participants