Skip to content

Commit

Permalink
Fix type of *WithInput::Output for non-constant functions (#100)
Browse files Browse the repository at this point in the history
* ethabi-derive: fix *WithInput::Output for non-constant functions

* Bump version

* Add test for *WithInput::Output
  • Loading branch information
axelchalon authored and tomusdrw committed Jun 7, 2018
1 parent 7b9cca3 commit 59faf54
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion 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 = "6.0.1"
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 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 = "6.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi-derive"
version = "6.0.0"
version = "6.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT"
Expand Down
14 changes: 2 additions & 12 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,8 @@ fn declare_output_functions(function: &Function) -> quote::Tokens {
fn declare_functions_input_wrappers(function: &Function) -> quote::Tokens {
let name = syn::Ident::from(function.name.to_camel_case());
let name_with_input = syn::Ident::from(format!("{}WithInput",function.name.to_camel_case()));
let output_kinds = if function.constant {
get_output_kinds(&function.outputs)
}
else {
quote!{()}
};
let output_fn_body = if function.constant {
quote!{functions::#name::default().decode_output(&_output_bytes)}
}
else {
quote!{Ok(())}
};
let output_kinds = get_output_kinds(&function.outputs);
let output_fn_body = quote!{functions::#name::default().decode_output(&_output_bytes)};

quote! {
/// Contract function with already defined input values
Expand Down
2 changes: 1 addition & 1 deletion ethabi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethabi"
version = "6.0.0"
version = "6.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://github.com/paritytech/ethabi"
license = "MIT"
Expand Down
11 changes: 10 additions & 1 deletion tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ mod tests {
fn test_decoding_function_output() {
// Make sure that the output param type of the derived contract is correct

use eip20::Eip20;
// given

use eip20::Eip20;
let contract = Eip20::default();
let output = "000000000000000000000000000000000000000000000000000000000036455B".from_hex().unwrap();

// when

let decoded_output = contract.outputs().total_supply(&output).unwrap();
let decoded_output2 = contract.functions().total_supply().output(output).unwrap();

// then

let expected_output: Uint = 0x36455b.into();
assert_eq!(expected_output, decoded_output);
assert_eq!(expected_output, decoded_output2);
}

#[test]
Expand Down

0 comments on commit 59faf54

Please sign in to comment.