mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 19:25:55 +00:00
Fix Polkadot and Kusama ‘SessionKey’ structs
I had failed to include the ‘Parachains’ component, which the default Substrate runtime doesn’t have.
This commit is contained in:
+19
-14
@@ -16,6 +16,10 @@ description = "Submit extrinsics (transactions) to a substrate node via RPC"
|
|||||||
keywords = ["parity", "substrate", "blockchain"]
|
keywords = ["parity", "substrate", "blockchain"]
|
||||||
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
|
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["kusama"]
|
||||||
|
kusama = ["polkadot"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
@@ -27,22 +31,23 @@ serde_json = "1.0"
|
|||||||
url = "2.1"
|
url = "2.1"
|
||||||
codec = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive", "full"] }
|
codec = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive", "full"] }
|
||||||
|
|
||||||
frame-metadata = { version = "11.0.0-rc2", package = "frame-metadata" }
|
frame-metadata = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
frame-support = { version = "2.0.0-rc2", package = "frame-support" }
|
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-runtime = { version = "2.0.0-rc2", package = "sp-runtime" }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-version = { version = "2.0.0-rc2", package = "sp-version" }
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
pallet-indices = { version = "2.0.0-rc2", package = "pallet-indices" }
|
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
hex = "0.4.0"
|
hex = "0.4.0"
|
||||||
sp-rpc = { version = "2.0.0-rc2", package = "sp-rpc" }
|
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-core = { version = "2.0.0-rc2", package = "sp-core" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-rpc-api = { version = "0.8.0-rc2", package = "sc-rpc-api" }
|
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-transaction-pool = { version = "2.0.0-rc2", package = "sp-transaction-pool" }
|
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
substrate-subxt-proc-macro = { version = "0.8.0", path = "proc-macro" }
|
substrate-subxt-proc-macro = { version = "0.8.0", path = "proc-macro" }
|
||||||
sp-std = "2.0.0-rc2"
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-finality-grandpa = "2.0.0-rc2"
|
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-consensus-babe = "0.8.0-rc2"
|
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
pallet-im-online = "2.0.0-rc2"
|
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-authority-discovery = "2.0.0-rc2"
|
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
polkadot = { git = "https://github.com/paritytech/polkadot", branch = "master", optional = true, default-features = false, features = ["std"], package = "polkadot-primitives" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
async-std = { version = "1.5.0", features = ["attributes"] }
|
async-std = { version = "1.5.0", features = ["attributes"] }
|
||||||
|
|||||||
+33
-2
@@ -49,6 +49,13 @@ impl sp_runtime::BoundToRuntimeAppPublic for Grandpa {
|
|||||||
|
|
||||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||||
|
|
||||||
|
/// Parachain marker struct
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
|
pub struct Parachains;
|
||||||
|
impl sp_runtime::BoundToRuntimeAppPublic for Parachains {
|
||||||
|
type Public = polkadot::parachain::ValidatorId;
|
||||||
|
}
|
||||||
|
|
||||||
/// Authority discovery marker struct
|
/// Authority discovery marker struct
|
||||||
pub struct AuthorityDiscovery;
|
pub struct AuthorityDiscovery;
|
||||||
impl sp_runtime::BoundToRuntimeAppPublic for AuthorityDiscovery {
|
impl sp_runtime::BoundToRuntimeAppPublic for AuthorityDiscovery {
|
||||||
@@ -56,7 +63,24 @@ impl sp_runtime::BoundToRuntimeAppPublic for AuthorityDiscovery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl_opaque_keys! {
|
impl_opaque_keys! {
|
||||||
/// Runtime keys
|
/// Substrate base runtime keys
|
||||||
|
pub struct BasicSessionKeys {
|
||||||
|
//// GRANDPA session key
|
||||||
|
pub grandpa: Grandpa,
|
||||||
|
//// BABE session key
|
||||||
|
pub babe: Babe,
|
||||||
|
//// ImOnline session key
|
||||||
|
pub im_online: ImOnline,
|
||||||
|
//// Parachain validation session key
|
||||||
|
pub parachains: Parachains,
|
||||||
|
//// AuthorityDiscovery session key
|
||||||
|
pub authority_discovery: AuthorityDiscovery,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
|
impl_opaque_keys! {
|
||||||
|
/// Polkadot/Kusama runtime keys
|
||||||
pub struct SessionKeys {
|
pub struct SessionKeys {
|
||||||
//// GRANDPA session key
|
//// GRANDPA session key
|
||||||
pub grandpa: Grandpa,
|
pub grandpa: Grandpa,
|
||||||
@@ -64,6 +88,8 @@ impl_opaque_keys! {
|
|||||||
pub babe: Babe,
|
pub babe: Babe,
|
||||||
//// ImOnline session key
|
//// ImOnline session key
|
||||||
pub im_online: ImOnline,
|
pub im_online: ImOnline,
|
||||||
|
//// ParachainValidator session key
|
||||||
|
pub parachain_validator: Parachains,
|
||||||
//// AuthorityDiscovery session key
|
//// AuthorityDiscovery session key
|
||||||
pub authority_discovery: AuthorityDiscovery,
|
pub authority_discovery: AuthorityDiscovery,
|
||||||
}
|
}
|
||||||
@@ -117,7 +143,7 @@ impl Balances for DefaultNodeRuntime {
|
|||||||
impl Session for DefaultNodeRuntime {
|
impl Session for DefaultNodeRuntime {
|
||||||
type SessionIndex = u32;
|
type SessionIndex = u32;
|
||||||
type ValidatorId = <Self as System>::AccountId;
|
type ValidatorId = <Self as System>::AccountId;
|
||||||
type Keys = SessionKeys;
|
type Keys = BasicSessionKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Contracts for DefaultNodeRuntime {}
|
impl Contracts for DefaultNodeRuntime {}
|
||||||
@@ -128,9 +154,11 @@ impl Contracts for DefaultNodeRuntime {}
|
|||||||
///
|
///
|
||||||
/// Main difference is `type Address = AccountId`.
|
/// Main difference is `type Address = AccountId`.
|
||||||
/// Also the contracts module is not part of the kusama runtime.
|
/// Also the contracts module is not part of the kusama runtime.
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct KusamaRuntime;
|
pub struct KusamaRuntime;
|
||||||
|
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
impl System for KusamaRuntime {
|
impl System for KusamaRuntime {
|
||||||
type Index = u32;
|
type Index = u32;
|
||||||
type BlockNumber = u32;
|
type BlockNumber = u32;
|
||||||
@@ -143,12 +171,14 @@ impl System for KusamaRuntime {
|
|||||||
type AccountData = AccountData<<Self as Balances>::Balance>;
|
type AccountData = AccountData<<Self as Balances>::Balance>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
impl Session for KusamaRuntime {
|
impl Session for KusamaRuntime {
|
||||||
type SessionIndex = u32;
|
type SessionIndex = u32;
|
||||||
type ValidatorId = <Self as System>::AccountId;
|
type ValidatorId = <Self as System>::AccountId;
|
||||||
type Keys = SessionKeys;
|
type Keys = SessionKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
impl Staking for KusamaRuntime {
|
impl Staking for KusamaRuntime {
|
||||||
type NominatorIndex = u32;
|
type NominatorIndex = u32;
|
||||||
type ValidatorIndex = u16;
|
type ValidatorIndex = u16;
|
||||||
@@ -158,6 +188,7 @@ impl Staking for KusamaRuntime {
|
|||||||
type RewardPoint = u32;
|
type RewardPoint = u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "kusama")]
|
||||||
impl Balances for KusamaRuntime {
|
impl Balances for KusamaRuntime {
|
||||||
type Balance = u128;
|
type Balance = u128;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user