Created
July 10, 2019 18:00
-
-
Save shawntabrizi/10015de643e936fdd1632e7fc4a586fe to your computer and use it in GitHub Desktop.
Substrate Enum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use support::{decl_module, decl_storage, StorageValue, dispatch::Result}; | |
use system::ensure_signed; | |
use parity_codec::{ Encode, Decode }; | |
#[derive(Encode, Decode, Clone, PartialEq)] | |
#[cfg_attr(feature = "std", derive(Debug))] | |
pub enum Choices { | |
None, | |
One, | |
Two, | |
Three, | |
} | |
pub trait Trait: timestamp::Trait {} | |
decl_storage! { | |
trait Store for Module<T: Trait> as TemplateModule { | |
Choice: Choices = Choices::None; | |
} | |
} | |
decl_module! { | |
pub struct Module<T: Trait> for enum Call where origin: T::Origin { | |
pub fn make_decision(origin, decision: Choices) -> Result { | |
let who = ensure_signed(origin)?; | |
<Choice<T>>::put(decision); | |
Ok(()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment