mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
origin to frame v2 (#3405)
This commit is contained in:
@@ -19,14 +19,8 @@
|
|||||||
use sp_std::result;
|
use sp_std::result;
|
||||||
use sp_runtime::traits::BadOrigin;
|
use sp_runtime::traits::BadOrigin;
|
||||||
use primitives::v1::Id as ParaId;
|
use primitives::v1::Id as ParaId;
|
||||||
use parity_scale_codec::{Decode, Encode};
|
|
||||||
|
|
||||||
/// Origin for the parachains.
|
pub use pallet::*;
|
||||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug)]
|
|
||||||
pub enum Origin {
|
|
||||||
/// It comes from a parachain.
|
|
||||||
Parachain(ParaId),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ensure that the origin `o` represents a parachain.
|
/// Ensure that the origin `o` represents a parachain.
|
||||||
/// Returns `Ok` with the parachain ID that effected the extrinsic or an `Err` otherwise.
|
/// 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
|
/// There is no way to register an origin type in `construct_runtime` without a pallet the origin
|
||||||
/// belongs to.
|
/// belongs to.
|
||||||
///
|
///
|
||||||
/// This module fulfills only the single purpose of housing the `Origin` in `construct_runtime`.
|
/// 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.
|
// 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 {}
|
#[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 {
|
impl From<u32> for Origin {
|
||||||
|
|||||||
Reference in New Issue
Block a user