Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate outputs by chain #185

Merged
36 changes: 29 additions & 7 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -115,7 +116,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// 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");
}
Expand All @@ -135,9 +140,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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);
Expand Down Expand Up @@ -205,7 +215,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// 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");
}
Expand All @@ -229,7 +243,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// 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");
}
Expand Down Expand Up @@ -257,7 +275,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// 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");
Jon-Becker marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading