From ffbffd44eb663034ff2f9a4bae31fcdcb8013f0f Mon Sep 17 00:00:00 2001 From: "Demi M. Obenour" Date: Sun, 17 May 2020 15:34:50 -0400 Subject: [PATCH] =?UTF-8?q?Use=20=E2=80=98#[module]=E2=80=99=20and=20imple?= =?UTF-8?q?ment=20session=20for=20Kusama?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frame/session.rs | 15 +++++++++------ src/frame/staking.rs | 6 +++++- src/runtimes.rs | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/frame/session.rs b/src/frame/session.rs index 7dcbe58da3..0a9cfc02b0 100644 --- a/src/frame/session.rs +++ b/src/frame/session.rs @@ -16,7 +16,10 @@ // Copyright 2019-2020 Parity Technologies (UK) Ltd. //! Session support -use crate::frame::system::System; +use crate::frame::system::{ + System, + SystemEventsDecoder as _, +}; use codec::Encode; use frame_support::Parameter; use std::{ @@ -26,14 +29,14 @@ use std::{ use substrate_subxt_proc_macro::Store; /// The trait needed for this module. +#[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; -} + type ValidatorId: Parameter + Debug + Ord + Default + Send + Sync + 'static; -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. #[derive(Encode, Store)] diff --git a/src/frame/staking.rs b/src/frame/staking.rs index 80ec46db18..40b247ac63 100644 --- a/src/frame/staking.rs +++ b/src/frame/staking.rs @@ -16,7 +16,10 @@ //! Implements support for the frame_staking module. -use super::system::{System, SystemEventsDecoder as _}; +use super::system::{ + System, + SystemEventsDecoder as _, +}; use codec::{ Decode, Encode, @@ -111,6 +114,7 @@ impl Default for ValidatorPrefs { /// The subset of the `frame::Trait` that a client must implement. #[module] pub trait Staking: System {} +impl Staking for T {} /// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked. #[derive(PartialEq, Eq, Clone, Encode, Decode)] diff --git a/src/runtimes.rs b/src/runtimes.rs index 3ced7ce0b5..10b9bc6f1d 100644 --- a/src/runtimes.rs +++ b/src/runtimes.rs @@ -31,6 +31,7 @@ use crate::frame::{ Balances, }, contracts::Contracts, + session::Session, system::System, }; @@ -82,6 +83,11 @@ impl System for KusamaRuntime { type AccountData = AccountData<::Balance>; } +impl Session for KusamaRuntime { + type SessionIndex = u32; + type ValidatorId = ::AccountId; +} + impl Balances for KusamaRuntime { type Balance = u128; }