// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
//! Eth rpc interface.
use jsonrpc_core::Error;
use jsonrpc_macros::Trailing;
use futures::BoxFuture;
use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index};
use v1::types::{Log, Receipt, SyncStatus, Transaction, Work};
use v1::types::{H64, H160, H256, U256};
build_rpc_trait! {
/// Eth rpc interface.
pub trait Eth {
type Metadata;
/// Returns protocol version encoded as a string (quotes are necessary).
#[rpc(name = "eth_protocolVersion")]
fn protocol_version(&self) -> Result;
/// Returns an object with data about the sync status or false. (wtf?)
#[rpc(name = "eth_syncing")]
fn syncing(&self) -> Result;
/// Returns the number of hashes per second that the node is mining with.
#[rpc(name = "eth_hashrate")]
fn hashrate(&self) -> Result;
/// Returns block author.
#[rpc(name = "eth_coinbase")]
fn author(&self) -> Result;
/// Returns true if client is actively mining new blocks.
#[rpc(name = "eth_mining")]
fn is_mining(&self) -> Result;
/// Returns current gas_price.
#[rpc(name = "eth_gasPrice")]
fn gas_price(&self) -> Result;
/// Returns accounts list.
#[rpc(meta, name = "eth_accounts")]
fn accounts(&self, Self::Metadata) -> BoxFuture, Error>;
/// Returns highest block number.
#[rpc(name = "eth_blockNumber")]
fn block_number(&self) -> Result;
/// Returns balance of the given account.
#[rpc(name = "eth_getBalance")]
fn balance(&self, H160, Trailing) -> Result;
/// Returns content of the storage at given address.
#[rpc(name = "eth_getStorageAt")]
fn storage_at(&self, H160, U256, Trailing) -> Result;
/// Returns block with given hash.
#[rpc(name = "eth_getBlockByHash")]
fn block_by_hash(&self, H256, bool) -> Result