Files
pezkuwi-subxt/polkadot/runtime/common/src/paras_sudo_wrapper.rs
T
Sergei Shulepov c69e5766db Breakdown the Router module on Dmp, Ump, Hrmp modules (#1939)
* Guide: Split router module in guide.

Now we have: DMP, UMP and Router module.

* Add a glossary entry for what used to be called Router

* Extract DMP

* Extract UMP

* Extract HRMP

* Switch over to new modules

* Router: goodbye sweet prince

* Link to messaging overview for details.

* Update missed rococo and test runtimes.

* Commit destroyed by rebase changes

* Don't deprecate Router but rather make it a meta-project

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>

* Fix typos suggestion

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>

* Fix repetition in the impl guide

* Clarify that processed_downward_messages has the u32 type

* Remove the router subdir.

* Deabbreviate DMP,UMP,HRMP

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
2020-11-16 14:02:01 +00:00

63 lines
2.0 KiB
Rust

// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! A simple wrapper allowing `Sudo` to call into `paras` routines.
use frame_support::{
decl_error, decl_module,
dispatch::DispatchResult,
weights::DispatchClass,
};
use frame_system::ensure_root;
use runtime_parachains::{
dmp, ump, hrmp, paras::{self, ParaGenesisArgs},
};
use primitives::v1::Id as ParaId;
/// The module's configuration trait.
pub trait Trait: paras::Trait + dmp::Trait + ump::Trait + hrmp::Trait { }
decl_error! {
pub enum Error for Module<T: Trait> { }
}
decl_module! {
/// A sudo wrapper to call into v1 paras module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
/// Schedule a para to be initialized at the start of the next session.
#[weight = (1_000, DispatchClass::Operational)]
pub fn sudo_schedule_para_initialize(
origin,
id: ParaId,
genesis: ParaGenesisArgs,
) -> DispatchResult {
ensure_root(origin)?;
runtime_parachains::schedule_para_initialize::<T>(id, genesis);
Ok(())
}
/// Schedule a para to be cleaned up at the start of the next session.
#[weight = (1_000, DispatchClass::Operational)]
pub fn sudo_schedule_para_cleanup(origin, id: ParaId) -> DispatchResult {
ensure_root(origin)?;
runtime_parachains::schedule_para_cleanup::<T>(id);
Ok(())
}
}
}