Skip to content

Commit

Permalink
Merge pull request #6 from ethcore/serde_up
Browse files Browse the repository at this point in the history
serde updated to 0.8
  • Loading branch information
debris authored Aug 29, 2016
2 parents fbed049 + 5926f64 commit cfc591b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 60 deletions.
106 changes: 56 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi"
version = "0.2.1"
version = "0.2.2"
authors = ["debris <[email protected]>"]
build = "build.rs"
homepage = "https://github.com/ethcore/ethabi"
Expand All @@ -10,15 +10,15 @@ description = "Easy to use conversion of ethereum contract calls to bytecode."

[dependencies]
rustc-serialize = "0.3"
serde = "0.7"
serde_json = "0.7"
serde = "0.8"
serde_json = "0.8"
tiny-keccak = "1.0"
serde_macros = { version = "0.7.0", optional = true }
serde_macros = { version = "0.8.0", optional = true }
clippy = { version = "0.0.63", optional = true }
docopt = { version = "0.6", optional = true }

[build-dependencies]
serde_codegen = { version = "0.7.0", optional = true }
serde_codegen = { version = "0.8.0", optional = true }

[features]
default = ["serde_codegen", "cli"]
Expand Down
10 changes: 5 additions & 5 deletions src/spec/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use serde::{Deserialize, Deserializer, Error as SerdeError};
use serde_json::Value;
use serde_json::value;
use serde_json::value::from_value;
use super::{Function, Event, Constructor};

/// Operation type.
Expand All @@ -22,11 +22,11 @@ impl Deserialize for Operation {
let v: Value = try!(Value::deserialize(deserializer));
let cloned = v.clone();
let map = try!(cloned.as_object().ok_or_else(|| SerdeError::custom("Invalid operation")));
let s = try!(map.get("type").and_then(Value::as_string).ok_or_else(|| SerdeError::custom("Invalid operation type")));
let s = try!(map.get("type").and_then(Value::as_str).ok_or_else(|| SerdeError::custom("Invalid operation type")));
let result = match s {
"constructor" => Deserialize::deserialize(&mut value::Deserializer::new(v)).map(Operation::Constructor),
"function" => Deserialize::deserialize(&mut value::Deserializer::new(v)).map(Operation::Function),
"event" => Deserialize::deserialize(&mut value::Deserializer::new(v)).map(Operation::Event),
"constructor" => from_value(v).map(Operation::Constructor),
"function" => from_value(v).map(Operation::Function),
"event" => from_value(v).map(Operation::Event),
_ => Err(SerdeError::custom("Invalid operation type.")),
};
result.map_err(|e| D::Error::custom(e.to_string()))
Expand Down

0 comments on commit cfc591b

Please sign in to comment.