Skip to content

Commit

Permalink
Runtime upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas committed Dec 19, 2019
1 parent 3530455 commit b89009c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
15 changes: 11 additions & 4 deletions rewards/src/lib.rs
Expand Up @@ -3,7 +3,7 @@
use rstd::{result, prelude::*};
use sr_primitives::RuntimeString;
use support::{
decl_module, decl_storage,
decl_module, decl_storage, decl_error, ensure,
traits::{Get, Currency},
weights::SimpleDispatchInfo,
};
Expand All @@ -17,6 +17,13 @@ pub trait Trait: balances::Trait {
type Reward: Get<Self::Balance>;
}

decl_error! {
pub enum Error for Module<T: Trait> {
/// Author already set in block.
AuthorAlreadySet,
}
}

decl_storage! {
trait Store for Module<T: Trait> as Rewards {
Author: Option<T::AccountId>;
Expand All @@ -25,13 +32,13 @@ decl_storage! {

decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
type Error = Error<T>;

#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
fn set_author(origin, author: T::AccountId) {
ensure_none(origin)?;
ensure!(<Self as Store>::Author::get().is_some(), Error::<T>::AuthorAlreadySet);

if <Self as Store>::Author::get().is_some() {
return Err("Author already set in block.")
}
<Self as Store>::Author::put(author);
}

Expand Down
4 changes: 4 additions & 0 deletions runtime/src/lib.rs
Expand Up @@ -131,6 +131,10 @@ impl system::Trait for Runtime {
/// Portion of the block weight that is available to all normal transactions.
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
/// Converts a module to the index of the module in `construct_runtime!`.
///
/// This type is being generated by `construct_runtime!`.
type ModuleToIndex = ModuleToIndex;
}

impl indices::Trait for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion vendor/substrate

0 comments on commit b89009c

Please sign in to comment.