-
Notifications
You must be signed in to change notification settings - Fork 729
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
Vision: Improve Developer Experience with better Config Traits #288
Comments
Hello @shawntabrizi is this particular issue available for pick up? |
That is not correct. You add the traits bounds that you are require for a certain type in your pallet. The runtime is only required to provide types that implement the given traits. |
@bkchr I think you are saying what I am saying? For example, we know We also know that something like the Or what am I misunderstanding? |
That is right what you are saying. I just wanted to highlight that some pallets may only require that a |
Related to paritytech/substrate#13454 |
I would say this is done with |
@kianenigma can you link context / solution? I saw paritytech/substrate#13454, but does not look like the same thing is being solved. this is still a common issue I found in the academy. Would love traits for storage items, callable parameters, basic unsigned integers, etc... |
True, I misjudged this based on the title. |
If and when done, the author should update https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_runtime_types/index.html as it goes into a lot of depth about how these Admittedly. if knowing the above article in depth, you would not feel confused by the trait bounds, but I get that having a simple setup is necessary, especially for something like |
A solution should look like this : // in frame/src/lib.rs
mod trait_bounds {
pub use frame_support::traits::{Parameter, Members};
// TODO: and fix for instancing
pub trait TRuntimeEvent<PalletEvent, T> = From<PalletEvent<T>> + IsType<<T as frame_system::Config>::RuntimeEvent>
pub trait TRuntimeCall<PalletCall, T> = ..;
// This one is a bit more tricky, as `PalletOrigin` might not exist.
pub trait TRuntimeOrigin<PalletOrigin, T> = ..; |
Isn't this going to be solved by this: #3743? Then we can get rid off all these extra |
@bkchr agree that will def solve a lot of the stuff inside the config. But I think there is much more overall that can be improved. From my original issue, I want to change things like: trait FrameCall: IsType<<Self as frame_system::Config>::Call>
+ Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
+ GetDispatchInfo
+ FullCodec
+ From<frame_system::Call<Self>>
{} To be a single trait which already has all the requirements we need, like: type Call: frame_support::FrameCall Again, coming from someone who does not know so deeply about all these different traits, we can def improve on things. Another example, in the same idea, is to create more easy to use derive macros. For example, instead of: #[derive(Encode, Decode, MaxEncodedLen, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct SomeStructForStorage<T: Config> {} We should be able to do: #[derive(SubstrateStorage(T))]
pub struct SomeStructForStorage<T: Config> {} I think this captures what I originally intended with the issue, and as long as we use valid rust syntax and rules (not a ton of macro magic), I think this will be a better experience for everyone. |
@shawntabrizi the storage thing you wished for will be solved by #4079 |
There are common types defined within the config of different pallets, such as:
All of these types have some complicated traits which are expected from the
construct_runtime!
macro, and often the user struggles to define all those types when doing runtime development.We could simply wrap all of these traits in a simple to understand trait exposed in frame_support like:
Then simply define:
or something like that.
The text was updated successfully, but these errors were encountered: