Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Council events #703

Merged
merged 11 commits into from
Sep 10, 2018
16 changes: 8 additions & 8 deletions demo/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("54048fe23d4e04fda6419771037922eb43d96a7ec76aa280672609711999c3ca").into(),
hex!("b7d85f23689ae4ae7951eda80e817dffb1c0925e77f5c0de8c94b265df80b9cf").into(),
vec![
CheckedExtrinsic {
signed: None,
Expand All @@ -282,7 +282,7 @@ mod tests {
construct_block(
2,
block1().1,
hex!("700c76e3b6125fd9d873629ca3f3cdc2f7704587c0a71def6b152f54b6a29805").into(),
hex!("a17d6006e9bb4292b8ebea3b14995672a88caff2c99eeef1d84aeb234e5a0534").into(),
vec![
CheckedExtrinsic {
signed: None,
Expand All @@ -307,7 +307,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("4428d38ae046f27254877b3a3bf0d8ec7731281aef65ebdb8bbbac86be5424a8").into(),
hex!("27555b6e51bfdb689457fc076a54153a4f5188f47a17607da75e180d844db527").into(),
vec![
CheckedExtrinsic {
signed: None,
Expand Down Expand Up @@ -411,23 +411,23 @@ mod tests {
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Spending(0))
event: Event::session(session::RawEvent::NewSession(1))
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Burnt(0))
event: Event::staking(staking::RawEvent::Reward(0))
},
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Rollover(0))
event: Event::treasury(treasury::RawEvent::Spending(0))
},
EventRecord {
phase: Phase::Finalization,
event: Event::session(session::RawEvent::NewSession(1))
event: Event::treasury(treasury::RawEvent::Burnt(0))
},
EventRecord {
phase: Phase::Finalization,
event: Event::staking(staking::RawEvent::Reward(0))
event: Event::treasury(treasury::RawEvent::Rollover(0))
}
]);
});
Expand Down
81 changes: 57 additions & 24 deletions demo/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ extern crate demo_primitives;
mod checked_block;

use rstd::prelude::*;
use substrate_primitives::u32_trait::{_2, _4};
use codec::{Encode, Decode, Input};
use demo_primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, SessionKey, Signature, InherentData};
use runtime_primitives::generic;
use runtime_primitives::traits::{Convert, BlakeTwo256, DigestItem};
use version::RuntimeVersion;
use codec::{Encode, Decode, Input};
use council::motions as council_motions;
use substrate_primitives::u32_trait::{_2, _4};
use council::{motions as council_motions, voting as council_voting};

#[cfg(any(feature = "std", test))]
pub use runtime_primitives::BuildStorage;
Expand Down Expand Up @@ -113,7 +113,7 @@ pub type System = system::Module<Runtime>;
impl balances::Trait for Runtime {
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnFreeBalanceZero = Staking;
type OnFreeBalanceZero = (Staking, Contract);
type EnsureAccountLiquid = Staking;
type Event = Event;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ impl session::Trait for Runtime {
pub type Session = session::Module<Runtime>;

impl staking::Trait for Runtime {
type OnRewardMinted = ();
type OnRewardMinted = Treasury;
type Event = Event;
}

Expand All @@ -172,10 +172,17 @@ impl democracy::Trait for Runtime {
/// Democracy module for this concrete runtime.
pub type Democracy = democracy::Module<Runtime>;

impl council::Trait for Runtime {}
impl council::Trait for Runtime {
type Event = Event;
}

/// Council module for this concrete runtime.
pub type Council = council::Module<Runtime>;

impl council::voting::Trait for Runtime {
type Event = Event;
}

/// Council voting module for this concrete runtime.
pub type CouncilVoting = council::voting::Module<Runtime>;

Expand Down Expand Up @@ -226,7 +233,16 @@ pub type Contract = contract::Module<Runtime>;

impl_outer_event! {
pub enum Event for Runtime {
balances, session, staking, democracy, treasury, council_motions
//consensus,
balances,
//timetstamp,
session,
staking,
democracy,
council,
council_voting,
council_motions,
treasury
}
}

Expand All @@ -246,9 +262,9 @@ impl_outer_dispatch! {
pub enum Call where origin: Origin {
Consensus,
Balances,
Timestamp,
Session,
Staking,
Timestamp,
Democracy,
Council,
CouncilVoting,
Expand All @@ -260,18 +276,48 @@ impl_outer_dispatch! {

impl_outer_config! {
pub struct GenesisConfig for Runtime {
ConsensusConfig => consensus,
SystemConfig => system,
ConsensusConfig => consensus,
BalancesConfig => balances,
TimestampConfig => timestamp,
SessionConfig => session,
StakingConfig => staking,
DemocracyConfig => democracy,
CouncilConfig => council,
TimestampConfig => timestamp,
TreasuryConfig => treasury,
}
}

type AllModules = (
Consensus,
Balances,
Timestamp,
Session,
Staking,
Democracy,
Council,
CouncilVoting,
CouncilMotions,
Treasury,
Contract,
);

impl_json_metadata!(
for Runtime with modules
system::Module with Storage,
consensus::Module with Storage,
balances::Module with Storage,
timestamp::Module with Storage,
session::Module with Storage,
staking::Module with Storage,
democracy::Module with Storage,
council::Module with Storage,
council_voting::Module with Storage,
council_motions::Module with Storage,
treasury::Module with Storage,
contract::Module with Storage,
);

impl DigestItem for Log {
type AuthorityId = SessionKey;

Expand All @@ -297,20 +343,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Index, Call,
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Index, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, Balances, Balances,
((((((((), Treasury), Council), Democracy), Staking), Session), Timestamp), Contract)>;

impl_json_metadata!(
for Runtime with modules
system::Module with Storage,
balances::Module with Storage,
consensus::Module with Storage,
timestamp::Module with Storage,
session::Module with Storage,
staking::Module with Storage,
democracy::Module with Storage,
council::Module with Storage
);
pub type Executive = executive::Executive<Runtime, Block, Balances, Balances, AllModules>;

pub mod api {
impl_stubs!(
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions substrate/rpc/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ build_rpc_trait! {
fn storage_size(&self, StorageKey, Trailing<Hash>) -> Result<Option<u64>>;

/// Returns the runtime metadata as JSON.
#[rpc(name = "state_metadata", alias = ["state_metadataAt", ])]
fn json_metadata(&self, Trailing<Hash>) -> Result<serde_json::Value>;
#[rpc(name = "state_getMetadata")]
fn metadata(&self, Trailing<Hash>) -> Result<serde_json::Value>;

/// Query historical storage entries (by key) starting from a block given as the second parameter.
///
Expand Down Expand Up @@ -143,7 +143,7 @@ impl<B, E, Block> StateApi<Block::Hash> for State<B, E, Block> where
Ok(self.storage(key, block)?.map(|x| x.0.len() as u64))
}

fn json_metadata(&self, block: Trailing<Block::Hash>) -> Result<serde_json::Value> {
fn metadata(&self, block: Trailing<Block::Hash>) -> Result<serde_json::Value> {
let block = self.unwrap_or_best(block)?;
let metadata = self.client.json_metadata(&BlockId::Hash(block))?;
serde_json::from_str(&metadata).map_err(Into::into)
Expand Down
Loading