Inside mod pallet {}, there is code for RawOrigin, which is

pub enum RawOrigin<AccountId> {

I don't know how we can use this AccountId type explicitly, I mean shouldn't the code look like this?

pub enum RawOrigin<T:config::AccounId> {

1 Answer 1


You should review how generics work in Rust.

By defining RawOrigin as pub enum RawOrigin<AccountId>, we allow this enum object to work for any generic AccountId type.

What you seem to want actually is defined in the frame_system pallet elsewhere:

/// Exposed trait-generic origin type.
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;

Here you can see we take this RawOrigin type, and directly use the AccountId definition from Config as you wanted.

However, doing it this way takes advantage of the #[pallet::origin] macro, which allows pallets to register new origins in the Substrate runtime, rather than making some hard coded assumptions about this kind of thing.

So this is a very intended abstraction, and part of the overall modular design of Substrate.

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.