-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Make pallet macro generate accessor to PalletInfo information on pallet placeholder #8630
Conversation
Why not make it a trait? |
I thought maybe ppl would be annoyed to have to import the trait in scope. |
now implemented with trait. |
We could put the trait into the prelude |
/// Provides information about the pallet setup in the runtime. | ||
/// | ||
/// Access the information provided by [`PalletInfo`] for a specific pallet. | ||
pub trait PalletInfoAccess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is PalletInfo
already taken? Access
is weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PalletInfo
is the trait giving the info for all pallets https://substrate.dev/rustdocs/v3.0.0/frame_support/traits/trait.PalletInfo.html
It is implemented by an associated type on frame-system https://substrate.dev/rustdocs/v3.0.0/frame_system/pallet/trait.Config.html#associatedtype.PalletInfo
Ideally PalletInfo
could be renamed PalletsInfo
as it contains info for all pallets, and thus we could use PalletInfo
here.
Anyway those 2 traits are very related, PalletInfoAccess
is implementing accessor to the info of the pallet. info of the pallet are retrieved from PalletInfo
which contains info for all pallets (but which is cumbersome to use directly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally PalletInfo could be renamed PalletsInfo as it contains info for all pallets, and thus we could use PalletInfo here.
Totally agree with this, maybe even in this PR? the naming is weird, but the functionality is great, working with the old PalletInfo
was not simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the same time I prefer not to break, as PalletInfoAccess
is also an OK name to me.
Maybe we can write it somewhere for when we want to break frame stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, lets stay backwards compat.
bot merge |
Error: Approval criteria was not satisfied. The following errors might have affected the outcome of this attempt:
Merge failed. Check out the criteria for merge. |
bot merge |
Trying merge. |
paritytech/polkadot-sdk#324
PalletInfoAccess
trait is introduced, and implemented by pallet macro onPallet
.Controversial
#[implement_pallet_info_access)]
or something similar.fn index
andfn name
directly on the struct to avoid having to import the trait in scope, but this makes generation less expectable and can break user code if they implement a function with such a name already)