mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
Use ‘#[module]’ and implement session for Kusama
This commit is contained in:
@@ -16,7 +16,10 @@
|
|||||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||||
|
|
||||||
//! Session support
|
//! Session support
|
||||||
use crate::frame::system::System;
|
use crate::frame::system::{
|
||||||
|
System,
|
||||||
|
SystemEventsDecoder as _,
|
||||||
|
};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::Parameter;
|
use frame_support::Parameter;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -26,14 +29,14 @@ use std::{
|
|||||||
use substrate_subxt_proc_macro::Store;
|
use substrate_subxt_proc_macro::Store;
|
||||||
|
|
||||||
/// The trait needed for this module.
|
/// The trait needed for this module.
|
||||||
|
#[module]
|
||||||
pub trait Session: System {
|
pub trait Session: System {
|
||||||
/// The validator account identifier type for the runtime.
|
/// The validator account identifier type for the runtime.
|
||||||
type ValidatorId: Parameter + Debug + Ord + Default;
|
type ValidatorId: Parameter + Debug + Ord + Default + Send + Sync + 'static;
|
||||||
/// The validator account identifier type for the runtime.
|
|
||||||
type SessionIndex: Parameter + Debug + Ord + Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MODULE: &str = "Session";
|
/// The validator account identifier type for the runtime.
|
||||||
|
type SessionIndex: Parameter + Debug + Ord + Default + Send + Sync + 'static;
|
||||||
|
}
|
||||||
|
|
||||||
/// The current set of validators.
|
/// The current set of validators.
|
||||||
#[derive(Encode, Store)]
|
#[derive(Encode, Store)]
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
//! Implements support for the frame_staking module.
|
//! Implements support for the frame_staking module.
|
||||||
|
|
||||||
use super::system::{System, SystemEventsDecoder as _};
|
use super::system::{
|
||||||
|
System,
|
||||||
|
SystemEventsDecoder as _,
|
||||||
|
};
|
||||||
use codec::{
|
use codec::{
|
||||||
Decode,
|
Decode,
|
||||||
Encode,
|
Encode,
|
||||||
@@ -111,6 +114,7 @@ impl Default for ValidatorPrefs {
|
|||||||
/// The subset of the `frame::Trait` that a client must implement.
|
/// The subset of the `frame::Trait` that a client must implement.
|
||||||
#[module]
|
#[module]
|
||||||
pub trait Staking: System {}
|
pub trait Staking: System {}
|
||||||
|
impl<T: System> Staking for T {}
|
||||||
|
|
||||||
/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
|
/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
|
||||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ use crate::frame::{
|
|||||||
Balances,
|
Balances,
|
||||||
},
|
},
|
||||||
contracts::Contracts,
|
contracts::Contracts,
|
||||||
|
session::Session,
|
||||||
system::System,
|
system::System,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,6 +83,11 @@ impl System for KusamaRuntime {
|
|||||||
type AccountData = AccountData<<Self as Balances>::Balance>;
|
type AccountData = AccountData<<Self as Balances>::Balance>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Session for KusamaRuntime {
|
||||||
|
type SessionIndex = u32;
|
||||||
|
type ValidatorId = <Self as System>::AccountId;
|
||||||
|
}
|
||||||
|
|
||||||
impl Balances for KusamaRuntime {
|
impl Balances for KusamaRuntime {
|
||||||
type Balance = u128;
|
type Balance = u128;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user