Skip to content

Commit

Permalink
Merge pull request #81 from Jon-Becker/fix/decompile-patches
Browse files Browse the repository at this point in the history
🔀 0.4.1 patches
  • Loading branch information
Jon-Becker authored Mar 19, 2023
2 parents f3fab2b + 3d6c73f commit 754aa10
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 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 cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heimdall-cache"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heimdall-common"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
6 changes: 4 additions & 2 deletions common/src/resources/transpose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fn _call_transpose(query: String, api_key: &String, logger: &Logger) -> Option<T
}

pub fn get_transaction_list(
chain: &String,
address: &String,
api_key: &String,
bounds: (&u128, &u128),
Expand All @@ -87,7 +88,7 @@ pub fn get_transaction_list(

// build the SQL query
let query = format!(
"{{\"sql\":\"SELECT block_number, transaction_hash FROM (SELECT transaction_hash, block_number FROM ethereum.transactions WHERE to_address = '{}' AND block_number BETWEEN {} AND {} UNION SELECT transaction_hash, block_number FROM ethereum.traces WHERE to_address = '{}' AND block_number BETWEEN {} AND {}) x\",\"parameters\":{{}},\"options\":{{\"timeout\": 999999999}}}}",
"{{\"sql\":\"SELECT block_number, transaction_hash FROM (SELECT transaction_hash, block_number FROM {chain}.transactions WHERE to_address = '{}' AND block_number BETWEEN {} AND {} UNION SELECT transaction_hash, block_number FROM {chain}.traces WHERE to_address = '{}' AND block_number BETWEEN {} AND {}) x\",\"parameters\":{{}},\"options\":{{\"timeout\": 999999999}}}}",
address,
bounds.0,
bounds.1,
Expand Down Expand Up @@ -152,6 +153,7 @@ pub fn get_transaction_list(
}

pub fn get_contract_creation(
chain: &String,
address: &String,
api_key: &String,
logger: &Logger
Expand All @@ -166,7 +168,7 @@ pub fn get_contract_creation(

// build the SQL query
let query = format!(
"{{\"sql\":\"SELECT block_number, transaction_hash FROM ethereum.transactions WHERE TIMESTAMP = ( SELECT created_timestamp FROM ethereum.accounts WHERE address = '{}' ) AND contract_address = '{}'\",\"parameters\":{{}},\"options\":{{\"timeout\": 999999999}}}}",
"{{\"sql\":\"SELECT block_number, transaction_hash FROM {chain}.transactions WHERE TIMESTAMP = ( SELECT created_timestamp FROM {chain}.accounts WHERE address = '{}' ) AND contract_address = '{}'\",\"parameters\":{{}},\"options\":{{\"timeout\": 999999999}}}}",
address,
address,
);
Expand Down
2 changes: 1 addition & 1 deletion config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heimdall-config"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion heimdall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keywords = ["ethereum", "web3", "decompiler", "evm", "crypto"]
license = "MIT"
name = "heimdall"
readme = "README.md"
version = "0.4.0"
version = "0.4.1"

[dependencies]
backtrace = "0.3"
Expand Down
1 change: 0 additions & 1 deletion heimdall/src/decompile/postprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ fn replace_resolved(
}

for (selector, event) in all_resolved_events.iter() {
let selector = selector.get(0..8).unwrap_or("00000000");
if cleaned.contains(selector) {
cleaned = cleaned.replace(&format!("Event_{selector}"), &event.name);
}
Expand Down
8 changes: 6 additions & 2 deletions heimdall/src/dump/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pub struct DumpArgs {
/// Whether to skip opening the TUI.
#[clap(long)]
pub no_tui: bool,

/// The chain of the target. Valid chains are ethereum, polygon, goerli, canto, and arbitrum.
#[clap(long, default_value = "ethereum", hide_default_value = true)]
pub chain: String,
}

pub fn dump(args: DumpArgs) {
Expand Down Expand Up @@ -101,7 +105,7 @@ pub fn dump(args: DumpArgs) {
// println!("{:?}", selectors);

// get the contract creation tx
let contract_creation_tx = match get_contract_creation(&args.target, &args.transpose_api_key, &logger) {
let contract_creation_tx = match get_contract_creation(&args.chain, &args.target, &args.transpose_api_key, &logger) {
Some(tx) => tx,
None => {
logger.error("failed to get contract creation transaction. Is the target a contract address?");
Expand Down Expand Up @@ -132,7 +136,7 @@ pub fn dump(args: DumpArgs) {
}

// fetch transactions
let transaction_list = get_transaction_list(&args.target, &args.transpose_api_key, (&args.from_block, &args.to_block), &logger);
let transaction_list = get_transaction_list(&args.chain, &args.target, &args.transpose_api_key, (&args.from_block, &args.to_block), &logger);

// convert to vec of Transaction
for transaction in transaction_list {
Expand Down
1 change: 1 addition & 0 deletions heimdall/src/dump/structures/dump_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl DumpState {
from_block: 0,
to_block: 9999999999,
no_tui: false,
chain: String::from("ethereum"),
},
scroll_index: 0,
selection_size: 1,
Expand Down

0 comments on commit 754aa10

Please sign in to comment.