Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

contracts: Add event field names #9896

Merged
3 commits merged into from
Sep 30, 2021
Merged

contracts: Add event field names #9896

3 commits merged into from
Sep 30, 2021

Conversation

ascjones
Copy link
Contributor

Use struct variants with field names for Event, instead of unnamed tuple variants. This will be automatically reflected (via the TypeInfo derive) in the metadata with variant fields having names attached.

Motivated by my having wasted a lot of time when I mixed up these fields Instantiated(T::AccountId, T::AccountId)

If this is acceptable then we can convert other pallet Events to this style.

@ascjones ascjones added A0-please_review Pull request needs code review. A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Sep 29, 2021
@ascjones ascjones requested a review from athei September 29, 2021 10:15
@@ -369,49 +369,44 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Contract deployed by address at the specified address. \[deployer, contract\]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jacogr I've removed this \[deployer, contract\], but is that used by polkadot.js currently for the field names?

Copy link
Contributor

@jacogr jacogr Sep 29, 2021

Choose a reason for hiding this comment

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

No, it not used at all - it purely appears in the md documentation generated from the metadata, aka https://polkadot.js.org/docs/.

Copy link
Member

@shawntabrizi shawntabrizi Sep 29, 2021

Choose a reason for hiding this comment

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

You will find this annotations sprinkled everywhere. If moving to this field name syntax, I think we can clean them all up :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this was a temporary solution until the events have named fields. More in PR #6684

Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

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

LGTM

@ascjones
Copy link
Contributor Author

bot merge

@ghost
Copy link

ghost commented Sep 30, 2021

Trying merge.

@ghost ghost merged commit 0bc873d into master Sep 30, 2021
@ghost ghost deleted the aj-contracts-named-event-fields branch September 30, 2021 08:12
ordian added a commit that referenced this pull request Oct 2, 2021
* master: (67 commits)
  Downstream `node-template` pull (#9915)
  Implement core::fmt::Debug for BoundedVec (#9914)
  Quickly skip invalid transactions during block authorship. (#9789)
  Add SS58 prefix for Automata (#9805)
  Clean up sc-peerset (#9806)
  Test each benchmark case in own #[test] (#9860)
  Add build with docker section to README (#9792)
  Simple Trait to Inspect Metadata (#9893)
  Pallet Assets: Create new asset classes from genesis config (#9742)
  doc: subkey usage (#9905)
  Silence alert about large-statement-fetcher (#9882)
  Fix democracy on-initialize weight (#9890)
  Fix basic authorship flaky test (#9906)
  contracts: Add event field names (#9896)
  subkey readme update on install (#9900)
  add feature wasmtime-jitdump (#9871)
  Return `target_hash` for finality_target instead of an Option (#9867)
  Update wasmtime to 0.29.0 (#9552)
  Less sleeps (#9848)
  remove unidiomatic (#9895)
  ...
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants