mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 11:57:56 +00:00
Use some upstream type definitions
Also add `Default` impls.
This commit is contained in:
@@ -32,6 +32,18 @@ use std::{
|
||||
};
|
||||
use substrate_subxt_proc_macro::Store;
|
||||
|
||||
macro_rules! def {
|
||||
($name:ident) => {
|
||||
impl<T: Session> Default for $name<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
_runtime: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The trait needed for this module.
|
||||
#[module]
|
||||
pub trait Session: System {
|
||||
@@ -53,6 +65,8 @@ pub struct ValidatorsStore<T: Session> {
|
||||
pub _runtime: PhantomData<T>,
|
||||
}
|
||||
|
||||
def!(ValidatorsStore);
|
||||
|
||||
/// Current index of the session.
|
||||
#[derive(Encode, Store, Debug)]
|
||||
pub struct CurrentIndexStore<T: Session> {
|
||||
@@ -61,6 +75,8 @@ pub struct CurrentIndexStore<T: Session> {
|
||||
pub _runtime: PhantomData<T>,
|
||||
}
|
||||
|
||||
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<T: Session> {
|
||||
pub _runtime: PhantomData<T>,
|
||||
}
|
||||
|
||||
def!(QueuedChangedStore);
|
||||
|
||||
/// The current set of validators.
|
||||
#[derive(Encode, Call, Debug)]
|
||||
pub struct SetKeysCall<T: Session> {
|
||||
@@ -78,3 +96,20 @@ pub struct SetKeysCall<T: Session> {
|
||||
/// The proof. This is not currently used and can be set to an empty vector.
|
||||
pub proof: Vec<u8>,
|
||||
}
|
||||
|
||||
#[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());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-21
@@ -161,26 +161,7 @@ pub struct UnlockChunk<T: Staking> {
|
||||
pub era: T::EraIndex,
|
||||
}
|
||||
|
||||
/// The ledger of a (bonded) stash.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, Ord, PartialOrd, Hash, Debug)]
|
||||
pub struct StakingLedger<T: Staking> {
|
||||
/// 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<UnlockChunk<T>>,
|
||||
/// List of eras for which the stakers behind a validator have claimed rewards. Only updated
|
||||
/// for validators.
|
||||
pub claimed_rewards: Vec<T::EraIndex>,
|
||||
}
|
||||
pub use pallet_staking::StakingLedger;
|
||||
|
||||
/// Number of eras to keep in history.
|
||||
///
|
||||
@@ -239,7 +220,7 @@ pub struct BondedStore<T: Staking> {
|
||||
/// 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<T: Staking> {
|
||||
#[store(returns = Option<StakingLedger<T>>)]
|
||||
#[store(returns = Option<StakingLedger<T::AccountId, T::Balance>>)]
|
||||
/// The controller account
|
||||
pub controller: T::AccountId,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user