mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
Implement set_keys
This is needed for Ledgeracio.
This commit is contained in:
@@ -38,6 +38,11 @@ sp-core = { version = "2.0.0-rc2", package = "sp-core" }
|
||||
sc-rpc-api = { version = "0.8.0-rc2", package = "sc-rpc-api" }
|
||||
sp-transaction-pool = { version = "2.0.0-rc2", package = "sp-transaction-pool" }
|
||||
substrate-subxt-proc-macro = { version = "0.8.0", path = "proc-macro" }
|
||||
sp-std = "2.0.0-rc2"
|
||||
sp-finality-grandpa = "2.0.0-rc2"
|
||||
sp-consensus-babe = "0.8.0-rc2"
|
||||
pallet-im-online = "2.0.0-rc2"
|
||||
sp-authority-discovery = "2.0.0-rc2"
|
||||
|
||||
[dev-dependencies]
|
||||
async-std = { version = "1.5.0", features = ["attributes"] }
|
||||
|
||||
@@ -22,6 +22,10 @@ use crate::frame::system::{
|
||||
};
|
||||
use codec::Encode;
|
||||
use frame_support::Parameter;
|
||||
use sp_runtime::traits::{
|
||||
Member,
|
||||
OpaqueKeys,
|
||||
};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
marker::PhantomData,
|
||||
@@ -36,6 +40,9 @@ pub trait Session: System {
|
||||
|
||||
/// The validator account identifier type for the runtime.
|
||||
type SessionIndex: Parameter + Debug + Ord + Default + Send + Sync + 'static;
|
||||
|
||||
/// The keys.
|
||||
type Keys: OpaqueKeys + Member + Parameter + Default;
|
||||
}
|
||||
|
||||
/// The current set of validators.
|
||||
@@ -62,3 +69,12 @@ pub struct QueuedChangedStore<T: Session> {
|
||||
/// Marker for the runtime
|
||||
pub _runtime: PhantomData<T>,
|
||||
}
|
||||
|
||||
/// The current set of validators.
|
||||
#[derive(Encode, Call)]
|
||||
pub struct SetKeysCall<T: Session> {
|
||||
/// The keys
|
||||
pub keys: T::Keys,
|
||||
/// The proof. This is not currently used and can be set to an empty vector.
|
||||
pub proof: Vec<u8>,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
bad_style,
|
||||
const_err,
|
||||
improper_ctypes,
|
||||
missing_docs,
|
||||
non_shorthand_field_patterns,
|
||||
no_mangle_generic_items,
|
||||
overflowing_literals,
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use sp_runtime::{
|
||||
generic::Header,
|
||||
impl_opaque_keys,
|
||||
traits::{
|
||||
BlakeTwo256,
|
||||
IdentifyAccount,
|
||||
@@ -24,6 +27,47 @@ use sp_runtime::{
|
||||
MultiSignature,
|
||||
OpaqueExtrinsic,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// BABE marker struct
|
||||
pub struct Babe;
|
||||
impl sp_runtime::BoundToRuntimeAppPublic for Babe {
|
||||
type Public = sp_consensus_babe::AuthorityId;
|
||||
}
|
||||
|
||||
/// ImOnline marker struct
|
||||
pub struct ImOnline;
|
||||
impl sp_runtime::BoundToRuntimeAppPublic for ImOnline {
|
||||
type Public = ImOnlineId;
|
||||
}
|
||||
|
||||
/// GRANDPA marker struct
|
||||
pub struct Grandpa;
|
||||
impl sp_runtime::BoundToRuntimeAppPublic for Grandpa {
|
||||
type Public = sp_finality_grandpa::AuthorityId;
|
||||
}
|
||||
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
|
||||
/// Authority discovery marker struct
|
||||
pub struct AuthorityDiscovery;
|
||||
impl sp_runtime::BoundToRuntimeAppPublic for AuthorityDiscovery {
|
||||
type Public = AuthorityDiscoveryId;
|
||||
}
|
||||
|
||||
impl_opaque_keys! {
|
||||
/// Runtime keys
|
||||
pub struct SessionKeys {
|
||||
//// GRANDPA session key
|
||||
pub grandpa: Grandpa,
|
||||
//// BABE session key
|
||||
pub babe: Babe,
|
||||
//// ImOnline session key
|
||||
pub im_online: ImOnline,
|
||||
//// AuthorityDiscovery session key
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
|
||||
use crate::frame::{
|
||||
balances::{
|
||||
@@ -73,6 +117,7 @@ impl Balances for DefaultNodeRuntime {
|
||||
impl Session for DefaultNodeRuntime {
|
||||
type SessionIndex = u32;
|
||||
type ValidatorId = <Self as System>::AccountId;
|
||||
type Keys = SessionKeys;
|
||||
}
|
||||
|
||||
impl Contracts for DefaultNodeRuntime {}
|
||||
@@ -101,6 +146,7 @@ impl System for KusamaRuntime {
|
||||
impl Session for KusamaRuntime {
|
||||
type SessionIndex = u32;
|
||||
type ValidatorId = <Self as System>::AccountId;
|
||||
type Keys = SessionKeys;
|
||||
}
|
||||
|
||||
impl Staking for KusamaRuntime {
|
||||
|
||||
Reference in New Issue
Block a user