Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
0be79eed
Unverified
Commit
0be79eed
authored
Aug 05, 2020
by
Fedor Sakharov
Committed by
GitHub
Aug 05, 2020
Browse files
Add an Origin to parachains v1 (#1542)
parent
00e45561
Pipeline
#103105
passed with stages
in 20 minutes and 43 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
runtime/parachains/src/lib.rs
View file @
0be79eed
...
...
@@ -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;
#[cfg(test)]
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.
Parachain
(
ParaId
),
}
/// 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
),
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment