diff --git a/cli/src/main.rs b/cli/src/main.rs index 9baf3149..1a174282 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -12,6 +12,7 @@ use crossterm::{ use heimdall_cache::{cache, CacheArgs}; use heimdall_common::{ constants::ADDRESS_REGEX, + ether::rpc, utils::{ io::{ file::{write_file, write_lines_to_file}, @@ -115,7 +116,11 @@ async fn main() -> Result<(), Box> { // write to file if ADDRESS_REGEX.is_match(&cmd.target).unwrap() { - output_path.push_str(&format!("/{}/disassembled.asm", &cmd.target)); + output_path.push_str(&format!( + "/{}/{}/disassembled.asm", + rpc::chain_id(&cmd.rpc_url).await.unwrap(), + &cmd.target + )); } else { output_path.push_str("/local/disassembled.asm"); } @@ -135,9 +140,14 @@ async fn main() -> Result<(), Box> { let solidity_output_path; let yul_output_path; if ADDRESS_REGEX.is_match(&cmd.target).unwrap() { - abi_output_path = format!("{}/{}/abi.json", &output_path, &cmd.target); - solidity_output_path = format!("{}/{}/decompiled.sol", &output_path, &cmd.target); - yul_output_path = format!("{}/{}/decompiled.yul", &output_path, &cmd.target); + let chain_id = rpc::chain_id(&cmd.rpc_url).await.unwrap(); + + abi_output_path = + format!("{}/{}/{}/abi.json", &output_path, &chain_id, &cmd.target); + solidity_output_path = + format!("{}/{}/{}/decompiled.sol", &output_path, &chain_id, &cmd.target); + yul_output_path = + format!("{}/{}/{}/decompiled.yul", &output_path, &chain_id, &cmd.target); } else { abi_output_path = format!("{}/local/abi.json", &output_path); solidity_output_path = format!("{}/local/decompiled.sol", &output_path); @@ -205,7 +215,11 @@ async fn main() -> Result<(), Box> { // write to file if ADDRESS_REGEX.is_match(&cmd.target).unwrap() { - output_path.push_str(&format!("/{}", &cmd.target)); + output_path.push_str(&format!( + "/{}/{}", + rpc::chain_id(&cmd.rpc_url).await.unwrap(), + &cmd.target + )); } else { output_path.push_str("/local"); } @@ -229,7 +243,11 @@ async fn main() -> Result<(), Box> { // write to file if ADDRESS_REGEX.is_match(&cmd.target).unwrap() { - output_path.push_str(&format!("/{}/dump.csv", &cmd.target)); + output_path.push_str(&format!( + "/{}/{}/dump.csv", + rpc::chain_id(&cmd.rpc_url).await.unwrap(), + &cmd.target + )); } else { output_path.push_str("/local/dump.csv"); } @@ -257,7 +275,11 @@ async fn main() -> Result<(), Box> { // write to file if ADDRESS_REGEX.is_match(&cmd.target).unwrap() { - output_path.push_str(&format!("/{}/snapshot.csv", &cmd.target)); + output_path.push_str(&format!( + "/{}/{}/snapshot.csv", + rpc::chain_id(&cmd.rpc_url).await.unwrap(), + &cmd.target, + )); } else { output_path.push_str("/local/snapshot.csv"); }