diff --git a/Cargo.toml b/Cargo.toml index 99e19dee93..aaca8753be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,11 +26,11 @@ log = "0.4.11" thiserror = "1.0.20" futures = "0.3.5" jsonrpsee = { version = "0.1.0", features = ["ws"] } -num-traits = { version = "0.2.12" } +num-traits = "0.2.12" serde = { version = "1.0.115", features = ["derive"] } serde_json = "1.0.57" url = "2.1.1" -codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive", "full"] } +codec = { package = "parity-scale-codec", version = "1.3.5", features = ["derive", "full"] } frame-metadata = { version = "11.0.0-rc6", package = "frame-metadata" } frame-support = { version = "2.0.0-rc6", package = "frame-support" } @@ -40,11 +40,11 @@ pallet-indices = { version = "2.0.0-rc6", package = "pallet-indices" } hex = "0.4.2" sp-std = "2.0.0-rc6" application-crypto = { version = "2.0.0-rc6", package = "sp-application-crypto" } -sp-finality-grandpa = { version = "2.0.0-rc6" } +sp-finality-grandpa = "2.0.0-rc6" sp-consensus-babe = "0.8.0-rc6" -pallet-im-online = { version = "2.0.0-rc6" } -sp-authority-discovery = { version = "2.0.0-rc6" } -pallet-staking = { version = "2.0.0-rc6" } +pallet-im-online = "2.0.0-rc6" +sp-authority-discovery = "2.0.0-rc6" +pallet-staking = "2.0.0-rc6" sp-rpc = { version = "2.0.0-rc6", package = "sp-rpc" } sp-core = { version = "2.0.0-rc6", package = "sp-core" } @@ -64,20 +64,20 @@ tempdir = "0.3.7" test-node = { path = "test-node" } wabt = "0.10.0" -[patch.crates-io] -frame-metadata = { git = "https://github.com/paritytech/substrate" } -frame-support = { git = "https://github.com/paritytech/substrate" } -sp-runtime = { git = "https://github.com/paritytech/substrate" } -sp-version = { git = "https://github.com/paritytech/substrate" } -pallet-indices = { git = "https://github.com/paritytech/substrate" } -sp-rpc = { git = "https://github.com/paritytech/substrate" } -sp-core = { git = "https://github.com/paritytech/substrate" } -sc-rpc-api = { git = "https://github.com/paritytech/substrate" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate" } -sp-std = { git = "https://github.com/paritytech/substrate" } -application-crypto = { git = "https://github.com/paritytech/substrate", package = "sp-application-crypto", default-features = false } -sp-finality-grandpa = { git = "https://github.com/paritytech/substrate" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate" } -pallet-im-online = { git = "https://github.com/paritytech/substrate" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate" } -pallet-staking = { git = "https://github.com/paritytech/substrate" } +# [patch.crates-io] +# frame-metadata = { git = "https://github.com/paritytech/substrate" } +# frame-support = { git = "https://github.com/paritytech/substrate" } +# sp-runtime = { git = "https://github.com/paritytech/substrate" } +# sp-version = { git = "https://github.com/paritytech/substrate" } +# pallet-indices = { git = "https://github.com/paritytech/substrate" } +# sp-rpc = { git = "https://github.com/paritytech/substrate" } +# sp-core = { git = "https://github.com/paritytech/substrate" } +# sc-rpc-api = { git = "https://github.com/paritytech/substrate" } +# sp-transaction-pool = { git = "https://github.com/paritytech/substrate" } +# sp-std = { git = "https://github.com/paritytech/substrate" } +# application-crypto = { git = "https://github.com/paritytech/substrate", package = "sp-application-crypto", default-features = false } +# sp-finality-grandpa = { git = "https://github.com/paritytech/substrate" } +# sp-consensus-babe = { git = "https://github.com/paritytech/substrate" } +# pallet-im-online = { git = "https://github.com/paritytech/substrate" } +# sp-authority-discovery = { git = "https://github.com/paritytech/substrate" } +# pallet-staking = { git = "https://github.com/paritytech/substrate" } diff --git a/src/frame/session.rs b/src/frame/session.rs index 4f7b90af6f..fca862a9a3 100644 --- a/src/frame/session.rs +++ b/src/frame/session.rs @@ -1,12 +1,12 @@ // Copyright 2019-2020 Parity Technologies (UK) Ltd. // This file is part of substrate-subxt. // -// subxt is free software: you can redistribute it and/or modify +// substrate-subxt is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // -// subxt is distributed in the hope that it will be useful, +// substrate-subxt is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. @@ -32,7 +32,9 @@ use std::{ }; use substrate_subxt_proc_macro::Store; -macro_rules! def { +/// Impls `Default::default` for some types that have a `_runtime` field of type +/// `PhantomData` as their only field. +macro_rules! default_impl { ($name:ident) => { impl Default for $name { fn default() -> Self { @@ -50,7 +52,7 @@ pub trait Session: System { /// The validator account identifier type for the runtime. type ValidatorId: Parameter + Debug + Ord + Default + Send + Sync + 'static; - /// The validator account identifier type for the runtime. + /// The session index identifier type for the runtime. type SessionIndex: Parameter + Debug + Ord + Default + Send + Sync + 'static; /// The keys. @@ -65,7 +67,7 @@ pub struct ValidatorsStore { pub _runtime: PhantomData, } -def!(ValidatorsStore); +default_impl!(ValidatorsStore); /// Current index of the session. #[derive(Encode, Store, Debug)] @@ -75,7 +77,7 @@ pub struct CurrentIndexStore { pub _runtime: PhantomData, } -def!(CurrentIndexStore); +default_impl!(CurrentIndexStore); /// True if the underlying economic identities or weighting behind the validators /// has changed in the queued validator set. @@ -86,9 +88,9 @@ pub struct QueuedChangedStore { pub _runtime: PhantomData, } -def!(QueuedChangedStore); +default_impl!(QueuedChangedStore); -/// The current set of validators. +/// Set the session keys for a validator. #[derive(Encode, Call, Debug)] pub struct SetKeysCall { /// The keys @@ -103,6 +105,7 @@ mod tests { use crate::tests::test_client; #[async_std::test] + #[ignore] async fn test_state_read_free_balance() { env_logger::try_init().ok(); let (client, _) = test_client().await; diff --git a/src/frame/staking.rs b/src/frame/staking.rs index 25a4d4e7cf..d4a6c7b469 100644 --- a/src/frame/staking.rs +++ b/src/frame/staking.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with substrate-subxt. If not, see . -//! Implements support for the frame_staking module. +//! Implements support for the pallet_staking module. use super::balances::{ Balances, @@ -51,7 +51,7 @@ pub use pallet_staking::{ /// /// This is keyed first by the era index to allow bulk deletion and then the stash account. /// -/// Is it removed after `HISTORY_DEPTH` eras. +/// It is removed after `HISTORY_DEPTH` eras. #[derive(Encode, Decode, Debug, Store)] pub struct ErasValidatorPrefsStore { #[store(returns = ValidatorPrefs)] @@ -76,7 +76,7 @@ pub struct ErasRewardPointsStore { #[derive(Clone, Encode, Decode, Debug, Call)] pub struct SetPayeeCall { /// The payee - pub payee: RewardDestination, + pub payee: RewardDestination, /// Marker for the runtime pub _runtime: PhantomData, } @@ -111,13 +111,13 @@ pub trait Staking: Balances { const MAX_NOMINATORS: usize; } -/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked. +/// A Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked. #[derive(Clone, Encode, Decode, Debug)] pub struct UnlockChunk { /// Amount of funds to be unlocked. #[codec(compact)] pub value: T::Balance, - /// Era number at which point it'll be unlocked. + /// Era number at which point the funds will be unlocked. #[codec(compact)] pub era: EraIndex, } @@ -183,7 +183,7 @@ pub struct LedgerStore { /// Where the reward payment should be made. Keyed by stash. #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct PayeeStore { - #[store(returns = RewardDestination)] + #[store(returns = RewardDestination)] /// Tٗhe stash account pub stash: T::AccountId, } @@ -235,7 +235,7 @@ pub struct EraRewardPoints { /// /// This is keyed fist by the era index to allow bulk deletion and then the stash account. /// -/// Is it removed after `HISTORY_DEPTH` eras. +/// It is removed after `HISTORY_DEPTH` eras. /// If stakers hasn't been set or has been removed then empty exposure is returned. #[derive(Encode, Copy, Clone, Debug, Store)] pub struct ErasStakersClippedStore { @@ -246,7 +246,7 @@ pub struct ErasStakersClippedStore { pub validator_stash: T::AccountId, } -/// The active era information, it holds index and start. +/// The active era information, holds index and start. /// /// The active era is the era currently rewarded. /// Validator set of this era must be equal to `SessionInterface::validators`. @@ -259,21 +259,10 @@ pub struct ActiveEraStore { /// Declare no desire to either validate or nominate. /// -/// Effects will be felt at the beginning of the next era. +/// Effective at the beginning of the next era. /// /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. -/// And, it can be only called when [`EraElectionStatus`] is `Closed`. -/// -/// # -/// - Independent of the arguments. Insignificant complexity. -/// - Contains one read. -/// - Writes are limited to the `origin` account key. -/// -------- -/// Base Weight: 16.53 µs -/// DB Weight: -/// - Read: EraElectionStatus, Ledger -/// - Write: Validators, Nominators -/// # +/// Can only be called when [`EraElectionStatus`] is `Closed`. #[derive(Debug, Call, Encode)] pub struct ChillCall { /// Runtime marker @@ -298,21 +287,10 @@ impl Copy for ChillCall {} /// Declare the desire to validate for the origin controller. /// -/// Effects will be felt at the beginning of the next era. +/// Effective at the beginning of the next era. /// /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. -/// And, it can be only called when [`EraElectionStatus`] is `Closed`. -/// -/// # -/// - Independent of the arguments. Insignificant complexity. -/// - Contains a limited number of reads. -/// - Writes are limited to the `origin` account key. -/// ----------- -/// Base Weight: 17.13 µs -/// DB Weight: -/// - Read: Era Election Status, Ledger -/// - Write: Nominators, Validators -/// # +/// Can only be called when [`EraElectionStatus`] is `Closed`. #[derive(Clone, Debug, PartialEq, Call, Encode)] pub struct ValidateCall { /// Runtime marker @@ -323,23 +301,10 @@ pub struct ValidateCall { /// Declare the desire to nominate `targets` for the origin controller. /// -/// Effects will be felt at the beginning of the next era. This can only be called when -/// [`EraElectionStatus`] is `Closed`. +/// Effective at the beginning of the next era. /// /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. -/// And, it can be only called when [`EraElectionStatus`] is `Closed`. -/// -/// # -/// - The transaction's complexity is proportional to the size of `targets` (N) -/// which is capped at CompactAssignments::LIMIT (MAX_NOMINATIONS). -/// - Both the reads and writes follow a similar pattern. -/// --------- -/// Base Weight: 22.34 + .36 * N µs -/// where N is the number of targets -/// DB Weight: -/// - Reads: Era Election Status, Ledger, Current Era -/// - Writes: Validators, Nominators -/// # +/// Can only be called when [`EraElectionStatus`] is `Closed`. #[derive(Call, Encode, Debug)] pub struct NominateCall { /// The targets that are being nominated diff --git a/src/lib.rs b/src/lib.rs index 49600f09b0..738420a11d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ pub use crate::{ rpc::{ BlockNumber, ExtrinsicSuccess, - Properties, + SystemProperties, }, runtimes::*, subscription::*, @@ -167,7 +167,7 @@ impl ClientBuilder { rpc.metadata(), rpc.genesis_hash(), rpc.runtime_version(None), - rpc.properties(), + rpc.system_properties(), ) .await; Ok(Client { @@ -187,7 +187,7 @@ pub struct Client { rpc: Rpc, genesis_hash: T::Hash, metadata: Metadata, - properties: Properties, + properties: SystemProperties, runtime_version: RuntimeVersion, _marker: PhantomData<(fn() -> T::Signature, T::Extra)>, page_size: u32, @@ -265,7 +265,7 @@ impl Client { } /// Returns the system properties - pub fn properties(&self) -> &Properties { + pub fn properties(&self) -> &SystemProperties { &self.properties } diff --git a/src/rpc.rs b/src/rpc.rs index 969a977782..25ec9c3e0f 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -99,7 +99,7 @@ impl From for BlockNumber { #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, Default)] #[serde(rename_all = "camelCase")] /// System properties for a Substrate-based runtime -pub struct Properties { +pub struct SystemProperties { /// The address format pub ss58_format: u8, /// The number of digits after the decimal point in the native token @@ -221,7 +221,7 @@ impl Rpc { } /// Fetch system properties - pub async fn properties(&self) -> Result { + pub async fn system_properties(&self) -> Result { Ok(self .client .request("system_properties", Params::None)