Unverified Commit 11f3ff69 authored by ferrell-code's avatar ferrell-code Committed by GitHub
Browse files

origin to frame v2 (#3405)

parent ade20586
Pipeline #145532 passed with stages
in 38 minutes and 29 seconds
......@@ -19,14 +19,8 @@
use sp_std::result;
use sp_runtime::traits::BadOrigin;
use primitives::v1::Id as ParaId;
use parity_scale_codec::{Decode, Encode};
/// Origin for the parachains.
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug)]
pub enum Origin {
/// It comes from a parachain.
Parachain(ParaId),
}
pub use pallet::*;
/// Ensure that the origin `o` represents a parachain.
/// Returns `Ok` with the parachain ID that effected the extrinsic or an `Err` otherwise.
......@@ -39,17 +33,31 @@ pub fn ensure_parachain<OuterOrigin>(o: OuterOrigin) -> result::Result<ParaId, B
}
}
/// The origin module.
pub trait Config: frame_system::Config {}
frame_support::decl_module! {
/// There is no way to register an origin type in `construct_runtime` without a pallet the origin
/// belongs to.
///
/// This module fulfills only the single purpose of housing the `Origin` in `construct_runtime`.
///
// ideally, though, the `construct_runtime` should support a free-standing origin.
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {}
/// There is no way to register an origin type in `construct_runtime` without a pallet the origin
/// belongs to.
///
/// This module fulfills only the single purpose of housing the `Origin` in `construct_runtime`.
///
// ideally, though, the `construct_runtime` should support a free-standing origin.
#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;
use super::*;
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {}
/// Origin for the parachains.
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug)]
pub enum Origin {
/// It comes from a parachain.
Parachain(ParaId),
}
}
impl From<u32> for Origin {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment