Skip to content

Commit

Permalink
feat: separate outputs by chain (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
iankressin authored Nov 20, 2023
1 parent a4a5ca2 commit 21a0b5f
Showing 1 changed file with 29 additions and 7 deletions.
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");
}
Expand Down

0 comments on commit 21a0b5f

Please sign in to comment.