Unverified Commit 0be79eed authored by Fedor Sakharov's avatar Fedor Sakharov Committed by GitHub
Browse files

Add an Origin to parachains v1 (#1542)

parent 00e45561
Pipeline #103105 passed with stages
in 20 minutes and 43 seconds
......@@ -23,6 +23,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::result;
use sp_runtime::traits::BadOrigin;
use primitives::v1::Id as ParaId;
use codec::{Decode, Encode};
pub mod configuration;
pub mod inclusion;
pub mod inclusion_inherent;
......@@ -35,3 +40,22 @@ pub mod runtime_api_impl;
mod mock;
/// Origin for the parachains.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Origin {
/// It comes from a parachain.
/// Ensure that the origin `o` represents a parachain.
/// Returns `Ok` with the parachain ID that effected the extrinsic or an `Err` otherwise.
pub fn ensure_parachain<OuterOrigin>(o: OuterOrigin) -> result::Result<ParaId, BadOrigin>
where OuterOrigin: Into<result::Result<Origin, OuterOrigin>>
match o.into() {
Ok(Origin::Parachain(id)) => Ok(id),
_ => Err(BadOrigin),
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