fix(rpc-types): replace uint and hash with ethereum_types v0.4 (#10217)

* fix(rpc-types): remove uint and hash wrappers

* fix(tests)

* fix(cleanup)

* grumbles(rpc-api): revert `verify_signature`

* revert change of `U64` -> `u64`

* fix(cleanup after bad merge)

* chore(bump ethereum-types)

* fix(bad merge)

* feat(tests ethereum-types): add tests

* chore(update `ethereum-types` to 0.4.2)

* feat(tests for h256)

* chore(rpc): remove `ethbloom` import

Use re-export from `ethereum-types` instead

* fix(bad merge): remove `DefaultAccount` type

* doc(add TODO with issue link)
This commit is contained in:
Niklas Adolfsson
2019-02-25 14:27:28 +01:00
committed by GitHub
parent bceb883d99
commit c5c3fb6a75
72 changed files with 360 additions and 624 deletions

View File

@@ -21,7 +21,7 @@ use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH};
use std::sync::Arc;
use rlp::Rlp;
use ethereum_types::{U256, H256, H160, Address};
use ethereum_types::{Address, H64, H160, H256, U64, U256};
use parking_lot::Mutex;
use ethash::{self, SeedHashCompute};
@@ -47,8 +47,7 @@ use v1::traits::Eth;
use v1::types::{
RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo,
Transaction, CallRequest, Index, Filter, Log, Receipt, Work, EthAccount, StorageProof,
H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, block_number_to_id,
U64 as RpcU64,
block_number_to_id
};
use v1::metadata::Metadata;
@@ -530,7 +529,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}
}
fn author(&self) -> Result<RpcH160> {
fn author(&self) -> Result<H160> {
let miner = self.miner.authoring_params().author;
if miner == 0.into() {
(self.accounts)()
@@ -539,7 +538,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
.map(From::from)
.ok_or_else(|| errors::account("No accounts were found", ""))
} else {
Ok(RpcH160::from(miner))
Ok(H160::from(miner))
}
}
@@ -547,32 +546,30 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Ok(self.miner.is_currently_sealing())
}
fn chain_id(&self) -> Result<Option<RpcU64>> {
Ok(self.client.signing_chain_id().map(RpcU64::from))
fn chain_id(&self) -> Result<Option<U64>> {
Ok(self.client.signing_chain_id().map(U64::from))
}
fn hashrate(&self) -> Result<RpcU256> {
Ok(RpcU256::from(self.external_miner.hashrate()))
fn hashrate(&self) -> Result<U256> {
Ok(U256::from(self.external_miner.hashrate()))
}
fn gas_price(&self) -> Result<RpcU256> {
Ok(RpcU256::from(default_gas_price(&*self.client, &*self.miner, self.options.gas_price_percentile)))
fn gas_price(&self) -> Result<U256> {
Ok(U256::from(default_gas_price(&*self.client, &*self.miner, self.options.gas_price_percentile)))
}
fn accounts(&self) -> Result<Vec<RpcH160>> {
fn accounts(&self) -> Result<Vec<H160>> {
self.deprecation_notice.print("eth_accounts", deprecated::msgs::ACCOUNTS);
let accounts = (self.accounts)();
Ok(accounts.into_iter().map(Into::into).collect())
}
fn block_number(&self) -> Result<RpcU256> {
Ok(RpcU256::from(self.client.chain_info().best_block_number))
fn block_number(&self) -> Result<U256> {
Ok(U256::from(self.client.chain_info().best_block_number))
}
fn balance(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
let address = address.into();
fn balance(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<U256> {
let num = num.unwrap_or_default();
try_bf!(check_known(&*self.client, num.clone()));
@@ -584,11 +581,10 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(res))
}
fn proof(&self, address: RpcH160, values: Vec<RpcH256>, num: Option<BlockNumber>) -> BoxFuture<EthAccount> {
fn proof(&self, address: H160, values: Vec<H256>, num: Option<BlockNumber>) -> BoxFuture<EthAccount> {
try_bf!(errors::require_experimental(self.options.allow_experimental_rpcs, "1186"));
let a: H160 = address.clone().into();
let key1 = keccak(a);
let key1 = keccak(address);
let num = num.unwrap_or_default();
let id = match num {
@@ -603,7 +599,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
try_bf!(check_known(&*self.client, num.clone()));
let res = match self.client.prove_account(key1, id) {
Some((proof,account)) => Ok(EthAccount {
Some((proof, account)) => Ok(EthAccount {
address: address,
balance: account.balance.into(),
nonce: account.nonce.into(),
@@ -627,10 +623,8 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(res))
}
fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Option<BlockNumber>) -> BoxFuture<RpcH256> {
let address: Address = RpcH160::into(address);
let position: U256 = RpcU256::into(pos);
fn storage_at(&self, address: H160, position: U256, num: Option<BlockNumber>) -> BoxFuture<H256> {
let address: Address = address.into();
let num = num.unwrap_or_default();
try_bf!(check_known(&*self.client, num.clone()));
@@ -642,8 +636,8 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(res))
}
fn transaction_count(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
let address: Address = RpcH160::into(address);
fn transaction_count(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<U256> {
let address: Address = address.into();
let res = match num.unwrap_or_default() {
BlockNumber::Pending if self.options.pending_nonce_from_queue => {
@@ -676,7 +670,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(res))
}
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
fn block_transaction_count_by_hash(&self, hash: H256) -> BoxFuture<Option<U256>> {
let trx_count = self.client.block(BlockId::Hash(hash.into()))
.map(|block| block.transactions_count().into());
let result = Ok(trx_count)
@@ -684,7 +678,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<U256>> {
Box::new(future::done(match num {
BlockNumber::Pending =>
Ok(Some(self.miner.pending_transaction_hashes(&*self.client).len().into())),
@@ -701,7 +695,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}))
}
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
fn block_uncles_count_by_hash(&self, hash: H256) -> BoxFuture<Option<U256>> {
let uncle_count = self.client.block(BlockId::Hash(hash.into()))
.map(|block| block.uncles_count().into());
let result = Ok(uncle_count)
@@ -709,7 +703,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<U256>> {
Box::new(future::done(match num {
BlockNumber::Pending => Ok(Some(0.into())),
_ => {
@@ -725,8 +719,8 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}))
}
fn code_at(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<Bytes> {
let address: Address = RpcH160::into(address);
fn code_at(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<Bytes> {
let address: Address = H160::into(address);
let num = num.unwrap_or_default();
try_bf!(check_known(&*self.client, num.clone()));
@@ -739,7 +733,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(res))
}
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
fn block_by_hash(&self, hash: H256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
let result = self.rich_block(BlockId::Hash(hash.into()).into(), include_txs)
.and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
Box::new(future::done(result))
@@ -751,8 +745,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>> {
let hash: H256 = hash.into();
fn transaction_by_hash(&self, hash: H256) -> BoxFuture<Option<Transaction>> {
let tx = try_bf!(self.transaction(PendingTransactionId::Hash(hash))).or_else(|| {
self.miner.transaction(&hash)
.map(|t| Transaction::from_pending(t.pending().clone()))
@@ -762,7 +755,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<Transaction>> {
fn transaction_by_block_hash_and_index(&self, hash: H256, index: Index) -> BoxFuture<Option<Transaction>> {
let id = PendingTransactionId::Location(PendingOrBlock::Block(BlockId::Hash(hash.into())), index.value());
let result = self.transaction(id).and_then(
errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
@@ -783,9 +776,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture<Option<Receipt>> {
let hash: H256 = hash.into();
fn transaction_receipt(&self, hash: H256) -> BoxFuture<Option<Receipt>> {
if self.options.allow_pending_receipt_query {
let best_block = self.client.chain_info().best_block_number;
if let Some(receipt) = self.miner.pending_receipt(best_block, &hash) {
@@ -799,7 +790,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
Box::new(future::done(result))
}
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture<Option<RichBlock>> {
fn uncle_by_block_hash_and_index(&self, hash: H256, index: Index) -> BoxFuture<Option<RichBlock>> {
let result = self.uncle(PendingUncleId {
id: PendingOrBlock::Block(BlockId::Hash(hash.into())),
position: index.value()
@@ -889,19 +880,19 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}
}
fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result<bool> {
fn submit_work(&self, nonce: H64, pow_hash: H256, mix_hash: H256) -> Result<bool> {
match helpers::submit_work_detail(&self.client, &self.miner, nonce, pow_hash, mix_hash) {
Ok(_) => Ok(true),
Err(_) => Ok(false),
}
}
fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result<bool> {
fn submit_hashrate(&self, rate: U256, id: H256) -> Result<bool> {
self.external_miner.submit_hashrate(rate.into(), id.into());
Ok(true)
}
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256> {
fn send_raw_transaction(&self, raw: Bytes) -> Result<H256> {
Rlp::new(&raw.into_vec()).as_val()
.map_err(errors::rlp)
.and_then(|tx| SignedTransaction::new(tx).map_err(errors::transaction))
@@ -916,7 +907,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
.map(Into::into)
}
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256> {
fn submit_transaction(&self, raw: Bytes) -> Result<H256> {
self.send_raw_transaction(raw)
}
@@ -960,7 +951,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
))
}
fn estimate_gas(&self, request: CallRequest, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
fn estimate_gas(&self, request: CallRequest, num: Option<BlockNumber>) -> BoxFuture<U256> {
let request = CallRequest::into(request);
let signed = try_bf!(fake_sign::sign_call(request));
let num = num.unwrap_or_default();

View File

@@ -21,7 +21,7 @@ use std::collections::{BTreeSet, VecDeque};
use ethcore::client::{BlockChainClient, BlockId};
use ethcore::miner::{self, MinerService};
use ethereum_types::H256;
use ethereum_types::{H256, U256};
use parking_lot::Mutex;
use types::filter::Filter as EthcoreFilter;
@@ -29,7 +29,7 @@ use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::futures::{future, Future};
use jsonrpc_core::futures::future::Either;
use v1::traits::EthFilter;
use v1::types::{BlockNumber, Index, Filter, FilterChanges, Log, H256 as RpcH256, U256 as RpcU256};
use v1::types::{BlockNumber, Index, Filter, FilterChanges, Log};
use v1::helpers::{errors, SyncPollFilter, PollFilter, PollManager, limit_logs};
use v1::impls::eth::pending_logs;
@@ -137,7 +137,7 @@ impl<C, M> Filterable for EthFilterClient<C, M> where
}
impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
fn new_filter(&self, filter: Filter) -> Result<RpcU256> {
fn new_filter(&self, filter: Filter) -> Result<U256> {
let mut polls = self.polls().lock();
let block_number = self.best_block_number();
let include_pending = filter.to_block == Some(BlockNumber::Pending);
@@ -150,7 +150,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
Ok(id.into())
}
fn new_block_filter(&self) -> Result<RpcU256> {
fn new_block_filter(&self) -> Result<U256> {
let mut polls = self.polls().lock();
// +1, since we don't want to include the current block
let id = polls.create_poll(SyncPollFilter::new(PollFilter::Block {
@@ -160,7 +160,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
Ok(id.into())
}
fn new_pending_transaction_filter(&self) -> Result<RpcU256> {
fn new_pending_transaction_filter(&self) -> Result<U256> {
let mut polls = self.polls().lock();
let pending_transactions = self.pending_transaction_hashes();
let id = polls.create_poll(SyncPollFilter::new(PollFilter::PendingTransaction(pending_transactions)));
@@ -191,7 +191,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
match self.block_hash(block_number) {
Some(hash) => {
*last_block_number = n;
hashes.push(RpcH256::from(hash));
hashes.push(H256::from(hash));
// Only keep the most recent history
if recent_reported_hashes.len() >= PollFilter::MAX_BLOCK_HISTORY_SIZE {
recent_reported_hashes.pop_back();

View File

@@ -28,7 +28,7 @@ use light::client::LightChainClient;
use light::{cht, TransactionQueue};
use light::on_demand::{request, OnDemand};
use ethereum_types::{U256, Address};
use ethereum_types::{Address, H64, H160, H256, U64, U256};
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP};
use parking_lot::{RwLock, Mutex};
use rlp::Rlp;
@@ -44,11 +44,8 @@ use v1::helpers::deprecated::{self, DeprecationNotice};
use v1::helpers::light_fetch::{self, LightFetch};
use v1::traits::Eth;
use v1::types::{
RichBlock, Block, BlockTransactions, BlockNumber, LightBlockNumber, Bytes,
SyncStatus as RpcSyncStatus, SyncInfo as RpcSyncInfo,
Transaction, CallRequest, Index, Filter, Log, Receipt, Work, EthAccount,
H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256,
U64 as RpcU64,
RichBlock, Block, BlockTransactions, BlockNumber, LightBlockNumber, Bytes, SyncStatus as RpcSyncStatus,
SyncInfo as RpcSyncInfo, Transaction, CallRequest, Index, Filter, Log, Receipt, Work, EthAccount
};
use v1::metadata::Metadata;
@@ -251,7 +248,7 @@ where
}
}
fn author(&self) -> Result<RpcH160> {
fn author(&self) -> Result<H160> {
(self.accounts)()
.first()
.cloned()
@@ -263,22 +260,22 @@ where
Ok(false)
}
fn chain_id(&self) -> Result<Option<RpcU64>> {
Ok(self.client.signing_chain_id().map(RpcU64::from))
fn chain_id(&self) -> Result<Option<U64>> {
Ok(self.client.signing_chain_id().map(U64::from))
}
fn hashrate(&self) -> Result<RpcU256> {
fn hashrate(&self) -> Result<U256> {
Ok(Default::default())
}
fn gas_price(&self) -> Result<RpcU256> {
fn gas_price(&self) -> Result<U256> {
Ok(self.cache.lock().gas_price_corpus()
.and_then(|c| c.percentile(self.gas_price_percentile).cloned())
.map(RpcU256::from)
.map(U256::from)
.unwrap_or_else(Default::default))
}
fn accounts(&self) -> Result<Vec<RpcH160>> {
fn accounts(&self) -> Result<Vec<H160>> {
self.deprecation_notice.print("eth_accounts", deprecated::msgs::ACCOUNTS);
Ok((self.accounts)()
@@ -287,20 +284,20 @@ where
.collect())
}
fn block_number(&self) -> Result<RpcU256> {
fn block_number(&self) -> Result<U256> {
Ok(self.client.chain_info().best_block_number.into())
}
fn balance(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
fn balance(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<U256> {
Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().to_block_id())
.map(|acc| acc.map_or(0.into(), |a| a.balance).into()))
}
fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Option<BlockNumber>) -> BoxFuture<RpcH256> {
fn storage_at(&self, _address: H160, _key: U256, _num: Option<BlockNumber>) -> BoxFuture<H256> {
Box::new(future::err(errors::unimplemented(None)))
}
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
fn block_by_hash(&self, hash: H256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
Box::new(self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some))
}
@@ -308,12 +305,12 @@ where
Box::new(self.rich_block(num.to_block_id(), include_txs).map(Some))
}
fn transaction_count(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
fn transaction_count(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<U256> {
Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().to_block_id())
.map(|acc| acc.map_or(0.into(), |a| a.nonce).into()))
}
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
fn block_transaction_count_by_hash(&self, hash: H256) -> BoxFuture<Option<U256>> {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
@@ -329,7 +326,7 @@ where
}))
}
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<U256>> {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
Box::new(self.fetcher().header(num.to_block_id()).and_then(move |hdr| {
@@ -345,7 +342,7 @@ where
}))
}
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>> {
fn block_uncles_count_by_hash(&self, hash: H256) -> BoxFuture<Option<U256>> {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
@@ -361,7 +358,7 @@ where
}))
}
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<U256>> {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
Box::new(self.fetcher().header(num.to_block_id()).and_then(move |hdr| {
@@ -377,11 +374,11 @@ where
}))
}
fn code_at(&self, address: RpcH160, num: Option<BlockNumber>) -> BoxFuture<Bytes> {
fn code_at(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<Bytes> {
Box::new(self.fetcher().code(address.into(), num.unwrap_or_default().to_block_id()).map(Into::into))
}
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256> {
fn send_raw_transaction(&self, raw: Bytes) -> Result<H256> {
let best_header = self.client.best_block_header().decode().map_err(errors::decode)?;
Rlp::new(&raw.into_vec()).as_val()
@@ -400,7 +397,7 @@ where
.map(Into::into)
}
fn submit_transaction(&self, raw: Bytes) -> Result<RpcH256> {
fn submit_transaction(&self, raw: Bytes) -> Result<H256> {
self.send_raw_transaction(raw)
}
@@ -413,7 +410,7 @@ where
}))
}
fn estimate_gas(&self, req: CallRequest, num: Option<BlockNumber>) -> BoxFuture<RpcU256> {
fn estimate_gas(&self, req: CallRequest, num: Option<BlockNumber>) -> BoxFuture<U256> {
// TODO: binary chop for more accurate estimates.
Box::new(self.fetcher().proved_read_only_execution(req, num).and_then(|res| {
match res {
@@ -423,7 +420,7 @@ where
}))
}
fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<Transaction>> {
fn transaction_by_hash(&self, hash: H256) -> BoxFuture<Option<Transaction>> {
let hash = hash.into();
{
@@ -438,7 +435,7 @@ where
Box::new(self.fetcher().transaction_by_hash(hash).map(|x| x.map(|(tx, _)| tx)))
}
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture<Option<Transaction>> {
fn transaction_by_block_hash_and_index(&self, hash: H256, idx: Index) -> BoxFuture<Option<Transaction>> {
Box::new(self.fetcher().block(BlockId::Hash(hash.into())).map(move |block| {
light_fetch::extract_transaction_at_index(block, idx.value())
}))
@@ -450,9 +447,9 @@ where
}))
}
fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture<Option<Receipt>> {
fn transaction_receipt(&self, hash: H256) -> BoxFuture<Option<Receipt>> {
let fetcher = self.fetcher();
Box::new(fetcher.transaction_by_hash(hash.clone().into()).and_then(move |tx| {
Box::new(fetcher.transaction_by_hash(hash.into()).and_then(move |tx| {
// the block hash included in the transaction object here has
// already been checked for canonicality and whether it contains
// the transaction.
@@ -480,7 +477,7 @@ where
}))
}
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture<Option<RichBlock>> {
fn uncle_by_block_hash_and_index(&self, hash: H256, 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)
@@ -494,7 +491,7 @@ where
}))
}
fn proof(&self, _address: RpcH160, _values:Vec<RpcH256>, _num: Option<BlockNumber>) -> BoxFuture<EthAccount> {
fn proof(&self, _address: H160, _values:Vec<H256>, _num: Option<BlockNumber>) -> BoxFuture<EthAccount> {
Box::new(future::err(errors::unimplemented(None)))
}
@@ -528,11 +525,11 @@ where
Err(errors::light_unimplemented(None))
}
fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result<bool> {
fn submit_work(&self, _nonce: H64, _pow_hash: H256, _mix_hash: H256) -> Result<bool> {
Err(errors::light_unimplemented(None))
}
fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result<bool> {
fn submit_hashrate(&self, _rate: U256, _id: H256) -> Result<bool> {
Err(errors::light_unimplemented(None))
}
}
@@ -545,11 +542,11 @@ where
{
fn best_block_number(&self) -> u64 { self.client.chain_info().best_block_number }
fn block_hash(&self, id: BlockId) -> Option<::ethereum_types::H256> {
fn block_hash(&self, id: BlockId) -> Option<H256> {
self.client.block_hash(id)
}
fn pending_transaction_hashes(&self) -> BTreeSet<::ethereum_types::H256> {
fn pending_transaction_hashes(&self) -> BTreeSet<H256> {
BTreeSet::new()
}

View File

@@ -24,6 +24,7 @@ use crypto::DEFAULT_MAC;
use ethkey::{crypto::ecies, Brain, Generator};
use ethstore::random_phrase;
use sync::{LightSyncInfo, LightSyncProvider, LightNetworkDispatcher, ManageNetwork};
use ethereum_types::{H64, H160, H256, H512, U64, U256};
use ethcore_logger::RotatingLogger;
use jsonrpc_core::{Result, BoxFuture};
@@ -35,7 +36,7 @@ use v1::helpers::light_fetch::{LightFetch, light_all_transactions};
use v1::metadata::Metadata;
use v1::traits::Parity;
use v1::types::{
Bytes, U256, U64, H64, H160, H256, H512, CallRequest,
Bytes, CallRequest,
Peers, Transaction, RpcSettings, Histogram,
TransactionStats, LocalTransactionStatus,
LightBlockNumber, ChainStatus, Receipt,

View File

@@ -20,15 +20,16 @@
use std::io;
use std::sync::Arc;
use sync::ManageNetwork;
use ethereum_types::{H160, H256, U256};
use fetch::{self, Fetch};
use hash::keccak_buffer;
use sync::ManageNetwork;
use jsonrpc_core::{Result, BoxFuture};
use jsonrpc_core::futures::Future;
use v1::helpers::errors;
use v1::traits::ParitySet;
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction};
use v1::types::{Bytes, ReleaseInfo, Transaction};
/// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<F> {

View File

@@ -16,11 +16,13 @@
//! Traces api implementation.
use ethereum_types::H256;
use jsonrpc_core::Result;
use v1::Metadata;
use v1::traits::Traces;
use v1::helpers::errors;
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, TraceResultsWithTransactionHash, TraceOptions, H256};
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults,
TraceResultsWithTransactionHash, TraceOptions};
/// Traces api implementation.
// TODO: all calling APIs should be possible w. proved remote TX execution.

View File

@@ -20,12 +20,12 @@ use std::str::FromStr;
use std::collections::BTreeMap;
use crypto::DEFAULT_MAC;
use ethereum_types::{Address, H64, H160, H256, H512, U64, U256};
use ethcore::client::{BlockChainClient, StateClient, Call};
use ethcore::miner::{self, MinerService};
use ethcore::snapshot::{SnapshotService, RestorationStatus};
use ethcore::state::StateInfo;
use ethcore_logger::RotatingLogger;
use ethereum_types::Address;
use ethkey::{crypto::ecies, Brain, Generator};
use ethstore::random_phrase;
use jsonrpc_core::futures::future;
@@ -41,7 +41,7 @@ use v1::helpers::external_signer::{SigningQueue, SignerService};
use v1::metadata::Metadata;
use v1::traits::Parity;
use v1::types::{
Bytes, U256, H64, U64, H160, H256, H512, CallRequest,
Bytes, CallRequest,
Peers, Transaction, RpcSettings, Histogram,
TransactionStats, LocalTransactionStatus,
BlockNumber, ConsensusCapability, VersionInfo,

View File

@@ -20,8 +20,8 @@ use std::collections::{
btree_map::{BTreeMap, Entry},
HashSet,
};
use ethereum_types::Address;
use ethereum_types::{Address, H160, H256, H520};
use ethkey::{Brain, Generator, Secret};
use ethstore::KeyFile;
use accounts::AccountProvider;
@@ -29,10 +29,7 @@ use jsonrpc_core::Result;
use v1::helpers::deprecated::{self, DeprecationNotice};
use v1::helpers::errors;
use v1::traits::{ParityAccounts, ParityAccountsInfo};
use v1::types::{
H160 as RpcH160, H256 as RpcH256, H520 as RpcH520, Derive, DeriveHierarchical, DeriveHash,
ExtAccountInfo, AccountInfo, HwAccountInfo,
};
use v1::types::{Derive, DeriveHierarchical, DeriveHash,ExtAccountInfo, AccountInfo, HwAccountInfo};
use ethkey::Password;
/// Account management (personal) rpc implementation.
@@ -58,7 +55,7 @@ impl ParityAccountsClient {
}
impl ParityAccountsInfo for ParityAccountsClient {
fn accounts_info(&self) -> Result<BTreeMap<RpcH160, AccountInfo>> {
fn accounts_info(&self) -> Result<BTreeMap<H160, AccountInfo>> {
self.deprecation_notice("parity_accountsInfo");
let dapp_accounts = self.accounts.accounts()
@@ -72,18 +69,18 @@ impl ParityAccountsInfo for ParityAccountsClient {
.into_iter()
.chain(other.into_iter())
.filter(|&(ref a, _)| dapp_accounts.contains(a))
.map(|(a, v)| (RpcH160::from(a), AccountInfo { name: v.name }))
.map(|(a, v)| (H160::from(a), AccountInfo { name: v.name }))
.collect()
)
}
fn hardware_accounts_info(&self) -> Result<BTreeMap<RpcH160, HwAccountInfo>> {
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>> {
self.deprecation_notice("parity_hardwareAccountsInfo");
let info = self.accounts.hardware_accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?;
Ok(info
.into_iter()
.map(|(a, v)| (RpcH160::from(a), HwAccountInfo { name: v.name, manufacturer: v.meta }))
.map(|(a, v)| (H160::from(a), HwAccountInfo { name: v.name, manufacturer: v.meta }))
.collect()
)
}
@@ -94,7 +91,7 @@ impl ParityAccountsInfo for ParityAccountsClient {
self.accounts.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))
}
fn default_account(&self) -> Result<RpcH160> {
fn default_account(&self) -> Result<H160> {
self.deprecation_notice("parity_defaultAccount");
Ok(self.accounts.default_account()
@@ -105,9 +102,7 @@ impl ParityAccountsInfo for ParityAccountsClient {
}
impl ParityAccounts for ParityAccountsClient {
fn all_accounts_info(&self) -> Result<BTreeMap<RpcH160, ExtAccountInfo>> {
self.deprecation_notice("parity_allAccountsInfo");
fn all_accounts_info(&self) -> Result<BTreeMap<H160, ExtAccountInfo>> {
let info = self.accounts.accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?;
let other = self.accounts.addresses_info();
@@ -120,7 +115,7 @@ impl ParityAccounts for ParityAccountsClient {
uuid: v.uuid.map(|uuid| uuid.to_string())
}));
let mut accounts: BTreeMap<RpcH160, ExtAccountInfo> = BTreeMap::new();
let mut accounts: BTreeMap<H160, ExtAccountInfo> = BTreeMap::new();
for (address, account) in account_iter {
match accounts.entry(address) {
@@ -138,27 +133,24 @@ impl ParityAccounts for ParityAccountsClient {
Ok(accounts)
}
fn new_account_from_phrase(&self, phrase: String, pass: Password) -> Result<RpcH160> {
fn new_account_from_phrase(&self, phrase: String, pass: Password) -> Result<H160> {
self.deprecation_notice("parity_newAccountFromPhrase");
let brain = Brain::new(phrase).generate().unwrap();
self.accounts.insert_account(brain.secret().clone(), &pass)
.map(Into::into)
.map_err(|e| errors::account("Could not create account.", e))
}
fn new_account_from_wallet(&self, json: String, pass: Password) -> Result<RpcH160> {
fn new_account_from_wallet(&self, json: String, pass: Password) -> Result<H160> {
self.deprecation_notice("parity_newAccountFromWallet");
self.accounts.import_presale(json.as_bytes(), &pass)
.or_else(|_| self.accounts.import_wallet(json.as_bytes(), &pass, true))
.map(Into::into)
.map_err(|e| errors::account("Could not create account.", e))
}
fn new_account_from_secret(&self, secret: RpcH256, pass: Password) -> Result<RpcH160> {
fn new_account_from_secret(&self, secret: H256, pass: Password) -> Result<H160> {
self.deprecation_notice("parity_newAccountFromSecret");
let secret = Secret::from_unsafe_slice(&secret.0)
.map_err(|e| errors::account("Could not create account.", e))?;
self.accounts.insert_account(secret, &pass)
@@ -166,9 +158,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not create account.", e))
}
fn test_password(&self, account: RpcH160, password: Password) -> Result<bool> {
fn test_password(&self, account: H160, password: Password) -> Result<bool> {
self.deprecation_notice("parity_testPassword");
let account: Address = account.into();
self.accounts
@@ -176,9 +167,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not fetch account info.", e))
}
fn change_password(&self, account: RpcH160, password: Password, new_password: Password) -> Result<bool> {
fn change_password(&self, account: H160, password: Password, new_password: Password) -> Result<bool> {
self.deprecation_notice("parity_changePassword");
let account: Address = account.into();
self.accounts
.change_password(&account, password, new_password)
@@ -186,9 +176,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not fetch account info.", e))
}
fn kill_account(&self, account: RpcH160, password: Password) -> Result<bool> {
fn kill_account(&self, account: H160, password: Password) -> Result<bool> {
self.deprecation_notice("parity_killAccount");
let account: Address = account.into();
self.accounts
.kill_account(&account, &password)
@@ -196,18 +185,16 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not delete account.", e))
}
fn remove_address(&self, addr: RpcH160) -> Result<bool> {
fn remove_address(&self, addr: H160) -> Result<bool> {
self.deprecation_notice("parity_removeAddresss");
let addr: Address = addr.into();
self.accounts.remove_address(addr);
Ok(true)
}
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool> {
fn set_account_name(&self, addr: H160, name: String) -> Result<bool> {
self.deprecation_notice("parity_setAccountName");
let addr: Address = addr.into();
self.accounts.set_account_name(addr.clone(), name.clone())
@@ -215,9 +202,8 @@ impl ParityAccounts for ParityAccountsClient {
Ok(true)
}
fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result<bool> {
fn set_account_meta(&self, addr: H160, meta: String) -> Result<bool> {
self.deprecation_notice("parity_setAccountMeta");
let addr: Address = addr.into();
self.accounts.set_account_meta(addr.clone(), meta.clone())
@@ -225,18 +211,16 @@ impl ParityAccounts for ParityAccountsClient {
Ok(true)
}
fn import_geth_accounts(&self, addresses: Vec<RpcH160>) -> Result<Vec<RpcH160>> {
fn import_geth_accounts(&self, addresses: Vec<H160>) -> Result<Vec<H160>> {
self.deprecation_notice("parity_importGethAccounts");
self.accounts
.import_geth_accounts(into_vec(addresses), false)
.map(into_vec)
.map_err(|e| errors::account("Couldn't import Geth accounts", e))
}
fn geth_accounts(&self) -> Result<Vec<RpcH160>> {
fn geth_accounts(&self) -> Result<Vec<H160>> {
self.deprecation_notice("parity_listGethAccounts");
Ok(into_vec(self.accounts.list_geth_accounts(false)))
}
@@ -292,9 +276,8 @@ impl ParityAccounts for ParityAccountsClient {
.map(|_| true)
}
fn change_vault(&self, address: RpcH160, new_vault: String) -> Result<bool> {
fn change_vault(&self, address: H160, new_vault: String) -> Result<bool> {
self.deprecation_notice("parity_changeVault");
self.accounts
.change_vault(address.into(), &new_vault)
.map_err(|e| errors::account("Could not change vault.", e))
@@ -318,9 +301,8 @@ impl ParityAccounts for ParityAccountsClient {
.map(|_| true)
}
fn derive_key_index(&self, addr: RpcH160, password: Password, derivation: DeriveHierarchical, save_as_account: bool) -> Result<RpcH160> {
fn derive_key_index(&self, addr: H160, password: Password, derivation: DeriveHierarchical, save_as_account: bool) -> Result<H160> {
self.deprecation_notice("parity_deriveAddressIndex");
let addr: Address = addr.into();
self.accounts
.derive_account(
@@ -333,9 +315,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not derive account.", e))
}
fn derive_key_hash(&self, addr: RpcH160, password: Password, derivation: DeriveHash, save_as_account: bool) -> Result<RpcH160> {
fn derive_key_hash(&self, addr: H160, password: Password, derivation: DeriveHash, save_as_account: bool) -> Result<H160> {
self.deprecation_notice("parity_deriveAddressHash");
let addr: Address = addr.into();
self.accounts
.derive_account(
@@ -348,9 +329,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not derive account.", e))
}
fn export_account(&self, addr: RpcH160, password: Password) -> Result<KeyFile> {
fn export_account(&self, addr: H160, password: Password) -> Result<KeyFile> {
self.deprecation_notice("parity_exportAccount");
let addr = addr.into();
self.accounts
.export_account(
@@ -361,9 +341,8 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not export account.", e))
}
fn sign_message(&self, addr: RpcH160, password: Password, message: RpcH256) -> Result<RpcH520> {
fn sign_message(&self, addr: H160, password: Password, message: H256) -> Result<H520> {
self.deprecation_notice("parity_signMessage");
self.accounts
.sign(
addr.into(),

View File

@@ -21,7 +21,7 @@ use std::time::Duration;
use ethcore::client::{BlockChainClient, Mode};
use ethcore::miner::{self, MinerService};
use ethereum_types::H256 as EthH256;
use ethereum_types::{H160, H256, U256};
use ethkey;
use fetch::{self, Fetch};
use hash::keccak_buffer;
@@ -32,7 +32,7 @@ use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::futures::Future;
use v1::helpers::errors;
use v1::traits::ParitySet;
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction};
use v1::types::{Bytes, ReleaseInfo, Transaction};
#[cfg(any(test, feature = "accounts"))]
pub mod accounts {
@@ -160,7 +160,6 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
}
fn set_engine_signer_secret(&self, secret: H256) -> Result<bool> {
let secret: EthH256 = secret.into();
let keypair = ethkey::KeyPair::from_secret(secret.into()).map_err(|e| errors::account("Invalid secret", e))?;
self.miner.set_author(miner::Author::Sealer(ethcore::engines::signer::from_keypair(keypair)));
Ok(true)

View File

@@ -21,7 +21,7 @@ use std::time::Duration;
use accounts::AccountProvider;
use bytes::Bytes;
use eip_712::{EIP712, hash_structured_data};
use ethereum_types::{H520, U128, Address};
use ethereum_types::{H160, H256, H520, U128, Address};
use ethkey::{public_to_address, recover, Signature};
use types::transaction::{PendingTransaction, SignedTransaction};
@@ -34,7 +34,6 @@ use v1::helpers::{errors, eip191};
use v1::metadata::Metadata;
use v1::traits::Personal;
use v1::types::{
H160 as RpcH160, H256 as RpcH256, H520 as RpcH520, U128 as RpcU128,
Bytes as RpcBytes,
ConfirmationPayload as RpcConfirmationPayload,
ConfirmationResponse as RpcConfirmationResponse,
@@ -108,24 +107,21 @@ impl<D: Dispatcher + 'static> PersonalClient<D> {
impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
type Metadata = Metadata;
fn accounts(&self) -> Result<Vec<RpcH160>> {
fn accounts(&self) -> Result<Vec<H160>> {
self.deprecation_notice.print("personal_accounts", deprecated::msgs::ACCOUNTS);
let accounts = self.accounts.accounts().map_err(|e| errors::account("Could not fetch accounts.", e))?;
Ok(accounts.into_iter().map(Into::into).collect::<Vec<RpcH160>>())
Ok(accounts.into_iter().map(Into::into).collect::<Vec<H160>>())
}
fn new_account(&self, pass: String) -> Result<RpcH160> {
fn new_account(&self, pass: String) -> Result<H160> {
self.deprecation_notice.print("personal_newAccount", deprecated::msgs::ACCOUNTS);
self.accounts.new_account(&pass.into())
.map(Into::into)
.map_err(|e| errors::account("Could not create account.", e))
}
fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option<RpcU128>) -> Result<bool> {
fn unlock_account(&self, account: H160, account_pass: String, duration: Option<U128>) -> Result<bool> {
self.deprecation_notice.print("personal_unlockAccount", deprecated::msgs::ACCOUNTS);
let account: Address = account.into();
let store = self.accounts.clone();
let duration = match duration {
@@ -157,9 +153,8 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
}
}
fn sign(&self, data: RpcBytes, account: RpcH160, password: String) -> BoxFuture<RpcH520> {
fn sign(&self, data: RpcBytes, account: H160, password: String) -> BoxFuture<H520> {
self.deprecation_notice.print("personal_sign", deprecated::msgs::ACCOUNTS);
let dispatcher = self.dispatcher.clone();
let accounts = Arc::new(dispatch::Signer::new(self.accounts.clone())) as _;
@@ -177,9 +172,8 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
}))
}
fn sign_191(&self, version: EIP191Version, data: Value, account: RpcH160, password: String) -> BoxFuture<RpcH520> {
fn sign_191(&self, version: EIP191Version, data: Value, account: H160, password: String) -> BoxFuture<H520> {
self.deprecation_notice.print("personal_sign191", deprecated::msgs::ACCOUNTS);
try_bf!(errors::require_experimental(self.allow_experimental_rpcs, "191"));
let data = try_bf!(eip191::hash_message(version, data));
@@ -201,9 +195,8 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
)
}
fn sign_typed_data(&self, typed_data: EIP712, account: RpcH160, password: String) -> BoxFuture<RpcH520> {
fn sign_typed_data(&self, typed_data: EIP712, account: H160, password: String) -> BoxFuture<H520> {
self.deprecation_notice.print("personal_signTypedData", deprecated::msgs::ACCOUNTS);
try_bf!(errors::require_experimental(self.allow_experimental_rpcs, "712"));
let data = match hash_structured_data(typed_data) {
@@ -228,7 +221,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
)
}
fn ec_recover(&self, data: RpcBytes, signature: RpcH520) -> BoxFuture<RpcH160> {
fn ec_recover(&self, data: RpcBytes, signature: H520) -> BoxFuture<H160> {
let signature: H520 = signature.into();
let signature = Signature::from_electrum(&signature);
let data: Bytes = data.into();
@@ -253,28 +246,25 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
.map(move |pending_tx| dispatcher.enrich(pending_tx.transaction)))
}
fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256> {
fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<H256> {
self.deprecation_notice.print("personal_sendTransaction", deprecated::msgs::ACCOUNTS);
let condition = request.condition.clone().map(Into::into);
let dispatcher = self.dispatcher.clone();
Box::new(
self.do_sign_transaction(meta, request, password, move |signed: WithToken<SignedTransaction>| {
self.do_sign_transaction(meta, request, password, move |signed: WithToken<SignedTransaction>| {
dispatcher.dispatch_transaction(
PendingTransaction::new(
signed.into_value(),
condition
)
)
}).and_then(|hash| {
Ok(RpcH256::from(hash))
})
)
}
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256> {
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<H256> {
self.deprecation_notice.print("personal_signAndSendTransaction", Some("use personal_sendTransaction instead."));
warn!("Using deprecated personal_signAndSendTransaction, use personal_sendTransaction instead.");
self.send_transaction(meta, request, password)
}
}

View File

@@ -21,11 +21,11 @@ use std::sync::Arc;
use rlp::Rlp;
use ethcore_private_tx::Provider as PrivateTransactionManager;
use ethereum_types::Address;
use ethereum_types::{Address, H160, H256, U256};
use types::transaction::SignedTransaction;
use jsonrpc_core::{Error};
use v1::types::{Bytes, PrivateTransactionReceipt, H160, H256, TransactionRequest, U256,
use v1::types::{Bytes, PrivateTransactionReceipt, TransactionRequest,
BlockNumber, PrivateTransactionReceiptAndTransaction, CallRequest, block_number_to_id};
use v1::traits::Private;
use v1::metadata::Metadata;

View File

@@ -19,16 +19,17 @@
use std::collections::BTreeSet;
use std::sync::Arc;
use crypto::DEFAULT_MAC;
use ethkey::Secret;
use accounts::AccountProvider;
use crypto::DEFAULT_MAC;
use ethereum_types::{H160, H256, H512};
use ethkey::Secret;
use jsonrpc_core::Result;
use v1::helpers::errors;
use v1::helpers::secretstore::{generate_document_key, encrypt_document,
decrypt_document, decrypt_document_with_shadow, ordered_servers_keccak};
use v1::traits::SecretStore;
use v1::types::{H160, H256, H512, Bytes, EncryptedDocumentKey};
use v1::types::{Bytes, EncryptedDocumentKey};
use ethkey::Password;
/// Parity implementation.

View File

@@ -18,6 +18,7 @@
use std::sync::Arc;
use ethereum_types::U256;
use ethkey;
use parity_runtime::Executor;
use parking_lot::Mutex;
@@ -34,7 +35,7 @@ use v1::helpers::{errors, ConfirmationPayload, FilledTransactionRequest, Subscri
use v1::helpers::external_signer::{SigningQueue, SignerService};
use v1::metadata::Metadata;
use v1::traits::Signer;
use v1::types::{TransactionModification, ConfirmationRequest, ConfirmationResponse, ConfirmationResponseWithToken, U256, Bytes};
use v1::types::{TransactionModification, ConfirmationRequest, ConfirmationResponse, ConfirmationResponseWithToken, Bytes};
/// Transactions confirmation (personal) rpc implementation.
pub struct SignerClient<D: Dispatcher> {

View File

@@ -18,9 +18,10 @@
use std::sync::Arc;
use transient_hashmap::TransientHashMap;
use ethereum_types::U256;
use parking_lot::Mutex;
use ethereum_types::{H160, H256, H520, U256};
use jsonrpc_core::{BoxFuture, Result, Error};
use jsonrpc_core::futures::{future, Future, Poll, Async};
use jsonrpc_core::futures::future::Either;
@@ -36,7 +37,7 @@ use v1::helpers::external_signer::{
use v1::metadata::Metadata;
use v1::traits::{EthSigning, ParitySigning};
use v1::types::{
H160 as RpcH160, H256 as RpcH256, U256 as RpcU256, Bytes as RpcBytes, H520 as RpcH520,
Bytes as RpcBytes,
Either as RpcEither,
RichRawTransaction as RpcRichRawTransaction,
TransactionRequest as RpcTransactionRequest,
@@ -142,9 +143,8 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
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>> {
fn post_sign(&self, meta: Metadata, address: H160, data: RpcBytes) -> BoxFuture<RpcEither<U256, RpcConfirmationResponse>> {
self.deprecation_notice.print("parity_postSign", deprecated::msgs::ACCOUNTS);
let executor = self.executor.clone();
let confirmations = self.confirmations.clone();
@@ -160,9 +160,8 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
}))
}
fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcEither<U256, RpcConfirmationResponse>> {
self.deprecation_notice.print("parity_postTransaction", deprecated::msgs::ACCOUNTS);
let executor = self.executor.clone();
let confirmations = self.confirmations.clone();
@@ -176,9 +175,8 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
}))
}
fn check_request(&self, id: RpcU256) -> Result<Option<RpcConfirmationResponse>> {
fn check_request(&self, id: U256) -> Result<Option<RpcConfirmationResponse>> {
self.deprecation_notice.print("parity_checkRequest", deprecated::msgs::ACCOUNTS);
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
@@ -187,9 +185,8 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
}
}
fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcBytes> {
fn decrypt_message(&self, meta: Metadata, address: H160, data: RpcBytes) -> BoxFuture<RpcBytes> {
self.deprecation_notice.print("parity_decryptMessage", deprecated::msgs::ACCOUNTS);
let res = self.dispatch(
RpcConfirmationPayload::Decrypt((address.clone(), data).into()),
meta.origin,
@@ -208,9 +205,8 @@ 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> {
fn sign(&self, meta: Metadata, address: H160, data: RpcBytes) -> BoxFuture<H520> {
self.deprecation_notice.print("eth_sign", deprecated::msgs::ACCOUNTS);
let res = self.dispatch(
RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()),
meta.origin,
@@ -224,9 +220,8 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
}))
}
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256> {
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<H256> {
self.deprecation_notice.print("eth_sendTransaction", deprecated::msgs::ACCOUNTS);
let res = self.dispatch(
RpcConfirmationPayload::SendTransaction(request),
meta.origin,

View File

@@ -18,8 +18,7 @@
use std::sync::Arc;
use ethereum_types::Address;
use ethereum_types::{Address, H160, H256, H520, U256};
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::futures::{future, Future};
use v1::helpers::{errors};
@@ -28,8 +27,7 @@ use v1::helpers::dispatch::{self, Dispatcher};
use v1::metadata::Metadata;
use v1::traits::{EthSigning, ParitySigning};
use v1::types::{
U256 as RpcU256,
H160 as RpcH160, H256 as RpcH256, H520 as RpcH520, Bytes as RpcBytes,
Bytes as RpcBytes,
Either as RpcEither,
RichRawTransaction as RpcRichRawTransaction,
TransactionRequest as RpcTransactionRequest,
@@ -70,9 +68,8 @@ impl<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
{
type Metadata = Metadata;
fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520> {
fn sign(&self, _: Metadata, address: H160, data: RpcBytes) -> BoxFuture<H520> {
self.deprecation_notice.print("eth_sign", deprecated::msgs::ACCOUNTS);
Box::new(self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into())
.then(|res| match res {
Ok(RpcConfirmationResponse::Signature(signature)) => Ok(signature),
@@ -81,9 +78,8 @@ impl<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
}))
}
fn send_transaction(&self, _meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256> {
fn send_transaction(&self, _meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<H256> {
self.deprecation_notice.print("eth_sendTransaction", deprecated::msgs::ACCOUNTS);
Box::new(self.handle(RpcConfirmationPayload::SendTransaction(request), self.accounts.default_account())
.then(|res| match res {
Ok(RpcConfirmationResponse::SendTransaction(hash)) => Ok(hash),
@@ -113,9 +109,8 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {
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> {
fn decrypt_message(&self, _: Metadata, address: H160, data: RpcBytes) -> BoxFuture<RpcBytes> {
self.deprecation_notice.print("parity_decryptMessage", deprecated::msgs::ACCOUNTS);
Box::new(self.handle(RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into())
.then(|res| match res {
Ok(RpcConfirmationResponse::Decrypt(data)) => Ok(data),
@@ -124,17 +119,17 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {
}))
}
fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
fn post_sign(&self, _: Metadata, _: H160, _: RpcBytes) -> BoxFuture<RpcEither<U256, 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>> {
fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture<RpcEither<U256, 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>> {
fn check_request(&self, _: U256) -> Result<Option<RpcConfirmationResponse>> {
// We don't support this in non-signer mode.
Err(errors::signer_disabled())
}

View File

@@ -19,6 +19,7 @@
use std::sync::Arc;
use ethcore::client::{BlockChainClient, CallAnalytics, TransactionId, TraceId, StateClient, StateInfo, Call, BlockId};
use ethereum_types::H256;
use rlp::Rlp;
use types::transaction::SignedTransaction;
@@ -26,7 +27,8 @@ use jsonrpc_core::Result;
use v1::Metadata;
use v1::traits::Traces;
use v1::helpers::{errors, fake_sign};
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, TraceResultsWithTransactionHash, TraceOptions, H256, block_number_to_id};
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults,
TraceResultsWithTransactionHash, TraceOptions, block_number_to_id};
fn to_call_analytics(flags: TraceOptions) -> CallAnalytics {
CallAnalytics {

View File

@@ -15,11 +15,12 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Web3 rpc implementation.
use ethereum_types::H256;
use hash::keccak;
use jsonrpc_core::Result;
use version::version;
use v1::traits::Web3;
use v1::types::{H256, Bytes};
use v1::types::Bytes;
/// Web3 rpc implementation.
pub struct Web3Client;