mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 06:47:57 +00:00
Add partial session support
This commit is contained in:
@@ -34,6 +34,7 @@ use sp_core::storage::StorageKey;
|
||||
|
||||
pub mod balances;
|
||||
pub mod contracts;
|
||||
pub mod session;
|
||||
pub mod staking;
|
||||
pub mod system;
|
||||
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
// 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<T: Session> {
|
||||
#[store(returns = Vec<<T as Session>::ValidatorId>)]
|
||||
/// The current set of validators.
|
||||
pub _runtime: PhantomData<T>,
|
||||
}
|
||||
|
||||
/// Current index of the session.
|
||||
#[derive(Encode, Store)]
|
||||
pub struct CurrentIndexStore<T: Session> {
|
||||
#[store(returns = <T as Session>::SessionIndex)]
|
||||
/// Current index of the session.
|
||||
pub _r: PhantomData<T>,
|
||||
}
|
||||
|
||||
/// True if the underlying economic identities or weighting behind the validators
|
||||
/// has changed in the queued validator set.
|
||||
#[derive(Encode, Store)]
|
||||
pub struct QueuedChangedStore<T: Session> {
|
||||
#[store(returns = bool)]
|
||||
/// True if the underlying economic identities or weighting behind the validators
|
||||
/// has changed in the queued validator set.
|
||||
pub _r: PhantomData<T>,
|
||||
}
|
||||
Reference in New Issue
Block a user