diff --git a/Cargo.toml b/Cargo.toml index 56f94428d3..76386197c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,7 @@ sp-finality-grandpa = { version = "2.0.0-rc3" } sp-consensus-babe = { version = "0.8.0-rc3" } pallet-im-online = { version = "2.0.0-rc3" } sp-authority-discovery = { version = "2.0.0-rc3" } +pallet-staking = "2.0.0-rc3" [dev-dependencies] async-std = { version = "=1.5.0", features = ["attributes"] } diff --git a/src/frame/session.rs b/src/frame/session.rs index f82e52f7c4..b352a91163 100644 --- a/src/frame/session.rs +++ b/src/frame/session.rs @@ -32,6 +32,18 @@ use std::{ }; use substrate_subxt_proc_macro::Store; +macro_rules! def { + ($name:ident) => { + impl Default for $name { + fn default() -> Self { + Self { + _runtime: PhantomData, + } + } + } + }; +} + /// The trait needed for this module. #[module] pub trait Session: System { @@ -53,6 +65,8 @@ pub struct ValidatorsStore { pub _runtime: PhantomData, } +def!(ValidatorsStore); + /// Current index of the session. #[derive(Encode, Store, Debug)] pub struct CurrentIndexStore { @@ -61,6 +75,8 @@ pub struct CurrentIndexStore { pub _runtime: PhantomData, } +def!(CurrentIndexStore); + /// True if the underlying economic identities or weighting behind the validators /// has changed in the queued validator set. #[derive(Encode, Store, Debug)] @@ -70,6 +86,8 @@ pub struct QueuedChangedStore { pub _runtime: PhantomData, } +def!(QueuedChangedStore); + /// The current set of validators. #[derive(Encode, Call, Debug)] pub struct SetKeysCall { @@ -78,3 +96,20 @@ pub struct SetKeysCall { /// The proof. This is not currently used and can be set to an empty vector. pub proof: Vec, } + +#[cfg(test)] +mod tests { + use super::*; + use crate::tests::test_client; + + #[async_std::test] + async fn test_state_read_free_balance() { + env_logger::try_init().ok(); + let (client, _) = test_client().await; + assert!(client + .fetch(QueuedChangedStore::default(), None) + .await + .unwrap() + .unwrap()); + } +} diff --git a/src/frame/staking.rs b/src/frame/staking.rs index bbdd145bcf..56ab8ca210 100644 --- a/src/frame/staking.rs +++ b/src/frame/staking.rs @@ -161,26 +161,7 @@ pub struct UnlockChunk { pub era: T::EraIndex, } -/// The ledger of a (bonded) stash. -#[derive(PartialEq, Eq, Clone, Encode, Decode, Ord, PartialOrd, Hash, Debug)] -pub struct StakingLedger { - /// The stash account whose balance is actually locked and at stake. - pub stash: T::AccountId, - /// The total amount of the stash's balance that we are currently accounting for. - /// It's just `active` plus all the `unlocking` balances. - #[codec(compact)] - pub total: T::Balance, - /// The total amount of the stash's balance that will be at stake in any forthcoming - /// rounds. - #[codec(compact)] - pub active: T::Balance, - /// Any balance that is becoming free, which may eventually be transferred out - /// of the stash (assuming it doesn't get slashed first). - pub unlocking: Vec>, - /// List of eras for which the stakers behind a validator have claimed rewards. Only updated - /// for validators. - pub claimed_rewards: Vec, -} +pub use pallet_staking::StakingLedger; /// Number of eras to keep in history. /// @@ -239,7 +220,7 @@ pub struct BondedStore { /// Map from all (unlocked) "controller" accounts to the info regarding the staking. #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct LedgerStore { - #[store(returns = Option>)] + #[store(returns = Option>)] /// The controller account pub controller: T::AccountId, }