diff --git a/Cargo.lock b/Cargo.lock
index f67f3b610..71061696d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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)",
diff --git a/cli-signer/Cargo.toml b/cli-signer/Cargo.toml
index f4fa86d94..11dd06107 100644
--- a/cli-signer/Cargo.toml
+++ b/cli-signer/Cargo.toml
@@ -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" }
diff --git a/cli-signer/rpc-client/Cargo.toml b/cli-signer/rpc-client/Cargo.toml
index e7eb35461..53ec98339 100644
--- a/cli-signer/rpc-client/Cargo.toml
+++ b/cli-signer/rpc-client/Cargo.toml
@@ -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"
diff --git a/cli-signer/rpc-client/src/lib.rs b/cli-signer/rpc-client/src/lib.rs
index df7936eae..d0e087e59 100644
--- a/cli-signer/rpc-client/src/lib.rs
+++ b/cli-signer/rpc-client/src/lib.rs
@@ -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;
diff --git a/cli-signer/rpc-client/src/signer_client.rs b/cli-signer/rpc-client/src/signer_client.rs
index 339f43b6e..997841936 100644
--- a/cli-signer/rpc-client/src/signer_client.rs
+++ b/cli-signer/rpc-client/src/signer_client.rs
@@ -15,7 +15,8 @@
// along with Parity Ethereum. If not, see .
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;
diff --git a/cli-signer/src/lib.rs b/cli-signer/src/lib.rs
index f09d4403a..3ef6e7054 100644
--- a/cli-signer/src/lib.rs
+++ b/cli-signer/src/lib.rs
@@ -14,13 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see .
+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;
diff --git a/rpc/src/v1/helpers/dispatch/mod.rs b/rpc/src/v1/helpers/dispatch/mod.rs
index d23619f41..887720972 100644
--- a/rpc/src/v1/helpers/dispatch/mod.rs
+++ b/rpc/src/v1/helpers/dispatch/mod.rs
@@ -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(
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(
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)
);
diff --git a/rpc/src/v1/helpers/external_signer/signing_queue.rs b/rpc/src/v1/helpers/external_signer/signing_queue.rs
index 764050052..9bbc778ec 100644
--- a/rpc/src/v1/helpers/external_signer/signing_queue.rs
+++ b/rpc/src/v1/helpers/external_signer/signing_queue.rs
@@ -15,6 +15,7 @@
// along with Parity Ethereum. If not, see .
use std::collections::BTreeMap;
+
use ethereum_types::U256;
use parking_lot::{Mutex, RwLock};
use super::oneshot;
diff --git a/rpc/src/v1/helpers/secretstore.rs b/rpc/src/v1/helpers/secretstore.rs
index d8a60d592..6e1cbca45 100644
--- a/rpc/src/v1/helpers/secretstore.rs
+++ b/rpc/src/v1/helpers/secretstore.rs
@@ -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.
diff --git a/rpc/src/v1/helpers/signature.rs b/rpc/src/v1/helpers/signature.rs
index b2bea2588..32827ea1e 100644
--- a/rpc/src/v1/helpers/signature.rs
+++ b/rpc/src/v1/helpers/signature.rs
@@ -15,8 +15,9 @@
// along with Parity Ethereum. If not, see .
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 {
v + if let Some(n) = chain_id { 35 + n * 2 } else { 0 }
diff --git a/rpc/src/v1/helpers/subscribers.rs b/rpc/src/v1/helpers/subscribers.rs
index 5b48b67a2..9483d8e32 100644
--- a/rpc/src/v1/helpers/subscribers.rs
+++ b/rpc/src/v1/helpers/subscribers.rs
@@ -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)
}
}
diff --git a/rpc/src/v1/helpers/work.rs b/rpc/src/v1/helpers/work.rs
index 0a90d446e..661b4cab8 100644
--- a/rpc/src/v1/helpers/work.rs
+++ b/rpc/src/v1/helpers/work.rs
@@ -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(client: &Arc, miner: &Arc, nonce: H64, pow_hash: H256, mix_hash: H256) -> Result {
// 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)
diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs
index 8d47b9b7b..31b8be10c 100644
--- a/rpc/src/v1/impls/eth.rs
+++ b/rpc/src/v1/impls/eth.rs
@@ -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 Eth for EthClient<
}
}
- fn author(&self) -> Result {
+ fn author(&self) -> Result {
let miner = self.miner.authoring_params().author;
if miner == 0.into() {
(self.accounts)()
@@ -539,7 +538,7 @@ impl 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 Eth for EthClient<
Ok(self.miner.is_currently_sealing())
}
- fn chain_id(&self) -> Result