Remove upgrade-key module from SRML (#2018)

* Remove upgrade-key from SRML. Update chain spec builder text

* bump spec_version, rebuild wasm

* Remove upgrade-key from SRML. Update chain spec builder text

* bump spec_version, rebuild wasm

* Rebase, Rebuild

* Rebuild wasm
This commit is contained in:
Shawn Tabrizi
2019-03-18 15:00:30 +01:00
committed by Bastian Köcher
parent 96d1f841cb
commit b513326ea7
12 changed files with 7 additions and 154 deletions
-26
View File
@@ -1,26 +0,0 @@
[package]
name = "srml-upgrade-key"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
serde = { version = "1.0", optional = true }
parity-codec = { version = "3.2", default-features = false }
sr-std = { path = "../../core/sr-std", default-features = false }
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
srml-support = { path = "../support", default-features = false }
system = { package = "srml-system", path = "../system", default-features = false }
consensus = { package = "srml-consensus", path = "../consensus", default-features = false }
[features]
default = ["std"]
std = [
"serde",
"parity-codec/std",
"sr-std/std",
"sr-primitives/std",
"srml-support/std",
"system/std",
"consensus/std",
]
-71
View File
@@ -1,71 +0,0 @@
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate 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.
// Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>.
//! The Example: A simple example of a runtime module demonstrating
//! concepts, APIs and structures common to most runtime modules.
#![cfg_attr(not(feature = "std"), no_std)]
use sr_std::prelude::*;
use sr_primitives::traits::StaticLookup;
use srml_support::{StorageValue, decl_module, decl_event, decl_storage, ensure};
use system::ensure_signed;
pub trait Trait: consensus::Trait + system::Trait {
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
decl_module! {
// Simple declaration of the `Module` type. Lets the macro know what its working on.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn deposit_event<T>() = default;
fn upgrade(origin, new: Vec<u8>) {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
ensure!(_sender == Self::key(), "only the current upgrade key can use the upgrade_key module");
<consensus::Module<T>>::set_code(new)?;
Self::deposit_event(RawEvent::Upgraded);
}
fn set_key(origin, new: <T::Lookup as StaticLookup>::Source) {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
ensure!(_sender == Self::key(), "only the current upgrade key can use the upgrade_key module");
let new = T::Lookup::lookup(new)?;
Self::deposit_event(RawEvent::KeyChanged(Self::key()));
<Key<T>>::put(new);
}
}
}
/// An event in this module.
decl_event!(
pub enum Event<T> where AccountId = <T as system::Trait>::AccountId {
/// An upgrade just happened.
Upgraded,
/// An upgrade just happened; old key is supplied as an argument.
KeyChanged(AccountId),
}
);
decl_storage! {
trait Store for Module<T: Trait> as UpgradeKey {
Key get(key) config(): T::AccountId;
}
}