-
Notifications
You must be signed in to change notification settings - Fork 770
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
Adds example for custom default configs #4965
base: master
Are you sure you want to change the base?
Conversation
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.
Reading the docs, I have no idea how to use this.
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Will update and provide more details. |
Should we add this to the polkadot-sdk-docs as well? We should probably have a section on macros, even if it is just a list of macros with links to their rust docs |
assert_type_eq_all!(<DummyRuntime as Config>::AccountId, u16); | ||
assert_type_eq_all!(<DummyRuntime as Config>::RuntimeOrigin, ()); | ||
assert_type_eq_all!(<DummyRuntime as Config>::RuntimeCall, ()); | ||
} |
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.
How about:
- One example that demonstrate how this can be used in a pallet, instead of
#[pallet::config(with_default)]
to create "partial configs" and skip providing defaults for things that we are not sure about, for example to solve the issue of @seadanda. - (This is the one I am more interested in) One example of how this can be used in a standalone trait. For example, to build a custom trait like:
trait OpinionatedSystem: frame_system::Config { // more types and fns.}
// register default for this.
#[frame::pallet] mod pallet {
#[pallet::config]
pub trait Config: OpinionatedSystem { .. }
}
mod runtime {
// Use the default provided
impl pallet::Config for Runtime { .. }
}
And please focus on making both as self-explanatory and e2e as possible?
Although the latter is not working properly, the re-export is not expanded. |
Reading #4056 (comment) again, the success scenario here is to make a new The manual approach here works, but it does lose all the type safety, FYI. In that, the |
And if we are to lose type-safety, we can alternatively do #5246. |
Closes #4827
This PR provides an example to create custom default configs for any pallet that could be created externally and shared across runtimes. Such a paradigm can be used in #4056.
It requires the following:
register_default_impl
derive_impl
at the actual impl site pointing to this default implementation