Skip to content

Commit

Permalink
Update ethereum-types. (#149)
Browse files Browse the repository at this point in the history
* Update ethereum-types.

* Fix derive.

* Bump major version.
  • Loading branch information
tomusdrw authored Apr 9, 2019
1 parent d05fdfa commit 3774554
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 68 deletions.
123 changes: 76 additions & 47 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi-cli"
version = "6.0.0"
version = "7.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
keywords = ["ethereum", "eth", "abi", "solidity", "cli"]
description = "Easy to use cli for conversion of ethereum contract calls to bytecode."
Expand All @@ -12,7 +12,7 @@ rustc-hex = "2.0"
serde = "1.0"
serde_derive = "1.0"
docopt = "1.0"
ethabi = { version = "6.0", path = "../ethabi" }
ethabi = { version = "7.0", path = "../ethabi" }
error-chain = { version = "0.12.0", default-features = false }

[features]
Expand Down
2 changes: 1 addition & 1 deletion contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi-contract"
version = "6.0.0"
version = "7.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT/Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi-derive"
version = "6.0.2"
version = "7.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT/Apache-2.0"
Expand All @@ -11,7 +11,7 @@ description = "Easy to use conversion of ethereum contract calls to bytecode."
proc-macro = true

[dependencies]
ethabi = { path = "../ethabi", version = "6.0" }
ethabi = { path = "../ethabi", version = "7.0" }
heck = "0.3"
syn = "0.15"
quote = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn to_token(name: &proc_macro2::TokenStream, kind: &ParamType) -> proc_macro2::T
match *kind {
ParamType::Address => quote! { ethabi::Token::Address(#name) },
ParamType::Bytes => quote! { ethabi::Token::Bytes(#name) },
ParamType::FixedBytes(_) => quote! { ethabi::Token::FixedBytes(#name.to_vec()) },
ParamType::FixedBytes(_) => quote! { ethabi::Token::FixedBytes(#name.as_ref().to_vec()) },
ParamType::Int(_) => quote! { ethabi::Token::Int(#name) },
ParamType::Uint(_) => quote! { ethabi::Token::Uint(#name) },
ParamType::Bool => quote! { ethabi::Token::Bool(#name) },
Expand Down
4 changes: 2 additions & 2 deletions ethabi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi"
version = "6.1.0"
version = "7.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT/Apache-2.0"
Expand All @@ -14,7 +14,7 @@ serde_json = "1.0"
serde_derive = "1.0"
tiny-keccak = "1.4"
error-chain = { version = "0.12", default-features = false }
ethereum-types = "0.4"
ethereum-types = "0.5.2"

[dev-dependencies]
hex-literal = "0.1.1"
Expand Down
8 changes: 4 additions & 4 deletions ethabi/src/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! ABI encoder.

use util::pad_u32;
use {Token, Hash, Bytes};
use {Token, Bytes};

fn pad_bytes(bytes: &[u8]) -> Vec<[u8; 32]> {
let mut result = vec![pad_u32(bytes.len() as u32)];
Expand Down Expand Up @@ -133,14 +133,14 @@ fn encode_token(token: &Token) -> Mediate {
match *token {
Token::Address(ref address) => {
let mut padded = [0u8; 32];
padded[12..].copy_from_slice(address);
padded[12..].copy_from_slice(address.as_ref());
Mediate::Raw(vec![padded])
},
Token::Bytes(ref bytes) => Mediate::Prefixed(pad_bytes(bytes)),
Token::String(ref s) => Mediate::Prefixed(pad_bytes(s.as_bytes())),
Token::FixedBytes(ref bytes) => Mediate::Raw(pad_fixed_bytes(bytes)),
Token::Int(ref int) => Mediate::Raw(vec![Hash::from(int).0]),
Token::Uint(ref uint) => Mediate::Raw(vec![Hash::from(uint).0]),
Token::Int(int) => Mediate::Raw(vec![int.into()]),
Token::Uint(uint) => Mediate::Raw(vec![uint.into()]),
Token::Bool(b) => {
let mut value = [0u8; 32];
if b {
Expand Down
10 changes: 5 additions & 5 deletions ethabi/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Event {

let flat_topics = topics.into_iter()
.skip(to_skip)
.flat_map(|t| t.to_vec())
.flat_map(|t| t.as_ref().to_vec())
.collect::<Vec<u8>>();

let topic_tokens = try!(decode(&topic_types, &flat_topics));
Expand Down Expand Up @@ -208,8 +208,8 @@ mod tests {
let log = RawLog {
topics: vec![
long_signature("foo", &[ParamType::Int(256), ParamType::Int(256), ParamType::Address, ParamType::Address]),
"0000000000000000000000000000000000000000000000000000000000000002".into(),
"0000000000000000000000001111111111111111111111111111111111111111".into(),
"0000000000000000000000000000000000000000000000000000000000000002".parse().unwrap(),
"0000000000000000000000001111111111111111111111111111111111111111".parse().unwrap(),
],
data:
("".to_owned() +
Expand All @@ -221,8 +221,8 @@ mod tests {
assert_eq!(result, Log { params: vec![
("a".to_owned(), Token::Int("0000000000000000000000000000000000000000000000000000000000000003".into())),
("b".to_owned(), Token::Int("0000000000000000000000000000000000000000000000000000000000000002".into())),
("c".to_owned(), Token::Address("2222222222222222222222222222222222222222".into())),
("d".to_owned(), Token::Address("1111111111111111111111111111111111111111".into())),
("c".to_owned(), Token::Address("2222222222222222222222222222222222222222".parse().unwrap())),
("d".to_owned(), Token::Address("1111111111111111111111111111111111111111".parse().unwrap())),
].into_iter().map(|(name, value)| LogParam { name, value }).collect::<Vec<_>>()});
}
}
Loading

0 comments on commit 3774554

Please sign in to comment.