Skip to content

Update events docs#297

Merged
cmichi merged 7 commits intomasterfrom
aj/events
Jan 18, 2024
Merged

Update events docs#297
cmichi merged 7 commits intomasterfrom
aj/events

Conversation

@ascjones
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@cmichi cmichi merged commit 7e0fc78 into master Jan 18, 2024
@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