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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 360 additions and 624 deletions

2
Cargo.lock generated
View File

@ -261,6 +261,7 @@ dependencies = [
name = "cli-signer"
version = "1.4.0"
dependencies = [
"ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-rpc 1.12.0",
"parity-rpc-client 1.4.0",
@ -2699,6 +2700,7 @@ dependencies = [
name = "parity-rpc-client"
version = "1.4.0"
dependencies = [
"ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -7,6 +7,7 @@ name = "cli-signer"
version = "1.4.0"
[dependencies]
ethereum-types = "0.4"
futures = "0.1"
rpassword = "1.0"
parity-rpc = { path = "../rpc" }

View File

@ -7,6 +7,7 @@ name = "parity-rpc-client"
version = "1.4.0"
[dependencies]
ethereum-types = "0.4"
futures = "0.1"
log = "0.4"
serde = "1.0"

View File

@ -17,6 +17,7 @@
pub mod client;
pub mod signer_client;
extern crate ethereum_types;
extern crate futures;
extern crate jsonrpc_core;
extern crate jsonrpc_ws_server as ws;

View File

@ -15,7 +15,8 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use client::{Rpc, RpcError};
use rpc::signer::{ConfirmationRequest, TransactionModification, U256, TransactionCondition};
use ethereum_types::U256;
use rpc::signer::{ConfirmationRequest, TransactionModification, TransactionCondition};
use serde;
use serde_json::{Value as JsonValue, to_value};
use std::path::PathBuf;

View File

@ -14,13 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
extern crate ethereum_types;
extern crate futures;
extern crate rpassword;
extern crate parity_rpc as rpc;
extern crate parity_rpc_client as client;
use rpc::signer::{U256, ConfirmationRequest};
use ethereum_types::U256;
use rpc::signer::ConfirmationRequest;
use client::signer_client::SignerRpc;
use std::io::{Write, BufRead, BufReader, stdout, stdin};
use std::path::PathBuf;

View File

@ -86,7 +86,7 @@ use jsonrpc_core::{BoxFuture, Result, Error};
use jsonrpc_core::futures::{future, Future, IntoFuture};
use v1::helpers::{TransactionRequest, FilledTransactionRequest, ConfirmationPayload};
use v1::types::{
H520 as RpcH520, Bytes as RpcBytes,
Bytes as RpcBytes,
RichRawTransaction as RpcRichRawTransaction,
ConfirmationPayload as RpcConfirmationPayload,
ConfirmationResponse,
@ -309,7 +309,6 @@ pub fn execute<D: Dispatcher + 'static>(
let res = signer.sign_message(address, pass, SignMessage::Data(data))
.map(|result| result
.map(|s| H520(s.into_electrum()))
.map(RpcH520::from)
.map(ConfirmationResponse::Signature)
);
@ -319,7 +318,6 @@ pub fn execute<D: Dispatcher + 'static>(
let res = signer.sign_message(address, pass, SignMessage::Hash(data))
.map(|result| result
.map(|rsv| H520(rsv.into_electrum()))
.map(RpcH520::from)
.map(ConfirmationResponse::Signature)
);

View File

@ -15,6 +15,7 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use std::collections::BTreeMap;
use ethereum_types::U256;
use parking_lot::{Mutex, RwLock};
use super::oneshot;

View File

@ -16,12 +16,13 @@
use std::collections::BTreeSet;
use rand::{Rng, OsRng};
use ethereum_types::{H256, H512};
use ethkey::{self, Public, Secret, Random, Generator, math};
use crypto;
use bytes::Bytes;
use jsonrpc_core::Error;
use v1::helpers::errors;
use v1::types::{H256, H512, EncryptedDocumentKey};
use v1::types::EncryptedDocumentKey;
use tiny_keccak::Keccak;
/// Initialization vector length.

View File

@ -15,8 +15,9 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethkey::{recover, public_to_address, Signature};
use ethereum_types::{H256, U64};
use jsonrpc_core::Result;
use v1::types::{Bytes, RecoveredAccount, H256, U64};
use v1::types::{Bytes, RecoveredAccount};
use v1::helpers::errors;
use v1::helpers::dispatch::eth_data_hash;
use hash::keccak;
@ -35,7 +36,7 @@ pub fn verify_signature(
} else {
keccak(message.0)
};
let v: u64 = v.into();
let v = v.as_u64();
let is_valid_for_current_chain = match (chain_id, v) {
(None, v) if v == 0 || v == 1 => true,
(Some(chain_id), v) if v >= 35 => (v - 35) / 2 == chain_id,
@ -54,7 +55,7 @@ pub fn verify_signature(
mod tests {
use super::*;
use ethkey::Generator;
use v1::types::H160;
use ethereum_types::{H160, U64};
pub fn add_chain_replay_protection(v: u64, chain_id: Option<u64>) -> u64 {
v + if let Some(n) = chain_id { 35 + n * 2 } else { 0 }

View File

@ -19,8 +19,8 @@
use std::{ops, str};
use std::collections::HashMap;
use jsonrpc_pubsub::{typed::{Subscriber, Sink}, SubscriptionId};
use ethereum_types::H64;
use rand::{Rng, StdRng};
use v1::types::H64;
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Id(H64);
@ -36,8 +36,9 @@ impl str::FromStr for Id {
}
}
impl Id {
// TODO: replace `format!` see [#10412](https://github.com/paritytech/parity-ethereum/issues/10412)
pub fn as_string(&self) -> String {
format!("0x{:?}", self.0)
format!("{:?}", self.0)
}
}

View File

@ -20,17 +20,13 @@ use std::sync::Arc;
use rlp;
use ethcore::miner::{BlockChainClient, MinerService};
use ethereum_types::{H64 as EthcoreH64, H256 as EthcoreH256};
use ethereum_types::{H64, H256};
use jsonrpc_core::Error;
use v1::types::{H64, H256};
use v1::helpers::errors;
// Submit a POW work and return the block's hash
pub fn submit_work_detail<C: BlockChainClient, M: MinerService>(client: &Arc<C>, miner: &Arc<M>, nonce: H64, pow_hash: H256, mix_hash: H256) -> Result<H256, Error> {
// TODO [ToDr] Should disallow submissions in case of PoA?
let nonce: EthcoreH64 = nonce.into();
let pow_hash: EthcoreH256 = pow_hash.into();
let mix_hash: EthcoreH256 = mix_hash.into();
trace!(target: "miner", "submit_work_detail: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
let seal = vec![rlp::encode(&mix_hash), rlp::encode(&nonce)];
let import = miner.submit_seal(pow_hash, seal)

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 {
@ -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,9 +246,8 @@ 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(
@ -266,15 +258,13 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
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;

View File

@ -53,5 +53,5 @@ pub mod signer {
#[cfg(any(test, feature = "accounts"))]
pub use super::helpers::engine_signer::EngineSigner;
pub use super::helpers::external_signer::{SignerService, ConfirmationsQueue};
pub use super::types::{ConfirmationRequest, TransactionModification, U256, TransactionCondition};
pub use super::types::{ConfirmationRequest, TransactionModification, TransactionCondition};
}

View File

@ -26,7 +26,7 @@ use ethcore::spec::{Genesis, Spec};
use ethcore::test_helpers;
use ethcore::verification::VerifierType;
use ethcore::verification::queue::kind::blocks::Unverified;
use ethereum_types::{H256, Address};
use ethereum_types::{Address, H256, U256};
use ethjson::blockchain::BlockChain;
use ethjson::spec::ForkSpec;
use io::IoChannel;
@ -42,7 +42,6 @@ use v1::impls::{EthClient, EthClientOptions, SigningUnsafeClient};
use v1::metadata::Metadata;
use v1::tests::helpers::{TestSnapshotService, TestSyncProvider, Config};
use v1::traits::{Eth, EthSigning};
use v1::types::U256 as NU256;
fn account_provider() -> Arc<AccountProvider> {
Arc::new(AccountProvider::transient_provider())
@ -459,7 +458,7 @@ fn verify_transaction_counts(name: String, chain: BlockChain) {
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"#.to_owned() + &::serde_json::to_string(&NU256::from(num)).unwrap() + r#"
"#.to_owned() + &::serde_json::to_string(&U256::from(num)).unwrap() + r#"
],
"id": "# + format!("{}", *id).as_ref() + r#"
}"#;

View File

@ -18,8 +18,8 @@ use std::sync::Arc;
use std::str::FromStr;
use bytes::ToPretty;
use ethereum_types::{U256, Address};
use accounts::AccountProvider;
use ethereum_types::{Address, H520, U256};
use ethcore::client::TestBlockChainClient;
use jsonrpc_core::IoHandler;
use parking_lot::Mutex;
@ -31,7 +31,7 @@ use v1::{PersonalClient, Personal, Metadata};
use v1::helpers::{nonce, eip191};
use v1::helpers::dispatch::{eth_data_hash, FullDispatcher};
use v1::tests::helpers::TestMinerService;
use v1::types::{EIP191Version, PresignedTransaction, H520};
use v1::types::{EIP191Version, PresignedTransaction};
use rustc_hex::ToHex;
use serde_json::to_value;
use ethkey::Secret;
@ -156,7 +156,7 @@ fn sign() {
let hash = eth_data_hash(data);
let signature = H520(tester.accounts.sign(address, Some("password123".into()), hash).unwrap().into_electrum());
let signature = format!("0x{:?}", signature);
let signature = format!("{:?}", signature);
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &signature + r#"","id":1}"#;
@ -264,7 +264,7 @@ fn ec_recover() {
let hash = eth_data_hash(data.clone());
let signature = H520(tester.accounts.sign(address, Some("password123".into()), hash).unwrap().into_electrum());
let signature = format!("0x{:?}", signature);
let signature = format!("{:?}", signature);
let request = r#"{
"jsonrpc": "2.0",

View File

@ -18,6 +18,7 @@ use std::sync::Arc;
use crypto::DEFAULT_MAC;
use accounts::AccountProvider;
use ethereum_types::H256;
use ethkey::{KeyPair, Signature, verify_public};
use serde_json;
@ -26,7 +27,7 @@ use v1::metadata::Metadata;
use v1::SecretStoreClient;
use v1::traits::secretstore::SecretStore;
use v1::helpers::secretstore::ordered_servers_keccak;
use v1::types::{H256, EncryptedDocumentKey};
use v1::types::EncryptedDocumentKey;
struct Dependencies {
pub accounts: Arc<AccountProvider>,

View File

@ -16,7 +16,7 @@
use std::sync::Arc;
use std::str::FromStr;
use ethereum_types::{U256, Address};
use ethereum_types::{H520, U256, Address};
use bytes::ToPretty;
use accounts::AccountProvider;
@ -31,7 +31,7 @@ use jsonrpc_core::IoHandler;
use v1::{SignerClient, Signer, Origin};
use v1::metadata::Metadata;
use v1::tests::helpers::TestMinerService;
use v1::types::{Bytes as RpcBytes, H520};
use v1::types::Bytes as RpcBytes;
use v1::helpers::{nonce, FilledTransactionRequest, ConfirmationPayload};
use v1::helpers::external_signer::{SigningQueue, SignerService};
use v1::helpers::dispatch::{self, FullDispatcher, eth_data_hash};
@ -495,7 +495,7 @@ fn should_confirm_data_sign_with_signature() {
let data_hash = eth_data_hash(vec![1, 2, 3, 4].into());
let signature = H520(tester.accounts.sign(address, Some("test".into()), data_hash).unwrap().into_electrum());
let signature = format!("0x{:?}", signature);
let signature = format!("{:?}", signature);
// when
let request = r#"{

View File

@ -210,7 +210,7 @@ fn rpc_eth_send_transaction_with_bad_to() {
"id": 1
}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: expected a hex-encoded hash with 0x prefix."},"id":1}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: prefix is missing."},"id":1}"#;
assert_eq!(tester.io.handle_request_sync(&request), Some(response.into()));
}

View File

@ -17,10 +17,10 @@
//! Eth rpc interface.
use jsonrpc_core::{Result, BoxFuture};
use jsonrpc_derive::rpc;
use ethereum_types::{H64, H160, H256, U64, U256};
use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, EthAccount};
use v1::types::{Log, Receipt, SyncStatus, Transaction, Work};
use v1::types::{H64, H160, H256, U256, U64};
/// Eth rpc interface.
#[rpc]

View File

@ -19,7 +19,8 @@
use jsonrpc_core::BoxFuture;
use jsonrpc_derive::rpc;
use v1::types::{Bytes, H160, H256, H520, TransactionRequest, RichRawTransaction};
use ethereum_types::{H160, H256, H520};
use v1::types::{Bytes, TransactionRequest, RichRawTransaction};
/// Signing methods implementation relying on unlocked accounts.
#[rpc]

View File

@ -18,10 +18,11 @@
use std::collections::BTreeMap;
use ethereum_types::{H64, H160, H256, H512, U64, U256};
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use v1::types::{
H160, H256, H512, U256, U64, H64, Bytes, CallRequest,
Bytes, CallRequest,
Peers, Transaction, RpcSettings, Histogram, RecoveredAccount,
TransactionStats, LocalTransactionStatus,
BlockNumber, ConsensusCapability, VersionInfo,

View File

@ -19,9 +19,10 @@ use std::collections::BTreeMap;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use ethereum_types::{H160, H256, H520};
use ethkey::Password;
use ethstore::KeyFile;
use v1::types::{H160, H256, H520, DeriveHash, DeriveHierarchical, ExtAccountInfo};
use v1::types::{DeriveHash, DeriveHierarchical, ExtAccountInfo};
use v1::types::{AccountInfo, HwAccountInfo};
/// Parity-specific read-only accounts rpc interface.

View File

@ -16,10 +16,11 @@
//! Parity-specific rpc interface for operations altering the settings.
use ethereum_types::{H160, H256, U256};
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction};
use v1::types::{Bytes, ReleaseInfo, Transaction};
/// Parity-specific rpc interface for operations altering the account-related settings.
#[rpc]

View File

@ -18,7 +18,8 @@
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use v1::types::{U256, H160, Bytes, ConfirmationResponse, TransactionRequest, Either};
use ethereum_types::{H160, U256};
use v1::types::{Bytes, ConfirmationResponse, TransactionRequest, Either};
/// Signing methods implementation.
#[rpc]

View File

@ -16,10 +16,11 @@
//! Personal rpc interface.
use eip_712::EIP712;
use ethereum_types::{H160, H256, H520, U128};
use jsonrpc_core::types::Value;
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use v1::types::{Bytes, U128, H160, H256, H520, TransactionRequest, RichRawTransaction as RpcRichRawTransaction, EIP191Version};
use v1::types::{Bytes, TransactionRequest, RichRawTransaction as RpcRichRawTransaction, EIP191Version};
/// Personal rpc interface. Safe (read-only) functions.
#[rpc]
@ -70,5 +71,4 @@ pub trait Personal {
/// @deprecated alias for `personal_sendTransaction`.
#[rpc(meta, name = "personal_signAndSendTransaction")]
fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256>;
}

View File

@ -16,10 +16,11 @@
//! SecretStore-specific rpc interface.
use ethereum_types::{H160, H256, U256};
use jsonrpc_core::Error;
use jsonrpc_derive::rpc;
use v1::types::{Bytes, PrivateTransactionReceipt, H160, H256, U256, BlockNumber,
use v1::types::{Bytes, PrivateTransactionReceipt, BlockNumber,
PrivateTransactionReceiptAndTransaction, CallRequest};
/// Private transaction management RPC interface.

View File

@ -17,11 +17,12 @@
//! SecretStore-specific rpc interface.
use std::collections::BTreeSet;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use ethereum_types::{H160, H256, H512};
use ethkey::Password;
use v1::types::{H160, H256, H512, Bytes, EncryptedDocumentKey};
use v1::types::{Bytes, EncryptedDocumentKey};
/// Parity-specific rpc interface.
#[rpc]

View File

@ -15,11 +15,13 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Parity Signer-related rpc interface.
use ethereum_types::U256;
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use jsonrpc_derive::rpc;
use v1::types::{U256, Bytes, TransactionModification, ConfirmationRequest, ConfirmationResponse, ConfirmationResponseWithToken};
use v1::types::{Bytes, TransactionModification, ConfirmationRequest, ConfirmationResponse, ConfirmationResponseWithToken};
/// Signer extension for confirmations rpc interface.
#[rpc]

View File

@ -16,9 +16,11 @@
//! Traces specific rpc interface.
use ethereum_types::H256;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, TraceResultsWithTransactionHash, H256, TraceOptions};
use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults,
TraceResultsWithTransactionHash, TraceOptions};
/// Traces specific rpc interface.
#[rpc]

View File

@ -15,10 +15,11 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Web3 rpc interface.
use ethereum_types::H256;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use v1::types::{H256, Bytes};
use v1::types::Bytes;
/// Web3 rpc interface.
#[rpc]

View File

@ -16,8 +16,8 @@
//! Return types for RPC calls
use ethereum_types::{Public, Address};
use v1::types::{H160, H256, U256, Bytes};
use ethereum_types::{Public, Address, H160, H256, U256};
use v1::types::Bytes;
/// Account information.
#[derive(Debug, Default, Clone, PartialEq, Serialize)]

View File

@ -17,11 +17,11 @@
use std::ops::Deref;
use std::collections::BTreeMap;
use ethereum_types::{H160, H256, U256, Bloom as H2048};
use serde::ser::Error;
use serde::{Serialize, Serializer};
use types::encoded::Header as EthHeader;
use v1::types::{Bytes, Transaction, H160, H256, H2048, U256};
use v1::types::{Bytes, Transaction};
/// Block Transactions
#[derive(Debug)]
@ -205,8 +205,9 @@ impl<T: Serialize> Serialize for Rich<T> {
#[cfg(test)]
mod tests {
use std::collections::BTreeMap;
use ethereum_types::{H64, H160, H256, U256, Bloom as H2048};
use serde_json;
use v1::types::{Transaction, H64, H160, H256, H2048, Bytes, U256};
use v1::types::{Transaction, Bytes};
use super::{Block, RichBlock, BlockTransactions, Header, RichHeader};
#[test]
@ -248,8 +249,8 @@ mod tests {
let rich_block = RichBlock {
inner: block,
extra_info: map![
"mixHash".into() => format!("0x{:?}", H256::default()),
"nonce".into() => format!("0x{:?}", H64::default())
"mixHash".into() => format!("{:?}", H256::default()),
"nonce".into() => format!("{:?}", H64::default())
],
};
let serialized_rich_block = serde_json::to_string(&rich_block).unwrap();
@ -286,8 +287,8 @@ mod tests {
let rich_block = RichBlock {
inner: block,
extra_info: map![
"mixHash".into() => format!("0x{:?}", H256::default()),
"nonce".into() => format!("0x{:?}", H64::default())
"mixHash".into() => format!("{:?}", H256::default()),
"nonce".into() => format!("{:?}", H64::default())
],
};
let serialized_rich_block = serde_json::to_string(&rich_block).unwrap();
@ -321,8 +322,8 @@ mod tests {
let rich_header = RichHeader {
inner: header,
extra_info: map![
"mixHash".into() => format!("0x{:?}", H256::default()),
"nonce".into() => format!("0x{:?}", H64::default())
"mixHash".into() => format!("{:?}", H256::default()),
"nonce".into() => format!("{:?}", H64::default())
],
};
let serialized_rich_header = serde_json::to_string(&rich_header).unwrap();

View File

@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::{H160, U256};
use v1::helpers::CallRequest as Request;
use v1::types::{Bytes, H160, U256};
use v1::types::Bytes;
/// Call request
#[derive(Debug, Default, PartialEq, Deserialize)]
@ -57,7 +58,7 @@ mod tests {
use std::str::FromStr;
use rustc_hex::FromHex;
use serde_json;
use v1::types::{U256, H160};
use ethereum_types::{U256, H160};
use super::CallRequest;
#[test]

View File

@ -21,7 +21,8 @@ use serde::{Serialize, Serializer};
use ansi_term::Colour;
use bytes::ToPretty;
use v1::types::{U256, TransactionRequest, RichRawTransaction, H160, H256, H520, Bytes, TransactionCondition, Origin};
use ethereum_types::{H160, H256, H520, U256};
use v1::types::{TransactionRequest, RichRawTransaction, Bytes, TransactionCondition, Origin};
use v1::helpers;
use ethkey::Password;
@ -281,8 +282,9 @@ impl<A, B> Serialize for Either<A, B> where
#[cfg(test)]
mod tests {
use std::str::FromStr;
use ethereum_types::{H256, U256};
use serde_json;
use v1::types::{U256, H256, TransactionCondition};
use v1::types::TransactionCondition;
use v1::helpers;
use super::*;

View File

@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::{H160, H256};
use semver;
use v1::types::{H160, H256};
use updater::{self, CapState};
/// Capability info

View File

@ -18,10 +18,9 @@ use std::fmt;
use serde::{Deserialize, Deserializer};
use serde::de::{Error, Visitor};
use ethereum_types::H256;
use ethstore;
use super::hash::H256;
/// Type of derivation
pub enum DerivationType {
/// Soft - allow proof of parent

View File

@ -15,9 +15,11 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! EIP-191 specific types
use ethereum_types::H160;
use serde::{Deserialize, Deserializer};
use serde::de;
use v1::types::{H160, Bytes};
use v1::types::Bytes;
/// EIP-191 version specifier
#[derive(Debug)]

View File

@ -0,0 +1,84 @@
use ethereum_types::{H256, U256};
use serde_json;
type Res = Result<U256, serde_json::Error>;
#[test]
fn should_serialize_u256() {
let serialized1 = serde_json::to_string(&U256::from(0)).unwrap();
let serialized2 = serde_json::to_string(&U256::from(1)).unwrap();
let serialized3 = serde_json::to_string(&U256::from(16)).unwrap();
let serialized4 = serde_json::to_string(&U256::from(256)).unwrap();
assert_eq!(serialized1, r#""0x0""#);
assert_eq!(serialized2, r#""0x1""#);
assert_eq!(serialized3, r#""0x10""#);
assert_eq!(serialized4, r#""0x100""#);
}
#[test]
fn should_serialize_h256() {
let serialized1 = serde_json::to_string(&H256::from(0)).unwrap();
let serialized2 = serde_json::to_string(&H256::from(1)).unwrap();
let serialized3 = serde_json::to_string(&H256::from(16)).unwrap();
let serialized4 = serde_json::to_string(&H256::from(256)).unwrap();
assert_eq!(serialized1, r#""0x0000000000000000000000000000000000000000000000000000000000000000""#);
assert_eq!(serialized2, r#""0x0000000000000000000000000000000000000000000000000000000000000001""#);
assert_eq!(serialized3, r#""0x0000000000000000000000000000000000000000000000000000000000000010""#);
assert_eq!(serialized4, r#""0x0000000000000000000000000000000000000000000000000000000000000100""#);
}
#[test]
fn should_fail_to_deserialize_decimals() {
let deserialized0: Res = serde_json::from_str(r#""∀∂""#);
let deserialized1: Res = serde_json::from_str(r#""""#);
let deserialized2: Res = serde_json::from_str(r#""0""#);
let deserialized3: Res = serde_json::from_str(r#""10""#);
let deserialized4: Res = serde_json::from_str(r#""1000000""#);
let deserialized5: Res = serde_json::from_str(r#""1000000000000000000""#);
let deserialized6: Res = serde_json::from_str(r#""0x""#);
assert!(deserialized0.is_err());
assert!(deserialized1.is_err());
assert!(deserialized2.is_err());
assert!(deserialized3.is_err());
assert!(deserialized4.is_err());
assert!(deserialized5.is_err());
assert!(deserialized6.is_err(), "Quantities should represent zero as 0x0");
}
#[test]
fn should_fail_to_deserialize_bad_hex_strings() {
let deserialized1: Result<H256, serde_json::Error> = serde_json::from_str(r#""0""#);
let deserialized2: Result<H256, serde_json::Error> = serde_json::from_str(r#""0x""#);
let deserialized3: Result<H256, serde_json::Error> = serde_json::from_str(r#""0x∀∂0000000000000000000000000000000000000000000000000000000000""#);
assert!(deserialized1.is_err(), "hex string should start with 0x");
assert!(deserialized2.is_err(), "0x-prefixed hex string of length 64");
assert!(deserialized3.is_err(), "hex string should only contain hex chars");
}
#[test]
fn should_deserialize_u256() {
let deserialized1: U256 = serde_json::from_str(r#""0x0""#).unwrap();
let deserialized2: U256 = serde_json::from_str(r#""0x1""#).unwrap();
let deserialized3: U256 = serde_json::from_str(r#""0x01""#).unwrap();
let deserialized4: U256 = serde_json::from_str(r#""0x100""#).unwrap();
assert_eq!(deserialized1, 0.into());
assert_eq!(deserialized2, 1.into());
assert_eq!(deserialized3, 1.into());
assert_eq!(deserialized4, 256.into());
}
#[test]
fn should_deserialize_h256() {
let deserialized1: H256 = serde_json::from_str(r#""0x0000000000000000000000000000000000000000000000000000000000000000""#).unwrap();
let deserialized2: H256 = serde_json::from_str(r#""0x0000000000000000000000000000000000000000000000000000000000000001""#).unwrap();
let deserialized3: H256 = serde_json::from_str(r#""0x0000000000000000000000000000000000000000000000000000000000000100""#).unwrap();
assert_eq!(deserialized1, 0.into());
assert_eq!(deserialized2, 1.into());
assert_eq!(deserialized3, 256.into());
}

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::{H160, H256};
use jsonrpc_core::{Error as RpcError};
use serde::de::{Error, DeserializeOwned};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@ -21,7 +22,7 @@ use serde_json::{Value, from_value};
use types::filter::Filter as EthFilter;
use types::ids::BlockId;
use v1::types::{BlockNumber, H160, H256, Log};
use v1::types::{BlockNumber, Log};
use v1::helpers::errors::invalid_params;
/// Variadic value

View File

@ -1,165 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
use std::fmt;
use std::str::FromStr;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
use serde;
use rustc_hex::{ToHex, FromHex};
use ethereum_types::{H64 as Eth64, H160 as Eth160, H256 as Eth256, H520 as Eth520, H512 as Eth512, Bloom as Eth2048};
macro_rules! impl_hash {
($name: ident, $other: ident, $size: expr) => {
/// Hash serialization
pub struct $name(pub [u8; $size]);
impl Eq for $name { }
impl Default for $name {
fn default() -> Self {
$name([0; $size])
}
}
impl fmt::Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0.to_hex())
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let hex = self.0.to_hex();
write!(f, "{}..{}", &hex[0..2], &hex[$size-2..$size])
}
}
impl<T> From<T> for $name where $other: From<T> {
fn from(o: T) -> Self {
$name($other::from(o).0)
}
}
impl FromStr for $name {
type Err = <$other as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
$other::from_str(s).map(|x| $name(x.0))
}
}
impl Into<$other> for $name {
fn into(self) -> $other {
$other(self.0)
}
}
impl PartialEq for $name {
fn eq(&self, other: &Self) -> bool {
let self_ref: &[u8] = &self.0;
let other_ref: &[u8] = &other.0;
self_ref == other_ref
}
}
impl PartialOrd for $name {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let self_ref: &[u8] = &self.0;
let other_ref: &[u8] = &other.0;
self_ref.partial_cmp(other_ref)
}
}
impl Ord for $name {
fn cmp(&self, other: &Self) -> Ordering {
let self_ref: &[u8] = &self.0;
let other_ref: &[u8] = &other.0;
self_ref.cmp(other_ref)
}
}
impl Hash for $name {
fn hash<H>(&self, state: &mut H) where H: Hasher {
let self_ref: &[u8] = &self.0;
Hash::hash(self_ref, state)
}
}
impl Clone for $name {
fn clone(&self) -> Self {
let mut r = [0; $size];
r.copy_from_slice(&self.0);
$name(r)
}
}
impl serde::Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
let mut hex = "0x".to_owned();
hex.push_str(&self.0.to_hex());
serializer.serialize_str(&hex)
}
}
impl<'a> serde::Deserialize<'a> for $name {
fn deserialize<D>(deserializer: D) -> Result<$name, D::Error> where D: serde::Deserializer<'a> {
struct HashVisitor;
impl<'b> serde::de::Visitor<'b> for HashVisitor {
type Value = $name;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a 0x-prefixed, padded, hex-encoded hash with length {}", $size * 2)
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> where E: serde::de::Error {
if value.len() < 2 || !value.starts_with("0x") {
return Err(E::custom("expected a hex-encoded hash with 0x prefix"));
}
if value.len() != 2 + $size * 2 {
return Err(E::invalid_length(value.len() - 2, &self));
}
match value[2..].from_hex() {
Ok(ref v) => {
let mut result = [0u8; $size];
result.copy_from_slice(v);
Ok($name(result))
},
Err(e) => Err(E::custom(format!("invalid hex value: {:?}", e))),
}
}
fn visit_string<E>(self, value: String) -> Result<Self::Value, E> where E: serde::de::Error {
self.visit_str(value.as_ref())
}
}
deserializer.deserialize_any(HashVisitor)
}
}
}
}
impl_hash!(H64, Eth64, 8);
impl_hash!(H160, Eth160, 20);
impl_hash!(H256, Eth256, 32);
impl_hash!(H512, Eth512, 64);
impl_hash!(H520, Eth520, 65);
impl_hash!(H2048, Eth2048, 256);

View File

@ -16,7 +16,7 @@
//! Gas prices histogram.
use v1::types::U256;
use ethereum_types::U256;
/// Values of RPC settings.
#[derive(Serialize, Deserialize)]

View File

@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::{H160, H256, U256};
use types::log_entry::{LocalizedLogEntry, LogEntry};
use v1::types::{Bytes, H160, H256, U256};
use v1::types::Bytes;
/// Log
#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone)]
@ -87,7 +88,8 @@ impl From<LogEntry> for Log {
mod tests {
use serde_json;
use std::str::FromStr;
use v1::types::{Log, H160, H256, U256};
use v1::types::Log;
use ethereum_types::{H160, H256, U256};
#[test]
fn log_serialization() {

View File

@ -16,6 +16,9 @@
//! RPC types
#[cfg(test)]
mod eth_types;
mod account_info;
mod block;
mod block_number;
@ -25,7 +28,6 @@ mod confirmations;
mod consensus_status;
mod derivation;
mod filter;
mod hash;
mod histogram;
mod index;
mod log;
@ -40,7 +42,6 @@ mod trace_filter;
mod transaction;
mod transaction_request;
mod transaction_condition;
mod uint;
mod work;
mod private_receipt;
mod eip191;
@ -60,7 +61,6 @@ pub use self::confirmations::{
pub use self::consensus_status::*;
pub use self::derivation::{DeriveHash, DeriveHierarchical, Derive};
pub use self::filter::{Filter, FilterChanges};
pub use self::hash::{H64, H160, H256, H512, H520, H2048};
pub use self::histogram::Histogram;
pub use self::index::Index;
pub use self::log::Log;
@ -78,7 +78,6 @@ pub use self::trace_filter::TraceFilter;
pub use self::transaction::{Transaction, RichRawTransaction, LocalTransactionStatus};
pub use self::transaction_request::TransactionRequest;
pub use self::transaction_condition::TransactionCondition;
pub use self::uint::{U128, U256, U64};
pub use self::work::Work;
pub use self::private_receipt::{PrivateTransactionReceipt, PrivateTransactionReceiptAndTransaction};

View File

@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use v1::types::{H160, H256, TransactionRequest};
use ethcore_private_tx::{Receipt as EthPrivateReceipt};
use ethereum_types::{H160, H256};
use v1::types::TransactionRequest;
/// Receipt
#[derive(Debug, Serialize)]

View File

@ -17,7 +17,7 @@
//! Request Provenance
use std::fmt;
use v1::types::H256;
use ethereum_types::H256;
/// RPC request origin
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

View File

@ -16,10 +16,11 @@
//! Pub-Sub types.
use ethereum_types::H256;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::Error;
use serde_json::{Value, from_value};
use v1::types::{RichHeader, Filter, Log, H256};
use v1::types::{RichHeader, Filter, Log};
/// Subscription result.
#[derive(Debug, Clone, PartialEq, Eq)]

View File

@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use v1::types::{Log, H160, H256, H2048, U256, U64};
use ethereum_types::{H160, H256, U64, U256, Bloom as H2048};
use v1::types::Log;
use types::receipt::{Receipt as EthReceipt, RichReceipt, LocalizedReceipt, TransactionOutcome};
/// Receipt

View File

@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use v1::types::{Bytes, H512};
use ethereum_types::H512;
use v1::types::Bytes;
/// Encrypted document key.
#[derive(Default, Debug, Serialize, PartialEq)]
@ -22,7 +23,7 @@ use v1::types::{Bytes, H512};
pub struct EncryptedDocumentKey {
/// Common encryption point. Pass this to Secret Store 'Document key storing session'
pub common_point: H512,
/// Ecnrypted point. Pass this to Secret Store 'Document key storing session'.
/// Encrypted point. Pass this to Secret Store 'Document key storing session'.
pub encrypted_point: H512,
/// Document key itself, encrypted with passed account public. Pass this to 'secretstore_encrypt'.
pub encrypted_key: Bytes,

View File

@ -16,9 +16,10 @@
use network::client_version::ClientVersion;
use std::collections::BTreeMap;
use ethereum_types::{U256, H512};
use sync::{self, PeerInfo as SyncPeerInfo, TransactionStats as SyncTransactionStats};
use serde::{Serialize, Serializer};
use v1::types::{U256, H512};
/// Sync info
#[derive(Default, Debug, Serialize, PartialEq)]

View File

@ -19,14 +19,14 @@ use std::collections::BTreeMap;
use ethcore::client::Executed;
use ethcore::trace as et;
use ethcore::trace::{FlatTrace, LocalizedTrace as EthLocalizedTrace, trace, TraceError};
use ethereum_types::H256 as EthH256;
use ethereum_types::{H160, H256, U256};
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
use types::account_diff;
use types::state_diff;
use vm;
use v1::types::{Bytes, H160, H256, U256};
use v1::types::Bytes;
#[derive(Debug, Serialize)]
/// A diff of some chunk of memory.
@ -639,8 +639,8 @@ pub struct TraceResultsWithTransactionHash {
pub transaction_hash: H256,
}
impl From<(EthH256, Executed)> for TraceResultsWithTransactionHash {
fn from(t: (EthH256, Executed)) -> Self {
impl From<(H256, Executed)> for TraceResultsWithTransactionHash {
fn from(t: (H256, Executed)) -> Self {
TraceResultsWithTransactionHash {
output: t.1.output.into(),
trace: t.1.trace.into_iter().map(Into::into).collect(),

View File

@ -18,7 +18,8 @@
use ethcore::client::BlockId;
use ethcore::client;
use v1::types::{BlockNumber, H160};
use ethereum_types::H160;
use v1::types::BlockNumber;
/// Trace filter
#[derive(Debug, PartialEq, Deserialize)]

View File

@ -19,9 +19,10 @@ use std::sync::Arc;
use serde::{Serialize, Serializer};
use serde::ser::SerializeStruct;
use ethcore::{contract_address, CreateContractAddress};
use ethereum_types::{H160, H256, H512, U64, U256};
use miner;
use types::transaction::{LocalizedTransaction, Action, PendingTransaction, SignedTransaction};
use v1::types::{Bytes, H160, H256, U256, H512, U64, TransactionCondition};
use v1::types::{Bytes, TransactionCondition};
/// Transaction
#[derive(Debug, Default, Clone, PartialEq, Serialize)]

View File

@ -16,7 +16,8 @@
//! `TransactionRequest` type
use v1::types::{Bytes, H160, U256, TransactionCondition};
use ethereum_types::{H160, U256};
use v1::types::{Bytes, TransactionCondition};
use v1::helpers;
use ansi_term::Colour;
@ -137,7 +138,8 @@ mod tests {
use std::str::FromStr;
use rustc_hex::FromHex;
use serde_json;
use v1::types::{U256, H160, TransactionCondition};
use v1::types::TransactionCondition;
use ethereum_types::{H160, U256};
use super::*;
#[test]

View File

@ -1,172 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
use std::str::FromStr;
use std::fmt;
use serde;
use ethereum_types::{U256 as EthU256, U128 as EthU128};
macro_rules! impl_uint {
($name: ident, $other: ident, $size: expr) => {
/// Uint serialization.
#[derive(Debug, Default, Clone, Copy, PartialEq, Hash)]
pub struct $name($other);
impl Eq for $name { }
impl<T> From<T> for $name where $other: From<T> {
fn from(o: T) -> Self {
$name($other::from(o))
}
}
impl FromStr for $name {
type Err = <$other as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
$other::from_str(s).map($name)
}
}
impl Into<$other> for $name {
fn into(self) -> $other {
self.0
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl fmt::LowerHex for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::LowerHex::fmt(&self.0, f)
}
}
impl<'a> serde::Deserialize<'a> for $name {
fn deserialize<D>(deserializer: D) -> Result<$name, D::Error>
where D: serde::Deserializer<'a> {
struct UintVisitor;
impl<'b> serde::de::Visitor<'b> for UintVisitor {
type Value = $name;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a 0x-prefixed, hex-encoded number of length {}", $size*16)
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> where E: serde::de::Error {
if value.len() < 2 || !value.starts_with("0x") {
return Err(E::custom("expected a hex-encoded numbers with 0x prefix"))
}
// 0x + len
if value.len() > 2 + $size * 16 {
return Err(E::invalid_length(value.len() - 2, &self));
}
$other::from_str(&value[2..]).map($name).map_err(|e| E::custom(&format!("invalid hex value: {:?}", e)))
}
fn visit_string<E>(self, value: String) -> Result<Self::Value, E> where E: serde::de::Error {
self.visit_str(&value)
}
}
deserializer.deserialize_any(UintVisitor)
}
}
}
}
impl_uint!(U128, EthU128, 2);
impl_uint!(U256, EthU256, 4);
impl_uint!(U64, u64, 1);
impl serde::Serialize for U128 {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
serializer.serialize_str(&format!("{:#x}", self))
}
}
impl serde::Serialize for U256 {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
serializer.serialize_str(&format!("{:#x}", self))
}
}
impl serde::Serialize for U64 {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
serializer.serialize_str(&format!("{:#x}", self))
}
}
#[cfg(test)]
mod tests {
use super::U256;
use serde_json;
type Res = Result<U256, serde_json::Error>;
#[test]
fn should_serialize_u256() {
let serialized1 = serde_json::to_string(&U256(0.into())).unwrap();
let serialized2 = serde_json::to_string(&U256(1.into())).unwrap();
let serialized3 = serde_json::to_string(&U256(16.into())).unwrap();
let serialized4 = serde_json::to_string(&U256(256.into())).unwrap();
assert_eq!(serialized1, r#""0x0""#);
assert_eq!(serialized2, r#""0x1""#);
assert_eq!(serialized3, r#""0x10""#);
assert_eq!(serialized4, r#""0x100""#);
}
#[test]
fn should_fail_to_deserialize_decimals() {
let deserialized0: Res = serde_json::from_str(r#""∀∂""#);
let deserialized1: Res = serde_json::from_str(r#""""#);
let deserialized2: Res = serde_json::from_str(r#""0""#);
let deserialized3: Res = serde_json::from_str(r#""10""#);
let deserialized4: Res = serde_json::from_str(r#""1000000""#);
let deserialized5: Res = serde_json::from_str(r#""1000000000000000000""#);
assert!(deserialized0.is_err());
assert!(deserialized1.is_err());
assert!(deserialized2.is_err());
assert!(deserialized3.is_err());
assert!(deserialized4.is_err());
assert!(deserialized5.is_err());
}
#[test]
fn should_deserialize_u256() {
let deserialized1: U256 = serde_json::from_str(r#""0x""#).unwrap();
let deserialized2: U256 = serde_json::from_str(r#""0x0""#).unwrap();
let deserialized3: U256 = serde_json::from_str(r#""0x1""#).unwrap();
let deserialized4: U256 = serde_json::from_str(r#""0x01""#).unwrap();
let deserialized5: U256 = serde_json::from_str(r#""0x100""#).unwrap();
assert_eq!(deserialized1, U256(0.into()));
assert_eq!(deserialized2, U256(0.into()));
assert_eq!(deserialized3, U256(1.into()));
assert_eq!(deserialized4, U256(1.into()));
assert_eq!(deserialized5, U256(256.into()));
}
}

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use super::{H256, U256};
use ethereum_types::{H256, U256};
use serde::{Serialize, Serializer};