updated serde to version 1.0

This commit is contained in:
debris
2017-07-06 11:36:15 +02:00
parent cc718bb108
commit 61d8f90530
116 changed files with 553 additions and 662 deletions

View File

@@ -8,7 +8,7 @@ rand = "0.3.14"
lazy_static = "0.2"
tiny-keccak = "1.2"
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
rustc-serialize = "0.3"
rustc-hex = "1.0"
ethcore-bigint = { path = "../util/bigint" }
rust-crypto = "0.2"
byteorder = "1.0"

View File

@@ -5,8 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
ethkey = { path = "../" }
rustc-serialize = "0.3"
docopt = "0.7"
serde = "1.0"
serde_derive = "1.0"
rustc-hex = "1.0"
docopt = "0.8"
[[bin]]
name = "ethkey"

View File

@@ -15,13 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern crate docopt;
extern crate rustc_serialize;
extern crate rustc_hex;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate ethkey;
use std::{env, fmt, process};
use std::num::ParseIntError;
use docopt::Docopt;
use rustc_serialize::hex::{FromHex, FromHexError};
use rustc_hex::{FromHex, FromHexError};
use ethkey::{KeyPair, Random, Brain, Prefix, Error as EthkeyError, Generator, sign, verify_public, verify_address};
pub const USAGE: &'static str = r#"
@@ -54,7 +57,7 @@ Commands:
verify Verify signer of the signature.
"#;
#[derive(Debug, RustcDecodable)]
#[derive(Debug, Deserialize)]
struct Args {
cmd_info: bool,
cmd_generate: bool,
@@ -83,6 +86,7 @@ enum Error {
Ethkey(EthkeyError),
FromHex(FromHexError),
ParseInt(ParseIntError),
Docopt(docopt::Error),
}
impl From<EthkeyError> for Error {
@@ -103,12 +107,19 @@ impl From<ParseIntError> for Error {
}
}
impl From<docopt::Error> for Error {
fn from(err: docopt::Error) -> Self {
Error::Docopt(err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Error::Ethkey(ref e) => write!(f, "{}", e),
Error::FromHex(ref e) => write!(f, "{}", e),
Error::ParseInt(ref e) => write!(f, "{}", e),
Error::Docopt(ref e) => write!(f, "{}", e),
}
}
}
@@ -155,8 +166,7 @@ fn display(keypair: KeyPair, mode: DisplayMode) -> String {
fn execute<S, I>(command: I) -> Result<String, Error> where I: IntoIterator<Item=S>, S: AsRef<str> {
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.argv(command).decode())
.unwrap_or_else(|e| e.exit());
.and_then(|d| d.argv(command).deserialize())?;
return if args.cmd_info {
let display_mode = DisplayMode::new(&args);

View File

@@ -16,7 +16,7 @@
use std::fmt;
use secp256k1::key;
use rustc_serialize::hex::ToHex;
use rustc_hex::ToHex;
use keccak::Keccak256;
use super::{Secret, Public, Address, SECP256K1, Error};

View File

@@ -19,7 +19,7 @@ extern crate rand;
extern crate lazy_static;
extern crate tiny_keccak;
extern crate secp256k1;
extern crate rustc_serialize;
extern crate rustc_hex;
extern crate ethcore_bigint as bigint;
extern crate crypto as rcrypto;
extern crate byteorder;

View File

@@ -21,7 +21,7 @@ use std::str::FromStr;
use std::hash::{Hash, Hasher};
use secp256k1::{Message as SecpMessage, RecoverableSignature, RecoveryId, Error as SecpError};
use secp256k1::key::{SecretKey, PublicKey};
use rustc_serialize::hex::{ToHex, FromHex};
use rustc_hex::{ToHex, FromHex};
use bigint::hash::{H520, H256};
use {Secret, Public, SECP256K1, Error, Message, public_to_address, Address};