mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
origin to frame v2 (#3405)
This commit is contained in:
@@ -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 {}
|
||||
/// 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::*;
|
||||
|
||||
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 {}
|
||||
#[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 {
|
||||
|
||||
Reference in New Issue
Block a user