Drop jsonrpc_core::Error
This commit is contained in:
parent
7e512c637a
commit
f7fa9f6e9d
@ -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<String, Box<Endpoint>>;
|
||||
pub type Response = BoxFuture<hyper::Response, hyper::Error>;
|
||||
pub type Response = Box<Future<Item=hyper::Response, Error=hyper::Error> + Send>;
|
||||
pub type Request = hyper::Request;
|
||||
|
||||
pub trait Endpoint : Send + Sync {
|
||||
|
@ -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<FetchState, ()>),
|
||||
InProgress(Box<Future<Item=FetchState, Error=()> + Send>),
|
||||
Streaming(hyper::Response),
|
||||
Done(local::Dapp, endpoint::Response),
|
||||
Empty,
|
||||
@ -289,7 +288,7 @@ impl ContentFetcherHandler {
|
||||
path: EndpointPath,
|
||||
errors: Errors,
|
||||
installer: H,
|
||||
) -> BoxFuture<FetchState, ()> {
|
||||
) -> Box<Future<Item=FetchState, Error=()> + Send> {
|
||||
// Start fetching the content
|
||||
let fetch2 = fetch.clone();
|
||||
let future = fetch.fetch_with_abort(url, abort.into()).then(move |result| {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -14,8 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<T: Fetch> ServerBuilder<T> {
|
||||
|
||||
/// 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<Server, http::Error> {
|
||||
pub fn start_unsecured_http(self, addr: &SocketAddr, io: IoHandler) -> io::Result<Server> {
|
||||
let fetch = self.fetch_client();
|
||||
Server::start_http(
|
||||
addr,
|
||||
@ -234,7 +233,7 @@ impl Server {
|
||||
remote: Remote,
|
||||
fetch: F,
|
||||
serve_ui: bool,
|
||||
) -> Result<Server, http::Error> {
|
||||
) -> io::Result<Server> {
|
||||
let health = NodeHealth::new(
|
||||
sync_status.clone(),
|
||||
TimeChecker::new::<String>(&[], CpuPool::new(1)),
|
||||
|
@ -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<Bytes, String> {
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item=Bytes, Error=String> + Send> {
|
||||
Box::new(self.client.call_contract(BlockId::Latest, address, data)
|
||||
.into_future())
|
||||
}
|
||||
@ -105,7 +104,7 @@ impl<T: LightChainClient + 'static> ContractClient for LightRegistrar<T> {
|
||||
})
|
||||
}
|
||||
|
||||
fn call(&self, address: Address, data: Bytes) -> BoxFuture<Bytes, String> {
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item=Bytes, Error=String> + 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()));
|
||||
|
@ -246,7 +246,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
|
||||
|
||||
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<D: rpc_apis::Dependencies>(
|
||||
|
||||
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)),
|
||||
|
@ -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<http::Error> 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<M, S, H, T, R>(
|
||||
addr: &SocketAddr,
|
||||
@ -147,7 +127,7 @@ pub fn start_http<M, S, H, T, R>(
|
||||
extractor: T,
|
||||
middleware: Option<R>,
|
||||
threads: usize,
|
||||
) -> Result<HttpServer, HttpServerError> where
|
||||
) -> ::std::io::Result<HttpServer> where
|
||||
M: jsonrpc_core::Metadata,
|
||||
S: jsonrpc_core::Middleware<M>,
|
||||
H: Into<jsonrpc_core::MetaIoHandler<M, S>>,
|
||||
|
@ -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<FilledTransactionRequest, Error>;
|
||||
-> BoxFuture<FilledTransactionRequest>;
|
||||
|
||||
/// Sign the given transaction request without dispatching, fetching appropriate nonce.
|
||||
fn sign(&self, accounts: Arc<AccountProvider>, filled: FilledTransactionRequest, password: SignWith)
|
||||
-> BoxFuture<WithToken<SignedTransaction>, Error>;
|
||||
-> BoxFuture<WithToken<SignedTransaction>>;
|
||||
|
||||
/// Converts a `SignedTransaction` into `RichRawTransaction`
|
||||
fn enrich(&self, SignedTransaction) -> RpcRichRawTransaction;
|
||||
|
||||
/// "Dispatch" a local transaction.
|
||||
fn dispatch_transaction(&self, signed_transaction: PendingTransaction)
|
||||
-> Result<H256, Error>;
|
||||
-> Result<H256>;
|
||||
}
|
||||
|
||||
/// A dispatcher which uses references to a client and miner in order to sign
|
||||
@ -118,7 +118,7 @@ impl<C: MiningBlockChainClient, M: MinerService> FullDispatcher<C, M> {
|
||||
}
|
||||
|
||||
/// Imports transaction to the miner's queue.
|
||||
pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result<H256, Error> {
|
||||
pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result<H256> {
|
||||
let hash = signed_transaction.transaction.hash();
|
||||
|
||||
miner.import_own_transaction(client, signed_transaction)
|
||||
@ -129,7 +129,7 @@ impl<C: MiningBlockChainClient, M: MinerService> FullDispatcher<C, M> {
|
||||
|
||||
impl<C: MiningBlockChainClient, M: MinerService> Dispatcher for FullDispatcher<C, M> {
|
||||
fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool)
|
||||
-> BoxFuture<FilledTransactionRequest, Error>
|
||||
-> BoxFuture<FilledTransactionRequest>
|
||||
{
|
||||
let request = request;
|
||||
let from = request.from.unwrap_or(default_sender);
|
||||
@ -153,7 +153,7 @@ impl<C: MiningBlockChainClient, M: MinerService> Dispatcher for FullDispatcher<C
|
||||
}
|
||||
|
||||
fn sign(&self, accounts: Arc<AccountProvider>, filled: FilledTransactionRequest, password: SignWith)
|
||||
-> BoxFuture<WithToken<SignedTransaction>, Error>
|
||||
-> BoxFuture<WithToken<SignedTransaction>>
|
||||
{
|
||||
let chain_id = self.client.signing_chain_id();
|
||||
|
||||
@ -171,7 +171,7 @@ impl<C: MiningBlockChainClient, M: MinerService> Dispatcher for FullDispatcher<C
|
||||
RpcRichRawTransaction::from_signed(signed_transaction, block_number, self.client.eip86_transition())
|
||||
}
|
||||
|
||||
fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result<H256, Error> {
|
||||
fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result<H256> {
|
||||
Self::dispatch_transaction(&*self.client, &*self.miner, signed_transaction)
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ pub fn fetch_gas_price_corpus(
|
||||
client: Arc<LightChainClient>,
|
||||
on_demand: Arc<OnDemand>,
|
||||
cache: Arc<Mutex<LightDataCache>>,
|
||||
) -> BoxFuture<Corpus<U256>, Error> {
|
||||
) -> BoxFuture<Corpus<U256>> {
|
||||
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<Corpus<U256>, Error> {
|
||||
pub fn gas_price_corpus(&self) -> BoxFuture<Corpus<U256>> {
|
||||
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<U256, Error> {
|
||||
pub fn next_nonce(&self, addr: Address) -> BoxFuture<U256> {
|
||||
// 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<FilledTransactionRequest, Error>
|
||||
-> BoxFuture<FilledTransactionRequest>
|
||||
{
|
||||
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<AccountProvider>, filled: FilledTransactionRequest, password: SignWith)
|
||||
-> BoxFuture<WithToken<SignedTransaction>, Error>
|
||||
-> BoxFuture<WithToken<SignedTransaction>>
|
||||
{
|
||||
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<H256, Error> {
|
||||
fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result<H256> {
|
||||
let hash = signed_transaction.transaction.hash();
|
||||
|
||||
self.transaction_queue.write().import(signed_transaction)
|
||||
@ -408,7 +408,7 @@ fn sign_transaction(
|
||||
chain_id: Option<u64>,
|
||||
nonce: U256,
|
||||
password: SignWith,
|
||||
) -> Result<WithToken<SignedTransaction>, Error> {
|
||||
) -> Result<WithToken<SignedTransaction>> {
|
||||
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<Result<WithToken<SignedTransaction>, Error>>,
|
||||
prospective: Option<Result<WithToken<SignedTransaction>>>,
|
||||
ready: Option<nonce::Ready>,
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ impl ProspectiveSigner {
|
||||
}
|
||||
}
|
||||
|
||||
fn sign(&self, nonce: &U256) -> Result<WithToken<SignedTransaction>, Error> {
|
||||
fn sign(&self, nonce: &U256) -> Result<WithToken<SignedTransaction>> {
|
||||
sign_transaction(
|
||||
&*self.accounts,
|
||||
self.filled.clone(),
|
||||
@ -637,7 +637,7 @@ pub fn execute<D: Dispatcher + 'static>(
|
||||
accounts: Arc<AccountProvider>,
|
||||
payload: ConfirmationPayload,
|
||||
pass: SignWith
|
||||
) -> BoxFuture<WithToken<ConfirmationResponse>, Error> {
|
||||
) -> BoxFuture<WithToken<ConfirmationResponse>> {
|
||||
match payload {
|
||||
ConfirmationPayload::SendTransaction(request) => {
|
||||
let condition = request.condition.clone().map(Into::into);
|
||||
@ -688,7 +688,7 @@ pub fn execute<D: Dispatcher + 'static>(
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result<WithToken<Signature>, Error> {
|
||||
fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result<WithToken<Signature>> {
|
||||
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<u64>)
|
||||
-> Result<SignedTransaction, Error>
|
||||
-> Result<SignedTransaction>
|
||||
{
|
||||
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<WithToken<Bytes>, Error> {
|
||||
fn decrypt(accounts: &AccountProvider, address: Address, msg: Bytes, password: SignWith) -> Result<WithToken<Bytes>> {
|
||||
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<C, M>(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<D>(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture<ConfirmationPayload, Error>
|
||||
pub fn from_rpc<D>(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture<ConfirmationPayload>
|
||||
where D: Dispatcher
|
||||
{
|
||||
match payload {
|
||||
|
@ -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<Executed, ExecutionError>;
|
||||
pub type ExecutionResult = ::std::result::Result<Executed, ExecutionError>;
|
||||
|
||||
// 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<encoded
|
||||
impl LightFetch {
|
||||
// push the necessary requests onto the request chain to get the header by the given ID.
|
||||
// yield a header reference which other requests can use.
|
||||
fn make_header_requests(&self, id: BlockId, reqs: &mut Vec<OnDemandRequest>) -> Result<HeaderRef, Error> {
|
||||
fn make_header_requests(&self, id: BlockId, reqs: &mut Vec<OnDemandRequest>) -> Result<HeaderRef> {
|
||||
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<encoded::Header, Error> {
|
||||
pub fn header(&self, id: BlockId) -> BoxFuture<encoded::Header> {
|
||||
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<Option<BasicAccount>, Error> {
|
||||
pub fn account(&self, address: Address, id: BlockId) -> BoxFuture<Option<BasicAccount>> {
|
||||
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<BlockNumber>) -> BoxFuture<ExecutionResult, Error> {
|
||||
pub fn proved_execution(&self, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<ExecutionResult> {
|
||||
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<encoded::Block, Error> {
|
||||
pub fn block(&self, id: BlockId) -> BoxFuture<encoded::Block> {
|
||||
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<Vec<Receipt>, Error> {
|
||||
pub fn receipts(&self, id: BlockId) -> BoxFuture<Vec<Receipt>> {
|
||||
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<Vec<Log>, Error> {
|
||||
pub fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>> {
|
||||
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<Option<(Transaction, usize)>, Error>
|
||||
-> BoxFuture<Option<(Transaction, usize)>>
|
||||
{
|
||||
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<ExecutionResult, Error> {
|
||||
fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture<ExecutionResult> {
|
||||
if !gas_known {
|
||||
Box::new(future::loop_fn(params, |mut params| {
|
||||
execute_tx(true, params.clone()).and_then(move |res| {
|
||||
|
@ -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<S: core::Middleware<Metadata>> GenericPollManager<S> {
|
||||
}).is_some()
|
||||
}
|
||||
|
||||
pub fn tick(&self) -> BoxFuture<(), ()> {
|
||||
pub fn tick(&self) -> Box<Future<Item=(), Error=()> + Send> {
|
||||
let mut futures = Vec::new();
|
||||
// poll all subscriptions
|
||||
for (id, subscription) in self.subscribers.iter() {
|
||||
|
@ -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<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
|
||||
/// Attempt to get the `Arc<AccountProvider>`, errors if provider was not
|
||||
/// set.
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
|
||||
fn block(&self, id: BlockId, include_txs: bool) -> Result<Option<RichBlock>, Error> {
|
||||
fn block(&self, id: BlockId, include_txs: bool) -> Result<Option<RichBlock>> {
|
||||
let client = &self.client;
|
||||
match (client.block(id.clone()), client.block_total_difficulty(id)) {
|
||||
(Some(block), Some(total_difficulty)) => {
|
||||
@ -181,14 +181,14 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
}
|
||||
}
|
||||
|
||||
fn transaction(&self, id: TransactionId) -> Result<Option<Transaction>, Error> {
|
||||
fn transaction(&self, id: TransactionId) -> Result<Option<Transaction>> {
|
||||
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<Option<RichBlock>, Error> {
|
||||
fn uncle(&self, id: UncleId) -> Result<Option<RichBlock>> {
|
||||
let client = &self.client;
|
||||
let uncle: BlockHeader = match client.uncle(id) {
|
||||
Some(hdr) => hdr.decode(),
|
||||
@ -232,7 +232,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
Ok(Some(block))
|
||||
}
|
||||
|
||||
fn dapp_accounts(&self, dapp: DappId) -> Result<Vec<H160>, Error> {
|
||||
fn dapp_accounts(&self, dapp: DappId) -> Result<Vec<H160>> {
|
||||
let store = self.account_provider()?;
|
||||
store
|
||||
.note_dapp_used(dapp.clone())
|
||||
@ -260,7 +260,7 @@ pub fn pending_logs<M>(miner: &M, best_block: EthBlockNumber, filter: &EthcoreFi
|
||||
result
|
||||
}
|
||||
|
||||
fn check_known<C>(client: &C, number: BlockNumber) -> Result<(), Error> where C: MiningBlockChainClient {
|
||||
fn check_known<C>(client: &C, number: BlockNumber) -> Result<()> where C: MiningBlockChainClient {
|
||||
use ethcore::block_status::BlockStatus;
|
||||
|
||||
match client.block_status(number.into()) {
|
||||
@ -281,12 +281,12 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
{
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn protocol_version(&self) -> Result<String, Error> {
|
||||
fn protocol_version(&self) -> Result<String> {
|
||||
let version = self.sync.status().protocol_version.to_owned();
|
||||
Ok(format!("{}", version))
|
||||
}
|
||||
|
||||
fn syncing(&self) -> Result<SyncStatus, Error> {
|
||||
fn syncing(&self) -> Result<SyncStatus> {
|
||||
use ethcore::snapshot::RestorationStatus;
|
||||
|
||||
let status = self.sync.status();
|
||||
@ -318,7 +318,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}
|
||||
}
|
||||
|
||||
fn author(&self, meta: Metadata) -> Result<RpcH160, Error> {
|
||||
fn author(&self, meta: Metadata) -> Result<RpcH160> {
|
||||
let dapp = meta.dapp_id();
|
||||
|
||||
let mut miner = self.miner.author();
|
||||
@ -329,30 +329,30 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Ok(RpcH160::from(miner))
|
||||
}
|
||||
|
||||
fn is_mining(&self) -> Result<bool, Error> {
|
||||
fn is_mining(&self) -> Result<bool> {
|
||||
Ok(self.miner.is_currently_sealing())
|
||||
}
|
||||
|
||||
fn hashrate(&self) -> Result<RpcU256, Error> {
|
||||
fn hashrate(&self) -> Result<RpcU256> {
|
||||
Ok(RpcU256::from(self.external_miner.hashrate()))
|
||||
}
|
||||
|
||||
fn gas_price(&self) -> Result<RpcU256, Error> {
|
||||
fn gas_price(&self) -> Result<RpcU256> {
|
||||
Ok(RpcU256::from(default_gas_price(&*self.client, &*self.miner)))
|
||||
}
|
||||
|
||||
fn accounts(&self, meta: Metadata) -> Result<Vec<RpcH160>, Error> {
|
||||
fn accounts(&self, meta: Metadata) -> Result<Vec<RpcH160>> {
|
||||
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<RpcU256, Error> {
|
||||
fn block_number(&self) -> Result<RpcU256> {
|
||||
Ok(RpcU256::from(self.client.chain_info().best_block_number))
|
||||
}
|
||||
|
||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
let address = address.into();
|
||||
|
||||
let id = num.unwrap_or_default();
|
||||
@ -366,7 +366,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing<BlockNumber>) -> BoxFuture<RpcH256, Error> {
|
||||
fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing<BlockNumber>) -> BoxFuture<RpcH256> {
|
||||
let address: Address = RpcH160::into(address);
|
||||
let position: U256 = RpcU256::into(pos);
|
||||
|
||||
@ -381,7 +381,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
let address: Address = RpcH160::into(address);
|
||||
|
||||
let res = match num.unwrap_or_default() {
|
||||
@ -406,12 +406,12 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
|
||||
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<Option<RpcU256>, Error> {
|
||||
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
|
||||
Box::new(future::ok(match num {
|
||||
BlockNumber::Pending => Some(
|
||||
self.miner.status().transactions_in_pending_block.into()
|
||||
@ -422,12 +422,12 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
|
||||
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<Option<RpcU256>, Error> {
|
||||
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
|
||||
Box::new(future::ok(match num {
|
||||
BlockNumber::Pending => Some(0.into()),
|
||||
_ => self.client.block(num.into())
|
||||
@ -436,7 +436,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}))
|
||||
}
|
||||
|
||||
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes> {
|
||||
let address: Address = RpcH160::into(address);
|
||||
|
||||
let id = num.unwrap_or_default();
|
||||
@ -450,15 +450,15 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||
Box::new(future::done(self.block(BlockId::Hash(hash.into()), include_txs)))
|
||||
}
|
||||
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||
Box::new(future::done(self.block(num.into(), include_txs)))
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>, Error> {
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::ok(tx))
|
||||
}
|
||||
|
||||
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<Transaction>> {
|
||||
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<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture<Option<Transaction>> {
|
||||
Box::new(future::done(
|
||||
self.transaction(TransactionId::Location(num.into(), index.value()))
|
||||
))
|
||||
}
|
||||
|
||||
fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture<Option<Receipt>, Error> {
|
||||
fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture<Option<Receipt>> {
|
||||
let best_block = self.client.chain_info().best_block_number;
|
||||
let hash: H256 = hash.into();
|
||||
|
||||
@ -494,25 +494,25 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}
|
||||
}
|
||||
|
||||
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<RichBlock>> {
|
||||
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<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture<Option<RichBlock>> {
|
||||
Box::new(future::done(self.uncle(UncleId {
|
||||
block: num.into(),
|
||||
position: index.value()
|
||||
})))
|
||||
}
|
||||
|
||||
fn compilers(&self) -> Result<Vec<String>, Error> {
|
||||
fn compilers(&self) -> Result<Vec<String>> {
|
||||
Err(errors::deprecated("Compilation functionality is deprecated.".to_string()))
|
||||
}
|
||||
|
||||
fn logs(&self, filter: Filter) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn logs(&self, filter: Filter) -> BoxFuture<Vec<Log>> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Box::new(future::ok(logs))
|
||||
}
|
||||
|
||||
fn work(&self, no_new_work_timeout: Trailing<u64>) -> Result<Work, Error> {
|
||||
fn work(&self, no_new_work_timeout: Trailing<u64>) -> Result<Work> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}).unwrap_or(Err(errors::internal("No work found.", "")))
|
||||
}
|
||||
|
||||
fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result<bool, Error> {
|
||||
fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result<bool> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok())
|
||||
}
|
||||
|
||||
fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result<bool, Error> {
|
||||
fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result<bool> {
|
||||
self.external_miner.submit_hashrate(rate.into(), id.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256, Error> {
|
||||
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256, Error> {
|
||||
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256> {
|
||||
self.send_raw_transaction(raw)
|
||||
}
|
||||
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes> {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = try_bf!(fake_sign::sign_call(request, meta.is_dapp()));
|
||||
|
||||
@ -636,7 +636,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
))
|
||||
}
|
||||
|
||||
fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
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<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
))
|
||||
}
|
||||
|
||||
fn compile_lll(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_lll(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string()))
|
||||
}
|
||||
|
||||
fn compile_serpent(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_serpent(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string()))
|
||||
}
|
||||
|
||||
fn compile_solidity(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_solidity(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string()))
|
||||
}
|
||||
}
|
||||
|
@ -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<H256>;
|
||||
|
||||
/// Get logs that match the given filter.
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>, Error>;
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>>;
|
||||
|
||||
/// Get logs from the pending block.
|
||||
fn pending_logs(&self, block_number: u64, filter: &EthcoreFilter) -> Vec<Log>;
|
||||
@ -88,7 +88,7 @@ impl<C, M> Filterable for EthFilterClient<C, M> where C: BlockChainClient, M: Mi
|
||||
self.miner.pending_transactions_hashes(best)
|
||||
}
|
||||
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>> {
|
||||
Box::new(future::ok(self.client.logs(filter).into_iter().map(Into::into).collect()))
|
||||
}
|
||||
|
||||
@ -102,20 +102,20 @@ impl<C, M> Filterable for EthFilterClient<C, M> where C: BlockChainClient, M: Mi
|
||||
|
||||
|
||||
impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
fn new_filter(&self, filter: Filter) -> Result<RpcU256, Error> {
|
||||
fn new_filter(&self, filter: Filter) -> Result<RpcU256> {
|
||||
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<RpcU256, Error> {
|
||||
fn new_block_filter(&self) -> Result<RpcU256> {
|
||||
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<RpcU256, Error> {
|
||||
fn new_pending_transaction_filter(&self) -> Result<RpcU256> {
|
||||
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<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
Ok(id.into())
|
||||
}
|
||||
|
||||
fn filter_changes(&self, index: Index) -> BoxFuture<FilterChanges, Error> {
|
||||
fn filter_changes(&self, index: Index) -> BoxFuture<FilterChanges> {
|
||||
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<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
})
|
||||
}
|
||||
|
||||
fn filter_logs(&self, index: Index) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn filter_logs(&self, index: Index) -> BoxFuture<Vec<Log>> {
|
||||
let filter = {
|
||||
let mut polls = self.polls().lock();
|
||||
|
||||
@ -240,7 +240,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
)
|
||||
}
|
||||
|
||||
fn uninstall_filter(&self, index: Index) -> Result<bool, Error> {
|
||||
fn uninstall_filter(&self, index: Index) -> Result<bool> {
|
||||
self.polls().lock().remove_poll(&index.value());
|
||||
Ok(true)
|
||||
}
|
||||
|
@ -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<encoded::Header>;
|
||||
|
||||
/// Fetch logs.
|
||||
fn logs(&self, filter: EthFilter) -> BoxFuture<Vec<Log>, Error>;
|
||||
fn logs(&self, filter: EthFilter) -> BoxFuture<Vec<Log>>;
|
||||
}
|
||||
|
||||
impl LightClient for LightFetch {
|
||||
@ -178,7 +178,7 @@ impl LightClient for LightFetch {
|
||||
self.client.block_header(id)
|
||||
}
|
||||
|
||||
fn logs(&self, filter: EthFilter) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn logs(&self, filter: EthFilter) -> BoxFuture<Vec<Log>> {
|
||||
LightFetch::logs(self, filter)
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ impl<C: Send + Sync + 'static> EthPubSub for EthPubSubClient<C> {
|
||||
let _ = subscriber.reject(error);
|
||||
}
|
||||
|
||||
fn unsubscribe(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
fn unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
|
||||
let res = self.heads_subscribers.write().remove(&id).is_some();
|
||||
let res2 = self.logs_subscribers.write().remove(&id).is_some();
|
||||
|
||||
|
@ -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<T: LightChainClient + 'static> EthClient<T> {
|
||||
}
|
||||
|
||||
// get a "rich" block structure. Fails on unknown block.
|
||||
fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture<RichBlock, Error> {
|
||||
fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture<RichBlock> {
|
||||
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<T: LightChainClient + 'static> EthClient<T> {
|
||||
impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn protocol_version(&self) -> Result<String, Error> {
|
||||
fn protocol_version(&self) -> Result<String> {
|
||||
Ok(format!("{}", ::light::net::MAX_PROTOCOL_VERSION))
|
||||
}
|
||||
|
||||
fn syncing(&self) -> Result<SyncStatus, Error> {
|
||||
fn syncing(&self) -> Result<SyncStatus> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn author(&self, _meta: Self::Metadata) -> Result<RpcH160, Error> {
|
||||
fn author(&self, _meta: Self::Metadata) -> Result<RpcH160> {
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
fn is_mining(&self) -> Result<bool, Error> {
|
||||
fn is_mining(&self) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn hashrate(&self) -> Result<RpcU256, Error> {
|
||||
fn hashrate(&self) -> Result<RpcU256> {
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
fn gas_price(&self) -> Result<RpcU256, Error> {
|
||||
fn gas_price(&self) -> Result<RpcU256> {
|
||||
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<Vec<RpcH160>, Error> {
|
||||
fn accounts(&self, meta: Metadata) -> Result<Vec<RpcH160>> {
|
||||
let dapp: DappId = meta.dapp_id().into();
|
||||
|
||||
self.accounts
|
||||
@ -254,33 +254,33 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
.map(|accs| accs.into_iter().map(Into::<RpcH160>::into).collect())
|
||||
}
|
||||
|
||||
fn block_number(&self) -> Result<RpcU256, Error> {
|
||||
fn block_number(&self) -> Result<RpcU256> {
|
||||
Ok(self.client.chain_info().best_block_number.into())
|
||||
}
|
||||
|
||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
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<BlockNumber>) -> BoxFuture<RpcH256, Error> {
|
||||
fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing<BlockNumber>) -> BoxFuture<RpcH256> {
|
||||
Box::new(future::err(errors::unimplemented(None)))
|
||||
}
|
||||
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||
Box::new(self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some))
|
||||
}
|
||||
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||
Box::new(self.rich_block(num.into(), include_txs).map(Some))
|
||||
}
|
||||
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
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<Option<RpcU256>, Error> {
|
||||
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn code_at(&self, _address: RpcH160, _num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
fn code_at(&self, _address: RpcH160, _num: Trailing<BlockNumber>) -> BoxFuture<Bytes> {
|
||||
Box::new(future::err(errors::unimplemented(None)))
|
||||
}
|
||||
|
||||
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256, Error> {
|
||||
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256> {
|
||||
let best_header = self.client.best_block_header().decode();
|
||||
|
||||
UntrustedRlp::new(&raw.into_vec()).as_val()
|
||||
@ -368,11 +368,11 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256, Error> {
|
||||
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256> {
|
||||
self.send_raw_transaction(raw)
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes> {
|
||||
Box::new(self.fetcher().proved_execution(req, num).and_then(|res| {
|
||||
match res {
|
||||
Ok(exec) => Ok(exec.output.into()),
|
||||
@ -381,7 +381,7 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256> {
|
||||
// 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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>, Error> {
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>> {
|
||||
let hash = hash.into();
|
||||
let eip86 = self.client.eip86_transition();
|
||||
|
||||
@ -409,21 +409,21 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
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<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture<Option<Transaction>> {
|
||||
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<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture<Option<Transaction>> {
|
||||
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<Option<Receipt>, Error> {
|
||||
fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture<Option<Receipt>> {
|
||||
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<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture<Option<RichBlock>> {
|
||||
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<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture<Option<RichBlock>> {
|
||||
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<Vec<String>, Error> {
|
||||
fn compilers(&self) -> Result<Vec<String>> {
|
||||
Err(errors::deprecated("Compilation functionality is deprecated.".to_string()))
|
||||
}
|
||||
|
||||
fn compile_lll(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_lll(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string()))
|
||||
}
|
||||
|
||||
fn compile_serpent(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_serpent(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string()))
|
||||
}
|
||||
|
||||
fn compile_solidity(&self, _: String) -> Result<Bytes, Error> {
|
||||
fn compile_solidity(&self, _: String) -> Result<Bytes> {
|
||||
Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string()))
|
||||
}
|
||||
|
||||
fn logs(&self, filter: Filter) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn logs(&self, filter: Filter) -> BoxFuture<Vec<Log>> {
|
||||
let limit = filter.limit;
|
||||
|
||||
Box::new(Filterable::logs(self, filter.into())
|
||||
.map(move|logs| limit_logs(logs, limit)))
|
||||
}
|
||||
|
||||
fn work(&self, _timeout: Trailing<u64>) -> Result<Work, Error> {
|
||||
fn work(&self, _timeout: Trailing<u64>) -> Result<Work> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result<bool, Error> {
|
||||
fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result<bool, Error> {
|
||||
fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
}
|
||||
@ -516,7 +516,7 @@ impl<T: LightChainClient + 'static> Filterable for EthClient<T> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>, Error> {
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>> {
|
||||
self.fetcher().logs(filter)
|
||||
}
|
||||
|
||||
|
@ -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<S: ?Sized> NetClient<S> where S: LightSyncProvider {
|
||||
}
|
||||
|
||||
impl<S: ?Sized + Sync + Send + 'static> Net for NetClient<S> where S: LightSyncProvider {
|
||||
fn version(&self) -> Result<String, Error> {
|
||||
fn version(&self) -> Result<String> {
|
||||
Ok(format!("{}", self.sync.network_id()).to_owned())
|
||||
}
|
||||
|
||||
fn peer_count(&self) -> Result<String, Error> {
|
||||
fn peer_count(&self) -> Result<String> {
|
||||
Ok(format!("0x{:x}", self.sync.peer_numbers().connected as u64).to_owned())
|
||||
}
|
||||
|
||||
fn is_listening(&self) -> Result<bool, Error> {
|
||||
fn is_listening(&self) -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
@ -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<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
||||
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>> {
|
||||
let dapp = dapp.unwrap_or_default();
|
||||
|
||||
let store = &self.accounts;
|
||||
@ -125,7 +125,7 @@ impl Parity for ParityClient {
|
||||
)
|
||||
}
|
||||
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>, Error> {
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>> {
|
||||
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<Vec<String>, Error> {
|
||||
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>> {
|
||||
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<H160, Error> {
|
||||
fn default_account(&self, meta: Self::Metadata) -> Result<H160> {
|
||||
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<usize, Error> {
|
||||
fn transactions_limit(&self) -> Result<usize> {
|
||||
Ok(usize::max_value())
|
||||
}
|
||||
|
||||
fn min_gas_price(&self) -> Result<U256, Error> {
|
||||
fn min_gas_price(&self) -> Result<U256> {
|
||||
Ok(U256::default())
|
||||
}
|
||||
|
||||
fn extra_data(&self) -> Result<Bytes, Error> {
|
||||
fn extra_data(&self) -> Result<Bytes> {
|
||||
Ok(Bytes::default())
|
||||
}
|
||||
|
||||
fn gas_floor_target(&self) -> Result<U256, Error> {
|
||||
fn gas_floor_target(&self) -> Result<U256> {
|
||||
Ok(U256::default())
|
||||
}
|
||||
|
||||
fn gas_ceil_target(&self) -> Result<U256, Error> {
|
||||
fn gas_ceil_target(&self) -> Result<U256> {
|
||||
Ok(U256::default())
|
||||
}
|
||||
|
||||
fn dev_logs(&self) -> Result<Vec<String>, Error> {
|
||||
fn dev_logs(&self) -> Result<Vec<String>> {
|
||||
let logs = self.logger.logs();
|
||||
Ok(logs.as_slice().to_owned())
|
||||
}
|
||||
|
||||
fn dev_logs_levels(&self) -> Result<String, Error> {
|
||||
fn dev_logs_levels(&self) -> Result<String> {
|
||||
Ok(self.logger.levels().to_owned())
|
||||
}
|
||||
|
||||
fn net_chain(&self) -> Result<String, Error> {
|
||||
fn net_chain(&self) -> Result<String> {
|
||||
Ok(self.settings.chain.clone())
|
||||
}
|
||||
|
||||
fn net_peers(&self) -> Result<Peers, Error> {
|
||||
fn net_peers(&self) -> Result<Peers> {
|
||||
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<u16, Error> {
|
||||
fn net_port(&self) -> Result<u16> {
|
||||
Ok(self.settings.network_port)
|
||||
}
|
||||
|
||||
fn node_name(&self) -> Result<String, Error> {
|
||||
fn node_name(&self) -> Result<String> {
|
||||
Ok(self.settings.name.clone())
|
||||
}
|
||||
|
||||
fn registry_address(&self) -> Result<Option<H160>, Error> {
|
||||
fn registry_address(&self) -> Result<Option<H160>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn rpc_settings(&self) -> Result<RpcSettings, Error> {
|
||||
fn rpc_settings(&self) -> Result<RpcSettings> {
|
||||
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<Bytes, Error> {
|
||||
fn default_extra_data(&self) -> Result<Bytes> {
|
||||
Ok(Bytes::new(version_data()))
|
||||
}
|
||||
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram, Error> {
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram> {
|
||||
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<usize, Error> {
|
||||
fn unsigned_transactions_count(&self) -> Result<usize> {
|
||||
match self.signer {
|
||||
None => Err(errors::signer_disabled()),
|
||||
Some(ref signer) => Ok(signer.len()),
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_secret_phrase(&self) -> Result<String, Error> {
|
||||
fn generate_secret_phrase(&self) -> Result<String> {
|
||||
Ok(random_phrase(12))
|
||||
}
|
||||
|
||||
fn phrase_to_address(&self, phrase: String) -> Result<H160, Error> {
|
||||
fn phrase_to_address(&self, phrase: String) -> Result<H160> {
|
||||
Ok(Brain::new(phrase).generate().unwrap().address().into())
|
||||
}
|
||||
|
||||
fn list_accounts(&self, _: u64, _: Option<H160>, _: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error> {
|
||||
fn list_accounts(&self, _: u64, _: Option<H160>, _: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn list_storage_keys(&self, _: H160, _: u64, _: Option<H256>, _: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error> {
|
||||
fn list_storage_keys(&self, _: H160, _: u64, _: Option<H256>, _: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result<Bytes, Error> {
|
||||
fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result<Bytes> {
|
||||
ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0)
|
||||
.map_err(errors::encryption)
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
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<Vec<Transaction>, Error> {
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
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<BTreeMap<H256, TransactionStats>, Error> {
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>> {
|
||||
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<BTreeMap<H256, LocalTransactionStatus>, Error> {
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>> {
|
||||
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<String, Error> {
|
||||
fn dapps_url(&self) -> Result<String> {
|
||||
helpers::to_url(&self.dapps_address)
|
||||
.ok_or_else(|| errors::dapps_disabled())
|
||||
}
|
||||
|
||||
fn ws_url(&self) -> Result<String, Error> {
|
||||
fn ws_url(&self) -> Result<String> {
|
||||
helpers::to_url(&self.ws_address)
|
||||
.ok_or_else(|| errors::ws_disabled())
|
||||
}
|
||||
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256, Error> {
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256> {
|
||||
Box::new(self.light_dispatch.next_nonce(address.into()).map(Into::into))
|
||||
}
|
||||
|
||||
fn mode(&self) -> Result<String, Error> {
|
||||
fn mode(&self) -> Result<String> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn chain_id(&self) -> Result<Option<U64>, Error> {
|
||||
fn chain_id(&self) -> Result<Option<U64>> {
|
||||
Ok(self.client.signing_chain_id().map(U64::from))
|
||||
}
|
||||
|
||||
fn chain(&self) -> Result<String, Error> {
|
||||
fn chain(&self) -> Result<String> {
|
||||
Ok(self.settings.chain.clone())
|
||||
}
|
||||
|
||||
fn enode(&self) -> Result<String, Error> {
|
||||
fn enode(&self) -> Result<String> {
|
||||
self.light_dispatch.sync.enode().ok_or_else(errors::network_disabled)
|
||||
}
|
||||
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability, Error> {
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn version_info(&self) -> Result<VersionInfo, Error> {
|
||||
fn version_info(&self) -> Result<VersionInfo> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>, Error> {
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn chain_status(&self) -> Result<ChainStatus, Error> {
|
||||
fn chain_status(&self) -> Result<ChainStatus> {
|
||||
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<BlockNumber>) -> BoxFuture<RichHeader, Error> {
|
||||
fn block_header(&self, number: Trailing<BlockNumber>) -> BoxFuture<RichHeader> {
|
||||
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<String, Error> {
|
||||
fn ipfs_cid(&self, content: Bytes) -> Result<String> {
|
||||
ipfs::cid(content)
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, _requests: Vec<CallRequest>, _block: Trailing<BlockNumber>) -> Result<Vec<Bytes>, Error> {
|
||||
fn call(&self, _meta: Self::Metadata, _requests: Vec<CallRequest>, _block: Trailing<BlockNumber>) -> Result<Vec<Bytes>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn node_health(&self) -> BoxFuture<Health, Error> {
|
||||
fn node_health(&self) -> BoxFuture<Health> {
|
||||
Box::new(self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err)))
|
||||
}
|
||||
|
@ -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<F: Fetch> ParitySetClient<F> {
|
||||
}
|
||||
|
||||
impl<F: Fetch> ParitySet for ParitySetClient<F> {
|
||||
fn set_min_gas_price(&self, _gas_price: U256) -> Result<bool, Error> {
|
||||
fn set_min_gas_price(&self, _gas_price: U256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_gas_floor_target(&self, _target: U256) -> Result<bool, Error> {
|
||||
fn set_gas_floor_target(&self, _target: U256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_gas_ceil_target(&self, _target: U256) -> Result<bool, Error> {
|
||||
fn set_gas_ceil_target(&self, _target: U256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_extra_data(&self, _extra_data: Bytes) -> Result<bool, Error> {
|
||||
fn set_extra_data(&self, _extra_data: Bytes) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_author(&self, _author: H160) -> Result<bool, Error> {
|
||||
fn set_author(&self, _author: H160) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_engine_signer(&self, _address: H160, _password: String) -> Result<bool, Error> {
|
||||
fn set_engine_signer(&self, _address: H160, _password: String) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_transactions_limit(&self, _limit: usize) -> Result<bool, Error> {
|
||||
fn set_transactions_limit(&self, _limit: usize) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_tx_gas_limit(&self, _limit: U256) -> Result<bool, Error> {
|
||||
fn set_tx_gas_limit(&self, _limit: U256) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn add_reserved_peer(&self, peer: String) -> Result<bool, Error> {
|
||||
fn add_reserved_peer(&self, peer: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn remove_reserved_peer(&self, peer: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn drop_non_reserved_peers(&self) -> Result<bool> {
|
||||
self.net.deny_unreserved_peers();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool, Error> {
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool> {
|
||||
self.net.accept_unreserved_peers();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn start_network(&self) -> Result<bool, Error> {
|
||||
fn start_network(&self) -> Result<bool> {
|
||||
self.net.start_network();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn stop_network(&self) -> Result<bool, Error> {
|
||||
fn stop_network(&self) -> Result<bool> {
|
||||
self.net.stop_network();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_mode(&self, _mode: String) -> Result<bool, Error> {
|
||||
fn set_mode(&self, _mode: String) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn set_spec_name(&self, _spec_name: String) -> Result<bool, Error> {
|
||||
fn set_spec_name(&self, _spec_name: String) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn hash_content(&self, url: String) -> BoxFuture<H256, Error> {
|
||||
fn hash_content(&self, url: String) -> BoxFuture<H256> {
|
||||
self.fetch.process(self.fetch.fetch(&url).then(move |result| {
|
||||
result
|
||||
.map_err(errors::fetch)
|
||||
@ -135,23 +135,23 @@ impl<F: Fetch> ParitySet for ParitySetClient<F> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn dapps_refresh(&self) -> Result<bool, Error> {
|
||||
fn dapps_refresh(&self) -> Result<bool> {
|
||||
self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled)
|
||||
}
|
||||
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>, Error> {
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>> {
|
||||
self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled)
|
||||
}
|
||||
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>, Error> {
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn execute_upgrade(&self) -> Result<bool, Error> {
|
||||
fn execute_upgrade(&self) -> Result<bool> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn remove_transaction(&self, _hash: H256) -> Result<Option<Transaction>, Error> {
|
||||
fn remove_transaction(&self, _hash: H256) -> Result<Option<Transaction>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
}
|
||||
|
@ -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<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn filter(&self, _filter: TraceFilter) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn block_traces(&self, _block_number: BlockNumber) -> Result<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn block_traces(&self, _block_number: BlockNumber) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn transaction_traces(&self, _transaction_hash: H256) -> Result<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn transaction_traces(&self, _transaction_hash: H256) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn trace(&self, _transaction_hash: H256, _address: Vec<Index>) -> Result<Option<LocalizedTrace>, Error> {
|
||||
fn trace(&self, _transaction_hash: H256, _address: Vec<Index>) -> Result<Option<LocalizedTrace>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>, Error> {
|
||||
fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result<TraceResults, Error> {
|
||||
fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result<TraceResults> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
}
|
||||
|
@ -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<S: ?Sized> NetClient<S> where S: SyncProvider {
|
||||
}
|
||||
|
||||
impl<S: ?Sized> Net for NetClient<S> where S: SyncProvider + 'static {
|
||||
fn version(&self) -> Result<String, Error> {
|
||||
fn version(&self) -> Result<String> {
|
||||
Ok(format!("{}", self.sync.status().network_id).to_owned())
|
||||
}
|
||||
|
||||
fn peer_count(&self) -> Result<String, Error> {
|
||||
fn peer_count(&self) -> Result<String> {
|
||||
Ok(format!("0x{:x}", self.sync.status().num_peers as u64).to_owned())
|
||||
}
|
||||
|
||||
fn is_listening(&self) -> Result<bool, Error> {
|
||||
fn is_listening(&self) -> Result<bool> {
|
||||
// right now (11 march 2016), we are always listening for incoming connections
|
||||
//
|
||||
// (this may not be true now -- 26 september 2016)
|
||||
|
@ -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<C, M, U> ParityClient<C, M, U> where
|
||||
|
||||
/// Attempt to get the `Arc<AccountProvider>`, errors if provider was not
|
||||
/// set.
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
{
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error> {
|
||||
fn accounts_info(&self, dapp: Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>> {
|
||||
let dapp = dapp.unwrap_or_default();
|
||||
|
||||
let store = self.account_provider()?;
|
||||
@ -141,7 +141,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
)
|
||||
}
|
||||
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>, Error> {
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>> {
|
||||
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<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
)
|
||||
}
|
||||
|
||||
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>, Error> {
|
||||
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>> {
|
||||
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<H160, Error> {
|
||||
fn default_account(&self, meta: Self::Metadata) -> Result<H160> {
|
||||
let dapp_id = meta.dapp_id();
|
||||
|
||||
Ok(self.account_provider()?
|
||||
@ -166,48 +166,48 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn transactions_limit(&self) -> Result<usize, Error> {
|
||||
fn transactions_limit(&self) -> Result<usize> {
|
||||
Ok(self.miner.transactions_limit())
|
||||
}
|
||||
|
||||
fn min_gas_price(&self) -> Result<U256, Error> {
|
||||
fn min_gas_price(&self) -> Result<U256> {
|
||||
Ok(U256::from(self.miner.minimal_gas_price()))
|
||||
}
|
||||
|
||||
fn extra_data(&self) -> Result<Bytes, Error> {
|
||||
fn extra_data(&self) -> Result<Bytes> {
|
||||
Ok(Bytes::new(self.miner.extra_data()))
|
||||
}
|
||||
|
||||
fn gas_floor_target(&self) -> Result<U256, Error> {
|
||||
fn gas_floor_target(&self) -> Result<U256> {
|
||||
Ok(U256::from(self.miner.gas_floor_target()))
|
||||
}
|
||||
|
||||
fn gas_ceil_target(&self) -> Result<U256, Error> {
|
||||
fn gas_ceil_target(&self) -> Result<U256> {
|
||||
Ok(U256::from(self.miner.gas_ceil_target()))
|
||||
}
|
||||
|
||||
fn dev_logs(&self) -> Result<Vec<String>, Error> {
|
||||
fn dev_logs(&self) -> Result<Vec<String>> {
|
||||
let logs = self.logger.logs();
|
||||
Ok(logs.as_slice().to_owned())
|
||||
}
|
||||
|
||||
fn dev_logs_levels(&self) -> Result<String, Error> {
|
||||
fn dev_logs_levels(&self) -> Result<String> {
|
||||
Ok(self.logger.levels().to_owned())
|
||||
}
|
||||
|
||||
fn net_chain(&self) -> Result<String, Error> {
|
||||
fn net_chain(&self) -> Result<String> {
|
||||
Ok(self.settings.chain.clone())
|
||||
}
|
||||
|
||||
fn chain_id(&self) -> Result<Option<U64>, Error> {
|
||||
fn chain_id(&self) -> Result<Option<U64>> {
|
||||
Ok(self.client.signing_chain_id().map(U64::from))
|
||||
}
|
||||
|
||||
fn chain(&self) -> Result<String, Error> {
|
||||
fn chain(&self) -> Result<String> {
|
||||
Ok(self.client.spec_name())
|
||||
}
|
||||
|
||||
fn net_peers(&self) -> Result<Peers, Error> {
|
||||
fn net_peers(&self) -> Result<Peers> {
|
||||
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<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
})
|
||||
}
|
||||
|
||||
fn net_port(&self) -> Result<u16, Error> {
|
||||
fn net_port(&self) -> Result<u16> {
|
||||
Ok(self.settings.network_port)
|
||||
}
|
||||
|
||||
fn node_name(&self) -> Result<String, Error> {
|
||||
fn node_name(&self) -> Result<String> {
|
||||
Ok(self.settings.name.clone())
|
||||
}
|
||||
|
||||
fn registry_address(&self) -> Result<Option<H160>, Error> {
|
||||
fn registry_address(&self) -> Result<Option<H160>> {
|
||||
Ok(
|
||||
self.client
|
||||
.additional_params()
|
||||
@ -238,7 +238,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
)
|
||||
}
|
||||
|
||||
fn rpc_settings(&self) -> Result<RpcSettings, Error> {
|
||||
fn rpc_settings(&self) -> Result<RpcSettings> {
|
||||
Ok(RpcSettings {
|
||||
enabled: self.settings.rpc_enabled,
|
||||
interface: self.settings.rpc_interface.clone(),
|
||||
@ -246,11 +246,11 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
})
|
||||
}
|
||||
|
||||
fn default_extra_data(&self) -> Result<Bytes, Error> {
|
||||
fn default_extra_data(&self) -> Result<Bytes> {
|
||||
Ok(Bytes::new(version_data()))
|
||||
}
|
||||
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram, Error> {
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram> {
|
||||
Box::new(future::done(self.client
|
||||
.gas_price_corpus(100)
|
||||
.histogram(10)
|
||||
@ -259,50 +259,50 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
))
|
||||
}
|
||||
|
||||
fn unsigned_transactions_count(&self) -> Result<usize, Error> {
|
||||
fn unsigned_transactions_count(&self) -> Result<usize> {
|
||||
match self.signer {
|
||||
None => Err(errors::signer_disabled()),
|
||||
Some(ref signer) => Ok(signer.len()),
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_secret_phrase(&self) -> Result<String, Error> {
|
||||
fn generate_secret_phrase(&self) -> Result<String> {
|
||||
Ok(random_phrase(12))
|
||||
}
|
||||
|
||||
fn phrase_to_address(&self, phrase: String) -> Result<H160, Error> {
|
||||
fn phrase_to_address(&self, phrase: String) -> Result<H160> {
|
||||
Ok(Brain::new(phrase).generate().unwrap().address().into())
|
||||
}
|
||||
|
||||
fn list_accounts(&self, count: u64, after: Option<H160>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error> {
|
||||
fn list_accounts(&self, count: u64, after: Option<H160>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>> {
|
||||
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<H256>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error> {
|
||||
fn list_storage_keys(&self, address: H160, count: u64, after: Option<H256>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>> {
|
||||
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<Bytes, Error> {
|
||||
fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result<Bytes> {
|
||||
ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0)
|
||||
.map_err(errors::encryption)
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
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::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
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::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>, Error> {
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>> {
|
||||
let stats = self.sync.transactions_stats();
|
||||
Ok(stats.into_iter()
|
||||
.map(|(hash, stats)| (hash.into(), stats.into()))
|
||||
@ -310,7 +310,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
)
|
||||
}
|
||||
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>, Error> {
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>> {
|
||||
// Return nothing if accounts are disabled (running as public node)
|
||||
if self.accounts.is_none() {
|
||||
return Ok(BTreeMap::new());
|
||||
@ -325,17 +325,17 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
)
|
||||
}
|
||||
|
||||
fn dapps_url(&self) -> Result<String, Error> {
|
||||
fn dapps_url(&self) -> Result<String> {
|
||||
helpers::to_url(&self.dapps_address)
|
||||
.ok_or_else(|| errors::dapps_disabled())
|
||||
}
|
||||
|
||||
fn ws_url(&self) -> Result<String, Error> {
|
||||
fn ws_url(&self) -> Result<String> {
|
||||
helpers::to_url(&self.ws_address)
|
||||
.ok_or_else(|| errors::ws_disabled())
|
||||
}
|
||||
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256, Error> {
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256> {
|
||||
let address: Address = address.into();
|
||||
|
||||
Box::new(future::ok(self.miner.last_nonce(&address)
|
||||
@ -345,7 +345,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
))
|
||||
}
|
||||
|
||||
fn mode(&self) -> Result<String, Error> {
|
||||
fn mode(&self) -> Result<String> {
|
||||
Ok(match self.client.mode() {
|
||||
Mode::Off => "offline",
|
||||
Mode::Dark(..) => "dark",
|
||||
@ -354,23 +354,23 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
}.into())
|
||||
}
|
||||
|
||||
fn enode(&self) -> Result<String, Error> {
|
||||
fn enode(&self) -> Result<String> {
|
||||
self.sync.enode().ok_or_else(errors::network_disabled)
|
||||
}
|
||||
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability, Error> {
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability> {
|
||||
Ok(self.updater.capability().into())
|
||||
}
|
||||
|
||||
fn version_info(&self) -> Result<VersionInfo, Error> {
|
||||
fn version_info(&self) -> Result<VersionInfo> {
|
||||
Ok(self.updater.version_info().into())
|
||||
}
|
||||
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>, Error> {
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>> {
|
||||
Ok(self.updater.info().map(Into::into))
|
||||
}
|
||||
|
||||
fn chain_status(&self) -> Result<ChainStatus, Error> {
|
||||
fn chain_status(&self) -> Result<ChainStatus> {
|
||||
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<C, M, U> Parity for ParityClient<C, M, U> 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<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
})
|
||||
}
|
||||
|
||||
fn block_header(&self, number: Trailing<BlockNumber>) -> BoxFuture<RichHeader, Error> {
|
||||
fn block_header(&self, number: Trailing<BlockNumber>) -> BoxFuture<RichHeader> {
|
||||
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<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
}))
|
||||
}
|
||||
|
||||
fn ipfs_cid(&self, content: Bytes) -> Result<String, Error> {
|
||||
fn ipfs_cid(&self, content: Bytes) -> Result<String> {
|
||||
ipfs::cid(content)
|
||||
}
|
||||
|
||||
fn call(&self, meta: Self::Metadata, requests: Vec<CallRequest>, block: Trailing<BlockNumber>) -> Result<Vec<Bytes>, Error> {
|
||||
fn call(&self, meta: Self::Metadata, requests: Vec<CallRequest>, block: Trailing<BlockNumber>) -> Result<Vec<Bytes>> {
|
||||
let requests = requests
|
||||
.into_iter()
|
||||
.map(|request| Ok((
|
||||
fake_sign::sign_call(request.into(), meta.is_dapp())?,
|
||||
Default::default()
|
||||
)))
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
let block = block.unwrap_or_default();
|
||||
|
||||
@ -430,7 +430,7 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn node_health(&self) -> BoxFuture<Health, Error> {
|
||||
fn node_health(&self) -> BoxFuture<Health> {
|
||||
Box::new(self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err)))
|
||||
}
|
||||
|
@ -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<AccountProvider>`, errors if provider was not
|
||||
/// set.
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
}
|
||||
|
||||
impl ParityAccounts for ParityAccountsClient {
|
||||
fn all_accounts_info(&self) -> Result<BTreeMap<RpcH160, ExtAccountInfo>, Error> {
|
||||
fn all_accounts_info(&self) -> Result<BTreeMap<RpcH160, ExtAccountInfo>> {
|
||||
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<RpcH160, Error> {
|
||||
fn new_account_from_phrase(&self, phrase: String, pass: String) -> Result<RpcH160> {
|
||||
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<RpcH160, Error> {
|
||||
fn new_account_from_wallet(&self, json: String, pass: String) -> Result<RpcH160> {
|
||||
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<RpcH160, Error> {
|
||||
fn new_account_from_secret(&self, secret: RpcH256, pass: String) -> Result<RpcH160> {
|
||||
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<bool, Error> {
|
||||
fn test_password(&self, account: RpcH160, password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn change_password(&self, account: RpcH160, password: String, new_password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn kill_account(&self, account: RpcH160, password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn remove_address(&self, addr: RpcH160) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result<bool> {
|
||||
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<Vec<RpcH160>>) -> Result<bool, Error> {
|
||||
fn set_dapp_addresses(&self, dapp: DappId, addresses: Option<Vec<RpcH160>>) -> Result<bool> {
|
||||
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<Vec<RpcH160>, Error> {
|
||||
fn dapp_addresses(&self, dapp: DappId) -> Result<Vec<RpcH160>> {
|
||||
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<bool, Error> {
|
||||
fn set_dapp_default_address(&self, dapp: DappId, address: RpcH160) -> Result<bool> {
|
||||
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<RpcH160, Error> {
|
||||
fn dapp_default_address(&self, dapp: DappId) -> Result<RpcH160> {
|
||||
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<Vec<RpcH160>>) -> Result<bool, Error> {
|
||||
fn set_new_dapps_addresses(&self, addresses: Option<Vec<RpcH160>>) -> Result<bool> {
|
||||
let store = self.account_provider()?;
|
||||
|
||||
store
|
||||
@ -201,7 +201,7 @@ impl ParityAccounts for ParityAccountsClient {
|
||||
.map(|_| true)
|
||||
}
|
||||
|
||||
fn new_dapps_addresses(&self) -> Result<Option<Vec<RpcH160>>, Error> {
|
||||
fn new_dapps_addresses(&self) -> Result<Option<Vec<RpcH160>>> {
|
||||
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<bool, Error> {
|
||||
fn set_new_dapps_default_address(&self, address: RpcH160) -> Result<bool> {
|
||||
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<RpcH160, Error> {
|
||||
fn new_dapps_default_address(&self) -> Result<RpcH160> {
|
||||
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<BTreeMap<DappId, u64>, Error> {
|
||||
fn recent_dapps(&self) -> Result<BTreeMap<DappId, u64>> {
|
||||
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<RpcH160>) -> Result<Vec<RpcH160>, Error> {
|
||||
fn import_geth_accounts(&self, addresses: Vec<RpcH160>) -> Result<Vec<RpcH160>> {
|
||||
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<Vec<RpcH160>, Error> {
|
||||
fn geth_accounts(&self) -> Result<Vec<RpcH160>> {
|
||||
let store = self.account_provider()?;
|
||||
|
||||
Ok(into_vec(store.list_geth_accounts(false)))
|
||||
}
|
||||
|
||||
fn create_vault(&self, name: String, password: String) -> Result<bool, Error> {
|
||||
fn create_vault(&self, name: String, password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn open_vault(&self, name: String, password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn close_vault(&self, name: String) -> Result<bool> {
|
||||
self.account_provider()?
|
||||
.close_vault(&name)
|
||||
.map_err(|e| errors::account("Could not close vault.", e))
|
||||
.map(|_| true)
|
||||
}
|
||||
|
||||
fn list_vaults(&self) -> Result<Vec<String>, Error> {
|
||||
fn list_vaults(&self) -> Result<Vec<String>> {
|
||||
self.account_provider()?
|
||||
.list_vaults()
|
||||
.map_err(|e| errors::account("Could not list vaults.", e))
|
||||
}
|
||||
|
||||
fn list_opened_vaults(&self) -> Result<Vec<String>, Error> {
|
||||
fn list_opened_vaults(&self) -> Result<Vec<String>> {
|
||||
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<bool, Error> {
|
||||
fn change_vault_password(&self, name: String, new_password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn change_vault(&self, address: RpcH160, new_vault: String) -> Result<bool> {
|
||||
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<String, Error> {
|
||||
fn get_vault_meta(&self, name: String) -> Result<String> {
|
||||
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<bool, Error> {
|
||||
fn set_vault_meta(&self, name: String, meta: String) -> Result<bool> {
|
||||
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<RpcH160, Error> {
|
||||
fn derive_key_index(&self, addr: RpcH160, password: String, derivation: DeriveHierarchical, save_as_account: bool) -> Result<RpcH160> {
|
||||
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<RpcH160, Error> {
|
||||
fn derive_key_hash(&self, addr: RpcH160, password: String, derivation: DeriveHash, save_as_account: bool) -> Result<RpcH160> {
|
||||
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<KeyFile, Error> {
|
||||
fn export_account(&self, addr: RpcH160, password: String) -> Result<KeyFile> {
|
||||
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<RpcH520, Error> {
|
||||
fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result<RpcH520> {
|
||||
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<bool, Error> {
|
||||
fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result<bool> {
|
||||
let store = self.account_provider()?;
|
||||
Ok(store.hardware_pin_matrix_ack(&path, &pin).map_err(|e| errors::account("Error communicating with hardware wallet.", e))?)
|
||||
}
|
||||
|
@ -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<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
|
||||
F: Fetch + 'static,
|
||||
{
|
||||
|
||||
fn set_min_gas_price(&self, gas_price: U256) -> Result<bool, Error> {
|
||||
fn set_min_gas_price(&self, gas_price: U256) -> Result<bool> {
|
||||
self.miner.set_minimal_gas_price(gas_price.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_gas_floor_target(&self, target: U256) -> Result<bool, Error> {
|
||||
fn set_gas_floor_target(&self, target: U256) -> Result<bool> {
|
||||
self.miner.set_gas_floor_target(target.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_gas_ceil_target(&self, target: U256) -> Result<bool, Error> {
|
||||
fn set_gas_ceil_target(&self, target: U256) -> Result<bool> {
|
||||
self.miner.set_gas_ceil_target(target.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_extra_data(&self, extra_data: Bytes) -> Result<bool, Error> {
|
||||
fn set_extra_data(&self, extra_data: Bytes) -> Result<bool> {
|
||||
self.miner.set_extra_data(extra_data.into_vec());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_author(&self, author: H160) -> Result<bool, Error> {
|
||||
fn set_author(&self, author: H160) -> Result<bool> {
|
||||
self.miner.set_author(author.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_engine_signer(&self, address: H160, password: String) -> Result<bool, Error> {
|
||||
fn set_engine_signer(&self, address: H160, password: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn set_transactions_limit(&self, limit: usize) -> Result<bool> {
|
||||
self.miner.set_transactions_limit(limit);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_tx_gas_limit(&self, limit: U256) -> Result<bool, Error> {
|
||||
fn set_tx_gas_limit(&self, limit: U256) -> Result<bool> {
|
||||
self.miner.set_tx_gas_limit(limit.into());
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn add_reserved_peer(&self, peer: String) -> Result<bool, Error> {
|
||||
fn add_reserved_peer(&self, peer: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn remove_reserved_peer(&self, peer: String) -> Result<bool> {
|
||||
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<bool, Error> {
|
||||
fn drop_non_reserved_peers(&self) -> Result<bool> {
|
||||
self.net.deny_unreserved_peers();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool, Error> {
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool> {
|
||||
self.net.accept_unreserved_peers();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn start_network(&self) -> Result<bool, Error> {
|
||||
fn start_network(&self) -> Result<bool> {
|
||||
self.net.start_network();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn stop_network(&self) -> Result<bool, Error> {
|
||||
fn stop_network(&self) -> Result<bool> {
|
||||
self.net.stop_network();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_mode(&self, mode: String) -> Result<bool, Error> {
|
||||
fn set_mode(&self, mode: String) -> Result<bool> {
|
||||
self.client.set_mode(match mode.as_str() {
|
||||
"offline" => Mode::Off,
|
||||
"dark" => Mode::Dark(300),
|
||||
@ -160,12 +160,12 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn set_spec_name(&self, spec_name: String) -> Result<bool, Error> {
|
||||
fn set_spec_name(&self, spec_name: String) -> Result<bool> {
|
||||
self.client.set_spec_name(spec_name);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn hash_content(&self, url: String) -> BoxFuture<H256, Error> {
|
||||
fn hash_content(&self, url: String) -> BoxFuture<H256> {
|
||||
self.fetch.process(self.fetch.fetch(&url).then(move |result| {
|
||||
result
|
||||
.map_err(errors::fetch)
|
||||
@ -176,23 +176,23 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
|
||||
}))
|
||||
}
|
||||
|
||||
fn dapps_refresh(&self) -> Result<bool, Error> {
|
||||
fn dapps_refresh(&self) -> Result<bool> {
|
||||
self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled)
|
||||
}
|
||||
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>, Error> {
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>> {
|
||||
self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled)
|
||||
}
|
||||
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>, Error> {
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>> {
|
||||
Ok(self.updater.upgrade_ready().map(Into::into))
|
||||
}
|
||||
|
||||
fn execute_upgrade(&self) -> Result<bool, Error> {
|
||||
fn execute_upgrade(&self) -> Result<bool> {
|
||||
Ok(self.updater.execute_upgrade())
|
||||
}
|
||||
|
||||
fn remove_transaction(&self, hash: H256) -> Result<Option<Transaction>, Error> {
|
||||
fn remove_transaction(&self, hash: H256) -> Result<Option<Transaction>> {
|
||||
let block_number = self.client.chain_info().best_block_number;
|
||||
let hash = hash.into();
|
||||
|
||||
|
@ -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<D: Dispatcher> PersonalClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
}
|
||||
@ -58,13 +58,13 @@ impl<D: Dispatcher> PersonalClient<D> {
|
||||
impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn accounts(&self) -> Result<Vec<RpcH160>, Error> {
|
||||
fn accounts(&self) -> Result<Vec<RpcH160>> {
|
||||
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::<Vec<RpcH160>>())
|
||||
}
|
||||
|
||||
fn new_account(&self, pass: String) -> Result<RpcH160, Error> {
|
||||
fn new_account(&self, pass: String) -> Result<RpcH160> {
|
||||
let store = self.account_provider()?;
|
||||
|
||||
store.new_account(&pass)
|
||||
@ -72,7 +72,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
.map_err(|e| errors::account("Could not create account.", e))
|
||||
}
|
||||
|
||||
fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option<RpcU128>) -> Result<bool, Error> {
|
||||
fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option<RpcU128>) -> Result<bool> {
|
||||
let account: Address = account.into();
|
||||
let store = self.account_provider()?;
|
||||
let duration = match duration {
|
||||
@ -104,7 +104,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> {
|
||||
fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256> {
|
||||
let dispatcher = self.dispatcher.clone();
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
|
||||
@ -137,7 +137,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> {
|
||||
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256> {
|
||||
warn!("Using deprecated personal_signAndSendTransaction, use personal_sendTransaction instead.");
|
||||
self.send_transaction(meta, request, password)
|
||||
}
|
||||
|
@ -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<S: core::Middleware<Metadata>> PubSub for PubSubClient<S> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parity_unsubscribe(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
fn parity_unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
|
||||
let res = self.poll_manager.write().unsubscribe(&id);
|
||||
Ok(res)
|
||||
}
|
||||
|
@ -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<BTreeMap<String, String>, Error> {
|
||||
fn rpc_modules(&self) -> Result<BTreeMap<String, String>> {
|
||||
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<BTreeMap<String, String>, Error> {
|
||||
fn modules(&self) -> Result<BTreeMap<String, String>> {
|
||||
let modules = self.modules.iter()
|
||||
.filter(|&(k, _v)| {
|
||||
self.valid_apis.contains(k)
|
||||
|
@ -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<AccountProvider>`, errors if provider was not
|
||||
/// set.
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
|
||||
/// Decrypt public key using account' private key
|
||||
fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result<Vec<u8>, Error> {
|
||||
fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result<Vec<u8>> {
|
||||
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<Secret, Error> {
|
||||
fn decrypt_secret(&self, address: H160, password: String, key: Bytes) -> Result<Secret> {
|
||||
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<Bytes, Error> {
|
||||
fn encrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result<Bytes> {
|
||||
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<Bytes, Error> {
|
||||
fn decrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result<Bytes> {
|
||||
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<Bytes>, data: Bytes) -> Result<Bytes, Error> {
|
||||
fn shadow_decrypt(&self, address: H160, password: String, decrypted_secret: H512, common_point: H512, decrypt_shadows: Vec<Bytes>, data: Bytes) -> Result<Bytes> {
|
||||
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)?);
|
||||
|
@ -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<D: Dispatcher + 'static> SignerClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
|
||||
fn confirm_internal<F, T>(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture<WithToken<ConfirmationResponse>, Error> where
|
||||
fn confirm_internal<F, T>(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture<WithToken<ConfirmationResponse>> where
|
||||
F: FnOnce(D, Arc<AccountProvider>, ConfirmationPayload) -> T,
|
||||
T: IntoFuture<Item=WithToken<ConfirmationResponse>, Error=Error>,
|
||||
T::Future: Send + 'static
|
||||
@ -124,8 +124,8 @@ impl<D: Dispatcher + 'static> SignerClient<D> {
|
||||
.unwrap_or_else(|| Either::B(future::err(errors::invalid_params("Unknown RequestID", id)))))
|
||||
}
|
||||
|
||||
fn verify_transaction<F>(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result<ConfirmationResponse, Error> where
|
||||
F: FnOnce(PendingTransaction) -> Result<ConfirmationResponse, Error>,
|
||||
fn verify_transaction<F>(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result<ConfirmationResponse> where
|
||||
F: FnOnce(PendingTransaction) -> Result<ConfirmationResponse>,
|
||||
{
|
||||
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<D: Dispatcher + 'static> SignerClient<D> {
|
||||
impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn requests_to_confirm(&self) -> Result<Vec<ConfirmationRequest>, Error> {
|
||||
fn requests_to_confirm(&self) -> Result<Vec<ConfirmationRequest>> {
|
||||
Ok(self.signer.requests()
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
@ -170,7 +170,7 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
// 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<ConfirmationResponse, Error>
|
||||
-> BoxFuture<ConfirmationResponse>
|
||||
{
|
||||
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<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
}
|
||||
|
||||
fn confirm_request_with_token(&self, id: U256, modification: TransactionModification, token: String)
|
||||
-> BoxFuture<ConfirmationResponseWithToken, Error>
|
||||
-> BoxFuture<ConfirmationResponseWithToken>
|
||||
{
|
||||
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<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result<ConfirmationResponse, Error> {
|
||||
fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result<ConfirmationResponse> {
|
||||
let id = id.into();
|
||||
|
||||
self.signer.peek(&id).map(|confirmation| {
|
||||
@ -230,17 +230,17 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
}).unwrap_or_else(|| Err(errors::invalid_params("Unknown RequestID", id)))
|
||||
}
|
||||
|
||||
fn reject_request(&self, id: U256) -> Result<bool, Error> {
|
||||
fn reject_request(&self, id: U256) -> Result<bool> {
|
||||
let res = self.signer.request_rejected(id.into());
|
||||
Ok(res.is_some())
|
||||
}
|
||||
|
||||
fn generate_token(&self) -> Result<String, Error> {
|
||||
fn generate_token(&self) -> Result<String> {
|
||||
self.signer.generate_token()
|
||||
.map_err(|e| errors::token(e))
|
||||
}
|
||||
|
||||
fn generate_web_proxy_token(&self, domain: String) -> Result<String, Error> {
|
||||
fn generate_web_proxy_token(&self, domain: String) -> Result<String> {
|
||||
Ok(self.signer.generate_web_proxy_access_token(domain.into()))
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
self.subscribers.lock().push(sub)
|
||||
}
|
||||
|
||||
fn unsubscribe_pending(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
fn unsubscribe_pending(&self, id: SubscriptionId) -> Result<bool> {
|
||||
let res = self.subscribers.lock().remove(&id).is_some();
|
||||
Ok(res)
|
||||
}
|
||||
|
@ -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<D: Dispatcher + 'static> SigningQueueClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
|
||||
fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture<DispatchResult, Error> {
|
||||
fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture<DispatchResult> {
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
let default_account = match default_account {
|
||||
DefaultAccount::Provided(acc) => acc,
|
||||
@ -143,13 +143,13 @@ impl<D: Dispatcher + 'static> SigningQueueClient<D> {
|
||||
impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest, Error> {
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest> {
|
||||
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<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
|
||||
let remote = self.remote.clone();
|
||||
let confirmations = self.confirmations.clone();
|
||||
|
||||
@ -166,7 +166,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
|
||||
let remote = self.remote.clone();
|
||||
let confirmations = self.confirmations.clone();
|
||||
|
||||
@ -180,7 +180,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn check_request(&self, id: RpcU256) -> Result<Option<RpcConfirmationResponse>, Error> {
|
||||
fn check_request(&self, id: RpcU256) -> Result<Option<RpcConfirmationResponse>> {
|
||||
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<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcBytes, Error> {
|
||||
fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcBytes> {
|
||||
let res = self.dispatch(
|
||||
RpcConfirmationPayload::Decrypt((address.clone(), data).into()),
|
||||
address.into(),
|
||||
@ -209,7 +209,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520, Error> {
|
||||
fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520> {
|
||||
let res = self.dispatch(
|
||||
RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()),
|
||||
address.into(),
|
||||
@ -224,7 +224,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256, Error> {
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256> {
|
||||
let res = self.dispatch(
|
||||
RpcConfirmationPayload::SendTransaction(request),
|
||||
meta.dapp_id().into(),
|
||||
@ -239,7 +239,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction, Error> {
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction> {
|
||||
let res = self.dispatch(
|
||||
RpcConfirmationPayload::SignTransaction(request),
|
||||
meta.dapp_id().into(),
|
||||
|
@ -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<D: Dispatcher + 'static> SigningUnsafeClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>, Error> {
|
||||
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
|
||||
unwrap_provider(&self.accounts)
|
||||
}
|
||||
|
||||
fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture<RpcConfirmationResponse, Error> {
|
||||
fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture<RpcConfirmationResponse> {
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
let default = match account {
|
||||
DefaultAccount::Provided(acc) => acc,
|
||||
@ -76,7 +76,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
{
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520, Error> {
|
||||
fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520> {
|
||||
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<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
}))
|
||||
}
|
||||
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256, Error> {
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256> {
|
||||
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<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction, Error> {
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction> {
|
||||
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<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
impl<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest, Error> {
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest> {
|
||||
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<RpcBytes, Error> {
|
||||
fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcBytes> {
|
||||
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<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
|
||||
// We don't support this in non-signer mode.
|
||||
Box::new(future::err(errors::signer_disabled()))
|
||||
}
|
||||
|
||||
fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
|
||||
// We don't support this in non-signer mode.
|
||||
Box::new(future::err((errors::signer_disabled())))
|
||||
}
|
||||
|
||||
fn check_request(&self, _: RpcU256) -> Result<Option<RpcConfirmationResponse>, Error> {
|
||||
fn check_request(&self, _: RpcU256) -> Result<Option<RpcConfirmationResponse>> {
|
||||
// We don't support this in non-signer mode.
|
||||
Err(errors::signer_disabled())
|
||||
}
|
||||
|
@ -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<C> TracesClient<C> {
|
||||
impl<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn filter(&self, filter: TraceFilter) -> Result<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn filter(&self, filter: TraceFilter) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
Ok(self.client.filter_traces(filter.into())
|
||||
.map(|traces| traces.into_iter().map(LocalizedTrace::from).collect()))
|
||||
}
|
||||
|
||||
fn block_traces(&self, block_number: BlockNumber) -> Result<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn block_traces(&self, block_number: BlockNumber) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
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<Option<Vec<LocalizedTrace>>, Error> {
|
||||
fn transaction_traces(&self, transaction_hash: H256) -> Result<Option<Vec<LocalizedTrace>>> {
|
||||
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<Index>) -> Result<Option<LocalizedTrace>, Error> {
|
||||
fn trace(&self, transaction_hash: H256, address: Vec<Index>) -> Result<Option<LocalizedTrace>> {
|
||||
let id = TraceId {
|
||||
transaction: TransactionId::Hash(transaction_hash.into()),
|
||||
address: address.into_iter().map(|i| i.value()).collect()
|
||||
@ -79,7 +79,7 @@ impl<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
|
||||
.map(LocalizedTrace::from))
|
||||
}
|
||||
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing<BlockNumber>) -> Result<TraceResults> {
|
||||
let block = block.unwrap_or_default();
|
||||
|
||||
let request = CallRequest::into(request);
|
||||
@ -90,7 +90,7 @@ impl<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>, Error> {
|
||||
fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>> {
|
||||
let block = block.unwrap_or_default();
|
||||
|
||||
let requests = requests.into_iter()
|
||||
@ -99,14 +99,14 @@ impl<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
|
||||
let signed = fake_sign::sign_call(request, meta.is_dapp())?;
|
||||
Ok((signed, to_call_analytics(flags)))
|
||||
})
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
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<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing<BlockNumber>) -> Result<TraceResults> {
|
||||
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<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result<TraceResults, Error> {
|
||||
fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result<TraceResults> {
|
||||
self.client.replay(TransactionId::Hash(transaction_hash.into()), to_call_analytics(flags))
|
||||
.map(TraceResults::from)
|
||||
.map_err(errors::call)
|
||||
|
@ -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<String, Error> {
|
||||
fn client_version(&self) -> Result<String> {
|
||||
Ok(version().to_owned().replace("Parity/", "Parity//"))
|
||||
}
|
||||
|
||||
fn sha3(&self, data: Bytes) -> Result<H256, Error> {
|
||||
fn sha3(&self, data: Bytes) -> Result<H256> {
|
||||
Ok(keccak(&data.0).into())
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<String, Error>;
|
||||
fn protocol_version(&self) -> Result<String>;
|
||||
|
||||
/// Returns an object with data about the sync status or false. (wtf?)
|
||||
#[rpc(name = "eth_syncing")]
|
||||
fn syncing(&self) -> Result<SyncStatus, Error>;
|
||||
fn syncing(&self) -> Result<SyncStatus>;
|
||||
|
||||
/// Returns the number of hashes per second that the node is mining with.
|
||||
#[rpc(name = "eth_hashrate")]
|
||||
fn hashrate(&self) -> Result<U256, Error>;
|
||||
fn hashrate(&self) -> Result<U256>;
|
||||
|
||||
/// Returns block author.
|
||||
#[rpc(meta, name = "eth_coinbase")]
|
||||
fn author(&self, Self::Metadata) -> Result<H160, Error>;
|
||||
fn author(&self, Self::Metadata) -> Result<H160>;
|
||||
|
||||
/// Returns true if client is actively mining new blocks.
|
||||
#[rpc(name = "eth_mining")]
|
||||
fn is_mining(&self) -> Result<bool, Error>;
|
||||
fn is_mining(&self) -> Result<bool>;
|
||||
|
||||
/// Returns current gas_price.
|
||||
#[rpc(name = "eth_gasPrice")]
|
||||
fn gas_price(&self) -> Result<U256, Error>;
|
||||
fn gas_price(&self) -> Result<U256>;
|
||||
|
||||
/// Returns accounts list.
|
||||
#[rpc(meta, name = "eth_accounts")]
|
||||
fn accounts(&self, Self::Metadata) -> Result<Vec<H160>, Error>;
|
||||
fn accounts(&self, Self::Metadata) -> Result<Vec<H160>>;
|
||||
|
||||
/// Returns highest block number.
|
||||
#[rpc(name = "eth_blockNumber")]
|
||||
fn block_number(&self) -> Result<U256, Error>;
|
||||
fn block_number(&self) -> Result<U256>;
|
||||
|
||||
/// Returns balance of the given account.
|
||||
#[rpc(name = "eth_getBalance")]
|
||||
fn balance(&self, H160, Trailing<BlockNumber>) -> BoxFuture<U256, Error>;
|
||||
fn balance(&self, H160, Trailing<BlockNumber>) -> BoxFuture<U256>;
|
||||
|
||||
/// Returns content of the storage at given address.
|
||||
#[rpc(name = "eth_getStorageAt")]
|
||||
fn storage_at(&self, H160, U256, Trailing<BlockNumber>) -> BoxFuture<H256, Error>;
|
||||
fn storage_at(&self, H160, U256, Trailing<BlockNumber>) -> BoxFuture<H256>;
|
||||
|
||||
/// Returns block with given hash.
|
||||
#[rpc(name = "eth_getBlockByHash")]
|
||||
fn block_by_hash(&self, H256, bool) -> BoxFuture<Option<RichBlock>, Error>;
|
||||
fn block_by_hash(&self, H256, bool) -> BoxFuture<Option<RichBlock>>;
|
||||
|
||||
/// Returns block with given number.
|
||||
#[rpc(name = "eth_getBlockByNumber")]
|
||||
fn block_by_number(&self, BlockNumber, bool) -> BoxFuture<Option<RichBlock>, Error>;
|
||||
fn block_by_number(&self, BlockNumber, bool) -> BoxFuture<Option<RichBlock>>;
|
||||
|
||||
/// Returns the number of transactions sent from given address at given time (block number).
|
||||
#[rpc(name = "eth_getTransactionCount")]
|
||||
fn transaction_count(&self, H160, Trailing<BlockNumber>) -> BoxFuture<U256, Error>;
|
||||
fn transaction_count(&self, H160, Trailing<BlockNumber>) -> BoxFuture<U256>;
|
||||
|
||||
/// Returns the number of transactions in a block with given hash.
|
||||
#[rpc(name = "eth_getBlockTransactionCountByHash")]
|
||||
fn block_transaction_count_by_hash(&self, H256) -> BoxFuture<Option<U256>, Error>;
|
||||
fn block_transaction_count_by_hash(&self, H256) -> BoxFuture<Option<U256>>;
|
||||
|
||||
/// 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<Option<U256>, Error>;
|
||||
fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture<Option<U256>>;
|
||||
|
||||
/// Returns the number of uncles in a block with given hash.
|
||||
#[rpc(name = "eth_getUncleCountByBlockHash")]
|
||||
fn block_uncles_count_by_hash(&self, H256) -> BoxFuture<Option<U256>, Error>;
|
||||
fn block_uncles_count_by_hash(&self, H256) -> BoxFuture<Option<U256>>;
|
||||
|
||||
/// 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<Option<U256>, Error>;
|
||||
fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture<Option<U256>>;
|
||||
|
||||
/// Returns the code at given address at given time (block number).
|
||||
#[rpc(name = "eth_getCode")]
|
||||
fn code_at(&self, H160, Trailing<BlockNumber>) -> BoxFuture<Bytes, Error>;
|
||||
fn code_at(&self, H160, Trailing<BlockNumber>) -> BoxFuture<Bytes>;
|
||||
|
||||
/// Sends signed transaction, returning its hash.
|
||||
#[rpc(name = "eth_sendRawTransaction")]
|
||||
fn send_raw_transaction(&self, Bytes) -> Result<H256, Error>;
|
||||
fn send_raw_transaction(&self, Bytes) -> Result<H256>;
|
||||
|
||||
/// @alias of `eth_sendRawTransaction`.
|
||||
#[rpc(name = "eth_submitTransaction")]
|
||||
fn submit_transaction(&self, Bytes) -> Result<H256, Error>;
|
||||
fn submit_transaction(&self, Bytes) -> Result<H256>;
|
||||
|
||||
/// Call contract, returning the output data.
|
||||
#[rpc(meta, name = "eth_call")]
|
||||
fn call(&self, Self::Metadata, CallRequest, Trailing<BlockNumber>) -> BoxFuture<Bytes, Error>;
|
||||
fn call(&self, Self::Metadata, CallRequest, Trailing<BlockNumber>) -> BoxFuture<Bytes>;
|
||||
|
||||
/// Estimate gas needed for execution of given contract.
|
||||
#[rpc(meta, name = "eth_estimateGas")]
|
||||
fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing<BlockNumber>) -> BoxFuture<U256, Error>;
|
||||
fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing<BlockNumber>) -> BoxFuture<U256>;
|
||||
|
||||
/// Get transaction by its hash.
|
||||
#[rpc(name = "eth_getTransactionByHash")]
|
||||
fn transaction_by_hash(&self, H256) -> BoxFuture<Option<Transaction>, Error>;
|
||||
fn transaction_by_hash(&self, H256) -> BoxFuture<Option<Transaction>>;
|
||||
|
||||
/// Returns transaction at given block hash and index.
|
||||
#[rpc(name = "eth_getTransactionByBlockHashAndIndex")]
|
||||
fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture<Option<Transaction>, Error>;
|
||||
fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture<Option<Transaction>>;
|
||||
|
||||
/// Returns transaction by given block number and index.
|
||||
#[rpc(name = "eth_getTransactionByBlockNumberAndIndex")]
|
||||
fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture<Option<Transaction>, Error>;
|
||||
fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture<Option<Transaction>>;
|
||||
|
||||
/// Returns transaction receipt by transaction hash.
|
||||
#[rpc(name = "eth_getTransactionReceipt")]
|
||||
fn transaction_receipt(&self, H256) -> BoxFuture<Option<Receipt>, Error>;
|
||||
fn transaction_receipt(&self, H256) -> BoxFuture<Option<Receipt>>;
|
||||
|
||||
/// Returns an uncles at given block and index.
|
||||
#[rpc(name = "eth_getUncleByBlockHashAndIndex")]
|
||||
fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture<Option<RichBlock>, Error>;
|
||||
fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture<Option<RichBlock>>;
|
||||
|
||||
/// Returns an uncles at given block and index.
|
||||
#[rpc(name = "eth_getUncleByBlockNumberAndIndex")]
|
||||
fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture<Option<RichBlock>, Error>;
|
||||
fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture<Option<RichBlock>>;
|
||||
|
||||
/// Returns available compilers.
|
||||
/// @deprecated
|
||||
#[rpc(name = "eth_getCompilers")]
|
||||
fn compilers(&self) -> Result<Vec<String>, Error>;
|
||||
fn compilers(&self) -> Result<Vec<String>>;
|
||||
|
||||
/// Compiles lll code.
|
||||
/// @deprecated
|
||||
#[rpc(name = "eth_compileLLL")]
|
||||
fn compile_lll(&self, String) -> Result<Bytes, Error>;
|
||||
fn compile_lll(&self, String) -> Result<Bytes>;
|
||||
|
||||
/// Compiles solidity.
|
||||
/// @deprecated
|
||||
#[rpc(name = "eth_compileSolidity")]
|
||||
fn compile_solidity(&self, String) -> Result<Bytes, Error>;
|
||||
fn compile_solidity(&self, String) -> Result<Bytes>;
|
||||
|
||||
/// Compiles serpent.
|
||||
/// @deprecated
|
||||
#[rpc(name = "eth_compileSerpent")]
|
||||
fn compile_serpent(&self, String) -> Result<Bytes, Error>;
|
||||
fn compile_serpent(&self, String) -> Result<Bytes>;
|
||||
|
||||
/// Returns logs matching given filter object.
|
||||
#[rpc(name = "eth_getLogs")]
|
||||
fn logs(&self, Filter) -> BoxFuture<Vec<Log>, Error>;
|
||||
fn logs(&self, Filter) -> BoxFuture<Vec<Log>>;
|
||||
|
||||
/// Returns the hash of the current block, the seedHash, and the boundary condition to be met.
|
||||
#[rpc(name = "eth_getWork")]
|
||||
fn work(&self, Trailing<u64>) -> Result<Work, Error>;
|
||||
fn work(&self, Trailing<u64>) -> Result<Work>;
|
||||
|
||||
/// Used for submitting a proof-of-work solution.
|
||||
#[rpc(name = "eth_submitWork")]
|
||||
fn submit_work(&self, H64, H256, H256) -> Result<bool, Error>;
|
||||
fn submit_work(&self, H64, H256, H256) -> Result<bool>;
|
||||
|
||||
/// Used for submitting mining hashrate.
|
||||
#[rpc(name = "eth_submitHashrate")]
|
||||
fn submit_hashrate(&self, U256, H256) -> Result<bool, Error>;
|
||||
fn submit_hashrate(&self, U256, H256) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<U256, Error>;
|
||||
fn new_filter(&self, Filter) -> Result<U256>;
|
||||
|
||||
/// Returns id of new block filter.
|
||||
#[rpc(name = "eth_newBlockFilter")]
|
||||
fn new_block_filter(&self) -> Result<U256, Error>;
|
||||
fn new_block_filter(&self) -> Result<U256>;
|
||||
|
||||
/// Returns id of new block filter.
|
||||
#[rpc(name = "eth_newPendingTransactionFilter")]
|
||||
fn new_pending_transaction_filter(&self) -> Result<U256, Error>;
|
||||
fn new_pending_transaction_filter(&self) -> Result<U256>;
|
||||
|
||||
/// Returns filter changes since last poll.
|
||||
#[rpc(name = "eth_getFilterChanges")]
|
||||
fn filter_changes(&self, Index) -> BoxFuture<FilterChanges, Error>;
|
||||
fn filter_changes(&self, Index) -> BoxFuture<FilterChanges>;
|
||||
|
||||
/// Returns all logs matching given filter (in a range 'from' - 'to').
|
||||
#[rpc(name = "eth_getFilterLogs")]
|
||||
fn filter_logs(&self, Index) -> BoxFuture<Vec<Log>, Error>;
|
||||
fn filter_logs(&self, Index) -> BoxFuture<Vec<Log>>;
|
||||
|
||||
/// Uninstalls filter.
|
||||
#[rpc(name = "eth_uninstallFilter")]
|
||||
fn uninstall_filter(&self, Index) -> Result<bool, Error>;
|
||||
fn uninstall_filter(&self, Index) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
|
@ -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<bool, Error>;
|
||||
fn unsubscribe(&self, SubscriptionId) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<H520, Error>;
|
||||
fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture<H520>;
|
||||
|
||||
/// 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<H256, Error>;
|
||||
fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture<H256>;
|
||||
|
||||
/// 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<RichRawTransaction, Error>;
|
||||
fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture<RichRawTransaction>;
|
||||
}
|
||||
}
|
||||
|
@ -15,22 +15,22 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<String, Error>;
|
||||
fn version(&self) -> Result<String>;
|
||||
|
||||
/// Returns number of peers connected to node.
|
||||
#[rpc(name = "net_peerCount")]
|
||||
fn peer_count(&self) -> Result<String, Error>;
|
||||
fn peer_count(&self) -> Result<String>;
|
||||
|
||||
/// Returns true if client is actively listening for network connections.
|
||||
/// Otherwise false.
|
||||
#[rpc(name = "net_listening")]
|
||||
fn is_listening(&self) -> Result<bool, Error>;
|
||||
fn is_listening(&self) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
|
@ -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<DappId>) -> Result<BTreeMap<H160, AccountInfo>, Error>;
|
||||
fn accounts_info(&self, Trailing<DappId>) -> Result<BTreeMap<H160, AccountInfo>>;
|
||||
|
||||
/// Returns hardware accounts information.
|
||||
#[rpc(name = "parity_hardwareAccountsInfo")]
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>, Error>;
|
||||
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>>;
|
||||
|
||||
/// Get a list of paths to locked hardware wallets
|
||||
#[rpc(name = "parity_lockedHardwareAccountsInfo")]
|
||||
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>, Error>;
|
||||
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>>;
|
||||
|
||||
/// Returns default account for dapp.
|
||||
#[rpc(meta, name = "parity_defaultAccount")]
|
||||
fn default_account(&self, Self::Metadata) -> Result<H160, Error>;
|
||||
fn default_account(&self, Self::Metadata) -> Result<H160>;
|
||||
|
||||
/// Returns current transactions limit.
|
||||
#[rpc(name = "parity_transactionsLimit")]
|
||||
fn transactions_limit(&self) -> Result<usize, Error>;
|
||||
fn transactions_limit(&self) -> Result<usize>;
|
||||
|
||||
/// Returns mining extra data.
|
||||
#[rpc(name = "parity_extraData")]
|
||||
fn extra_data(&self) -> Result<Bytes, Error>;
|
||||
fn extra_data(&self) -> Result<Bytes>;
|
||||
|
||||
/// Returns mining gas floor target.
|
||||
#[rpc(name = "parity_gasFloorTarget")]
|
||||
fn gas_floor_target(&self) -> Result<U256, Error>;
|
||||
fn gas_floor_target(&self) -> Result<U256>;
|
||||
|
||||
/// Returns mining gas floor cap.
|
||||
#[rpc(name = "parity_gasCeilTarget")]
|
||||
fn gas_ceil_target(&self) -> Result<U256, Error>;
|
||||
fn gas_ceil_target(&self) -> Result<U256>;
|
||||
|
||||
/// Returns minimal gas price for transaction to be included in queue.
|
||||
#[rpc(name = "parity_minGasPrice")]
|
||||
fn min_gas_price(&self) -> Result<U256, Error>;
|
||||
fn min_gas_price(&self) -> Result<U256>;
|
||||
|
||||
/// Returns latest logs
|
||||
#[rpc(name = "parity_devLogs")]
|
||||
fn dev_logs(&self) -> Result<Vec<String>, Error>;
|
||||
fn dev_logs(&self) -> Result<Vec<String>>;
|
||||
|
||||
/// Returns logs levels
|
||||
#[rpc(name = "parity_devLogsLevels")]
|
||||
fn dev_logs_levels(&self) -> Result<String, Error>;
|
||||
fn dev_logs_levels(&self) -> Result<String>;
|
||||
|
||||
/// Returns chain name - DEPRECATED. Use `parity_chainName` instead.
|
||||
#[rpc(name = "parity_netChain")]
|
||||
fn net_chain(&self) -> Result<String, Error>;
|
||||
fn net_chain(&self) -> Result<String>;
|
||||
|
||||
/// Returns peers details
|
||||
#[rpc(name = "parity_netPeers")]
|
||||
fn net_peers(&self) -> Result<Peers, Error>;
|
||||
fn net_peers(&self) -> Result<Peers>;
|
||||
|
||||
/// Returns network port
|
||||
#[rpc(name = "parity_netPort")]
|
||||
fn net_port(&self) -> Result<u16, Error>;
|
||||
fn net_port(&self) -> Result<u16>;
|
||||
|
||||
/// Returns rpc settings
|
||||
#[rpc(name = "parity_rpcSettings")]
|
||||
fn rpc_settings(&self) -> Result<RpcSettings, Error>;
|
||||
fn rpc_settings(&self) -> Result<RpcSettings>;
|
||||
|
||||
/// Returns node name
|
||||
#[rpc(name = "parity_nodeName")]
|
||||
fn node_name(&self) -> Result<String, Error>;
|
||||
fn node_name(&self) -> Result<String>;
|
||||
|
||||
/// Returns default extra data
|
||||
#[rpc(name = "parity_defaultExtraData")]
|
||||
fn default_extra_data(&self) -> Result<Bytes, Error>;
|
||||
fn default_extra_data(&self) -> Result<Bytes>;
|
||||
|
||||
/// Returns distribution of gas price in latest blocks.
|
||||
#[rpc(name = "parity_gasPriceHistogram")]
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram, Error>;
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram>;
|
||||
|
||||
/// 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<usize, Error>;
|
||||
fn unsigned_transactions_count(&self) -> Result<usize>;
|
||||
|
||||
/// Returns a cryptographically random phrase sufficient for securely seeding a secret key.
|
||||
#[rpc(name = "parity_generateSecretPhrase")]
|
||||
fn generate_secret_phrase(&self) -> Result<String, Error>;
|
||||
fn generate_secret_phrase(&self) -> Result<String>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn phrase_to_address(&self, String) -> Result<H160>;
|
||||
|
||||
/// Returns the value of the registrar for this network.
|
||||
#[rpc(name = "parity_registryAddress")]
|
||||
fn registry_address(&self) -> Result<Option<H160>, Error>;
|
||||
fn registry_address(&self) -> Result<Option<H160>>;
|
||||
|
||||
/// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not.
|
||||
#[rpc(name = "parity_listAccounts")]
|
||||
fn list_accounts(&self, u64, Option<H160>, Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error>;
|
||||
fn list_accounts(&self, u64, Option<H160>, Trailing<BlockNumber>) -> Result<Option<Vec<H160>>>;
|
||||
|
||||
/// 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<H256>, Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error>;
|
||||
fn list_storage_keys(&self, H160, u64, Option<H256>, Trailing<BlockNumber>) -> Result<Option<Vec<H256>>>;
|
||||
|
||||
/// 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<Bytes, Error>;
|
||||
fn encrypt_message(&self, H512, Bytes) -> Result<Bytes>;
|
||||
|
||||
/// Returns all pending transactions from transaction queue.
|
||||
#[rpc(name = "parity_pendingTransactions")]
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>, Error>;
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>>;
|
||||
|
||||
/// Returns all future transactions from transaction queue.
|
||||
#[rpc(name = "parity_futureTransactions")]
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>, Error>;
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>>;
|
||||
|
||||
/// Returns propagation statistics on transactions pending in the queue.
|
||||
#[rpc(name = "parity_pendingTransactionsStats")]
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>, Error>;
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>>;
|
||||
|
||||
/// Returns a list of current and past local transactions with status details.
|
||||
#[rpc(name = "parity_localTransactions")]
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>, Error>;
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>>;
|
||||
|
||||
/// Returns current Dapps Server interface and port or an error if dapps server is disabled.
|
||||
#[rpc(name = "parity_dappsUrl")]
|
||||
fn dapps_url(&self) -> Result<String, Error>;
|
||||
fn dapps_url(&self) -> Result<String>;
|
||||
|
||||
/// Returns current WS Server interface and port or an error if ws server is disabled.
|
||||
#[rpc(name = "parity_wsUrl")]
|
||||
fn ws_url(&self) -> Result<String, Error>;
|
||||
fn ws_url(&self) -> Result<String>;
|
||||
|
||||
/// Returns next nonce for particular sender. Should include all transactions in the queue.
|
||||
#[rpc(name = "parity_nextNonce")]
|
||||
fn next_nonce(&self, H160) -> BoxFuture<U256, Error>;
|
||||
fn next_nonce(&self, H160) -> BoxFuture<U256>;
|
||||
|
||||
/// Get the mode. Returns one of: "active", "passive", "dark", "offline".
|
||||
#[rpc(name = "parity_mode")]
|
||||
fn mode(&self) -> Result<String, Error>;
|
||||
fn mode(&self) -> Result<String>;
|
||||
|
||||
/// 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<Option<U64>, Error>;
|
||||
fn chain_id(&self) -> Result<Option<U64>>;
|
||||
|
||||
/// Get the chain name. Returns one of: "foundation", "kovan", &c. of a filename.
|
||||
#[rpc(name = "parity_chain")]
|
||||
fn chain(&self) -> Result<String, Error>;
|
||||
fn chain(&self) -> Result<String>;
|
||||
|
||||
/// Get the enode of this node.
|
||||
#[rpc(name = "parity_enode")]
|
||||
fn enode(&self) -> Result<String, Error>;
|
||||
fn enode(&self) -> Result<String>;
|
||||
|
||||
/// Returns information on current consensus capability.
|
||||
#[rpc(name = "parity_consensusCapability")]
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability, Error>;
|
||||
fn consensus_capability(&self) -> Result<ConsensusCapability>;
|
||||
|
||||
/// Get our version information in a nice object.
|
||||
#[rpc(name = "parity_versionInfo")]
|
||||
fn version_info(&self) -> Result<VersionInfo, Error>;
|
||||
fn version_info(&self) -> Result<VersionInfo>;
|
||||
|
||||
/// Get information concerning the latest releases if available.
|
||||
#[rpc(name = "parity_releasesInfo")]
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>, Error>;
|
||||
fn releases_info(&self) -> Result<Option<OperationsInfo>>;
|
||||
|
||||
/// Get the current chain status.
|
||||
#[rpc(name = "parity_chainStatus")]
|
||||
fn chain_status(&self) -> Result<ChainStatus, Error>;
|
||||
fn chain_status(&self) -> Result<ChainStatus>;
|
||||
|
||||
/// 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<BlockNumber>) -> BoxFuture<RichHeader, Error>;
|
||||
fn block_header(&self, Trailing<BlockNumber>) -> BoxFuture<RichHeader>;
|
||||
|
||||
/// Get IPFS CIDv0 given protobuf encoded bytes.
|
||||
#[rpc(name = "parity_cidV0")]
|
||||
fn ipfs_cid(&self, Bytes) -> Result<String, Error>;
|
||||
fn ipfs_cid(&self, Bytes) -> Result<String>;
|
||||
|
||||
/// Call contract, returning the output data.
|
||||
#[rpc(meta, name = "parity_call")]
|
||||
fn call(&self, Self::Metadata, Vec<CallRequest>, Trailing<BlockNumber>) -> Result<Vec<Bytes>, Error>;
|
||||
fn call(&self, Self::Metadata, Vec<CallRequest>, Trailing<BlockNumber>) -> Result<Vec<Bytes>>;
|
||||
|
||||
/// Returns node's health report.
|
||||
#[rpc(name = "parity_nodeHealth")]
|
||||
fn node_health(&self) -> BoxFuture<Health, Error>;
|
||||
fn node_health(&self) -> BoxFuture<Health>;
|
||||
}
|
||||
}
|
||||
|
@ -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<BTreeMap<H160, ExtAccountInfo>, Error>;
|
||||
fn all_accounts_info(&self) -> Result<BTreeMap<H160, ExtAccountInfo>>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn new_account_from_phrase(&self, String, String) -> Result<H160>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn new_account_from_wallet(&self, String, String) -> Result<H160>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn new_account_from_secret(&self, H256, String) -> Result<H160>;
|
||||
|
||||
/// Returns true if given `password` would unlock given `account`.
|
||||
/// Arguments: `account`, `password`.
|
||||
#[rpc(name = "parity_testPassword")]
|
||||
fn test_password(&self, H160, String) -> Result<bool, Error>;
|
||||
fn test_password(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// Changes an account's password.
|
||||
/// Arguments: `account`, `password`, `new_password`.
|
||||
#[rpc(name = "parity_changePassword")]
|
||||
fn change_password(&self, H160, String, String) -> Result<bool, Error>;
|
||||
fn change_password(&self, H160, String, String) -> Result<bool>;
|
||||
|
||||
/// Permanently deletes an account.
|
||||
/// Arguments: `account`, `password`.
|
||||
#[rpc(name = "parity_killAccount")]
|
||||
fn kill_account(&self, H160, String) -> Result<bool, Error>;
|
||||
fn kill_account(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// Permanently deletes an address from the addressbook
|
||||
/// Arguments: `address`
|
||||
#[rpc(name = "parity_removeAddress")]
|
||||
fn remove_address(&self, H160) -> Result<bool, Error>;
|
||||
fn remove_address(&self, H160) -> Result<bool>;
|
||||
|
||||
/// Set an account's name.
|
||||
#[rpc(name = "parity_setAccountName")]
|
||||
fn set_account_name(&self, H160, String) -> Result<bool, Error>;
|
||||
fn set_account_name(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// Set an account's metadata string.
|
||||
#[rpc(name = "parity_setAccountMeta")]
|
||||
fn set_account_meta(&self, H160, String) -> Result<bool, Error>;
|
||||
fn set_account_meta(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// 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<Vec<H160>>) -> Result<bool, Error>;
|
||||
fn set_dapp_addresses(&self, DappId, Option<Vec<H160>>) -> Result<bool>;
|
||||
|
||||
/// Gets accounts exposed for particular dapp.
|
||||
#[rpc(name = "parity_getDappAddresses")]
|
||||
fn dapp_addresses(&self, DappId) -> Result<Vec<H160>, Error>;
|
||||
fn dapp_addresses(&self, DappId) -> Result<Vec<H160>>;
|
||||
|
||||
/// 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<bool, Error>;
|
||||
fn set_dapp_default_address(&self, DappId, H160) -> Result<bool>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn dapp_default_address(&self, DappId) -> Result<H160>;
|
||||
|
||||
/// 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<Vec<H160>>) -> Result<bool, Error>;
|
||||
fn set_new_dapps_addresses(&self, Option<Vec<H160>>) -> Result<bool>;
|
||||
|
||||
/// Gets accounts exposed for new dapps.
|
||||
/// `None` means that all accounts are exposes.
|
||||
#[rpc(name = "parity_getNewDappsAddresses")]
|
||||
fn new_dapps_addresses(&self) -> Result<Option<Vec<H160>>, Error>;
|
||||
fn new_dapps_addresses(&self) -> Result<Option<Vec<H160>>>;
|
||||
|
||||
/// 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<bool, Error>;
|
||||
fn set_new_dapps_default_address(&self, H160) -> Result<bool>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn new_dapps_default_address(&self) -> Result<H160>;
|
||||
|
||||
/// Returns identified dapps that recently used RPC
|
||||
/// Includes last usage timestamp.
|
||||
#[rpc(name = "parity_listRecentDapps")]
|
||||
fn recent_dapps(&self) -> Result<BTreeMap<DappId, u64>, Error>;
|
||||
fn recent_dapps(&self) -> Result<BTreeMap<DappId, u64>>;
|
||||
|
||||
/// Imports a number of Geth accounts, with the list provided as the argument.
|
||||
#[rpc(name = "parity_importGethAccounts")]
|
||||
fn import_geth_accounts(&self, Vec<H160>) -> Result<Vec<H160>, Error>;
|
||||
fn import_geth_accounts(&self, Vec<H160>) -> Result<Vec<H160>>;
|
||||
|
||||
/// Returns the accounts available for importing from Geth.
|
||||
#[rpc(name = "parity_listGethAccounts")]
|
||||
fn geth_accounts(&self) -> Result<Vec<H160>, Error>;
|
||||
fn geth_accounts(&self) -> Result<Vec<H160>>;
|
||||
|
||||
/// Create new vault.
|
||||
#[rpc(name = "parity_newVault")]
|
||||
fn create_vault(&self, String, String) -> Result<bool, Error>;
|
||||
fn create_vault(&self, String, String) -> Result<bool>;
|
||||
|
||||
/// Open existing vault.
|
||||
#[rpc(name = "parity_openVault")]
|
||||
fn open_vault(&self, String, String) -> Result<bool, Error>;
|
||||
fn open_vault(&self, String, String) -> Result<bool>;
|
||||
|
||||
/// Close previously opened vault.
|
||||
#[rpc(name = "parity_closeVault")]
|
||||
fn close_vault(&self, String) -> Result<bool, Error>;
|
||||
fn close_vault(&self, String) -> Result<bool>;
|
||||
|
||||
/// List all vaults.
|
||||
#[rpc(name = "parity_listVaults")]
|
||||
fn list_vaults(&self) -> Result<Vec<String>, Error>;
|
||||
fn list_vaults(&self) -> Result<Vec<String>>;
|
||||
|
||||
/// List all currently opened vaults.
|
||||
#[rpc(name = "parity_listOpenedVaults")]
|
||||
fn list_opened_vaults(&self) -> Result<Vec<String>, Error>;
|
||||
fn list_opened_vaults(&self) -> Result<Vec<String>>;
|
||||
|
||||
/// Change vault password.
|
||||
#[rpc(name = "parity_changeVaultPassword")]
|
||||
fn change_vault_password(&self, String, String) -> Result<bool, Error>;
|
||||
fn change_vault_password(&self, String, String) -> Result<bool>;
|
||||
|
||||
/// Change vault of the given address.
|
||||
#[rpc(name = "parity_changeVault")]
|
||||
fn change_vault(&self, H160, String) -> Result<bool, Error>;
|
||||
fn change_vault(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// Get vault metadata string.
|
||||
#[rpc(name = "parity_getVaultMeta")]
|
||||
fn get_vault_meta(&self, String) -> Result<String, Error>;
|
||||
fn get_vault_meta(&self, String) -> Result<String>;
|
||||
|
||||
/// Set vault metadata string.
|
||||
#[rpc(name = "parity_setVaultMeta")]
|
||||
fn set_vault_meta(&self, String, String) -> Result<bool, Error>;
|
||||
fn set_vault_meta(&self, String, String) -> Result<bool>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn derive_key_hash(&self, H160, String, DeriveHash, bool) -> Result<H160>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn derive_key_index(&self, H160, String, DeriveHierarchical, bool) -> Result<H160>;
|
||||
|
||||
/// Exports an account with given address if provided password matches.
|
||||
#[rpc(name = "parity_exportAccount")]
|
||||
fn export_account(&self, H160, String) -> Result<KeyFile, Error>;
|
||||
fn export_account(&self, H160, String) -> Result<KeyFile>;
|
||||
|
||||
/// Sign raw hash with the key corresponding to address and password.
|
||||
#[rpc(name = "parity_signMessage")]
|
||||
fn sign_message(&self, H160, String, H256) -> Result<H520, Error>;
|
||||
fn sign_message(&self, H160, String, H256) -> Result<H520>;
|
||||
|
||||
/// Send a PinMatrixAck to a hardware wallet, unlocking it
|
||||
#[rpc(name = "parity_hardwarePinMatrixAck")]
|
||||
fn hardware_pin_matrix_ack(&self, String, String) -> Result<bool, Error>;
|
||||
fn hardware_pin_matrix_ack(&self, String, String) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
|
@ -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<bool, Error>;
|
||||
fn set_min_gas_price(&self, U256) -> Result<bool>;
|
||||
|
||||
/// Sets new gas floor target for mined blocks.
|
||||
#[rpc(name = "parity_setGasFloorTarget")]
|
||||
fn set_gas_floor_target(&self, U256) -> Result<bool, Error>;
|
||||
fn set_gas_floor_target(&self, U256) -> Result<bool>;
|
||||
|
||||
/// Sets new gas ceiling target for mined blocks.
|
||||
#[rpc(name = "parity_setGasCeilTarget")]
|
||||
fn set_gas_ceil_target(&self, U256) -> Result<bool, Error>;
|
||||
fn set_gas_ceil_target(&self, U256) -> Result<bool>;
|
||||
|
||||
/// Sets new extra data for mined blocks.
|
||||
#[rpc(name = "parity_setExtraData")]
|
||||
fn set_extra_data(&self, Bytes) -> Result<bool, Error>;
|
||||
fn set_extra_data(&self, Bytes) -> Result<bool>;
|
||||
|
||||
/// Sets new author for mined block.
|
||||
#[rpc(name = "parity_setAuthor")]
|
||||
fn set_author(&self, H160) -> Result<bool, Error>;
|
||||
fn set_author(&self, H160) -> Result<bool>;
|
||||
|
||||
/// Sets account for signing consensus messages.
|
||||
#[rpc(name = "parity_setEngineSigner")]
|
||||
fn set_engine_signer(&self, H160, String) -> Result<bool, Error>;
|
||||
fn set_engine_signer(&self, H160, String) -> Result<bool>;
|
||||
|
||||
/// Sets the limits for transaction queue.
|
||||
#[rpc(name = "parity_setTransactionsLimit")]
|
||||
fn set_transactions_limit(&self, usize) -> Result<bool, Error>;
|
||||
fn set_transactions_limit(&self, usize) -> Result<bool>;
|
||||
|
||||
/// Sets the maximum amount of gas a single transaction may consume.
|
||||
#[rpc(name = "parity_setMaxTransactionGas")]
|
||||
fn set_tx_gas_limit(&self, U256) -> Result<bool, Error>;
|
||||
fn set_tx_gas_limit(&self, U256) -> Result<bool>;
|
||||
|
||||
/// Add a reserved peer.
|
||||
#[rpc(name = "parity_addReservedPeer")]
|
||||
fn add_reserved_peer(&self, String) -> Result<bool, Error>;
|
||||
fn add_reserved_peer(&self, String) -> Result<bool>;
|
||||
|
||||
/// Remove a reserved peer.
|
||||
#[rpc(name = "parity_removeReservedPeer")]
|
||||
fn remove_reserved_peer(&self, String) -> Result<bool, Error>;
|
||||
fn remove_reserved_peer(&self, String) -> Result<bool>;
|
||||
|
||||
/// Drop all non-reserved peers.
|
||||
#[rpc(name = "parity_dropNonReservedPeers")]
|
||||
fn drop_non_reserved_peers(&self) -> Result<bool, Error>;
|
||||
fn drop_non_reserved_peers(&self) -> Result<bool>;
|
||||
|
||||
/// Accept non-reserved peers (default behavior)
|
||||
#[rpc(name = "parity_acceptNonReservedPeers")]
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool, Error>;
|
||||
fn accept_non_reserved_peers(&self) -> Result<bool>;
|
||||
|
||||
/// Start the network.
|
||||
///
|
||||
/// @deprecated - Use `set_mode("active")` instead.
|
||||
#[rpc(name = "parity_startNetwork")]
|
||||
fn start_network(&self) -> Result<bool, Error>;
|
||||
fn start_network(&self) -> Result<bool>;
|
||||
|
||||
/// Stop the network.
|
||||
///
|
||||
/// @deprecated - Use `set_mode("offline")` instead.
|
||||
#[rpc(name = "parity_stopNetwork")]
|
||||
fn stop_network(&self) -> Result<bool, Error>;
|
||||
fn stop_network(&self) -> Result<bool>;
|
||||
|
||||
/// Set the mode. Argument must be one of: "active", "passive", "dark", "offline".
|
||||
#[rpc(name = "parity_setMode")]
|
||||
fn set_mode(&self, String) -> Result<bool, Error>;
|
||||
fn set_mode(&self, String) -> Result<bool>;
|
||||
|
||||
/// 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<bool, Error>;
|
||||
fn set_spec_name(&self, String) -> Result<bool>;
|
||||
|
||||
/// Hash a file content under given URL.
|
||||
#[rpc(name = "parity_hashContent")]
|
||||
fn hash_content(&self, String) -> BoxFuture<H256, Error>;
|
||||
fn hash_content(&self, String) -> BoxFuture<H256>;
|
||||
|
||||
/// Returns true if refresh successful, error if unsuccessful or server is disabled.
|
||||
#[rpc(name = "parity_dappsRefresh")]
|
||||
fn dapps_refresh(&self) -> Result<bool, Error>;
|
||||
fn dapps_refresh(&self) -> Result<bool>;
|
||||
|
||||
/// Returns a list of local dapps
|
||||
#[rpc(name = "parity_dappsList")]
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>, Error>;
|
||||
fn dapps_list(&self) -> Result<Vec<LocalDapp>>;
|
||||
|
||||
/// Is there a release ready for install?
|
||||
#[rpc(name = "parity_upgradeReady")]
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>, Error>;
|
||||
fn upgrade_ready(&self) -> Result<Option<ReleaseInfo>>;
|
||||
|
||||
/// Execute a release which is ready according to upgrade_ready().
|
||||
#[rpc(name = "parity_executeUpgrade")]
|
||||
fn execute_upgrade(&self) -> Result<bool, Error>;
|
||||
fn execute_upgrade(&self) -> Result<bool>;
|
||||
|
||||
/// 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<Option<Transaction>, Error>;
|
||||
fn remove_transaction(&self, H256) -> Result<Option<Transaction>>;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<TransactionRequest, Error>;
|
||||
fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture<TransactionRequest>;
|
||||
|
||||
/// 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<Either<U256, ConfirmationResponse>, Error>;
|
||||
fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture<Either<U256, ConfirmationResponse>>;
|
||||
|
||||
/// 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<Either<U256, ConfirmationResponse>, Error>;
|
||||
fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture<Either<U256, ConfirmationResponse>>;
|
||||
|
||||
/// 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<Option<ConfirmationResponse>, Error>;
|
||||
fn check_request(&self, U256) -> Result<Option<ConfirmationResponse>>;
|
||||
|
||||
/// 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<Bytes, Error>;
|
||||
fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture<Bytes>;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<Vec<H160>, Error>;
|
||||
fn accounts(&self) -> Result<Vec<H160>>;
|
||||
|
||||
/// 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<H160, Error>;
|
||||
fn new_account(&self, String) -> Result<H160>;
|
||||
|
||||
/// 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<U128>) -> Result<bool, Error>;
|
||||
fn unlock_account(&self, H160, String, Option<U128>) -> Result<bool>;
|
||||
|
||||
/// 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<H256, Error>;
|
||||
fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256>;
|
||||
|
||||
/// @deprecated alias for `personal_sendTransaction`.
|
||||
#[rpc(meta, name = "personal_signAndSendTransaction")]
|
||||
fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256, Error>;
|
||||
fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256>;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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<bool, Error>;
|
||||
fn parity_unsubscribe(&self, SubscriptionId) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<BTreeMap<String, String>, Error>;
|
||||
fn modules(&self) -> Result<BTreeMap<String, String>>;
|
||||
|
||||
/// Returns supported modules for Geth 1.4.0
|
||||
/// @ignore
|
||||
#[rpc(name = "rpc_modules")]
|
||||
fn rpc_modules(&self) -> Result<BTreeMap<String, String>, Error>;
|
||||
fn rpc_modules(&self) -> Result<BTreeMap<String, String>>;
|
||||
}
|
||||
}
|
||||
|
@ -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<Bytes, Error>;
|
||||
fn encrypt(&self, H160, String, Bytes, Bytes) -> Result<Bytes>;
|
||||
|
||||
/// 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<Bytes, Error>;
|
||||
fn decrypt(&self, H160, String, Bytes, Bytes) -> Result<Bytes>;
|
||||
|
||||
/// 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>, Bytes) -> Result<Bytes, Error>;
|
||||
fn shadow_decrypt(&self, H160, String, H512, H512, Vec<Bytes>, Bytes) -> Result<Bytes>;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<Vec<ConfirmationRequest>, Error>;
|
||||
fn requests_to_confirm(&self) -> Result<Vec<ConfirmationRequest>>;
|
||||
|
||||
/// Confirm specific request.
|
||||
#[rpc(name = "signer_confirmRequest")]
|
||||
fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture<ConfirmationResponse, Error>;
|
||||
fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture<ConfirmationResponse>;
|
||||
|
||||
/// Confirm specific request with token.
|
||||
#[rpc(name = "signer_confirmRequestWithToken")]
|
||||
fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture<ConfirmationResponseWithToken, Error>;
|
||||
fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture<ConfirmationResponseWithToken>;
|
||||
|
||||
/// Confirm specific request with already signed data.
|
||||
#[rpc(name = "signer_confirmRequestRaw")]
|
||||
fn confirm_request_raw(&self, U256, Bytes) -> Result<ConfirmationResponse, Error>;
|
||||
fn confirm_request_raw(&self, U256, Bytes) -> Result<ConfirmationResponse>;
|
||||
|
||||
/// Reject the confirmation request.
|
||||
#[rpc(name = "signer_rejectRequest")]
|
||||
fn reject_request(&self, U256) -> Result<bool, Error>;
|
||||
fn reject_request(&self, U256) -> Result<bool>;
|
||||
|
||||
/// Generates new authorization token.
|
||||
#[rpc(name = "signer_generateAuthorizationToken")]
|
||||
fn generate_token(&self) -> Result<String, Error>;
|
||||
fn generate_token(&self) -> Result<String>;
|
||||
|
||||
/// Generates new web proxy access token for particular domain.
|
||||
#[rpc(name = "signer_generateWebProxyAccessToken")]
|
||||
fn generate_web_proxy_token(&self, String) -> Result<String, Error>;
|
||||
fn generate_web_proxy_token(&self, String) -> Result<String>;
|
||||
|
||||
#[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<bool, Error>;
|
||||
fn unsubscribe_pending(&self, SubscriptionId) -> Result<bool>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Option<Vec<LocalizedTrace>>, Error>;
|
||||
fn filter(&self, TraceFilter) -> Result<Option<Vec<LocalizedTrace>>>;
|
||||
|
||||
/// Returns transaction trace at given index.
|
||||
#[rpc(name = "trace_get")]
|
||||
fn trace(&self, H256, Vec<Index>) -> Result<Option<LocalizedTrace>, Error>;
|
||||
fn trace(&self, H256, Vec<Index>) -> Result<Option<LocalizedTrace>>;
|
||||
|
||||
/// Returns all traces of given transaction.
|
||||
#[rpc(name = "trace_transaction")]
|
||||
fn transaction_traces(&self, H256) -> Result<Option<Vec<LocalizedTrace>>, Error>;
|
||||
fn transaction_traces(&self, H256) -> Result<Option<Vec<LocalizedTrace>>>;
|
||||
|
||||
/// Returns all traces produced at given block.
|
||||
#[rpc(name = "trace_block")]
|
||||
fn block_traces(&self, BlockNumber) -> Result<Option<Vec<LocalizedTrace>>, Error>;
|
||||
fn block_traces(&self, BlockNumber) -> Result<Option<Vec<LocalizedTrace>>>;
|
||||
|
||||
/// 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<BlockNumber>) -> Result<TraceResults, Error>;
|
||||
fn call(&self, Self::Metadata, CallRequest, TraceOptions, Trailing<BlockNumber>) -> Result<TraceResults>;
|
||||
|
||||
/// 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<BlockNumber>) -> Result<Vec<TraceResults>, Error>;
|
||||
fn call_many(&self, Self::Metadata, Vec<(CallRequest, TraceOptions)>, Trailing<BlockNumber>) -> Result<Vec<TraceResults>>;
|
||||
|
||||
/// 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<BlockNumber>) -> Result<TraceResults, Error>;
|
||||
fn raw_transaction(&self, Bytes, TraceOptions, Trailing<BlockNumber>) -> Result<TraceResults>;
|
||||
|
||||
/// 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<TraceResults, Error>;
|
||||
fn replay_transaction(&self, H256, TraceOptions) -> Result<TraceResults>;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<String, Error>;
|
||||
fn client_version(&self) -> Result<String>;
|
||||
|
||||
/// Returns sha3 of the given data
|
||||
#[rpc(name = "web3_sha3")]
|
||||
fn sha3(&self, Bytes) -> Result<H256, Error>;
|
||||
fn sha3(&self, Bytes) -> Result<H256>;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -18,6 +18,8 @@ extern crate log;
|
||||
#[macro_use]
|
||||
extern crate matches;
|
||||
|
||||
/// Boxed future response.
|
||||
pub type BoxFuture<T, E> = Box<futures::Future<Item=T, Error=E> + Send>;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -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,
|
||||
|
@ -450,7 +450,7 @@ impl<T> SessionImpl<T> 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
|
||||
|
Loading…
Reference in New Issue
Block a user