diff --git a/src/frame/mod.rs b/src/frame/mod.rs index 7f55b338aa..061b593cba 100644 --- a/src/frame/mod.rs +++ b/src/frame/mod.rs @@ -34,6 +34,7 @@ use sp_core::storage::StorageKey; pub mod balances; pub mod contracts; +pub mod session; pub mod staking; pub mod system; diff --git a/src/frame/session.rs b/src/frame/session.rs new file mode 100644 index 0000000000..1b96b898fe --- /dev/null +++ b/src/frame/session.rs @@ -0,0 +1,60 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of substrate-subxt. +// +// subxt 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. +// +// subxt 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-subxt. If not, see . +// Copyright 2019-2020 Parity Technologies (UK) Ltd. + +//! Session support +#![warn(missing_docs)] // yuck ☹ +use crate::frame::system::System; +use codec::Encode; +use frame_support::Parameter; +use std::{fmt::Debug, marker::PhantomData}; +use substrate_subxt_proc_macro::Store; + +/// The trait needed for this module. +pub trait Session: System { + /// The validator account identifier type for the runtime. + type ValidatorId: Parameter + Debug + Ord + Default; + /// The validator account identifier type for the runtime. + type SessionIndex: Parameter + Debug + Ord + Default; +} + +const MODULE: &str = "Session"; + +/// The current set of validators. +#[derive(Encode, Store)] +pub struct ValidatorsStore { + #[store(returns = Vec<::ValidatorId>)] + /// The current set of validators. + pub _runtime: PhantomData, +} + +/// Current index of the session. +#[derive(Encode, Store)] +pub struct CurrentIndexStore { + #[store(returns = ::SessionIndex)] + /// Current index of the session. + pub _r: PhantomData, +} + +/// True if the underlying economic identities or weighting behind the validators +/// has changed in the queued validator set. +#[derive(Encode, Store)] +pub struct QueuedChangedStore { + #[store(returns = bool)] + /// True if the underlying economic identities or weighting behind the validators + /// has changed in the queued validator set. + pub _r: PhantomData, +}