Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
bf7aff26
Commit
bf7aff26
authored
3 years ago
by
ferrell-code
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
origin to frame v2 (#3405)
parent
c4d45c97
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
polkadot/runtime/parachains/src/origin.rs
+26
-18
26 additions, 18 deletions
polkadot/runtime/parachains/src/origin.rs
with
26 additions
and
18 deletions
polkadot/runtime/parachains/src/origin.rs
+
26
−
18
View file @
bf7aff26
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment