1

Below is my block of code where I am implementing this trait Config. I am not sure what I am doing wrong here I keep getting error "the type parameter T is not constrained by the impl trait, self type, or predicates"

pub trait Config: frame_system::Config {
    type Who;
    type RuntimeEvent;
    type OriginSuccess;
    type SchemaCreatorId;
    type MaxEncodedSchemaLength;
    type WeightInfo;
    type EnsureOrigin;
    type Origin;
}
impl<T: frame_system::Config> Config for Test {
    type Who = u64;
    type RuntimeEvent = Event<T>;
    type EnsureOrigin = frame_system::EnsureSignedBy<Self::Who, Self::AccountId>;
    type OriginSuccess = ();
    type SchemaCreatorId = AccountId32;
    type MaxEncodedSchemaLength = Self::MaxEncodedSchemaLength;
    type WeightInfo = Self::WeightInfo;
}

Attached is the screenshot of the error. unconstrained type parameter Also the codefile CodeFile If anyone can point me what I am doing wrong that would be help

2 Answers 2

2

that's because you are basically defining a trait that is bound by frame_system::Config, meaning the type that must implement your Config trait must also implement frame_system::Config

what you want to do is something like this:

impl my_pallet::Config for Test{...}

this will work only if Test already implements frame_system::Config (which it does in substrate https://github.com/paritytech/substrate/blob/a7bc9c2a8c0a14fd6033de1f972a11a2b3dbb73a/bin/node/runtime/src/lib.rs#L217

or for tests

https://github.com/substrate-developer-hub/substrate-node-template/blob/700c3a186e55d0d6542c564ccff17260238ed752/pallets/template/src/mock.rs#L24 )

1
1

There are a lot of examples here.

https://github.com/paritytech/substrate/blob/a7bc9c2a8c0a14fd6033de1f972a11a2b3dbb73a/bin/node/runtime/src/lib.rs#L246-L251

You just need impl xxx::Config for Runtime/Test { ... }.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.