Skip to content

Commit

Permalink
fix: change "bytes memory" to "bytes" in json abi output (#418)
Browse files Browse the repository at this point in the history
* fix json abi formatting

* overwrite bytes memory only in abi output

* corrected print

---------

Co-authored-by: Jonathan Becker <[email protected]>
  • Loading branch information
fala13 and Jon-Becker authored May 30, 2024
1 parent b3a6a2f commit e68c8f4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0.50"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
eyre = "0.6.12"
alloy-json-abi = "0.7.0"
alloy-json-abi = "0.7.4"

[[bin]]
name = "heimdall"
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/ether/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl ResolveSelector for ResolvedFunction {
None => selector,
};

trace!("resolving event selector {}", &selector);
trace!("resolving function selector {}", &selector);

// get cached results
if let Some(cached_results) =
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ derive_builder = "0.12.0"
async-convert = "1.0.0"
futures = "0.3.28"
tracing = "0.1.40"
alloy-json-abi = { version = "0.7.4", features = ["serde_json"]}

# modules
heimdall-cfg = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/core/tests/test_decompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ mod benchmark {

#[cfg(test)]
mod integration_tests {
use alloy_json_abi::JsonAbi;
use heimdall_common::utils::io::file::delete_path;
use heimdall_decompiler::{decompile, DecompilerArgs};

Expand Down Expand Up @@ -391,6 +392,10 @@ mod integration_tests {
if output.contains("error CustomError_") {
is_error_covered = true;
}

let abi_serialized = serde_json::to_string(&result.abi).unwrap();
let abi_deserialized = JsonAbi::from_json_str(&abi_serialized);
assert!(abi_deserialized.is_ok());
}

// assert that all flags are true
Expand Down
2 changes: 1 addition & 1 deletion crates/decompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ heimdall-cache = { workspace = true }
thiserror = "1.0.50"
clap = { workspace = true, features = ["derive"] }
derive_builder = "0.12.0"
alloy-json-abi = "0.7.0"
alloy-json-abi = "0.7.4"
tracing = "0.1.40"
eyre = "0.6.12"
ethers = "2.0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/decompile/src/core/out/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn build_abi(
vec![Param {
name: "".to_string(),
internal_type: None,
ty: r.clone(),
ty: if r == "bytes memory" { "bytes".to_string() } else { r.clone() },
components: vec![],
}]
})
Expand Down

0 comments on commit e68c8f4

Please sign in to comment.