JSON-RPC client generation (#2778)

* Bump jsonrpc & generate clients.

* Initial version of JSON-RPC client.

* Re-wort

* Remove spurious `#[derive(Encode, Decode)]`

They did not compile, since `Encode` and `Decode` are deliberately not
implemented for `usize`.

Fixes #2742.

* Re-write rpc-client example.

* Update to jsonrpc=12.0.0

* Remove unnecessary import

* Bump version.

* Revert version bump.

* Bump again.
This commit is contained in:
Tomasz Drwięga
2019-06-04 18:43:55 +02:00
committed by Gavin Wood
parent 5df89a8a6f
commit 6112f815b3
18 changed files with 289 additions and 103 deletions
+5
View File
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
//! State RPC errors.
use client;
use crate::rpc;
use crate::errors;
@@ -29,8 +31,11 @@ pub enum Error {
/// Provided block range couldn't be resolved to a list of blocks.
#[display(fmt = "Cannot resolve a block range ['{:?}' ... '{:?}]. {}", from, to, details)]
InvalidBlockRange {
/// Beginning of the block range.
from: String,
/// End of the block range.
to: String,
/// Details of the error message.
details: String,
},
}
+14 -13
View File
@@ -16,36 +16,37 @@
//! Substrate state API.
pub mod error;
#[cfg(test)]
mod tests;
use std::{
collections::{BTreeMap, HashMap},
ops::Range,
sync::Arc,
};
use log::{warn, trace};
use client::{self, Client, CallExecutor, BlockchainEvents, runtime_api::Metadata};
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use primitives::{H256, Blake2Hasher, Bytes};
use primitives::hexdisplay::HexDisplay;
use primitives::storage::{self, StorageKey, StorageData, StorageChangeSet};
use crate::rpc::Result as RpcResult;
use crate::rpc::futures::{stream, Future, Sink, Stream};
use crate::subscriptions::Subscriptions;
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use log::{warn, trace};
use primitives::hexdisplay::HexDisplay;
use primitives::storage::{self, StorageKey, StorageData, StorageChangeSet};
use primitives::{H256, Blake2Hasher, Bytes};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{
Block as BlockT, Header, ProvideRuntimeApi, NumberFor,
SaturatedConversion
};
use runtime_version::RuntimeVersion;
use self::error::Result;
use state_machine::{self, ExecutionStrategy};
use crate::subscriptions::Subscriptions;
mod error;
#[cfg(test)]
mod tests;
use self::error::Result;
pub use self::gen_client::Client as StateClient;
/// Substrate state API
#[rpc]