From f7fa9f6e9dd02fa5c14ab866485920a24c1f46c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Nov 2017 11:38:17 +0100 Subject: [PATCH] Drop jsonrpc_core::Error --- dapps/src/endpoint.rs | 4 +- dapps/src/handlers/fetch.rs | 5 +- dapps/src/lib.rs | 5 +- dapps/src/tests/helpers/mod.rs | 7 +- parity/dapps.rs | 5 +- parity/rpc.rs | 4 +- rpc/src/lib.rs | 22 +---- rpc/src/v1/helpers/dispatch.rs | 44 ++++----- rpc/src/v1/helpers/light_fetch.rs | 22 ++--- rpc/src/v1/helpers/subscription_manager.rs | 4 +- rpc/src/v1/impls/eth.rs | 86 ++++++++--------- rpc/src/v1/impls/eth_filter.rs | 18 ++-- rpc/src/v1/impls/eth_pubsub.rs | 8 +- rpc/src/v1/impls/light/eth.rs | 78 +++++++-------- rpc/src/v1/impls/light/net.rs | 8 +- rpc/src/v1/impls/light/parity.rs | 92 +++++++++--------- rpc/src/v1/impls/light/parity_set.rs | 46 ++++----- rpc/src/v1/impls/light/trace.rs | 18 ++-- rpc/src/v1/impls/net.rs | 8 +- rpc/src/v1/impls/parity.rs | 96 +++++++++---------- rpc/src/v1/impls/parity_accounts.rs | 74 +++++++------- rpc/src/v1/impls/parity_set.rs | 46 ++++----- rpc/src/v1/impls/personal.rs | 14 +-- rpc/src/v1/impls/pubsub.rs | 4 +- rpc/src/v1/impls/rpc.rs | 6 +- rpc/src/v1/impls/secretstore.rs | 14 +-- rpc/src/v1/impls/signer.rs | 26 ++--- rpc/src/v1/impls/signing.rs | 22 ++--- rpc/src/v1/impls/signing_unsafe.rs | 22 ++--- rpc/src/v1/impls/traces.rs | 20 ++-- rpc/src/v1/impls/web3.rs | 6 +- rpc/src/v1/traits/eth.rs | 86 ++++++++--------- rpc/src/v1/traits/eth_pubsub.rs | 4 +- rpc/src/v1/traits/eth_signing.rs | 8 +- rpc/src/v1/traits/net.rs | 8 +- rpc/src/v1/traits/parity.rs | 92 +++++++++--------- rpc/src/v1/traits/parity_accounts.rs | 72 +++++++------- rpc/src/v1/traits/parity_set.rs | 46 ++++----- rpc/src/v1/traits/parity_signing.rs | 12 +-- rpc/src/v1/traits/personal.rs | 12 +-- rpc/src/v1/traits/pubsub.rs | 4 +- rpc/src/v1/traits/rpc.rs | 6 +- rpc/src/v1/traits/secretstore.rs | 8 +- rpc/src/v1/traits/signer.rs | 18 ++-- rpc/src/v1/traits/traces.rs | 18 ++-- rpc/src/v1/traits/web3.rs | 6 +- rpc_client/src/client.rs | 4 +- rpc_client/src/lib.rs | 2 + rpc_client/src/signer_client.rs | 2 +- .../admin_sessions/share_add_session.rs | 8 +- 50 files changed, 616 insertions(+), 634 deletions(-) diff --git a/dapps/src/endpoint.rs b/dapps/src/endpoint.rs index c612ad5b8..2dbcf209f 100644 --- a/dapps/src/endpoint.rs +++ b/dapps/src/endpoint.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::BoxFuture; +use futures::Future; use hyper; #[derive(Debug, PartialEq, Default, Clone)] @@ -47,7 +47,7 @@ pub struct EndpointInfo { } pub type Endpoints = BTreeMap>; -pub type Response = BoxFuture; +pub type Response = Box + Send>; pub type Request = hyper::Request; pub trait Endpoint : Send + Sync { diff --git a/dapps/src/handlers/fetch.rs b/dapps/src/handlers/fetch.rs index 27429bd01..8e0fc021e 100644 --- a/dapps/src/handlers/fetch.rs +++ b/dapps/src/handlers/fetch.rs @@ -24,7 +24,6 @@ use fetch::{self, Fetch}; use futures::sync::oneshot; use futures::{self, Future}; use hyper::{self, Method, StatusCode}; -use jsonrpc_core::BoxFuture; use parking_lot::Mutex; use endpoint::{self, EndpointPath}; @@ -212,7 +211,7 @@ impl Errors { enum FetchState { Error(ContentHandler), - InProgress(BoxFuture), + InProgress(Box + Send>), Streaming(hyper::Response), Done(local::Dapp, endpoint::Response), Empty, @@ -289,7 +288,7 @@ impl ContentFetcherHandler { path: EndpointPath, errors: Errors, installer: H, - ) -> BoxFuture { + ) -> Box + Send> { // Start fetching the content let fetch2 = fetch.clone(); let future = fetch.fetch_with_abort(url, abort.into()).then(move |result| { diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 36b5bec4c..e63f30c23 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -32,7 +32,6 @@ extern crate serde_json; extern crate unicase; extern crate zip; -extern crate jsonrpc_core; extern crate jsonrpc_http_server; extern crate ethcore_util as util; @@ -52,10 +51,12 @@ extern crate log; #[macro_use] extern crate serde_derive; +#[cfg(test)] +extern crate env_logger; #[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(test)] -extern crate env_logger; +extern crate jsonrpc_core; #[cfg(test)] extern crate parity_reactor; diff --git a/dapps/src/tests/helpers/mod.rs b/dapps/src/tests/helpers/mod.rs index 81ed5ed41..fd60e5bf4 100644 --- a/dapps/src/tests/helpers/mod.rs +++ b/dapps/src/tests/helpers/mod.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::env; -use std::str; +use std::{env, io, str}; use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -187,7 +186,7 @@ impl ServerBuilder { /// Asynchronously start server with no authentication, /// returns result with `Server` handle on success or an error. - pub fn start_unsecured_http(self, addr: &SocketAddr, io: IoHandler) -> Result { + pub fn start_unsecured_http(self, addr: &SocketAddr, io: IoHandler) -> io::Result { let fetch = self.fetch_client(); Server::start_http( addr, @@ -234,7 +233,7 @@ impl Server { remote: Remote, fetch: F, serve_ui: bool, - ) -> Result { + ) -> io::Result { let health = NodeHealth::new( sync_status.clone(), TimeChecker::new::(&[], CpuPool::new(1)), diff --git a/parity/dapps.rs b/parity/dapps.rs index 364f563c5..c15b16337 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -22,7 +22,6 @@ use ethcore::client::{Client, BlockChainClient, BlockId}; use ethcore::transaction::{Transaction, Action}; use ethsync::LightSync; use futures::{future, IntoFuture, Future}; -use jsonrpc_core::BoxFuture; use hash_fetch::fetch::Client as FetchClient; use hash_fetch::urlhint::ContractClient; use helpers::replace_home; @@ -80,7 +79,7 @@ impl ContractClient for FullRegistrar { }) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { Box::new(self.client.call_contract(BlockId::Latest, address, data) .into_future()) } @@ -105,7 +104,7 @@ impl ContractClient for LightRegistrar { }) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { let header = self.client.best_block_header(); let env_info = self.client.env_info(BlockId::Hash(header.hash())) .ok_or_else(|| format!("Cannot fetch env info for header {}", header.hash())); diff --git a/parity/rpc.rs b/parity/rpc.rs index d67362b5f..3a202b590 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -246,7 +246,7 @@ pub fn new_ws( match start_result { Ok(server) => Ok(Some(server)), - Err(rpc::ws::Error::Io(ref err)) if err.kind() == io::ErrorKind::AddrInUse => Err( + Err(rpc::ws::Error(rpc::ws::ErrorKind::Io(ref err), _)) if err.kind() == io::ErrorKind::AddrInUse => Err( format!("WebSockets address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ws-port and --ws-interface options.", url) ), Err(e) => Err(format!("WebSockets error: {:?}", e)), @@ -286,7 +286,7 @@ pub fn new_http( match start_result { Ok(server) => Ok(Some(server)), - Err(rpc::HttpServerError::Io(ref err)) if err.kind() == io::ErrorKind::AddrInUse => Err( + Err(ref err) if err.kind() == io::ErrorKind::AddrInUse => Err( format!("{} address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --{}-port and --{}-interface options.", id, url, options, options) ), Err(e) => Err(format!("{} error: {:?}", id, e)), diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index ab0b9082d..3d782d419 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -117,26 +117,6 @@ use http::tokio_core; /// RPC HTTP Server instance pub type HttpServer = http::Server; - -/// RPC HTTP Server error -#[derive(Debug)] -pub enum HttpServerError { - /// IO error - Io(::std::io::Error), - /// Other hyper error - Hyper(hyper::Error), -} - -impl From for HttpServerError { - fn from(e: http::Error) -> Self { - use self::HttpServerError::*; - match e { - http::Error::Io(io) => Io(io), - http::Error::Other(hyper) => Hyper(hyper), - } - } -} - /// Start http server asynchronously and returns result with `Server` handle on success or an error. pub fn start_http( addr: &SocketAddr, @@ -147,7 +127,7 @@ pub fn start_http( extractor: T, middleware: Option, threads: usize, -) -> Result where +) -> ::std::io::Result where M: jsonrpc_core::Metadata, S: jsonrpc_core::Middleware, H: Into>, diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index c556226b5..52d8e3aa6 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -42,7 +42,7 @@ use ethcore::transaction::{Action, SignedTransaction, PendingTransaction, Transa use ethcore::account_provider::AccountProvider; use crypto::DEFAULT_MAC; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{future, Future, Poll, Async}; use jsonrpc_core::futures::future::Either; use v1::helpers::{errors, nonce, TransactionRequest, FilledTransactionRequest, ConfirmationPayload}; @@ -67,18 +67,18 @@ pub trait Dispatcher: Send + Sync + Clone { /// Fill optional fields of a transaction request, fetching gas price but not nonce. fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture; + -> BoxFuture; /// Sign the given transaction request without dispatching, fetching appropriate nonce. fn sign(&self, accounts: Arc, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error>; + -> BoxFuture>; /// Converts a `SignedTransaction` into `RichRawTransaction` fn enrich(&self, SignedTransaction) -> RpcRichRawTransaction; /// "Dispatch" a local transaction. fn dispatch_transaction(&self, signed_transaction: PendingTransaction) - -> Result; + -> Result; } /// A dispatcher which uses references to a client and miner in order to sign @@ -118,7 +118,7 @@ impl FullDispatcher { } /// Imports transaction to the miner's queue. - pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result { + pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result { let hash = signed_transaction.transaction.hash(); miner.import_own_transaction(client, signed_transaction) @@ -129,7 +129,7 @@ impl FullDispatcher { impl Dispatcher for FullDispatcher { fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture + -> BoxFuture { let request = request; let from = request.from.unwrap_or(default_sender); @@ -153,7 +153,7 @@ impl Dispatcher for FullDispatcher, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error> + -> BoxFuture> { let chain_id = self.client.signing_chain_id(); @@ -171,7 +171,7 @@ impl Dispatcher for FullDispatcher Result { + fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { Self::dispatch_transaction(&*self.client, &*self.miner, signed_transaction) } } @@ -183,7 +183,7 @@ pub fn fetch_gas_price_corpus( client: Arc, on_demand: Arc, cache: Arc>, -) -> BoxFuture, Error> { +) -> BoxFuture> { const GAS_PRICE_SAMPLE_SIZE: usize = 100; if let Some(cached) = { cache.lock().gas_price_corpus() } { @@ -279,7 +279,7 @@ impl LightDispatcher { /// Get a recent gas price corpus. // TODO: this could be `impl Trait`. - pub fn gas_price_corpus(&self) -> BoxFuture, Error> { + pub fn gas_price_corpus(&self) -> BoxFuture> { fetch_gas_price_corpus( self.sync.clone(), self.client.clone(), @@ -289,7 +289,7 @@ impl LightDispatcher { } /// Get an account's next nonce. - pub fn next_nonce(&self, addr: Address) -> BoxFuture { + pub fn next_nonce(&self, addr: Address) -> BoxFuture { // fast path where we don't go to network; nonce provided or can be gotten from queue. let maybe_nonce = self.transaction_queue.read().next_nonce(&addr); if let Some(nonce) = maybe_nonce { @@ -315,7 +315,7 @@ impl LightDispatcher { impl Dispatcher for LightDispatcher { fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture + -> BoxFuture { const DEFAULT_GAS_PRICE: U256 = U256([0, 0, 0, 21_000_000]); @@ -369,7 +369,7 @@ impl Dispatcher for LightDispatcher { } fn sign(&self, accounts: Arc, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error> + -> BoxFuture> { let chain_id = self.client.signing_chain_id(); @@ -392,7 +392,7 @@ impl Dispatcher for LightDispatcher { RpcRichRawTransaction::from_signed(signed_transaction, block_number, self.client.eip86_transition()) } - fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { + fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { let hash = signed_transaction.transaction.hash(); self.transaction_queue.write().import(signed_transaction) @@ -408,7 +408,7 @@ fn sign_transaction( chain_id: Option, nonce: U256, password: SignWith, -) -> Result, Error> { +) -> Result> { let t = Transaction { nonce: nonce, action: filled.to.map_or(Action::Create, Action::Call), @@ -445,7 +445,7 @@ struct ProspectiveSigner { reserved: nonce::Reserved, password: SignWith, state: ProspectiveSignerState, - prospective: Option, Error>>, + prospective: Option>>, ready: Option, } @@ -479,7 +479,7 @@ impl ProspectiveSigner { } } - fn sign(&self, nonce: &U256) -> Result, Error> { + fn sign(&self, nonce: &U256) -> Result> { sign_transaction( &*self.accounts, self.filled.clone(), @@ -637,7 +637,7 @@ pub fn execute( accounts: Arc, payload: ConfirmationPayload, pass: SignWith -) -> BoxFuture, Error> { +) -> BoxFuture> { match payload { ConfirmationPayload::SendTransaction(request) => { let condition = request.condition.clone().map(Into::into); @@ -688,7 +688,7 @@ pub fn execute( } } -fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result, Error> { +fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result> { match password.clone() { SignWith::Nothing => accounts.sign(address, None, hash).map(WithToken::No), SignWith::Password(pass) => accounts.sign(address, Some(pass), hash).map(WithToken::No), @@ -701,7 +701,7 @@ fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: // obtain a hardware signature from the given account. fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transaction, chain_id: Option) - -> Result + -> Result { debug_assert!(accounts.is_hardware_address(&address)); @@ -720,7 +720,7 @@ fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transacti }) } -fn decrypt(accounts: &AccountProvider, address: Address, msg: Bytes, password: SignWith) -> Result, Error> { +fn decrypt(accounts: &AccountProvider, address: Address, msg: Bytes, password: SignWith) -> Result> { match password.clone() { SignWith::Nothing => accounts.decrypt(address, None, &DEFAULT_MAC, &msg).map(WithToken::No), SignWith::Password(pass) => accounts.decrypt(address, Some(pass), &DEFAULT_MAC, &msg).map(WithToken::No), @@ -741,7 +741,7 @@ pub fn default_gas_price(client: &C, miner: &M) -> U256 where /// Convert RPC confirmation payload to signer confirmation payload. /// May need to resolve in the future to fetch things like gas price. -pub fn from_rpc(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture +pub fn from_rpc(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture where D: Dispatcher { match payload { diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 2544f66b0..64f075b01 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -26,7 +26,7 @@ use ethcore::filter::Filter as EthcoreFilter; use ethcore::transaction::{Action, Transaction as EthTransaction, SignedTransaction, LocalizedTransaction}; use ethcore::receipt::Receipt; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use jsonrpc_macros::Trailing; @@ -87,7 +87,7 @@ pub fn extract_transaction_at_index(block: encoded::Block, index: usize, eip86_t /// Type alias for convenience. -pub type ExecutionResult = Result; +pub type ExecutionResult = ::std::result::Result; // extract the header indicated by the given `HeaderRef` from the given responses. // fails only if they do not correspond. @@ -104,7 +104,7 @@ fn extract_header(res: &[OnDemandResponse], header: HeaderRef) -> Option) -> Result { + fn make_header_requests(&self, id: BlockId, reqs: &mut Vec) -> Result { if let Some(h) = self.client.block_header(id) { return Ok(h.into()); } @@ -138,7 +138,7 @@ impl LightFetch { } /// Get a block header from the on demand service or client, or error. - pub fn header(&self, id: BlockId) -> BoxFuture { + pub fn header(&self, id: BlockId) -> BoxFuture { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -162,7 +162,7 @@ impl LightFetch { /// Helper for getting account info at a given block. /// `None` indicates the account doesn't exist at the given block. - pub fn account(&self, address: Address, id: BlockId) -> BoxFuture, Error> { + pub fn account(&self, address: Address, id: BlockId) -> BoxFuture> { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -188,7 +188,7 @@ impl LightFetch { } /// Helper for getting proved execution. - pub fn proved_execution(&self, req: CallRequest, num: Trailing) -> BoxFuture { + pub fn proved_execution(&self, req: CallRequest, num: Trailing) -> BoxFuture { const DEFAULT_GAS_PRICE: u64 = 21_000; // starting gas when gas not provided. const START_GAS: u64 = 50_000; @@ -265,7 +265,7 @@ impl LightFetch { } /// Get a block itself. Fails on unknown block ID. - pub fn block(&self, id: BlockId) -> BoxFuture { + pub fn block(&self, id: BlockId) -> BoxFuture { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -291,7 +291,7 @@ impl LightFetch { } /// Get the block receipts. Fails on unknown block ID. - pub fn receipts(&self, id: BlockId) -> BoxFuture, Error> { + pub fn receipts(&self, id: BlockId) -> BoxFuture> { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -317,7 +317,7 @@ impl LightFetch { } /// Get transaction logs - pub fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + pub fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { use std::collections::BTreeMap; use jsonrpc_core::futures::stream::{self, Stream}; @@ -375,7 +375,7 @@ impl LightFetch { // Get a transaction by hash. also returns the index in the block. // Only returns transactions in the canonical chain. pub fn transaction_by_hash(&self, tx_hash: H256, eip86_transition: u64) - -> BoxFuture, Error> + -> BoxFuture> { let params = (self.sync.clone(), self.on_demand.clone()); let fetcher: Self = self.clone(); @@ -445,7 +445,7 @@ struct ExecuteParams { // has a peer execute the transaction with given params. If `gas_known` is false, // this will double the gas on each `OutOfGas` error. -fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture { +fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture { if !gas_known { Box::new(future::loop_fn(params, |mut params| { execute_tx(true, params.clone()).and_then(move |res| { diff --git a/rpc/src/v1/helpers/subscription_manager.rs b/rpc/src/v1/helpers/subscription_manager.rs index a6d6f9d51..5988824b6 100644 --- a/rpc/src/v1/helpers/subscription_manager.rs +++ b/rpc/src/v1/helpers/subscription_manager.rs @@ -23,7 +23,7 @@ use parking_lot::Mutex; use jsonrpc_core::futures::future::{self, Either}; use jsonrpc_core::futures::sync::mpsc; use jsonrpc_core::futures::{Sink, Future}; -use jsonrpc_core::{self as core, MetaIoHandler, BoxFuture}; +use jsonrpc_core::{self as core, MetaIoHandler}; use jsonrpc_pubsub::SubscriptionId; use v1::helpers::Subscribers; @@ -87,7 +87,7 @@ impl> GenericPollManager { }).is_some() } - pub fn tick(&self) -> BoxFuture<(), ()> { + pub fn tick(&self) -> Box + Send> { let mut futures = Vec::new(); // poll all subscriptions for (id, subscription) in self.subscribers.iter() { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 8de7a31db..f9b684a31 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -40,7 +40,7 @@ use ethcore::transaction::SignedTransaction; use ethcore::snapshot::SnapshotService; use ethsync::{SyncProvider}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::future; use jsonrpc_macros::Trailing; @@ -139,11 +139,11 @@ impl EthClient where /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn block(&self, id: BlockId, include_txs: bool) -> Result, Error> { + fn block(&self, id: BlockId, include_txs: bool) -> Result> { let client = &self.client; match (client.block(id.clone()), client.block_total_difficulty(id)) { (Some(block), Some(total_difficulty)) => { @@ -181,14 +181,14 @@ impl EthClient where } } - fn transaction(&self, id: TransactionId) -> Result, Error> { + fn transaction(&self, id: TransactionId) -> Result> { match self.client.transaction(id) { Some(t) => Ok(Some(Transaction::from_localized(t, self.eip86_transition))), None => Ok(None), } } - fn uncle(&self, id: UncleId) -> Result, Error> { + fn uncle(&self, id: UncleId) -> Result> { let client = &self.client; let uncle: BlockHeader = match client.uncle(id) { Some(hdr) => hdr.decode(), @@ -232,7 +232,7 @@ impl EthClient where Ok(Some(block)) } - fn dapp_accounts(&self, dapp: DappId) -> Result, Error> { + fn dapp_accounts(&self, dapp: DappId) -> Result> { let store = self.account_provider()?; store .note_dapp_used(dapp.clone()) @@ -260,7 +260,7 @@ pub fn pending_logs(miner: &M, best_block: EthBlockNumber, filter: &EthcoreFi result } -fn check_known(client: &C, number: BlockNumber) -> Result<(), Error> where C: MiningBlockChainClient { +fn check_known(client: &C, number: BlockNumber) -> Result<()> where C: MiningBlockChainClient { use ethcore::block_status::BlockStatus; match client.block_status(number.into()) { @@ -281,12 +281,12 @@ impl Eth for EthClient where { type Metadata = Metadata; - fn protocol_version(&self) -> Result { + fn protocol_version(&self) -> Result { let version = self.sync.status().protocol_version.to_owned(); Ok(format!("{}", version)) } - fn syncing(&self) -> Result { + fn syncing(&self) -> Result { use ethcore::snapshot::RestorationStatus; let status = self.sync.status(); @@ -318,7 +318,7 @@ impl Eth for EthClient where } } - fn author(&self, meta: Metadata) -> Result { + fn author(&self, meta: Metadata) -> Result { let dapp = meta.dapp_id(); let mut miner = self.miner.author(); @@ -329,30 +329,30 @@ impl Eth for EthClient where Ok(RpcH160::from(miner)) } - fn is_mining(&self) -> Result { + fn is_mining(&self) -> Result { Ok(self.miner.is_currently_sealing()) } - fn hashrate(&self) -> Result { + fn hashrate(&self) -> Result { Ok(RpcU256::from(self.external_miner.hashrate())) } - fn gas_price(&self) -> Result { + fn gas_price(&self) -> Result { Ok(RpcU256::from(default_gas_price(&*self.client, &*self.miner))) } - fn accounts(&self, meta: Metadata) -> Result, Error> { + fn accounts(&self, meta: Metadata) -> Result> { let dapp = meta.dapp_id(); let accounts = self.dapp_accounts(dapp.into())?; Ok(accounts.into_iter().map(Into::into).collect()) } - fn block_number(&self) -> Result { + fn block_number(&self) -> Result { Ok(RpcU256::from(self.client.chain_info().best_block_number)) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address = address.into(); let id = num.unwrap_or_default(); @@ -366,7 +366,7 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { + fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); @@ -381,7 +381,7 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let res = match num.unwrap_or_default() { @@ -406,12 +406,12 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { Box::new(future::ok(self.client.block(BlockId::Hash(hash.into())) .map(|block| block.transactions_count().into()))) } - fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture> { Box::new(future::ok(match num { BlockNumber::Pending => Some( self.miner.status().transactions_in_pending_block.into() @@ -422,12 +422,12 @@ impl Eth for EthClient where })) } - fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { Box::new(future::ok(self.client.block(BlockId::Hash(hash.into())) .map(|block| block.uncles_count().into()))) } - fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture> { Box::new(future::ok(match num { BlockNumber::Pending => Some(0.into()), _ => self.client.block(num.into()) @@ -436,7 +436,7 @@ impl Eth for EthClient where })) } - fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let id = num.unwrap_or_default(); @@ -450,15 +450,15 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture, Error> { + fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture> { Box::new(future::done(self.block(BlockId::Hash(hash.into()), include_txs))) } - fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture, Error> { + fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture> { Box::new(future::done(self.block(num.into(), include_txs))) } - fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture> { let hash: H256 = hash.into(); let block_number = self.client.chain_info().best_block_number; let tx = try_bf!(self.transaction(TransactionId::Hash(hash))).or_else(|| { @@ -469,19 +469,19 @@ impl Eth for EthClient where Box::new(future::ok(tx)) } - fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture, Error> { + fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture> { Box::new(future::done( self.transaction(TransactionId::Location(BlockId::Hash(hash.into()), index.value())) )) } - fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture, Error> { + fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture> { Box::new(future::done( self.transaction(TransactionId::Location(num.into(), index.value())) )) } - fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture> { let best_block = self.client.chain_info().best_block_number; let hash: H256 = hash.into(); @@ -494,25 +494,25 @@ impl Eth for EthClient where } } - fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture, Error> { + fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture> { Box::new(future::done(self.uncle(UncleId { block: BlockId::Hash(hash.into()), position: index.value() }))) } - fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture, Error> { + fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture> { Box::new(future::done(self.uncle(UncleId { block: num.into(), position: index.value() }))) } - fn compilers(&self) -> Result, Error> { + fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } - fn logs(&self, filter: Filter) -> BoxFuture, Error> { + fn logs(&self, filter: Filter) -> BoxFuture> { let include_pending = filter.to_block == Some(BlockNumber::Pending); let filter: EthcoreFilter = filter.into(); let mut logs = self.client.logs(filter.clone()) @@ -531,7 +531,7 @@ impl Eth for EthClient where Box::new(future::ok(logs)) } - fn work(&self, no_new_work_timeout: Trailing) -> Result { + fn work(&self, no_new_work_timeout: Trailing) -> Result { if !self.miner.can_produce_work_package() { warn!(target: "miner", "Cannot give work package - engine seals internally."); return Err(errors::no_work_required()) @@ -585,7 +585,7 @@ impl Eth for EthClient where }).unwrap_or(Err(errors::internal("No work found.", ""))) } - fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result { + fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result { if !self.miner.can_produce_work_package() { warn!(target: "miner", "Cannot submit work - engine seals internally."); return Err(errors::no_work_required()) @@ -600,12 +600,12 @@ impl Eth for EthClient where Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok()) } - fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result { + fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result { self.external_miner.submit_hashrate(rate.into(), id.into()); Ok(true) } - fn send_raw_transaction(&self, raw: Bytes) -> Result { + fn send_raw_transaction(&self, raw: Bytes) -> Result { UntrustedRlp::new(&raw.into_vec()).as_val() .map_err(errors::rlp) .and_then(|tx| SignedTransaction::new(tx).map_err(errors::transaction)) @@ -619,11 +619,11 @@ impl Eth for EthClient where .map(Into::into) } - fn submit_transaction(&self, raw: Bytes) -> Result { + fn submit_transaction(&self, raw: Bytes) -> Result { self.send_raw_transaction(raw) } - fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request, meta.is_dapp())); @@ -636,7 +636,7 @@ impl Eth for EthClient where )) } - fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request, meta.is_dapp())); Box::new(future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into()) @@ -645,15 +645,15 @@ impl Eth for EthClient where )) } - fn compile_lll(&self, _: String) -> Result { + fn compile_lll(&self, _: String) -> Result { Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string())) } - fn compile_serpent(&self, _: String) -> Result { + fn compile_serpent(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string())) } - fn compile_solidity(&self, _: String) -> Result { + fn compile_solidity(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string())) } } diff --git a/rpc/src/v1/impls/eth_filter.rs b/rpc/src/v1/impls/eth_filter.rs index a7a4a3ed2..f90a969da 100644 --- a/rpc/src/v1/impls/eth_filter.rs +++ b/rpc/src/v1/impls/eth_filter.rs @@ -25,7 +25,7 @@ use ethcore::client::{BlockChainClient, BlockId}; use bigint::hash::H256; use parking_lot::Mutex; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use v1::traits::EthFilter; @@ -45,7 +45,7 @@ pub trait Filterable { fn pending_transactions_hashes(&self, block_number: u64) -> Vec; /// Get logs that match the given filter. - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error>; + fn logs(&self, filter: EthcoreFilter) -> BoxFuture>; /// Get logs from the pending block. fn pending_logs(&self, block_number: u64, filter: &EthcoreFilter) -> Vec; @@ -88,7 +88,7 @@ impl Filterable for EthFilterClient where C: BlockChainClient, M: Mi self.miner.pending_transactions_hashes(best) } - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { Box::new(future::ok(self.client.logs(filter).into_iter().map(Into::into).collect())) } @@ -102,20 +102,20 @@ impl Filterable for EthFilterClient where C: BlockChainClient, M: Mi impl EthFilter for T { - fn new_filter(&self, filter: Filter) -> Result { + fn new_filter(&self, filter: Filter) -> Result { let mut polls = self.polls().lock(); let block_number = self.best_block_number(); let id = polls.create_poll(PollFilter::Logs(block_number, Default::default(), filter)); Ok(id.into()) } - fn new_block_filter(&self) -> Result { + fn new_block_filter(&self) -> Result { let mut polls = self.polls().lock(); let id = polls.create_poll(PollFilter::Block(self.best_block_number())); Ok(id.into()) } - fn new_pending_transaction_filter(&self) -> Result { + fn new_pending_transaction_filter(&self) -> Result { let mut polls = self.polls().lock(); let best_block = self.best_block_number(); let pending_transactions = self.pending_transactions_hashes(best_block); @@ -123,7 +123,7 @@ impl EthFilter for T { Ok(id.into()) } - fn filter_changes(&self, index: Index) -> BoxFuture { + fn filter_changes(&self, index: Index) -> BoxFuture { let mut polls = self.polls().lock(); Box::new(match polls.poll_mut(&index.value()) { None => Either::A(future::ok(FilterChanges::Empty)), @@ -209,7 +209,7 @@ impl EthFilter for T { }) } - fn filter_logs(&self, index: Index) -> BoxFuture, Error> { + fn filter_logs(&self, index: Index) -> BoxFuture> { let filter = { let mut polls = self.polls().lock(); @@ -240,7 +240,7 @@ impl EthFilter for T { ) } - fn uninstall_filter(&self, index: Index) -> Result { + fn uninstall_filter(&self, index: Index) -> Result { self.polls().lock().remove_poll(&index.value()); Ok(true) } diff --git a/rpc/src/v1/impls/eth_pubsub.rs b/rpc/src/v1/impls/eth_pubsub.rs index 74b37d7d0..cc6e0d260 100644 --- a/rpc/src/v1/impls/eth_pubsub.rs +++ b/rpc/src/v1/impls/eth_pubsub.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use std::collections::BTreeMap; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{self, Future, IntoFuture}; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::{Sink, Subscriber}; @@ -170,7 +170,7 @@ pub trait LightClient: Send + Sync { fn block_header(&self, id: BlockId) -> Option; /// Fetch logs. - fn logs(&self, filter: EthFilter) -> BoxFuture, Error>; + fn logs(&self, filter: EthFilter) -> BoxFuture>; } impl LightClient for LightFetch { @@ -178,7 +178,7 @@ impl LightClient for LightFetch { self.client.block_header(id) } - fn logs(&self, filter: EthFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthFilter) -> BoxFuture> { LightFetch::logs(self, filter) } } @@ -272,7 +272,7 @@ impl EthPubSub for EthPubSubClient { let _ = subscriber.reject(error); } - fn unsubscribe(&self, id: SubscriptionId) -> Result { + fn unsubscribe(&self, id: SubscriptionId) -> Result { let res = self.heads_subscribers.write().remove(&id).is_some(); let res2 = self.logs_subscribers.write().remove(&id).is_some(); diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index d498c6ccd..768fd4705 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -18,7 +18,7 @@ use std::sync::Arc; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use jsonrpc_macros::Trailing; @@ -112,7 +112,7 @@ impl EthClient { } // get a "rich" block structure. Fails on unknown block. - fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture { + fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture { let (on_demand, sync) = (self.on_demand.clone(), self.sync.clone()); let (client, engine) = (self.client.clone(), self.client.engine().clone()); let eip86_transition = self.client.eip86_transition(); @@ -202,11 +202,11 @@ impl EthClient { impl Eth for EthClient { type Metadata = Metadata; - fn protocol_version(&self) -> Result { + fn protocol_version(&self) -> Result { Ok(format!("{}", ::light::net::MAX_PROTOCOL_VERSION)) } - fn syncing(&self) -> Result { + fn syncing(&self) -> Result { if self.sync.is_major_importing() { let chain_info = self.client.chain_info(); let current_block = U256::from(chain_info.best_block_number); @@ -225,26 +225,26 @@ impl Eth for EthClient { } } - fn author(&self, _meta: Self::Metadata) -> Result { + fn author(&self, _meta: Self::Metadata) -> Result { Ok(Default::default()) } - fn is_mining(&self) -> Result { + fn is_mining(&self) -> Result { Ok(false) } - fn hashrate(&self) -> Result { + fn hashrate(&self) -> Result { Ok(Default::default()) } - fn gas_price(&self) -> Result { + fn gas_price(&self) -> Result { Ok(self.cache.lock().gas_price_corpus() .and_then(|c| c.median().cloned()) .map(RpcU256::from) .unwrap_or_else(Default::default)) } - fn accounts(&self, meta: Metadata) -> Result, Error> { + fn accounts(&self, meta: Metadata) -> Result> { let dapp: DappId = meta.dapp_id().into(); self.accounts @@ -254,33 +254,33 @@ impl Eth for EthClient { .map(|accs| accs.into_iter().map(Into::::into).collect()) } - fn block_number(&self) -> Result { + fn block_number(&self) -> Result { Ok(self.client.chain_info().best_block_number.into()) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.balance).into())) } - fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing) -> BoxFuture { + fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } - fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture, Error> { + fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture> { Box::new(self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some)) } - fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture, Error> { + fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture> { Box::new(self.rich_block(num.into(), include_txs).map(Some)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.nonce).into())) } - fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| { @@ -296,7 +296,7 @@ impl Eth for EthClient { })) } - fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(num.into()).and_then(move |hdr| { @@ -312,7 +312,7 @@ impl Eth for EthClient { })) } - fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| { @@ -328,7 +328,7 @@ impl Eth for EthClient { })) } - fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(num.into()).and_then(move |hdr| { @@ -344,11 +344,11 @@ impl Eth for EthClient { })) } - fn code_at(&self, _address: RpcH160, _num: Trailing) -> BoxFuture { + fn code_at(&self, _address: RpcH160, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } - fn send_raw_transaction(&self, raw: Bytes) -> Result { + fn send_raw_transaction(&self, raw: Bytes) -> Result { let best_header = self.client.best_block_header().decode(); UntrustedRlp::new(&raw.into_vec()).as_val() @@ -368,11 +368,11 @@ impl Eth for EthClient { .map(Into::into) } - fn submit_transaction(&self, raw: Bytes) -> Result { + fn submit_transaction(&self, raw: Bytes) -> Result { self.send_raw_transaction(raw) } - fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { Box::new(self.fetcher().proved_execution(req, num).and_then(|res| { match res { Ok(exec) => Ok(exec.output.into()), @@ -381,7 +381,7 @@ impl Eth for EthClient { })) } - fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { // TODO: binary chop for more accurate estimates. Box::new(self.fetcher().proved_execution(req, num).and_then(|res| { match res { @@ -391,7 +391,7 @@ impl Eth for EthClient { })) } - fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture> { let hash = hash.into(); let eip86 = self.client.eip86_transition(); @@ -409,21 +409,21 @@ impl Eth for EthClient { Box::new(self.fetcher().transaction_by_hash(hash, eip86).map(|x| x.map(|(tx, _)| tx))) } - fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture, Error> { + fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture> { let eip86 = self.client.eip86_transition(); Box::new(self.fetcher().block(BlockId::Hash(hash.into())).map(move |block| { light_fetch::extract_transaction_at_index(block, idx.value(), eip86) })) } - fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture, Error> { + fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture> { let eip86 = self.client.eip86_transition(); Box::new(self.fetcher().block(num.into()).map(move |block| { light_fetch::extract_transaction_at_index(block, idx.value(), eip86) })) } - fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture> { let eip86 = self.client.eip86_transition(); let fetcher = self.fetcher(); Box::new(fetcher.transaction_by_hash(hash.clone().into(), eip86).and_then(move |tx| { @@ -454,52 +454,52 @@ impl Eth for EthClient { })) } - fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture, Error> { + fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture> { let client = self.client.clone(); Box::new(self.fetcher().block(BlockId::Hash(hash.into())).map(move |block| { extract_uncle_at_index(block, idx, client) })) } - fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture, Error> { + fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture> { let client = self.client.clone(); Box::new(self.fetcher().block(num.into()).map(move |block| { extract_uncle_at_index(block, idx, client) })) } - fn compilers(&self) -> Result, Error> { + fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } - fn compile_lll(&self, _: String) -> Result { + fn compile_lll(&self, _: String) -> Result { Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string())) } - fn compile_serpent(&self, _: String) -> Result { + fn compile_serpent(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string())) } - fn compile_solidity(&self, _: String) -> Result { + fn compile_solidity(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string())) } - fn logs(&self, filter: Filter) -> BoxFuture, Error> { + fn logs(&self, filter: Filter) -> BoxFuture> { let limit = filter.limit; Box::new(Filterable::logs(self, filter.into()) .map(move|logs| limit_logs(logs, limit))) } - fn work(&self, _timeout: Trailing) -> Result { + fn work(&self, _timeout: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result { + fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result { Err(errors::light_unimplemented(None)) } - fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result { + fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result { Err(errors::light_unimplemented(None)) } } @@ -516,7 +516,7 @@ impl Filterable for EthClient { Vec::new() } - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { self.fetcher().logs(filter) } diff --git a/rpc/src/v1/impls/light/net.rs b/rpc/src/v1/impls/light/net.rs index 4f0ede48f..3491b35ba 100644 --- a/rpc/src/v1/impls/light/net.rs +++ b/rpc/src/v1/impls/light/net.rs @@ -16,7 +16,7 @@ //! Net rpc implementation. use std::sync::Arc; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethsync::LightSyncProvider; use v1::traits::Net; @@ -35,15 +35,15 @@ impl NetClient where S: LightSyncProvider { } impl Net for NetClient where S: LightSyncProvider { - fn version(&self) -> Result { + fn version(&self) -> Result { Ok(format!("{}", self.sync.network_id()).to_owned()) } - fn peer_count(&self) -> Result { + fn peer_count(&self) -> Result { Ok(format!("0x{:x}", self.sync.peer_numbers().connected as u64).to_owned()) } - fn is_listening(&self) -> Result { + fn is_listening(&self) -> Result { Ok(true) } } diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index a896a5f4d..6987f8082 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -30,7 +30,7 @@ use node_health::{NodeHealth, Health}; use light::client::LightChainClient; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::Future; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, ipfs, SigningQueue, SignerService, NetworkSettings}; @@ -103,7 +103,7 @@ impl ParityClient { impl Parity for ParityClient { type Metadata = Metadata; - fn accounts_info(&self, dapp: Trailing) -> Result, Error> { + fn accounts_info(&self, dapp: Trailing) -> Result> { let dapp = dapp.unwrap_or_default(); let store = &self.accounts; @@ -125,7 +125,7 @@ impl Parity for ParityClient { ) } - fn hardware_accounts_info(&self) -> Result, Error> { + fn hardware_accounts_info(&self) -> Result> { let store = &self.accounts; let info = store.hardware_accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; Ok(info @@ -135,12 +135,12 @@ impl Parity for ParityClient { ) } - fn locked_hardware_accounts_info(&self) -> Result, Error> { + fn locked_hardware_accounts_info(&self) -> Result> { let store = &self.accounts; Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } - fn default_account(&self, meta: Self::Metadata) -> Result { + fn default_account(&self, meta: Self::Metadata) -> Result { let dapp_id = meta.dapp_id(); Ok(self.accounts .dapp_addresses(dapp_id.into()) @@ -150,40 +150,40 @@ impl Parity for ParityClient { .unwrap_or_default()) } - fn transactions_limit(&self) -> Result { + fn transactions_limit(&self) -> Result { Ok(usize::max_value()) } - fn min_gas_price(&self) -> Result { + fn min_gas_price(&self) -> Result { Ok(U256::default()) } - fn extra_data(&self) -> Result { + fn extra_data(&self) -> Result { Ok(Bytes::default()) } - fn gas_floor_target(&self) -> Result { + fn gas_floor_target(&self) -> Result { Ok(U256::default()) } - fn gas_ceil_target(&self) -> Result { + fn gas_ceil_target(&self) -> Result { Ok(U256::default()) } - fn dev_logs(&self) -> Result, Error> { + fn dev_logs(&self) -> Result> { let logs = self.logger.logs(); Ok(logs.as_slice().to_owned()) } - fn dev_logs_levels(&self) -> Result { + fn dev_logs_levels(&self) -> Result { Ok(self.logger.levels().to_owned()) } - fn net_chain(&self) -> Result { + fn net_chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn net_peers(&self) -> Result { + fn net_peers(&self) -> Result { let peers = self.light_dispatch.sync.peers().into_iter().map(Into::into).collect(); let peer_numbers = self.light_dispatch.sync.peer_numbers(); @@ -195,19 +195,19 @@ impl Parity for ParityClient { }) } - fn net_port(&self) -> Result { + fn net_port(&self) -> Result { Ok(self.settings.network_port) } - fn node_name(&self) -> Result { + fn node_name(&self) -> Result { Ok(self.settings.name.clone()) } - fn registry_address(&self) -> Result, Error> { + fn registry_address(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn rpc_settings(&self) -> Result { + fn rpc_settings(&self) -> Result { Ok(RpcSettings { enabled: self.settings.rpc_enabled, interface: self.settings.rpc_interface.clone(), @@ -215,46 +215,46 @@ impl Parity for ParityClient { }) } - fn default_extra_data(&self) -> Result { + fn default_extra_data(&self) -> Result { Ok(Bytes::new(version_data())) } - fn gas_price_histogram(&self) -> BoxFuture { + fn gas_price_histogram(&self) -> BoxFuture { Box::new(self.light_dispatch.gas_price_corpus() .and_then(|corpus| corpus.histogram(10).ok_or_else(errors::not_enough_data)) .map(Into::into)) } - fn unsigned_transactions_count(&self) -> Result { + fn unsigned_transactions_count(&self) -> Result { match self.signer { None => Err(errors::signer_disabled()), Some(ref signer) => Ok(signer.len()), } } - fn generate_secret_phrase(&self) -> Result { + fn generate_secret_phrase(&self) -> Result { Ok(random_phrase(12)) } - fn phrase_to_address(&self, phrase: String) -> Result { + fn phrase_to_address(&self, phrase: String) -> Result { Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, _: u64, _: Option, _: Trailing) -> Result>, Error> { + fn list_accounts(&self, _: u64, _: Option, _: Trailing) -> Result>> { Err(errors::light_unimplemented(None)) } - fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Trailing) -> Result>, Error> { + fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Trailing) -> Result>> { Err(errors::light_unimplemented(None)) } - fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { + fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0) .map_err(errors::encryption) .map(Into::into) } - fn pending_transactions(&self) -> Result, Error> { + fn pending_transactions(&self) -> Result> { let txq = self.light_dispatch.transaction_queue.read(); let chain_info = self.light_dispatch.client.chain_info(); Ok( @@ -265,7 +265,7 @@ impl Parity for ParityClient { ) } - fn future_transactions(&self) -> Result, Error> { + fn future_transactions(&self) -> Result> { let txq = self.light_dispatch.transaction_queue.read(); let chain_info = self.light_dispatch.client.chain_info(); Ok( @@ -276,7 +276,7 @@ impl Parity for ParityClient { ) } - fn pending_transactions_stats(&self) -> Result, Error> { + fn pending_transactions_stats(&self) -> Result> { let stats = self.light_dispatch.sync.transactions_stats(); Ok(stats.into_iter() .map(|(hash, stats)| (hash.into(), stats.into())) @@ -284,7 +284,7 @@ impl Parity for ParityClient { ) } - fn local_transactions(&self) -> Result, Error> { + fn local_transactions(&self) -> Result> { let mut map = BTreeMap::new(); let chain_info = self.light_dispatch.client.chain_info(); let (best_num, best_tm) = (chain_info.best_block_number, chain_info.best_block_timestamp); @@ -303,49 +303,49 @@ impl Parity for ParityClient { Ok(map) } - fn dapps_url(&self) -> Result { + fn dapps_url(&self) -> Result { helpers::to_url(&self.dapps_address) .ok_or_else(|| errors::dapps_disabled()) } - fn ws_url(&self) -> Result { + fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) } - fn next_nonce(&self, address: H160) -> BoxFuture { + fn next_nonce(&self, address: H160) -> BoxFuture { Box::new(self.light_dispatch.next_nonce(address.into()).map(Into::into)) } - fn mode(&self) -> Result { + fn mode(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn chain_id(&self) -> Result, Error> { + fn chain_id(&self) -> Result> { Ok(self.client.signing_chain_id().map(U64::from)) } - fn chain(&self) -> Result { + fn chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn enode(&self) -> Result { + fn enode(&self) -> Result { self.light_dispatch.sync.enode().ok_or_else(errors::network_disabled) } - fn consensus_capability(&self) -> Result { + fn consensus_capability(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn version_info(&self) -> Result { + fn version_info(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn releases_info(&self) -> Result, Error> { + fn releases_info(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn chain_status(&self) -> Result { + fn chain_status(&self) -> Result { let chain_info = self.light_dispatch.client.chain_info(); let gap = chain_info.ancient_block_number.map(|x| U256::from(x + 1)) @@ -356,7 +356,7 @@ impl Parity for ParityClient { }) } - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error> { + fn node_kind(&self) -> Result<::v1::types::NodeKind> { use ::v1::types::{NodeKind, Availability, Capability}; Ok(NodeKind { @@ -365,7 +365,7 @@ impl Parity for ParityClient { }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Trailing) -> BoxFuture { use ethcore::encoded; let engine = self.light_dispatch.client.engine().clone(); @@ -399,15 +399,15 @@ impl Parity for ParityClient { Box::new(self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded)) } - fn ipfs_cid(&self, content: Bytes) -> Result { + fn ipfs_cid(&self, content: Bytes) -> Result { ipfs::cid(content) } - fn call(&self, _meta: Self::Metadata, _requests: Vec, _block: Trailing) -> Result, Error> { + fn call(&self, _meta: Self::Metadata, _requests: Vec, _block: Trailing) -> Result> { Err(errors::light_unimplemented(None)) } - fn node_health(&self) -> BoxFuture { + fn node_health(&self) -> BoxFuture { Box::new(self.health.health() .map_err(|err| errors::internal("Health API failure.", err))) } diff --git a/rpc/src/v1/impls/light/parity_set.rs b/rpc/src/v1/impls/light/parity_set.rs index 2887f2836..6b8f0dc4d 100644 --- a/rpc/src/v1/impls/light/parity_set.rs +++ b/rpc/src/v1/impls/light/parity_set.rs @@ -24,7 +24,7 @@ use ethsync::ManageNetwork; use fetch::Fetch; use hash::keccak_buffer; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::Future; use v1::helpers::dapps::DappsService; use v1::helpers::errors; @@ -50,81 +50,81 @@ impl ParitySetClient { } impl ParitySet for ParitySetClient { - fn set_min_gas_price(&self, _gas_price: U256) -> Result { + fn set_min_gas_price(&self, _gas_price: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_gas_floor_target(&self, _target: U256) -> Result { + fn set_gas_floor_target(&self, _target: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_gas_ceil_target(&self, _target: U256) -> Result { + fn set_gas_ceil_target(&self, _target: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_extra_data(&self, _extra_data: Bytes) -> Result { + fn set_extra_data(&self, _extra_data: Bytes) -> Result { Err(errors::light_unimplemented(None)) } - fn set_author(&self, _author: H160) -> Result { + fn set_author(&self, _author: H160) -> Result { Err(errors::light_unimplemented(None)) } - fn set_engine_signer(&self, _address: H160, _password: String) -> Result { + fn set_engine_signer(&self, _address: H160, _password: String) -> Result { Err(errors::light_unimplemented(None)) } - fn set_transactions_limit(&self, _limit: usize) -> Result { + fn set_transactions_limit(&self, _limit: usize) -> Result { Err(errors::light_unimplemented(None)) } - fn set_tx_gas_limit(&self, _limit: U256) -> Result { + fn set_tx_gas_limit(&self, _limit: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn add_reserved_peer(&self, peer: String) -> Result { + fn add_reserved_peer(&self, peer: String) -> Result { match self.net.add_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn remove_reserved_peer(&self, peer: String) -> Result { + fn remove_reserved_peer(&self, peer: String) -> Result { match self.net.remove_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn drop_non_reserved_peers(&self) -> Result { + fn drop_non_reserved_peers(&self) -> Result { self.net.deny_unreserved_peers(); Ok(true) } - fn accept_non_reserved_peers(&self) -> Result { + fn accept_non_reserved_peers(&self) -> Result { self.net.accept_unreserved_peers(); Ok(true) } - fn start_network(&self) -> Result { + fn start_network(&self) -> Result { self.net.start_network(); Ok(true) } - fn stop_network(&self) -> Result { + fn stop_network(&self) -> Result { self.net.stop_network(); Ok(true) } - fn set_mode(&self, _mode: String) -> Result { + fn set_mode(&self, _mode: String) -> Result { Err(errors::light_unimplemented(None)) } - fn set_spec_name(&self, _spec_name: String) -> Result { + fn set_spec_name(&self, _spec_name: String) -> Result { Err(errors::light_unimplemented(None)) } - fn hash_content(&self, url: String) -> BoxFuture { + fn hash_content(&self, url: String) -> BoxFuture { self.fetch.process(self.fetch.fetch(&url).then(move |result| { result .map_err(errors::fetch) @@ -135,23 +135,23 @@ impl ParitySet for ParitySetClient { })) } - fn dapps_refresh(&self) -> Result { + fn dapps_refresh(&self) -> Result { self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled) } - fn dapps_list(&self) -> Result, Error> { + fn dapps_list(&self) -> Result> { self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled) } - fn upgrade_ready(&self) -> Result, Error> { + fn upgrade_ready(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn execute_upgrade(&self) -> Result { + fn execute_upgrade(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn remove_transaction(&self, _hash: H256) -> Result, Error> { + fn remove_transaction(&self, _hash: H256) -> Result> { Err(errors::light_unimplemented(None)) } } diff --git a/rpc/src/v1/impls/light/trace.rs b/rpc/src/v1/impls/light/trace.rs index 742944e36..ae2763545 100644 --- a/rpc/src/v1/impls/light/trace.rs +++ b/rpc/src/v1/impls/light/trace.rs @@ -16,7 +16,7 @@ //! Traces api implementation. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; @@ -30,35 +30,35 @@ pub struct TracesClient; impl Traces for TracesClient { type Metadata = Metadata; - fn filter(&self, _filter: TraceFilter) -> Result>, Error> { + fn filter(&self, _filter: TraceFilter) -> Result>> { Err(errors::light_unimplemented(None)) } - fn block_traces(&self, _block_number: BlockNumber) -> Result>, Error> { + fn block_traces(&self, _block_number: BlockNumber) -> Result>> { Err(errors::light_unimplemented(None)) } - fn transaction_traces(&self, _transaction_hash: H256) -> Result>, Error> { + fn transaction_traces(&self, _transaction_hash: H256) -> Result>> { Err(errors::light_unimplemented(None)) } - fn trace(&self, _transaction_hash: H256, _address: Vec) -> Result, Error> { + fn trace(&self, _transaction_hash: H256, _address: Vec) -> Result> { Err(errors::light_unimplemented(None)) } - fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing) -> Result { + fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing) -> Result, Error> { + fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing) -> Result> { Err(errors::light_unimplemented(None)) } - fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing) -> Result { + fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result { + fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result { Err(errors::light_unimplemented(None)) } } diff --git a/rpc/src/v1/impls/net.rs b/rpc/src/v1/impls/net.rs index 97f50b633..50dbffdc7 100644 --- a/rpc/src/v1/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -16,7 +16,7 @@ //! Net rpc implementation. use std::sync::Arc; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethsync::SyncProvider; use v1::traits::Net; @@ -35,15 +35,15 @@ impl NetClient where S: SyncProvider { } impl Net for NetClient where S: SyncProvider + 'static { - fn version(&self) -> Result { + fn version(&self) -> Result { Ok(format!("{}", self.sync.status().network_id).to_owned()) } - fn peer_count(&self) -> Result { + fn peer_count(&self) -> Result { Ok(format!("0x{:x}", self.sync.status().num_peers as u64).to_owned()) } - fn is_listening(&self) -> Result { + fn is_listening(&self) -> Result { // right now (11 march 2016), we are always listening for incoming connections // // (this may not be true now -- 26 september 2016) diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index c586ea985..b10659322 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -35,7 +35,7 @@ use ethcore_logger::RotatingLogger; use node_health::{NodeHealth, Health}; use updater::{Service as UpdateService}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings}; @@ -107,7 +107,7 @@ impl ParityClient where /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } @@ -119,7 +119,7 @@ impl Parity for ParityClient where { type Metadata = Metadata; - fn accounts_info(&self, dapp: Trailing) -> Result, Error> { + fn accounts_info(&self, dapp: Trailing) -> Result> { let dapp = dapp.unwrap_or_default(); let store = self.account_provider()?; @@ -141,7 +141,7 @@ impl Parity for ParityClient where ) } - fn hardware_accounts_info(&self) -> Result, Error> { + fn hardware_accounts_info(&self) -> Result> { let store = self.account_provider()?; let info = store.hardware_accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; Ok(info @@ -151,12 +151,12 @@ impl Parity for ParityClient where ) } - fn locked_hardware_accounts_info(&self) -> Result, Error> { + fn locked_hardware_accounts_info(&self) -> Result> { let store = self.account_provider()?; Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } - fn default_account(&self, meta: Self::Metadata) -> Result { + fn default_account(&self, meta: Self::Metadata) -> Result { let dapp_id = meta.dapp_id(); Ok(self.account_provider()? @@ -166,48 +166,48 @@ impl Parity for ParityClient where .unwrap_or_default()) } - fn transactions_limit(&self) -> Result { + fn transactions_limit(&self) -> Result { Ok(self.miner.transactions_limit()) } - fn min_gas_price(&self) -> Result { + fn min_gas_price(&self) -> Result { Ok(U256::from(self.miner.minimal_gas_price())) } - fn extra_data(&self) -> Result { + fn extra_data(&self) -> Result { Ok(Bytes::new(self.miner.extra_data())) } - fn gas_floor_target(&self) -> Result { + fn gas_floor_target(&self) -> Result { Ok(U256::from(self.miner.gas_floor_target())) } - fn gas_ceil_target(&self) -> Result { + fn gas_ceil_target(&self) -> Result { Ok(U256::from(self.miner.gas_ceil_target())) } - fn dev_logs(&self) -> Result, Error> { + fn dev_logs(&self) -> Result> { let logs = self.logger.logs(); Ok(logs.as_slice().to_owned()) } - fn dev_logs_levels(&self) -> Result { + fn dev_logs_levels(&self) -> Result { Ok(self.logger.levels().to_owned()) } - fn net_chain(&self) -> Result { + fn net_chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn chain_id(&self) -> Result, Error> { + fn chain_id(&self) -> Result> { Ok(self.client.signing_chain_id().map(U64::from)) } - fn chain(&self) -> Result { + fn chain(&self) -> Result { Ok(self.client.spec_name()) } - fn net_peers(&self) -> Result { + fn net_peers(&self) -> Result { let sync_status = self.sync.status(); let net_config = self.net.network_config(); let peers = self.sync.peers().into_iter().map(Into::into).collect(); @@ -220,15 +220,15 @@ impl Parity for ParityClient where }) } - fn net_port(&self) -> Result { + fn net_port(&self) -> Result { Ok(self.settings.network_port) } - fn node_name(&self) -> Result { + fn node_name(&self) -> Result { Ok(self.settings.name.clone()) } - fn registry_address(&self) -> Result, Error> { + fn registry_address(&self) -> Result> { Ok( self.client .additional_params() @@ -238,7 +238,7 @@ impl Parity for ParityClient where ) } - fn rpc_settings(&self) -> Result { + fn rpc_settings(&self) -> Result { Ok(RpcSettings { enabled: self.settings.rpc_enabled, interface: self.settings.rpc_interface.clone(), @@ -246,11 +246,11 @@ impl Parity for ParityClient where }) } - fn default_extra_data(&self) -> Result { + fn default_extra_data(&self) -> Result { Ok(Bytes::new(version_data())) } - fn gas_price_histogram(&self) -> BoxFuture { + fn gas_price_histogram(&self) -> BoxFuture { Box::new(future::done(self.client .gas_price_corpus(100) .histogram(10) @@ -259,50 +259,50 @@ impl Parity for ParityClient where )) } - fn unsigned_transactions_count(&self) -> Result { + fn unsigned_transactions_count(&self) -> Result { match self.signer { None => Err(errors::signer_disabled()), Some(ref signer) => Ok(signer.len()), } } - fn generate_secret_phrase(&self) -> Result { + fn generate_secret_phrase(&self) -> Result { Ok(random_phrase(12)) } - fn phrase_to_address(&self, phrase: String) -> Result { + fn phrase_to_address(&self, phrase: String) -> Result { Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { + fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>> { Ok(self.client .list_accounts(block_number.unwrap_or_default().into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } - fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { + fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>> { Ok(self.client .list_storage(block_number.unwrap_or_default().into(), &address.into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } - fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { + fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0) .map_err(errors::encryption) .map(Into::into) } - fn pending_transactions(&self) -> Result, Error> { + fn pending_transactions(&self) -> Result> { let block_number = self.client.chain_info().best_block_number; Ok(self.miner.pending_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::>()) } - fn future_transactions(&self) -> Result, Error> { + fn future_transactions(&self) -> Result> { let block_number = self.client.chain_info().best_block_number; Ok(self.miner.future_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::>()) } - fn pending_transactions_stats(&self) -> Result, Error> { + fn pending_transactions_stats(&self) -> Result> { let stats = self.sync.transactions_stats(); Ok(stats.into_iter() .map(|(hash, stats)| (hash.into(), stats.into())) @@ -310,7 +310,7 @@ impl Parity for ParityClient where ) } - fn local_transactions(&self) -> Result, Error> { + fn local_transactions(&self) -> Result> { // Return nothing if accounts are disabled (running as public node) if self.accounts.is_none() { return Ok(BTreeMap::new()); @@ -325,17 +325,17 @@ impl Parity for ParityClient where ) } - fn dapps_url(&self) -> Result { + fn dapps_url(&self) -> Result { helpers::to_url(&self.dapps_address) .ok_or_else(|| errors::dapps_disabled()) } - fn ws_url(&self) -> Result { + fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) } - fn next_nonce(&self, address: H160) -> BoxFuture { + fn next_nonce(&self, address: H160) -> BoxFuture { let address: Address = address.into(); Box::new(future::ok(self.miner.last_nonce(&address) @@ -345,7 +345,7 @@ impl Parity for ParityClient where )) } - fn mode(&self) -> Result { + fn mode(&self) -> Result { Ok(match self.client.mode() { Mode::Off => "offline", Mode::Dark(..) => "dark", @@ -354,23 +354,23 @@ impl Parity for ParityClient where }.into()) } - fn enode(&self) -> Result { + fn enode(&self) -> Result { self.sync.enode().ok_or_else(errors::network_disabled) } - fn consensus_capability(&self) -> Result { + fn consensus_capability(&self) -> Result { Ok(self.updater.capability().into()) } - fn version_info(&self) -> Result { + fn version_info(&self) -> Result { Ok(self.updater.version_info().into()) } - fn releases_info(&self) -> Result, Error> { + fn releases_info(&self) -> Result> { Ok(self.updater.info().map(Into::into)) } - fn chain_status(&self) -> Result { + fn chain_status(&self) -> Result { let chain_info = self.client.chain_info(); let gap = chain_info.ancient_block_number.map(|x| U256::from(x + 1)) @@ -381,7 +381,7 @@ impl Parity for ParityClient where }) } - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error> { + fn node_kind(&self) -> Result<::v1::types::NodeKind> { use ::v1::types::{NodeKind, Availability, Capability}; let availability = match self.accounts { @@ -395,7 +395,7 @@ impl Parity for ParityClient where }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Trailing) -> BoxFuture { const EXTRA_INFO_PROOF: &'static str = "Object exists in in blockchain (fetched earlier), extra_info is always available if object exists; qed"; let id: BlockId = number.unwrap_or_default().into(); @@ -410,18 +410,18 @@ impl Parity for ParityClient where })) } - fn ipfs_cid(&self, content: Bytes) -> Result { + fn ipfs_cid(&self, content: Bytes) -> Result { ipfs::cid(content) } - fn call(&self, meta: Self::Metadata, requests: Vec, block: Trailing) -> Result, Error> { + fn call(&self, meta: Self::Metadata, requests: Vec, block: Trailing) -> Result> { let requests = requests .into_iter() .map(|request| Ok(( fake_sign::sign_call(request.into(), meta.is_dapp())?, Default::default() ))) - .collect::, Error>>()?; + .collect::>>()?; let block = block.unwrap_or_default(); @@ -430,7 +430,7 @@ impl Parity for ParityClient where .map_err(errors::call) } - fn node_health(&self) -> BoxFuture { + fn node_health(&self) -> BoxFuture { Box::new(self.health.health() .map_err(|err| errors::internal("Health API failure.", err))) } diff --git a/rpc/src/v1/impls/parity_accounts.rs b/rpc/src/v1/impls/parity_accounts.rs index d41837186..4aa1232f3 100644 --- a/rpc/src/v1/impls/parity_accounts.rs +++ b/rpc/src/v1/impls/parity_accounts.rs @@ -23,7 +23,7 @@ use ethkey::{Brain, Generator, Secret}; use ethstore::KeyFile; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::helpers::errors; use v1::helpers::accounts::unwrap_provider; use v1::traits::ParityAccounts; @@ -44,13 +44,13 @@ impl ParityAccountsClient { /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } impl ParityAccounts for ParityAccountsClient { - fn all_accounts_info(&self) -> Result, Error> { + fn all_accounts_info(&self) -> Result> { let store = self.account_provider()?; let info = store.accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; let other = store.addresses_info(); @@ -82,7 +82,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(accounts) } - fn new_account_from_phrase(&self, phrase: String, pass: String) -> Result { + fn new_account_from_phrase(&self, phrase: String, pass: String) -> Result { let store = self.account_provider()?; let brain = Brain::new(phrase).generate().unwrap(); @@ -91,7 +91,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn new_account_from_wallet(&self, json: String, pass: String) -> Result { + fn new_account_from_wallet(&self, json: String, pass: String) -> Result { let store = self.account_provider()?; store.import_presale(json.as_bytes(), &pass) @@ -100,7 +100,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn new_account_from_secret(&self, secret: RpcH256, pass: String) -> Result { + fn new_account_from_secret(&self, secret: RpcH256, pass: String) -> Result { let store = self.account_provider()?; let secret = Secret::from_unsafe_slice(&secret.0) @@ -110,7 +110,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn test_password(&self, account: RpcH160, password: String) -> Result { + fn test_password(&self, account: RpcH160, password: String) -> Result { let account: Address = account.into(); self.account_provider()? @@ -118,7 +118,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not fetch account info.", e)) } - fn change_password(&self, account: RpcH160, password: String, new_password: String) -> Result { + fn change_password(&self, account: RpcH160, password: String, new_password: String) -> Result { let account: Address = account.into(); self.account_provider()? .change_password(&account, password, new_password) @@ -126,7 +126,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not fetch account info.", e)) } - fn kill_account(&self, account: RpcH160, password: String) -> Result { + fn kill_account(&self, account: RpcH160, password: String) -> Result { let account: Address = account.into(); self.account_provider()? .kill_account(&account, &password) @@ -134,7 +134,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not delete account.", e)) } - fn remove_address(&self, addr: RpcH160) -> Result { + fn remove_address(&self, addr: RpcH160) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -142,7 +142,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_account_name(&self, addr: RpcH160, name: String) -> Result { + fn set_account_name(&self, addr: RpcH160, name: String) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -151,7 +151,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result { + fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -160,7 +160,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_dapp_addresses(&self, dapp: DappId, addresses: Option>) -> Result { + fn set_dapp_addresses(&self, dapp: DappId, addresses: Option>) -> Result { let store = self.account_provider()?; store.set_dapp_addresses(dapp.into(), addresses.map(into_vec)) @@ -168,7 +168,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn dapp_addresses(&self, dapp: DappId) -> Result, Error> { + fn dapp_addresses(&self, dapp: DappId) -> Result> { let store = self.account_provider()?; store.dapp_addresses(dapp.into()) @@ -176,7 +176,7 @@ impl ParityAccounts for ParityAccountsClient { .map(into_vec) } - fn set_dapp_default_address(&self, dapp: DappId, address: RpcH160) -> Result { + fn set_dapp_default_address(&self, dapp: DappId, address: RpcH160) -> Result { let store = self.account_provider()?; store.set_dapp_default_address(dapp.into(), address.into()) @@ -184,7 +184,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn dapp_default_address(&self, dapp: DappId) -> Result { + fn dapp_default_address(&self, dapp: DappId) -> Result { let store = self.account_provider()?; store.dapp_default_address(dapp.into()) @@ -192,7 +192,7 @@ impl ParityAccounts for ParityAccountsClient { .map(Into::into) } - fn set_new_dapps_addresses(&self, addresses: Option>) -> Result { + fn set_new_dapps_addresses(&self, addresses: Option>) -> Result { let store = self.account_provider()?; store @@ -201,7 +201,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn new_dapps_addresses(&self) -> Result>, Error> { + fn new_dapps_addresses(&self) -> Result>> { let store = self.account_provider()?; store.new_dapps_addresses() @@ -209,7 +209,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|accounts| accounts.map(into_vec)) } - fn set_new_dapps_default_address(&self, address: RpcH160) -> Result { + fn set_new_dapps_default_address(&self, address: RpcH160) -> Result { let store = self.account_provider()?; store.set_new_dapps_default_address(address.into()) @@ -217,7 +217,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn new_dapps_default_address(&self) -> Result { + fn new_dapps_default_address(&self) -> Result { let store = self.account_provider()?; store.new_dapps_default_address() @@ -225,7 +225,7 @@ impl ParityAccounts for ParityAccountsClient { .map(Into::into) } - fn recent_dapps(&self) -> Result, Error> { + fn recent_dapps(&self) -> Result> { let store = self.account_provider()?; store.recent_dapps() @@ -233,7 +233,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|map| map.into_iter().map(|(k, v)| (k.into(), v)).collect()) } - fn import_geth_accounts(&self, addresses: Vec) -> Result, Error> { + fn import_geth_accounts(&self, addresses: Vec) -> Result> { let store = self.account_provider()?; store @@ -242,73 +242,73 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Couldn't import Geth accounts", e)) } - fn geth_accounts(&self) -> Result, Error> { + fn geth_accounts(&self) -> Result> { let store = self.account_provider()?; Ok(into_vec(store.list_geth_accounts(false))) } - fn create_vault(&self, name: String, password: String) -> Result { + fn create_vault(&self, name: String, password: String) -> Result { self.account_provider()? .create_vault(&name, &password) .map_err(|e| errors::account("Could not create vault.", e)) .map(|_| true) } - fn open_vault(&self, name: String, password: String) -> Result { + fn open_vault(&self, name: String, password: String) -> Result { self.account_provider()? .open_vault(&name, &password) .map_err(|e| errors::account("Could not open vault.", e)) .map(|_| true) } - fn close_vault(&self, name: String) -> Result { + fn close_vault(&self, name: String) -> Result { self.account_provider()? .close_vault(&name) .map_err(|e| errors::account("Could not close vault.", e)) .map(|_| true) } - fn list_vaults(&self) -> Result, Error> { + fn list_vaults(&self) -> Result> { self.account_provider()? .list_vaults() .map_err(|e| errors::account("Could not list vaults.", e)) } - fn list_opened_vaults(&self) -> Result, Error> { + fn list_opened_vaults(&self) -> Result> { self.account_provider()? .list_opened_vaults() .map_err(|e| errors::account("Could not list vaults.", e)) } - fn change_vault_password(&self, name: String, new_password: String) -> Result { + fn change_vault_password(&self, name: String, new_password: String) -> Result { self.account_provider()? .change_vault_password(&name, &new_password) .map_err(|e| errors::account("Could not change vault password.", e)) .map(|_| true) } - fn change_vault(&self, address: RpcH160, new_vault: String) -> Result { + fn change_vault(&self, address: RpcH160, new_vault: String) -> Result { self.account_provider()? .change_vault(address.into(), &new_vault) .map_err(|e| errors::account("Could not change vault.", e)) .map(|_| true) } - fn get_vault_meta(&self, name: String) -> Result { + fn get_vault_meta(&self, name: String) -> Result { self.account_provider()? .get_vault_meta(&name) .map_err(|e| errors::account("Could not get vault metadata.", e)) } - fn set_vault_meta(&self, name: String, meta: String) -> Result { + fn set_vault_meta(&self, name: String, meta: String) -> Result { self.account_provider()? .set_vault_meta(&name, &meta) .map_err(|e| errors::account("Could not update vault metadata.", e)) .map(|_| true) } - fn derive_key_index(&self, addr: RpcH160, password: String, derivation: DeriveHierarchical, save_as_account: bool) -> Result { + fn derive_key_index(&self, addr: RpcH160, password: String, derivation: DeriveHierarchical, save_as_account: bool) -> Result { let addr: Address = addr.into(); self.account_provider()? .derive_account( @@ -321,7 +321,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not derive account.", e)) } - fn derive_key_hash(&self, addr: RpcH160, password: String, derivation: DeriveHash, save_as_account: bool) -> Result { + fn derive_key_hash(&self, addr: RpcH160, password: String, derivation: DeriveHash, save_as_account: bool) -> Result { let addr: Address = addr.into(); self.account_provider()? .derive_account( @@ -334,7 +334,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not derive account.", e)) } - fn export_account(&self, addr: RpcH160, password: String) -> Result { + fn export_account(&self, addr: RpcH160, password: String) -> Result { let addr = addr.into(); self.account_provider()? .export_account( @@ -345,7 +345,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not export account.", e)) } - fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result { + fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result { self.account_provider()? .sign( addr.into(), @@ -356,7 +356,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not sign message.", e)) } - fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result { + fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result { let store = self.account_provider()?; Ok(store.hardware_pin_matrix_ack(&path, &pin).map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } diff --git a/rpc/src/v1/impls/parity_set.rs b/rpc/src/v1/impls/parity_set.rs index 5e01455be..4864e7806 100644 --- a/rpc/src/v1/impls/parity_set.rs +++ b/rpc/src/v1/impls/parity_set.rs @@ -26,7 +26,7 @@ use fetch::{self, Fetch}; use hash::keccak_buffer; use updater::{Service as UpdateService}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::Future; use v1::helpers::dapps::DappsService; use v1::helpers::errors; @@ -75,81 +75,81 @@ impl ParitySet for ParitySetClient where F: Fetch + 'static, { - fn set_min_gas_price(&self, gas_price: U256) -> Result { + fn set_min_gas_price(&self, gas_price: U256) -> Result { self.miner.set_minimal_gas_price(gas_price.into()); Ok(true) } - fn set_gas_floor_target(&self, target: U256) -> Result { + fn set_gas_floor_target(&self, target: U256) -> Result { self.miner.set_gas_floor_target(target.into()); Ok(true) } - fn set_gas_ceil_target(&self, target: U256) -> Result { + fn set_gas_ceil_target(&self, target: U256) -> Result { self.miner.set_gas_ceil_target(target.into()); Ok(true) } - fn set_extra_data(&self, extra_data: Bytes) -> Result { + fn set_extra_data(&self, extra_data: Bytes) -> Result { self.miner.set_extra_data(extra_data.into_vec()); Ok(true) } - fn set_author(&self, author: H160) -> Result { + fn set_author(&self, author: H160) -> Result { self.miner.set_author(author.into()); Ok(true) } - fn set_engine_signer(&self, address: H160, password: String) -> Result { + fn set_engine_signer(&self, address: H160, password: String) -> Result { self.miner.set_engine_signer(address.into(), password).map_err(Into::into).map_err(errors::password)?; Ok(true) } - fn set_transactions_limit(&self, limit: usize) -> Result { + fn set_transactions_limit(&self, limit: usize) -> Result { self.miner.set_transactions_limit(limit); Ok(true) } - fn set_tx_gas_limit(&self, limit: U256) -> Result { + fn set_tx_gas_limit(&self, limit: U256) -> Result { self.miner.set_tx_gas_limit(limit.into()); Ok(true) } - fn add_reserved_peer(&self, peer: String) -> Result { + fn add_reserved_peer(&self, peer: String) -> Result { match self.net.add_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn remove_reserved_peer(&self, peer: String) -> Result { + fn remove_reserved_peer(&self, peer: String) -> Result { match self.net.remove_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn drop_non_reserved_peers(&self) -> Result { + fn drop_non_reserved_peers(&self) -> Result { self.net.deny_unreserved_peers(); Ok(true) } - fn accept_non_reserved_peers(&self) -> Result { + fn accept_non_reserved_peers(&self) -> Result { self.net.accept_unreserved_peers(); Ok(true) } - fn start_network(&self) -> Result { + fn start_network(&self) -> Result { self.net.start_network(); Ok(true) } - fn stop_network(&self) -> Result { + fn stop_network(&self) -> Result { self.net.stop_network(); Ok(true) } - fn set_mode(&self, mode: String) -> Result { + fn set_mode(&self, mode: String) -> Result { self.client.set_mode(match mode.as_str() { "offline" => Mode::Off, "dark" => Mode::Dark(300), @@ -160,12 +160,12 @@ impl ParitySet for ParitySetClient where Ok(true) } - fn set_spec_name(&self, spec_name: String) -> Result { + fn set_spec_name(&self, spec_name: String) -> Result { self.client.set_spec_name(spec_name); Ok(true) } - fn hash_content(&self, url: String) -> BoxFuture { + fn hash_content(&self, url: String) -> BoxFuture { self.fetch.process(self.fetch.fetch(&url).then(move |result| { result .map_err(errors::fetch) @@ -176,23 +176,23 @@ impl ParitySet for ParitySetClient where })) } - fn dapps_refresh(&self) -> Result { + fn dapps_refresh(&self) -> Result { self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled) } - fn dapps_list(&self) -> Result, Error> { + fn dapps_list(&self) -> Result> { self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled) } - fn upgrade_ready(&self) -> Result, Error> { + fn upgrade_ready(&self) -> Result> { Ok(self.updater.upgrade_ready().map(Into::into)) } - fn execute_upgrade(&self) -> Result { + fn execute_upgrade(&self) -> Result { Ok(self.updater.execute_upgrade()) } - fn remove_transaction(&self, hash: H256) -> Result, Error> { + fn remove_transaction(&self, hash: H256) -> Result> { let block_number = self.client.chain_info().best_block_number; let hash = hash.into(); diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 6ad2285f9..03e4ef573 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -24,7 +24,7 @@ use bigint::prelude::U128; use util::Address; use bytes::ToPretty; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use v1::helpers::errors; use v1::helpers::dispatch::{Dispatcher, SignWith}; @@ -50,7 +50,7 @@ impl PersonalClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } @@ -58,13 +58,13 @@ impl PersonalClient { impl Personal for PersonalClient { type Metadata = Metadata; - fn accounts(&self) -> Result, Error> { + fn accounts(&self) -> Result> { let store = self.account_provider()?; let accounts = store.accounts().map_err(|e| errors::account("Could not fetch accounts.", e))?; Ok(accounts.into_iter().map(Into::into).collect::>()) } - fn new_account(&self, pass: String) -> Result { + fn new_account(&self, pass: String) -> Result { let store = self.account_provider()?; store.new_account(&pass) @@ -72,7 +72,7 @@ impl Personal for PersonalClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option) -> Result { + fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option) -> Result { let account: Address = account.into(); let store = self.account_provider()?; let duration = match duration { @@ -104,7 +104,7 @@ impl Personal for PersonalClient { } } - fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { let dispatcher = self.dispatcher.clone(); let accounts = try_bf!(self.account_provider()); @@ -137,7 +137,7 @@ impl Personal for PersonalClient { })) } - fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { + fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { warn!("Using deprecated personal_signAndSendTransaction, use personal_sendTransaction instead."); self.send_transaction(meta, request, password) } diff --git a/rpc/src/v1/impls/pubsub.rs b/rpc/src/v1/impls/pubsub.rs index 04234bf2a..59eef1953 100644 --- a/rpc/src/v1/impls/pubsub.rs +++ b/rpc/src/v1/impls/pubsub.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::time::Duration; use parking_lot::RwLock; -use jsonrpc_core::{self as core, Error, MetaIoHandler}; +use jsonrpc_core::{self as core, Result, MetaIoHandler}; use jsonrpc_core::futures::{Future, Stream, Sink}; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; @@ -94,7 +94,7 @@ impl> PubSub for PubSubClient { } } - fn parity_unsubscribe(&self, id: SubscriptionId) -> Result { + fn parity_unsubscribe(&self, id: SubscriptionId) -> Result { let res = self.poll_manager.write().unsubscribe(&id); Ok(res) } diff --git a/rpc/src/v1/impls/rpc.rs b/rpc/src/v1/impls/rpc.rs index d0b10cddb..3c76a3164 100644 --- a/rpc/src/v1/impls/rpc.rs +++ b/rpc/src/v1/impls/rpc.rs @@ -16,7 +16,7 @@ //! RPC generic methods implementation. use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::traits::Rpc; /// RPC generic methods implementation. @@ -39,7 +39,7 @@ impl RpcClient { } impl Rpc for RpcClient { - fn rpc_modules(&self) -> Result, Error> { + fn rpc_modules(&self) -> Result> { let modules = self.modules.iter() .fold(BTreeMap::new(), |mut map, (k, v)| { map.insert(k.to_owned(), v.to_owned()); @@ -49,7 +49,7 @@ impl Rpc for RpcClient { Ok(modules) } - fn modules(&self) -> Result, Error> { + fn modules(&self) -> Result> { let modules = self.modules.iter() .filter(|&(k, _v)| { self.valid_apis.contains(k) diff --git a/rpc/src/v1/impls/secretstore.rs b/rpc/src/v1/impls/secretstore.rs index 26a09705d..6ddb4a7a0 100644 --- a/rpc/src/v1/impls/secretstore.rs +++ b/rpc/src/v1/impls/secretstore.rs @@ -22,7 +22,7 @@ use crypto::DEFAULT_MAC; use ethkey::Secret; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::helpers::errors; use v1::helpers::accounts::unwrap_provider; use v1::helpers::secretstore::{encrypt_document, decrypt_document, decrypt_document_with_shadow}; @@ -44,36 +44,36 @@ impl SecretStoreClient { /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } /// Decrypt public key using account' private key - fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result, Error> { + fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result> { let store = self.account_provider()?; store.decrypt(address.into(), Some(password), &DEFAULT_MAC, &key.0) .map_err(|e| errors::account("Could not decrypt key.", e)) } /// Decrypt secret key using account' private key - fn decrypt_secret(&self, address: H160, password: String, key: Bytes) -> Result { + fn decrypt_secret(&self, address: H160, password: String, key: Bytes) -> Result { self.decrypt_key(address, password, key) .and_then(|s| Secret::from_unsafe_slice(&s).map_err(|e| errors::account("invalid secret", e))) } } impl SecretStore for SecretStoreClient { - fn encrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { + fn encrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { encrypt_document(self.decrypt_key(address, password, key)?, data.0) .map(Into::into) } - fn decrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { + fn decrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { decrypt_document(self.decrypt_key(address, password, key)?, data.0) .map(Into::into) } - fn shadow_decrypt(&self, address: H160, password: String, decrypted_secret: H512, common_point: H512, decrypt_shadows: Vec, data: Bytes) -> Result { + fn shadow_decrypt(&self, address: H160, password: String, decrypted_secret: H512, common_point: H512, decrypt_shadows: Vec, data: Bytes) -> Result { let mut shadows = Vec::with_capacity(decrypt_shadows.len()); for decrypt_shadow in decrypt_shadows { shadows.push(self.decrypt_secret(address.clone(), password.clone(), decrypt_shadow)?); diff --git a/rpc/src/v1/impls/signer.rs b/rpc/src/v1/impls/signer.rs index cecd1f2db..04f510702 100644 --- a/rpc/src/v1/impls/signer.rs +++ b/rpc/src/v1/impls/signer.rs @@ -25,7 +25,7 @@ use parity_reactor::Remote; use rlp::UntrustedRlp; use parking_lot::Mutex; -use jsonrpc_core::{Error, BoxFuture}; +use jsonrpc_core::{Result, BoxFuture, Error}; use jsonrpc_core::futures::{future, Future, IntoFuture}; use jsonrpc_core::futures::future::Either; use jsonrpc_pubsub::SubscriptionId; @@ -78,11 +78,11 @@ impl SignerClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn confirm_internal(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture, Error> where + fn confirm_internal(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture> where F: FnOnce(D, Arc, ConfirmationPayload) -> T, T: IntoFuture, Error=Error>, T::Future: Send + 'static @@ -124,8 +124,8 @@ impl SignerClient { .unwrap_or_else(|| Either::B(future::err(errors::invalid_params("Unknown RequestID", id))))) } - fn verify_transaction(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result where - F: FnOnce(PendingTransaction) -> Result, + fn verify_transaction(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result where + F: FnOnce(PendingTransaction) -> Result, { let signed_transaction = UntrustedRlp::new(&bytes.0).as_val().map_err(errors::rlp)?; let signed_transaction = SignedTransaction::new(signed_transaction).map_err(|e| errors::invalid_params("Invalid signature.", e))?; @@ -159,7 +159,7 @@ impl SignerClient { impl Signer for SignerClient { type Metadata = Metadata; - fn requests_to_confirm(&self) -> Result, Error> { + fn requests_to_confirm(&self) -> Result> { Ok(self.signer.requests() .into_iter() .map(Into::into) @@ -170,7 +170,7 @@ impl Signer for SignerClient { // TODO [ToDr] TransactionModification is redundant for some calls // might be better to replace it in future fn confirm_request(&self, id: U256, modification: TransactionModification, pass: String) - -> BoxFuture + -> BoxFuture { Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| { dispatch::execute(dis, accounts, payload, dispatch::SignWith::Password(pass)) @@ -178,7 +178,7 @@ impl Signer for SignerClient { } fn confirm_request_with_token(&self, id: U256, modification: TransactionModification, token: String) - -> BoxFuture + -> BoxFuture { Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| { dispatch::execute(dis, accounts, payload, dispatch::SignWith::Token(token)) @@ -191,7 +191,7 @@ impl Signer for SignerClient { })) } - fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result { + fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result { let id = id.into(); self.signer.peek(&id).map(|confirmation| { @@ -230,17 +230,17 @@ impl Signer for SignerClient { }).unwrap_or_else(|| Err(errors::invalid_params("Unknown RequestID", id))) } - fn reject_request(&self, id: U256) -> Result { + fn reject_request(&self, id: U256) -> Result { let res = self.signer.request_rejected(id.into()); Ok(res.is_some()) } - fn generate_token(&self) -> Result { + fn generate_token(&self) -> Result { self.signer.generate_token() .map_err(|e| errors::token(e)) } - fn generate_web_proxy_token(&self, domain: String) -> Result { + fn generate_web_proxy_token(&self, domain: String) -> Result { Ok(self.signer.generate_web_proxy_access_token(domain.into())) } @@ -248,7 +248,7 @@ impl Signer for SignerClient { self.subscribers.lock().push(sub) } - fn unsubscribe_pending(&self, id: SubscriptionId) -> Result { + fn unsubscribe_pending(&self, id: SubscriptionId) -> Result { let res = self.subscribers.lock().remove(&id).is_some(); Ok(res) } diff --git a/rpc/src/v1/impls/signing.rs b/rpc/src/v1/impls/signing.rs index 139e554ca..dd6507c42 100644 --- a/rpc/src/v1/impls/signing.rs +++ b/rpc/src/v1/impls/signing.rs @@ -23,7 +23,7 @@ use parking_lot::Mutex; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{future, Future, Poll, Async}; use jsonrpc_core::futures::future::Either; use v1::helpers::{ @@ -109,11 +109,11 @@ impl SigningQueueClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture { + fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = match default_account { DefaultAccount::Provided(acc) => acc, @@ -143,13 +143,13 @@ impl SigningQueueClient { impl ParitySigning for SigningQueueClient { type Metadata = Metadata; - fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { + fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default(); Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into)) } - fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture, Error> { + fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture> { let remote = self.remote.clone(); let confirmations = self.confirmations.clone(); @@ -166,7 +166,7 @@ impl ParitySigning for SigningQueueClient { })) } - fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture, Error> { + fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture> { let remote = self.remote.clone(); let confirmations = self.confirmations.clone(); @@ -180,7 +180,7 @@ impl ParitySigning for SigningQueueClient { })) } - fn check_request(&self, id: RpcU256) -> Result, Error> { + fn check_request(&self, id: RpcU256) -> Result> { let id: U256 = id.into(); match self.confirmations.lock().get(&id) { None => Err(errors::request_not_found()), // Request info has been dropped, or even never been there @@ -189,7 +189,7 @@ impl ParitySigning for SigningQueueClient { } } - fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into(), @@ -209,7 +209,7 @@ impl ParitySigning for SigningQueueClient { impl EthSigning for SigningQueueClient { type Metadata = Metadata; - fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into(), @@ -224,7 +224,7 @@ impl EthSigning for SigningQueueClient { })) } - fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into(), @@ -239,7 +239,7 @@ impl EthSigning for SigningQueueClient { })) } - fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into(), diff --git a/rpc/src/v1/impls/signing_unsafe.rs b/rpc/src/v1/impls/signing_unsafe.rs index 779e9f20e..e2bf27d39 100644 --- a/rpc/src/v1/impls/signing_unsafe.rs +++ b/rpc/src/v1/impls/signing_unsafe.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use v1::helpers::{errors, DefaultAccount}; use v1::helpers::dispatch::{self, Dispatcher}; @@ -52,11 +52,11 @@ impl SigningUnsafeClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture { + fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default = match account { DefaultAccount::Provided(acc) => acc, @@ -76,7 +76,7 @@ impl EthSigning for SigningUnsafeClient { type Metadata = Metadata; - fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into()) .then(|res| match res { Ok(RpcConfirmationResponse::Signature(signature)) => Ok(signature), @@ -85,7 +85,7 @@ impl EthSigning for SigningUnsafeClient })) } - fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into()) .then(|res| match res { Ok(RpcConfirmationResponse::SendTransaction(hash)) => Ok(hash), @@ -94,7 +94,7 @@ impl EthSigning for SigningUnsafeClient })) } - fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into()) .then(|res| match res { Ok(RpcConfirmationResponse::SignTransaction(tx)) => Ok(tx), @@ -107,13 +107,13 @@ impl EthSigning for SigningUnsafeClient impl ParitySigning for SigningUnsafeClient { type Metadata = Metadata; - fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { + fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default(); Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into)) } - fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into()) .then(|res| match res { Ok(RpcConfirmationResponse::Decrypt(data)) => Ok(data), @@ -122,17 +122,17 @@ impl ParitySigning for SigningUnsafeClient { })) } - fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture, Error> { + fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture> { // We don't support this in non-signer mode. Box::new(future::err(errors::signer_disabled())) } - fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture, Error> { + fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture> { // We don't support this in non-signer mode. Box::new(future::err((errors::signer_disabled()))) } - fn check_request(&self, _: RpcU256) -> Result, Error> { + fn check_request(&self, _: RpcU256) -> Result> { // We don't support this in non-signer mode. Err(errors::signer_disabled()) } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 8fca11efe..34fe36e67 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -22,7 +22,7 @@ use ethcore::client::{MiningBlockChainClient, CallAnalytics, TransactionId, Trac use ethcore::transaction::SignedTransaction; use rlp::UntrustedRlp; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; @@ -54,22 +54,22 @@ impl TracesClient { impl Traces for TracesClient where C: MiningBlockChainClient + 'static { type Metadata = Metadata; - fn filter(&self, filter: TraceFilter) -> Result>, Error> { + fn filter(&self, filter: TraceFilter) -> Result>> { Ok(self.client.filter_traces(filter.into()) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn block_traces(&self, block_number: BlockNumber) -> Result>, Error> { + fn block_traces(&self, block_number: BlockNumber) -> Result>> { Ok(self.client.block_traces(block_number.into()) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn transaction_traces(&self, transaction_hash: H256) -> Result>, Error> { + fn transaction_traces(&self, transaction_hash: H256) -> Result>> { Ok(self.client.transaction_traces(TransactionId::Hash(transaction_hash.into())) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn trace(&self, transaction_hash: H256, address: Vec) -> Result, Error> { + fn trace(&self, transaction_hash: H256, address: Vec) -> Result> { let id = TraceId { transaction: TransactionId::Hash(transaction_hash.into()), address: address.into_iter().map(|i| i.value()).collect() @@ -79,7 +79,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map(LocalizedTrace::from)) } - fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing) -> Result { + fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing) -> Result { let block = block.unwrap_or_default(); let request = CallRequest::into(request); @@ -90,7 +90,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map_err(errors::call) } - fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing) -> Result, Error> { + fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing) -> Result> { let block = block.unwrap_or_default(); let requests = requests.into_iter() @@ -99,14 +99,14 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { let signed = fake_sign::sign_call(request, meta.is_dapp())?; Ok((signed, to_call_analytics(flags))) }) - .collect::, Error>>()?; + .collect::>>()?; self.client.call_many(&requests, block.into()) .map(|results| results.into_iter().map(TraceResults::from).collect()) .map_err(errors::call) } - fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing) -> Result { + fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing) -> Result { let block = block.unwrap_or_default(); let tx = UntrustedRlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?; @@ -117,7 +117,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map_err(errors::call) } - fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result { + fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result { self.client.replay(TransactionId::Hash(transaction_hash.into()), to_call_analytics(flags)) .map(TraceResults::from) .map_err(errors::call) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index b636ba608..44055507f 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -16,7 +16,7 @@ //! Web3 rpc implementation. use hash::keccak; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use util::version; use v1::traits::Web3; use v1::types::{H256, Bytes}; @@ -30,11 +30,11 @@ impl Web3Client { } impl Web3 for Web3Client { - fn client_version(&self) -> Result { + fn client_version(&self) -> Result { Ok(version().to_owned().replace("Parity/", "Parity//")) } - fn sha3(&self, data: Bytes) -> Result { + fn sha3(&self, data: Bytes) -> Result { Ok(keccak(&data.0).into()) } } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 6c052bf31..f4ea1e10d 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Eth rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_macros::Trailing; use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index}; @@ -29,151 +29,151 @@ build_rpc_trait! { /// Returns protocol version encoded as a string (quotes are necessary). #[rpc(name = "eth_protocolVersion")] - fn protocol_version(&self) -> Result; + fn protocol_version(&self) -> Result; /// Returns an object with data about the sync status or false. (wtf?) #[rpc(name = "eth_syncing")] - fn syncing(&self) -> Result; + fn syncing(&self) -> Result; /// Returns the number of hashes per second that the node is mining with. #[rpc(name = "eth_hashrate")] - fn hashrate(&self) -> Result; + fn hashrate(&self) -> Result; /// Returns block author. #[rpc(meta, name = "eth_coinbase")] - fn author(&self, Self::Metadata) -> Result; + fn author(&self, Self::Metadata) -> Result; /// Returns true if client is actively mining new blocks. #[rpc(name = "eth_mining")] - fn is_mining(&self) -> Result; + fn is_mining(&self) -> Result; /// Returns current gas_price. #[rpc(name = "eth_gasPrice")] - fn gas_price(&self) -> Result; + fn gas_price(&self) -> Result; /// Returns accounts list. #[rpc(meta, name = "eth_accounts")] - fn accounts(&self, Self::Metadata) -> Result, Error>; + fn accounts(&self, Self::Metadata) -> Result>; /// Returns highest block number. #[rpc(name = "eth_blockNumber")] - fn block_number(&self) -> Result; + fn block_number(&self) -> Result; /// Returns balance of the given account. #[rpc(name = "eth_getBalance")] - fn balance(&self, H160, Trailing) -> BoxFuture; + fn balance(&self, H160, Trailing) -> BoxFuture; /// Returns content of the storage at given address. #[rpc(name = "eth_getStorageAt")] - fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; + fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; /// Returns block with given hash. #[rpc(name = "eth_getBlockByHash")] - fn block_by_hash(&self, H256, bool) -> BoxFuture, Error>; + fn block_by_hash(&self, H256, bool) -> BoxFuture>; /// Returns block with given number. #[rpc(name = "eth_getBlockByNumber")] - fn block_by_number(&self, BlockNumber, bool) -> BoxFuture, Error>; + fn block_by_number(&self, BlockNumber, bool) -> BoxFuture>; /// Returns the number of transactions sent from given address at given time (block number). #[rpc(name = "eth_getTransactionCount")] - fn transaction_count(&self, H160, Trailing) -> BoxFuture; + fn transaction_count(&self, H160, Trailing) -> BoxFuture; /// Returns the number of transactions in a block with given hash. #[rpc(name = "eth_getBlockTransactionCountByHash")] - fn block_transaction_count_by_hash(&self, H256) -> BoxFuture, Error>; + fn block_transaction_count_by_hash(&self, H256) -> BoxFuture>; /// Returns the number of transactions in a block with given block number. #[rpc(name = "eth_getBlockTransactionCountByNumber")] - fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture, Error>; + fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture>; /// Returns the number of uncles in a block with given hash. #[rpc(name = "eth_getUncleCountByBlockHash")] - fn block_uncles_count_by_hash(&self, H256) -> BoxFuture, Error>; + fn block_uncles_count_by_hash(&self, H256) -> BoxFuture>; /// Returns the number of uncles in a block with given block number. #[rpc(name = "eth_getUncleCountByBlockNumber")] - fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture, Error>; + fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture>; /// Returns the code at given address at given time (block number). #[rpc(name = "eth_getCode")] - fn code_at(&self, H160, Trailing) -> BoxFuture; + fn code_at(&self, H160, Trailing) -> BoxFuture; /// Sends signed transaction, returning its hash. #[rpc(name = "eth_sendRawTransaction")] - fn send_raw_transaction(&self, Bytes) -> Result; + fn send_raw_transaction(&self, Bytes) -> Result; /// @alias of `eth_sendRawTransaction`. #[rpc(name = "eth_submitTransaction")] - fn submit_transaction(&self, Bytes) -> Result; + fn submit_transaction(&self, Bytes) -> Result; /// Call contract, returning the output data. #[rpc(meta, name = "eth_call")] - fn call(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; + fn call(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; /// Estimate gas needed for execution of given contract. #[rpc(meta, name = "eth_estimateGas")] - fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; + fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; /// Get transaction by its hash. #[rpc(name = "eth_getTransactionByHash")] - fn transaction_by_hash(&self, H256) -> BoxFuture, Error>; + fn transaction_by_hash(&self, H256) -> BoxFuture>; /// Returns transaction at given block hash and index. #[rpc(name = "eth_getTransactionByBlockHashAndIndex")] - fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture, Error>; + fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; /// Returns transaction by given block number and index. #[rpc(name = "eth_getTransactionByBlockNumberAndIndex")] - fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture, Error>; + fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; /// Returns transaction receipt by transaction hash. #[rpc(name = "eth_getTransactionReceipt")] - fn transaction_receipt(&self, H256) -> BoxFuture, Error>; + fn transaction_receipt(&self, H256) -> BoxFuture>; /// Returns an uncles at given block and index. #[rpc(name = "eth_getUncleByBlockHashAndIndex")] - fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture, Error>; + fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; /// Returns an uncles at given block and index. #[rpc(name = "eth_getUncleByBlockNumberAndIndex")] - fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture, Error>; + fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; /// Returns available compilers. /// @deprecated #[rpc(name = "eth_getCompilers")] - fn compilers(&self) -> Result, Error>; + fn compilers(&self) -> Result>; /// Compiles lll code. /// @deprecated #[rpc(name = "eth_compileLLL")] - fn compile_lll(&self, String) -> Result; + fn compile_lll(&self, String) -> Result; /// Compiles solidity. /// @deprecated #[rpc(name = "eth_compileSolidity")] - fn compile_solidity(&self, String) -> Result; + fn compile_solidity(&self, String) -> Result; /// Compiles serpent. /// @deprecated #[rpc(name = "eth_compileSerpent")] - fn compile_serpent(&self, String) -> Result; + fn compile_serpent(&self, String) -> Result; /// Returns logs matching given filter object. #[rpc(name = "eth_getLogs")] - fn logs(&self, Filter) -> BoxFuture, Error>; + fn logs(&self, Filter) -> BoxFuture>; /// Returns the hash of the current block, the seedHash, and the boundary condition to be met. #[rpc(name = "eth_getWork")] - fn work(&self, Trailing) -> Result; + fn work(&self, Trailing) -> Result; /// Used for submitting a proof-of-work solution. #[rpc(name = "eth_submitWork")] - fn submit_work(&self, H64, H256, H256) -> Result; + fn submit_work(&self, H64, H256, H256) -> Result; /// Used for submitting mining hashrate. #[rpc(name = "eth_submitHashrate")] - fn submit_hashrate(&self, U256, H256) -> Result; + fn submit_hashrate(&self, U256, H256) -> Result; } } @@ -183,26 +183,26 @@ build_rpc_trait! { pub trait EthFilter { /// Returns id of new filter. #[rpc(name = "eth_newFilter")] - fn new_filter(&self, Filter) -> Result; + fn new_filter(&self, Filter) -> Result; /// Returns id of new block filter. #[rpc(name = "eth_newBlockFilter")] - fn new_block_filter(&self) -> Result; + fn new_block_filter(&self) -> Result; /// Returns id of new block filter. #[rpc(name = "eth_newPendingTransactionFilter")] - fn new_pending_transaction_filter(&self) -> Result; + fn new_pending_transaction_filter(&self) -> Result; /// Returns filter changes since last poll. #[rpc(name = "eth_getFilterChanges")] - fn filter_changes(&self, Index) -> BoxFuture; + fn filter_changes(&self, Index) -> BoxFuture; /// Returns all logs matching given filter (in a range 'from' - 'to'). #[rpc(name = "eth_getFilterLogs")] - fn filter_logs(&self, Index) -> BoxFuture, Error>; + fn filter_logs(&self, Index) -> BoxFuture>; /// Uninstalls filter. #[rpc(name = "eth_uninstallFilter")] - fn uninstall_filter(&self, Index) -> Result; + fn uninstall_filter(&self, Index) -> Result; } } diff --git a/rpc/src/v1/traits/eth_pubsub.rs b/rpc/src/v1/traits/eth_pubsub.rs index 12d637862..cfbe4c54b 100644 --- a/rpc/src/v1/traits/eth_pubsub.rs +++ b/rpc/src/v1/traits/eth_pubsub.rs @@ -16,7 +16,7 @@ //! Eth PUB-SUB rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; use jsonrpc_pubsub::SubscriptionId; @@ -35,7 +35,7 @@ build_rpc_trait! { /// Unsubscribe from existing Eth subscription. #[rpc(name = "eth_unsubscribe")] - fn unsubscribe(&self, SubscriptionId) -> Result; + fn unsubscribe(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/eth_signing.rs b/rpc/src/v1/traits/eth_signing.rs index 1b84fe3f8..9830ac54d 100644 --- a/rpc/src/v1/traits/eth_signing.rs +++ b/rpc/src/v1/traits/eth_signing.rs @@ -16,7 +16,7 @@ //! Eth rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::BoxFuture; use v1::types::{Bytes, H160, H256, H520, TransactionRequest, RichRawTransaction}; @@ -27,18 +27,18 @@ build_rpc_trait! { /// Signs the hash of data with given address signature. #[rpc(meta, name = "eth_sign")] - fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; + fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; /// Sends transaction; will block waiting for signer to return the /// transaction hash. /// If Signer is disable it will require the account to be unlocked. #[rpc(meta, name = "eth_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; /// Signs transactions without dispatching it to the network. /// Returns signed transaction RLP representation and the transaction itself. /// It can be later submitted using `eth_sendRawTransaction/eth_submitTransaction`. #[rpc(meta, name = "eth_signTransaction")] - fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/net.rs b/rpc/src/v1/traits/net.rs index 109c10344..bc2068ff9 100644 --- a/rpc/src/v1/traits/net.rs +++ b/rpc/src/v1/traits/net.rs @@ -15,22 +15,22 @@ // along with Parity. If not, see . //! Net rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; build_rpc_trait! { /// Net rpc interface. pub trait Net { /// Returns protocol version. #[rpc(name = "net_version")] - fn version(&self) -> Result; + fn version(&self) -> Result; /// Returns number of peers connected to node. #[rpc(name = "net_peerCount")] - fn peer_count(&self) -> Result; + fn peer_count(&self) -> Result; /// Returns true if client is actively listening for network connections. /// Otherwise false. #[rpc(name = "net_listening")] - fn is_listening(&self) -> Result; + fn is_listening(&self) -> Result; } } diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 7e1fc9a21..81c406fb3 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_macros::Trailing; use node_health::Health; @@ -38,188 +38,188 @@ build_rpc_trait! { /// Returns accounts information. #[rpc(name = "parity_accountsInfo")] - fn accounts_info(&self, Trailing) -> Result, Error>; + fn accounts_info(&self, Trailing) -> Result>; /// Returns hardware accounts information. #[rpc(name = "parity_hardwareAccountsInfo")] - fn hardware_accounts_info(&self) -> Result, Error>; + fn hardware_accounts_info(&self) -> Result>; /// Get a list of paths to locked hardware wallets #[rpc(name = "parity_lockedHardwareAccountsInfo")] - fn locked_hardware_accounts_info(&self) -> Result, Error>; + fn locked_hardware_accounts_info(&self) -> Result>; /// Returns default account for dapp. #[rpc(meta, name = "parity_defaultAccount")] - fn default_account(&self, Self::Metadata) -> Result; + fn default_account(&self, Self::Metadata) -> Result; /// Returns current transactions limit. #[rpc(name = "parity_transactionsLimit")] - fn transactions_limit(&self) -> Result; + fn transactions_limit(&self) -> Result; /// Returns mining extra data. #[rpc(name = "parity_extraData")] - fn extra_data(&self) -> Result; + fn extra_data(&self) -> Result; /// Returns mining gas floor target. #[rpc(name = "parity_gasFloorTarget")] - fn gas_floor_target(&self) -> Result; + fn gas_floor_target(&self) -> Result; /// Returns mining gas floor cap. #[rpc(name = "parity_gasCeilTarget")] - fn gas_ceil_target(&self) -> Result; + fn gas_ceil_target(&self) -> Result; /// Returns minimal gas price for transaction to be included in queue. #[rpc(name = "parity_minGasPrice")] - fn min_gas_price(&self) -> Result; + fn min_gas_price(&self) -> Result; /// Returns latest logs #[rpc(name = "parity_devLogs")] - fn dev_logs(&self) -> Result, Error>; + fn dev_logs(&self) -> Result>; /// Returns logs levels #[rpc(name = "parity_devLogsLevels")] - fn dev_logs_levels(&self) -> Result; + fn dev_logs_levels(&self) -> Result; /// Returns chain name - DEPRECATED. Use `parity_chainName` instead. #[rpc(name = "parity_netChain")] - fn net_chain(&self) -> Result; + fn net_chain(&self) -> Result; /// Returns peers details #[rpc(name = "parity_netPeers")] - fn net_peers(&self) -> Result; + fn net_peers(&self) -> Result; /// Returns network port #[rpc(name = "parity_netPort")] - fn net_port(&self) -> Result; + fn net_port(&self) -> Result; /// Returns rpc settings #[rpc(name = "parity_rpcSettings")] - fn rpc_settings(&self) -> Result; + fn rpc_settings(&self) -> Result; /// Returns node name #[rpc(name = "parity_nodeName")] - fn node_name(&self) -> Result; + fn node_name(&self) -> Result; /// Returns default extra data #[rpc(name = "parity_defaultExtraData")] - fn default_extra_data(&self) -> Result; + fn default_extra_data(&self) -> Result; /// Returns distribution of gas price in latest blocks. #[rpc(name = "parity_gasPriceHistogram")] - fn gas_price_histogram(&self) -> BoxFuture; + fn gas_price_histogram(&self) -> BoxFuture; /// Returns number of unsigned transactions waiting in the signer queue (if signer enabled) /// Returns error when signer is disabled #[rpc(name = "parity_unsignedTransactionsCount")] - fn unsigned_transactions_count(&self) -> Result; + fn unsigned_transactions_count(&self) -> Result; /// Returns a cryptographically random phrase sufficient for securely seeding a secret key. #[rpc(name = "parity_generateSecretPhrase")] - fn generate_secret_phrase(&self) -> Result; + fn generate_secret_phrase(&self) -> Result; /// Returns whatever address would be derived from the given phrase if it were to seed a brainwallet. #[rpc(name = "parity_phraseToAddress")] - fn phrase_to_address(&self, String) -> Result; + fn phrase_to_address(&self, String) -> Result; /// Returns the value of the registrar for this network. #[rpc(name = "parity_registryAddress")] - fn registry_address(&self) -> Result, Error>; + fn registry_address(&self) -> Result>; /// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not. #[rpc(name = "parity_listAccounts")] - fn list_accounts(&self, u64, Option, Trailing) -> Result>, Error>; + fn list_accounts(&self, u64, Option, Trailing) -> Result>>; /// Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), /// or null if not. #[rpc(name = "parity_listStorageKeys")] - fn list_storage_keys(&self, H160, u64, Option, Trailing) -> Result>, Error>; + fn list_storage_keys(&self, H160, u64, Option, Trailing) -> Result>>; /// Encrypt some data with a public key under ECIES. /// First parameter is the 512-byte destination public key, second is the message. #[rpc(name = "parity_encryptMessage")] - fn encrypt_message(&self, H512, Bytes) -> Result; + fn encrypt_message(&self, H512, Bytes) -> Result; /// Returns all pending transactions from transaction queue. #[rpc(name = "parity_pendingTransactions")] - fn pending_transactions(&self) -> Result, Error>; + fn pending_transactions(&self) -> Result>; /// Returns all future transactions from transaction queue. #[rpc(name = "parity_futureTransactions")] - fn future_transactions(&self) -> Result, Error>; + fn future_transactions(&self) -> Result>; /// Returns propagation statistics on transactions pending in the queue. #[rpc(name = "parity_pendingTransactionsStats")] - fn pending_transactions_stats(&self) -> Result, Error>; + fn pending_transactions_stats(&self) -> Result>; /// Returns a list of current and past local transactions with status details. #[rpc(name = "parity_localTransactions")] - fn local_transactions(&self) -> Result, Error>; + fn local_transactions(&self) -> Result>; /// Returns current Dapps Server interface and port or an error if dapps server is disabled. #[rpc(name = "parity_dappsUrl")] - fn dapps_url(&self) -> Result; + fn dapps_url(&self) -> Result; /// Returns current WS Server interface and port or an error if ws server is disabled. #[rpc(name = "parity_wsUrl")] - fn ws_url(&self) -> Result; + fn ws_url(&self) -> Result; /// Returns next nonce for particular sender. Should include all transactions in the queue. #[rpc(name = "parity_nextNonce")] - fn next_nonce(&self, H160) -> BoxFuture; + fn next_nonce(&self, H160) -> BoxFuture; /// Get the mode. Returns one of: "active", "passive", "dark", "offline". #[rpc(name = "parity_mode")] - fn mode(&self) -> Result; + fn mode(&self) -> Result; /// Returns the chain ID used for transaction signing at the /// current best block. An empty string is returned if not /// available. #[rpc(name = "parity_chainId")] - fn chain_id(&self) -> Result, Error>; + fn chain_id(&self) -> Result>; /// Get the chain name. Returns one of: "foundation", "kovan", &c. of a filename. #[rpc(name = "parity_chain")] - fn chain(&self) -> Result; + fn chain(&self) -> Result; /// Get the enode of this node. #[rpc(name = "parity_enode")] - fn enode(&self) -> Result; + fn enode(&self) -> Result; /// Returns information on current consensus capability. #[rpc(name = "parity_consensusCapability")] - fn consensus_capability(&self) -> Result; + fn consensus_capability(&self) -> Result; /// Get our version information in a nice object. #[rpc(name = "parity_versionInfo")] - fn version_info(&self) -> Result; + fn version_info(&self) -> Result; /// Get information concerning the latest releases if available. #[rpc(name = "parity_releasesInfo")] - fn releases_info(&self) -> Result, Error>; + fn releases_info(&self) -> Result>; /// Get the current chain status. #[rpc(name = "parity_chainStatus")] - fn chain_status(&self) -> Result; + fn chain_status(&self) -> Result; /// Get node kind info. #[rpc(name = "parity_nodeKind")] - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error>; + fn node_kind(&self) -> Result<::v1::types::NodeKind>; /// Get block header. /// Same as `eth_getBlockByNumber` but without uncles and transactions. #[rpc(name = "parity_getBlockHeaderByNumber")] - fn block_header(&self, Trailing) -> BoxFuture; + fn block_header(&self, Trailing) -> BoxFuture; /// Get IPFS CIDv0 given protobuf encoded bytes. #[rpc(name = "parity_cidV0")] - fn ipfs_cid(&self, Bytes) -> Result; + fn ipfs_cid(&self, Bytes) -> Result; /// Call contract, returning the output data. #[rpc(meta, name = "parity_call")] - fn call(&self, Self::Metadata, Vec, Trailing) -> Result, Error>; + fn call(&self, Self::Metadata, Vec, Trailing) -> Result>; /// Returns node's health report. #[rpc(name = "parity_nodeHealth")] - fn node_health(&self) -> BoxFuture; + fn node_health(&self) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/parity_accounts.rs b/rpc/src/v1/traits/parity_accounts.rs index f7bdc1172..494f1576c 100644 --- a/rpc/src/v1/traits/parity_accounts.rs +++ b/rpc/src/v1/traits/parity_accounts.rs @@ -17,7 +17,7 @@ //! Parity Accounts-related rpc interface. use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethstore::KeyFile; use v1::types::{H160, H256, H520, DappId, DeriveHash, DeriveHierarchical, ExtAccountInfo}; @@ -26,167 +26,167 @@ build_rpc_trait! { pub trait ParityAccounts { /// Returns accounts information. #[rpc(name = "parity_allAccountsInfo")] - fn all_accounts_info(&self) -> Result, Error>; + fn all_accounts_info(&self) -> Result>; /// Creates new account from the given phrase using standard brainwallet mechanism. /// Second parameter is password for the new account. #[rpc(name = "parity_newAccountFromPhrase")] - fn new_account_from_phrase(&self, String, String) -> Result; + fn new_account_from_phrase(&self, String, String) -> Result; /// Creates new account from the given JSON wallet. /// Second parameter is password for the wallet and the new account. #[rpc(name = "parity_newAccountFromWallet")] - fn new_account_from_wallet(&self, String, String) -> Result; + fn new_account_from_wallet(&self, String, String) -> Result; /// Creates new account from the given raw secret. /// Second parameter is password for the new account. #[rpc(name = "parity_newAccountFromSecret")] - fn new_account_from_secret(&self, H256, String) -> Result; + fn new_account_from_secret(&self, H256, String) -> Result; /// Returns true if given `password` would unlock given `account`. /// Arguments: `account`, `password`. #[rpc(name = "parity_testPassword")] - fn test_password(&self, H160, String) -> Result; + fn test_password(&self, H160, String) -> Result; /// Changes an account's password. /// Arguments: `account`, `password`, `new_password`. #[rpc(name = "parity_changePassword")] - fn change_password(&self, H160, String, String) -> Result; + fn change_password(&self, H160, String, String) -> Result; /// Permanently deletes an account. /// Arguments: `account`, `password`. #[rpc(name = "parity_killAccount")] - fn kill_account(&self, H160, String) -> Result; + fn kill_account(&self, H160, String) -> Result; /// Permanently deletes an address from the addressbook /// Arguments: `address` #[rpc(name = "parity_removeAddress")] - fn remove_address(&self, H160) -> Result; + fn remove_address(&self, H160) -> Result; /// Set an account's name. #[rpc(name = "parity_setAccountName")] - fn set_account_name(&self, H160, String) -> Result; + fn set_account_name(&self, H160, String) -> Result; /// Set an account's metadata string. #[rpc(name = "parity_setAccountMeta")] - fn set_account_meta(&self, H160, String) -> Result; + fn set_account_meta(&self, H160, String) -> Result; /// Sets addresses exposed for particular dapp. /// Setting a non-empty list will also override default account. /// Setting `None` will resets visible account to what's visible for new dapps /// (does not affect default account though) #[rpc(name = "parity_setDappAddresses")] - fn set_dapp_addresses(&self, DappId, Option>) -> Result; + fn set_dapp_addresses(&self, DappId, Option>) -> Result; /// Gets accounts exposed for particular dapp. #[rpc(name = "parity_getDappAddresses")] - fn dapp_addresses(&self, DappId) -> Result, Error>; + fn dapp_addresses(&self, DappId) -> Result>; /// Changes dapp default address. /// Does not affect other accounts exposed for this dapp, but /// default account will always be retured as the first one. #[rpc(name = "parity_setDappDefaultAddress")] - fn set_dapp_default_address(&self, DappId, H160) -> Result; + fn set_dapp_default_address(&self, DappId, H160) -> Result; /// Returns current dapp default address. /// If not set explicite for the dapp will return global default. #[rpc(name = "parity_getDappDefaultAddress")] - fn dapp_default_address(&self, DappId) -> Result; + fn dapp_default_address(&self, DappId) -> Result; /// Sets accounts exposed for new dapps. /// Setting a non-empty list will also override default account. /// Setting `None` exposes all internal-managed accounts. /// (does not affect default account though) #[rpc(name = "parity_setNewDappsAddresses")] - fn set_new_dapps_addresses(&self, Option>) -> Result; + fn set_new_dapps_addresses(&self, Option>) -> Result; /// Gets accounts exposed for new dapps. /// `None` means that all accounts are exposes. #[rpc(name = "parity_getNewDappsAddresses")] - fn new_dapps_addresses(&self) -> Result>, Error>; + fn new_dapps_addresses(&self) -> Result>>; /// Changes default address for new dapps (global default address) /// Does not affect other accounts exposed for new dapps, but /// default account will always be retured as the first one. #[rpc(name = "parity_setNewDappsDefaultAddress")] - fn set_new_dapps_default_address(&self, H160) -> Result; + fn set_new_dapps_default_address(&self, H160) -> Result; /// Returns current default address for new dapps (global default address) /// In case it's not set explicite will return first available account. /// If no accounts are available will return `0x0` #[rpc(name = "parity_getNewDappsDefaultAddress")] - fn new_dapps_default_address(&self) -> Result; + fn new_dapps_default_address(&self) -> Result; /// Returns identified dapps that recently used RPC /// Includes last usage timestamp. #[rpc(name = "parity_listRecentDapps")] - fn recent_dapps(&self) -> Result, Error>; + fn recent_dapps(&self) -> Result>; /// Imports a number of Geth accounts, with the list provided as the argument. #[rpc(name = "parity_importGethAccounts")] - fn import_geth_accounts(&self, Vec) -> Result, Error>; + fn import_geth_accounts(&self, Vec) -> Result>; /// Returns the accounts available for importing from Geth. #[rpc(name = "parity_listGethAccounts")] - fn geth_accounts(&self) -> Result, Error>; + fn geth_accounts(&self) -> Result>; /// Create new vault. #[rpc(name = "parity_newVault")] - fn create_vault(&self, String, String) -> Result; + fn create_vault(&self, String, String) -> Result; /// Open existing vault. #[rpc(name = "parity_openVault")] - fn open_vault(&self, String, String) -> Result; + fn open_vault(&self, String, String) -> Result; /// Close previously opened vault. #[rpc(name = "parity_closeVault")] - fn close_vault(&self, String) -> Result; + fn close_vault(&self, String) -> Result; /// List all vaults. #[rpc(name = "parity_listVaults")] - fn list_vaults(&self) -> Result, Error>; + fn list_vaults(&self) -> Result>; /// List all currently opened vaults. #[rpc(name = "parity_listOpenedVaults")] - fn list_opened_vaults(&self) -> Result, Error>; + fn list_opened_vaults(&self) -> Result>; /// Change vault password. #[rpc(name = "parity_changeVaultPassword")] - fn change_vault_password(&self, String, String) -> Result; + fn change_vault_password(&self, String, String) -> Result; /// Change vault of the given address. #[rpc(name = "parity_changeVault")] - fn change_vault(&self, H160, String) -> Result; + fn change_vault(&self, H160, String) -> Result; /// Get vault metadata string. #[rpc(name = "parity_getVaultMeta")] - fn get_vault_meta(&self, String) -> Result; + fn get_vault_meta(&self, String) -> Result; /// Set vault metadata string. #[rpc(name = "parity_setVaultMeta")] - fn set_vault_meta(&self, String, String) -> Result; + fn set_vault_meta(&self, String, String) -> Result; /// Derive new address from given account address using specific hash. /// Resulting address can be either saved as a new account (with the same password). #[rpc(name = "parity_deriveAddressHash")] - fn derive_key_hash(&self, H160, String, DeriveHash, bool) -> Result; + fn derive_key_hash(&self, H160, String, DeriveHash, bool) -> Result; /// Derive new address from given account address using /// hierarchical derivation (sequence of 32-bit integer indices). /// Resulting address can be either saved as a new account (with the same password). #[rpc(name = "parity_deriveAddressIndex")] - fn derive_key_index(&self, H160, String, DeriveHierarchical, bool) -> Result; + fn derive_key_index(&self, H160, String, DeriveHierarchical, bool) -> Result; /// Exports an account with given address if provided password matches. #[rpc(name = "parity_exportAccount")] - fn export_account(&self, H160, String) -> Result; + fn export_account(&self, H160, String) -> Result; /// Sign raw hash with the key corresponding to address and password. #[rpc(name = "parity_signMessage")] - fn sign_message(&self, H160, String, H256) -> Result; + fn sign_message(&self, H160, String, H256) -> Result; /// Send a PinMatrixAck to a hardware wallet, unlocking it #[rpc(name = "parity_hardwarePinMatrixAck")] - fn hardware_pin_matrix_ack(&self, String, String) -> Result; + fn hardware_pin_matrix_ack(&self, String, String) -> Result; } } diff --git a/rpc/src/v1/traits/parity_set.rs b/rpc/src/v1/traits/parity_set.rs index 7b3c593dc..40aad1a4b 100644 --- a/rpc/src/v1/traits/parity_set.rs +++ b/rpc/src/v1/traits/parity_set.rs @@ -16,7 +16,7 @@ //! Parity-specific rpc interface for operations altering the settings. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction, LocalDapp}; @@ -25,91 +25,91 @@ build_rpc_trait! { pub trait ParitySet { /// Sets new minimal gas price for mined blocks. #[rpc(name = "parity_setMinGasPrice")] - fn set_min_gas_price(&self, U256) -> Result; + fn set_min_gas_price(&self, U256) -> Result; /// Sets new gas floor target for mined blocks. #[rpc(name = "parity_setGasFloorTarget")] - fn set_gas_floor_target(&self, U256) -> Result; + fn set_gas_floor_target(&self, U256) -> Result; /// Sets new gas ceiling target for mined blocks. #[rpc(name = "parity_setGasCeilTarget")] - fn set_gas_ceil_target(&self, U256) -> Result; + fn set_gas_ceil_target(&self, U256) -> Result; /// Sets new extra data for mined blocks. #[rpc(name = "parity_setExtraData")] - fn set_extra_data(&self, Bytes) -> Result; + fn set_extra_data(&self, Bytes) -> Result; /// Sets new author for mined block. #[rpc(name = "parity_setAuthor")] - fn set_author(&self, H160) -> Result; + fn set_author(&self, H160) -> Result; /// Sets account for signing consensus messages. #[rpc(name = "parity_setEngineSigner")] - fn set_engine_signer(&self, H160, String) -> Result; + fn set_engine_signer(&self, H160, String) -> Result; /// Sets the limits for transaction queue. #[rpc(name = "parity_setTransactionsLimit")] - fn set_transactions_limit(&self, usize) -> Result; + fn set_transactions_limit(&self, usize) -> Result; /// Sets the maximum amount of gas a single transaction may consume. #[rpc(name = "parity_setMaxTransactionGas")] - fn set_tx_gas_limit(&self, U256) -> Result; + fn set_tx_gas_limit(&self, U256) -> Result; /// Add a reserved peer. #[rpc(name = "parity_addReservedPeer")] - fn add_reserved_peer(&self, String) -> Result; + fn add_reserved_peer(&self, String) -> Result; /// Remove a reserved peer. #[rpc(name = "parity_removeReservedPeer")] - fn remove_reserved_peer(&self, String) -> Result; + fn remove_reserved_peer(&self, String) -> Result; /// Drop all non-reserved peers. #[rpc(name = "parity_dropNonReservedPeers")] - fn drop_non_reserved_peers(&self) -> Result; + fn drop_non_reserved_peers(&self) -> Result; /// Accept non-reserved peers (default behavior) #[rpc(name = "parity_acceptNonReservedPeers")] - fn accept_non_reserved_peers(&self) -> Result; + fn accept_non_reserved_peers(&self) -> Result; /// Start the network. /// /// @deprecated - Use `set_mode("active")` instead. #[rpc(name = "parity_startNetwork")] - fn start_network(&self) -> Result; + fn start_network(&self) -> Result; /// Stop the network. /// /// @deprecated - Use `set_mode("offline")` instead. #[rpc(name = "parity_stopNetwork")] - fn stop_network(&self) -> Result; + fn stop_network(&self) -> Result; /// Set the mode. Argument must be one of: "active", "passive", "dark", "offline". #[rpc(name = "parity_setMode")] - fn set_mode(&self, String) -> Result; + fn set_mode(&self, String) -> Result; /// Set the network spec. Argument must be one of: "foundation", "ropsten", "morden", "kovan", "olympic", "classic", "dev", "expanse", "musicoin" or a filename. #[rpc(name = "parity_setChain")] - fn set_spec_name(&self, String) -> Result; + fn set_spec_name(&self, String) -> Result; /// Hash a file content under given URL. #[rpc(name = "parity_hashContent")] - fn hash_content(&self, String) -> BoxFuture; + fn hash_content(&self, String) -> BoxFuture; /// Returns true if refresh successful, error if unsuccessful or server is disabled. #[rpc(name = "parity_dappsRefresh")] - fn dapps_refresh(&self) -> Result; + fn dapps_refresh(&self) -> Result; /// Returns a list of local dapps #[rpc(name = "parity_dappsList")] - fn dapps_list(&self) -> Result, Error>; + fn dapps_list(&self) -> Result>; /// Is there a release ready for install? #[rpc(name = "parity_upgradeReady")] - fn upgrade_ready(&self) -> Result, Error>; + fn upgrade_ready(&self) -> Result>; /// Execute a release which is ready according to upgrade_ready(). #[rpc(name = "parity_executeUpgrade")] - fn execute_upgrade(&self) -> Result; + fn execute_upgrade(&self) -> Result; /// Removes transaction from transaction queue. /// Makes sense only for transactions that were not propagated to other peers yet @@ -118,6 +118,6 @@ build_rpc_trait! { /// or excessive gas limit that are not accepted by other peers whp. /// Returns `true` when transaction was removed, `false` if it was not found. #[rpc(name = "parity_removeTransaction")] - fn remove_transaction(&self, H256) -> Result, Error>; + fn remove_transaction(&self, H256) -> Result>; } } diff --git a/rpc/src/v1/traits/parity_signing.rs b/rpc/src/v1/traits/parity_signing.rs index cf20dba36..8015b0431 100644 --- a/rpc/src/v1/traits/parity_signing.rs +++ b/rpc/src/v1/traits/parity_signing.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! ParitySigning rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{U256, H160, Bytes, ConfirmationResponse, TransactionRequest, Either}; @@ -27,26 +27,26 @@ build_rpc_trait! { /// Given partial transaction request produces transaction with all fields filled in. /// Such transaction can be then signed externally. #[rpc(meta, name = "parity_composeTransaction")] - fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; /// Posts sign request asynchronously. /// Will return a confirmation ID for later use with check_transaction. #[rpc(meta, name = "parity_postSign")] - fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture, Error>; + fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture>; /// Posts transaction asynchronously. /// Will return a transaction ID for later use with check_transaction. #[rpc(meta, name = "parity_postTransaction")] - fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture, Error>; + fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture>; /// Checks the progress of a previously posted request (transaction/sign). /// Should be given a valid send_transaction ID. #[rpc(name = "parity_checkRequest")] - fn check_request(&self, U256) -> Result, Error>; + fn check_request(&self, U256) -> Result>; /// Decrypt some ECIES-encrypted message. /// First parameter is the address with which it is encrypted, second is the ciphertext. #[rpc(meta, name = "parity_decryptMessage")] - fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; + fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/personal.rs b/rpc/src/v1/traits/personal.rs index a8f575c30..3d6d29b28 100644 --- a/rpc/src/v1/traits/personal.rs +++ b/rpc/src/v1/traits/personal.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Personal rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{U128, H160, H256, TransactionRequest}; @@ -26,24 +26,24 @@ build_rpc_trait! { /// Lists all stored accounts #[rpc(name = "personal_listAccounts")] - fn accounts(&self) -> Result, Error>; + fn accounts(&self) -> Result>; /// Creates new account (it becomes new current unlocked account) /// Param is the password for the account. #[rpc(name = "personal_newAccount")] - fn new_account(&self, String) -> Result; + fn new_account(&self, String) -> Result; /// Unlocks specified account for use (can only be one unlocked account at one moment) #[rpc(name = "personal_unlockAccount")] - fn unlock_account(&self, H160, String, Option) -> Result; + fn unlock_account(&self, H160, String, Option) -> Result; /// Sends transaction and signs it in single call. The account is not unlocked in such case. #[rpc(meta, name = "personal_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; /// @deprecated alias for `personal_sendTransaction`. #[rpc(meta, name = "personal_signAndSendTransaction")] - fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/pubsub.rs b/rpc/src/v1/traits/pubsub.rs index 27d79c911..0b77fc64d 100644 --- a/rpc/src/v1/traits/pubsub.rs +++ b/rpc/src/v1/traits/pubsub.rs @@ -16,7 +16,7 @@ //! Parity-specific PUB-SUB rpc interface. -use jsonrpc_core::{Error, Value, Params}; +use jsonrpc_core::{Result, Value, Params}; use jsonrpc_pubsub::SubscriptionId; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; @@ -33,7 +33,7 @@ build_rpc_trait! { /// Unsubscribe from existing Parity subscription. #[rpc(name = "parity_unsubscribe")] - fn parity_unsubscribe(&self, SubscriptionId) -> Result; + fn parity_unsubscribe(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/rpc.rs b/rpc/src/v1/traits/rpc.rs index 96a3f48ac..a813aa94e 100644 --- a/rpc/src/v1/traits/rpc.rs +++ b/rpc/src/v1/traits/rpc.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; build_rpc_trait! { /// RPC Interface. @@ -26,11 +26,11 @@ build_rpc_trait! { /// Returns supported modules for Geth 1.3.6 /// @ignore #[rpc(name = "modules")] - fn modules(&self) -> Result, Error>; + fn modules(&self) -> Result>; /// Returns supported modules for Geth 1.4.0 /// @ignore #[rpc(name = "rpc_modules")] - fn rpc_modules(&self) -> Result, Error>; + fn rpc_modules(&self) -> Result>; } } diff --git a/rpc/src/v1/traits/secretstore.rs b/rpc/src/v1/traits/secretstore.rs index c13367562..e625cf331 100644 --- a/rpc/src/v1/traits/secretstore.rs +++ b/rpc/src/v1/traits/secretstore.rs @@ -16,7 +16,7 @@ //! SecretStore-specific rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::types::{H160, H512, Bytes}; @@ -26,16 +26,16 @@ build_rpc_trait! { /// Encrypt data with key, received from secret store. /// Arguments: `account`, `password`, `key`, `data`. #[rpc(name = "secretstore_encrypt")] - fn encrypt(&self, H160, String, Bytes, Bytes) -> Result; + fn encrypt(&self, H160, String, Bytes, Bytes) -> Result; /// Decrypt data with key, received from secret store. /// Arguments: `account`, `password`, `key`, `data`. #[rpc(name = "secretstore_decrypt")] - fn decrypt(&self, H160, String, Bytes, Bytes) -> Result; + fn decrypt(&self, H160, String, Bytes, Bytes) -> Result; /// Decrypt data with shadow key, received from secret store. /// Arguments: `account`, `password`, `decrypted_secret`, `common_point`, `decrypt_shadows`, `data`. #[rpc(name = "secretstore_shadowDecrypt")] - fn shadow_decrypt(&self, H160, String, H512, H512, Vec, Bytes) -> Result; + fn shadow_decrypt(&self, H160, String, H512, H512, Vec, Bytes) -> Result; } } diff --git a/rpc/src/v1/traits/signer.rs b/rpc/src/v1/traits/signer.rs index 107def9f2..b7f60619e 100644 --- a/rpc/src/v1/traits/signer.rs +++ b/rpc/src/v1/traits/signer.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Parity Signer-related rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_pubsub::SubscriptionId; use jsonrpc_macros::pubsub::Subscriber; @@ -28,31 +28,31 @@ build_rpc_trait! { /// Returns a list of items to confirm. #[rpc(name = "signer_requestsToConfirm")] - fn requests_to_confirm(&self) -> Result, Error>; + fn requests_to_confirm(&self) -> Result>; /// Confirm specific request. #[rpc(name = "signer_confirmRequest")] - fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; + fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; /// Confirm specific request with token. #[rpc(name = "signer_confirmRequestWithToken")] - fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; + fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; /// Confirm specific request with already signed data. #[rpc(name = "signer_confirmRequestRaw")] - fn confirm_request_raw(&self, U256, Bytes) -> Result; + fn confirm_request_raw(&self, U256, Bytes) -> Result; /// Reject the confirmation request. #[rpc(name = "signer_rejectRequest")] - fn reject_request(&self, U256) -> Result; + fn reject_request(&self, U256) -> Result; /// Generates new authorization token. #[rpc(name = "signer_generateAuthorizationToken")] - fn generate_token(&self) -> Result; + fn generate_token(&self) -> Result; /// Generates new web proxy access token for particular domain. #[rpc(name = "signer_generateWebProxyAccessToken")] - fn generate_web_proxy_token(&self, String) -> Result; + fn generate_web_proxy_token(&self, String) -> Result; #[pubsub(name = "signer_pending")] { /// Subscribe to new pending requests on signer interface. @@ -61,7 +61,7 @@ build_rpc_trait! { /// Unsubscribe from pending requests subscription. #[rpc(name = "signer_unsubscribePending")] - fn unsubscribe_pending(&self, SubscriptionId) -> Result; + fn unsubscribe_pending(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/traces.rs b/rpc/src/v1/traits/traces.rs index a6cb43810..35b601e3f 100644 --- a/rpc/src/v1/traits/traces.rs +++ b/rpc/src/v1/traits/traces.rs @@ -16,7 +16,7 @@ //! Traces specific rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, H256, TraceOptions}; @@ -27,34 +27,34 @@ build_rpc_trait! { /// Returns traces matching given filter. #[rpc(name = "trace_filter")] - fn filter(&self, TraceFilter) -> Result>, Error>; + fn filter(&self, TraceFilter) -> Result>>; /// Returns transaction trace at given index. #[rpc(name = "trace_get")] - fn trace(&self, H256, Vec) -> Result, Error>; + fn trace(&self, H256, Vec) -> Result>; /// Returns all traces of given transaction. #[rpc(name = "trace_transaction")] - fn transaction_traces(&self, H256) -> Result>, Error>; + fn transaction_traces(&self, H256) -> Result>>; /// Returns all traces produced at given block. #[rpc(name = "trace_block")] - fn block_traces(&self, BlockNumber) -> Result>, Error>; + fn block_traces(&self, BlockNumber) -> Result>>; /// Executes the given call and returns a number of possible traces for it. #[rpc(meta, name = "trace_call")] - fn call(&self, Self::Metadata, CallRequest, TraceOptions, Trailing) -> Result; + fn call(&self, Self::Metadata, CallRequest, TraceOptions, Trailing) -> Result; /// Executes all given calls and returns a number of possible traces for each of it. #[rpc(meta, name = "trace_callMany")] - fn call_many(&self, Self::Metadata, Vec<(CallRequest, TraceOptions)>, Trailing) -> Result, Error>; + fn call_many(&self, Self::Metadata, Vec<(CallRequest, TraceOptions)>, Trailing) -> Result>; /// Executes the given raw transaction and returns a number of possible traces for it. #[rpc(name = "trace_rawTransaction")] - fn raw_transaction(&self, Bytes, TraceOptions, Trailing) -> Result; + fn raw_transaction(&self, Bytes, TraceOptions, Trailing) -> Result; /// Executes the transaction with the given hash and returns a number of possible traces for it. #[rpc(name = "trace_replayTransaction")] - fn replay_transaction(&self, H256, TraceOptions) -> Result; + fn replay_transaction(&self, H256, TraceOptions) -> Result; } } diff --git a/rpc/src/v1/traits/web3.rs b/rpc/src/v1/traits/web3.rs index b56f028d7..e4fb8b0d1 100644 --- a/rpc/src/v1/traits/web3.rs +++ b/rpc/src/v1/traits/web3.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Web3 rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::types::{H256, Bytes}; @@ -24,10 +24,10 @@ build_rpc_trait! { pub trait Web3 { /// Returns current client version. #[rpc(name = "web3_clientVersion")] - fn client_version(&self) -> Result; + fn client_version(&self) -> Result; /// Returns sha3 of the given data #[rpc(name = "web3_sha3")] - fn sha3(&self, Bytes) -> Result; + fn sha3(&self, Bytes) -> Result; } } diff --git a/rpc_client/src/client.rs b/rpc_client/src/client.rs index fa6144fd2..8f330629b 100644 --- a/rpc_client/src/client.rs +++ b/rpc_client/src/client.rs @@ -33,10 +33,12 @@ use serde_json::{ use futures::{Canceled, Complete, Future, oneshot, done}; -use jsonrpc_core::{BoxFuture, Id, Version, Params, Error as JsonRpcError}; +use jsonrpc_core::{Id, Version, Params, Error as JsonRpcError}; use jsonrpc_core::request::MethodCall; use jsonrpc_core::response::{Output, Success, Failure}; +use BoxFuture; + /// The actual websocket connection handler, passed into the /// event loop of ws-rs struct RpcHandler { diff --git a/rpc_client/src/lib.rs b/rpc_client/src/lib.rs index 680c0484b..7981052ed 100644 --- a/rpc_client/src/lib.rs +++ b/rpc_client/src/lib.rs @@ -18,6 +18,8 @@ extern crate log; #[macro_use] extern crate matches; +/// Boxed future response. +pub type BoxFuture = Box + Send>; #[cfg(test)] mod tests { diff --git a/rpc_client/src/signer_client.rs b/rpc_client/src/signer_client.rs index df3744052..cee063109 100644 --- a/rpc_client/src/signer_client.rs +++ b/rpc_client/src/signer_client.rs @@ -4,7 +4,7 @@ use serde; use serde_json::{Value as JsonValue, to_value}; use std::path::PathBuf; use futures::{Canceled}; -use jsonrpc_core::BoxFuture; +use {BoxFuture}; pub struct SignerRpc { rpc: Rpc, diff --git a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs index 9c5f4087e..040360d7d 100644 --- a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs +++ b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs @@ -450,7 +450,7 @@ impl SessionImpl where T: SessionTransport { data.key_share_common_point = message.common_point.clone().map(Into::into); data.key_share_encrypted_point = message.encrypted_point.clone().map(Into::into); - let mut id_numbers = data.id_numbers.as_mut() + let id_numbers = data.id_numbers.as_mut() .expect("common key share data is expected after initialization; id_numers are filled during initialization; qed"); for (node, id_number) in &message.id_numbers { let id_number: Secret = id_number.clone().into(); @@ -1153,7 +1153,7 @@ pub mod tests { // check that session has completed on all nodes assert!(ml.nodes.values().all(|n| n.session.is_finished())); - + // check that secret is still the same as before adding the share check_secret_is_preserved(ml.original_key_pair.clone(), ml.nodes.iter().map(|(k, v)| (k.clone(), v.key_storage.clone())).collect()); } @@ -1187,7 +1187,7 @@ pub mod tests { // check that session has completed on all nodes assert!(ml.nodes.values().all(|n| n.session.is_finished())); - + // check that secret is still the same as before adding the share check_secret_is_preserved(ml.original_key_pair.clone(), ml.nodes .iter() @@ -1245,7 +1245,7 @@ pub mod tests { .iter() .map(|(k, v)| (k.clone(), v.key_storage.clone())) .collect()); - + // check that all oldest nodes have versions A, B, C // isolated node has version A, C // new nodes have versions B, C