Skip to content

Commit 3bb20f0

Browse files
committed
chore: clippy / fmt
1 parent 6b7d78e commit 3bb20f0

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

examples/trevm_inspector_example.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ impl Tx for CallContract {
4747
// Helper function to extract created contract address from ExecutionResult
4848
const fn get_created_address(result: &ExecutionResult) -> Option<Address> {
4949
match result {
50-
ExecutionResult::Success { output, .. } => match output {
51-
Output::Create(_bytes, address) => *address,
52-
_ => None,
53-
},
50+
ExecutionResult::Success { output: Output::Create(_bytes, address), .. } => *address,
5451
_ => None,
5552
}
5653
}

examples/tx_tracer_cli.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6464
// Example 1: Contract deployment
6565
let deploy_bytecode = hex::decode("608060405234801561001057600080fd5b50600a600081905550")?;
6666

67-
let mut deploy_tx_env = TxEnv::default();
68-
deploy_tx_env.caller = caller;
69-
deploy_tx_env.kind = TxKind::Create;
70-
deploy_tx_env.data = deploy_bytecode.into();
71-
deploy_tx_env.gas_limit = 500_000;
72-
deploy_tx_env.gas_price = 1_000_000_000; // 1 gwei (must be >= basefee)
73-
deploy_tx_env.nonce = 0;
67+
let deploy_tx_env = TxEnv {
68+
caller,
69+
kind: TxKind::Create,
70+
data: deploy_bytecode.into(),
71+
gas_limit: 500_000,
72+
gas_price: 1_000_000_000, // 1 gwei (must be >= basefee)
73+
nonce: 0,
74+
..Default::default()
75+
};
7476

7577
let deploy_tx = TracedTransaction { tx_env: deploy_tx_env };
7678

7779
// Prepare block environment
78-
let mut block_env = BlockEnv::default();
79-
block_env.number = U256::from(1u64);
80-
block_env.timestamp = U256::from(1234567890u64);
81-
block_env.gas_limit = 30_000_000;
82-
block_env.basefee = 1_000_000_000; // 1 gwei
83-
block_env.beneficiary = Address::with_last_byte(255);
80+
let block_env = BlockEnv {
81+
number: U256::from(1u64),
82+
timestamp: U256::from(1234567890u64),
83+
gas_limit: 30_000_000,
84+
basefee: 1_000_000_000, // 1 gwei
85+
beneficiary: Address::with_last_byte(255),
86+
..Default::default()
87+
};
8488

8589
let traced_block = TracedBlock { block_env };
8690

@@ -136,13 +140,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
136140
println!("\n🔄 Tracing simple transfer...");
137141
println!("{}", "=".repeat(80));
138142

139-
let mut transfer_tx_env = TxEnv::default();
140-
transfer_tx_env.caller = caller;
141-
transfer_tx_env.kind = TxKind::Call(contract_addr);
142-
transfer_tx_env.value = U256::from(100_000_000_000_000_000u64); // 0.1 ETH
143-
transfer_tx_env.gas_limit = 21_000;
144-
transfer_tx_env.gas_price = 1_000_000_000; // 1 gwei (must be >= basefee)
145-
transfer_tx_env.nonce = 1;
143+
let transfer_tx_env = TxEnv {
144+
caller,
145+
kind: TxKind::Call(contract_addr),
146+
value: U256::from(100_000_000_000_000_000u64), // 0.1 ETH
147+
data: vec![].into(), // No data for simple transfer
148+
gas_limit: 21_000,
149+
gas_price: 1_000_000_000, // 1 gwei (must be >= basefee)
150+
nonce: 1, // Increment nonce for the transfer
151+
..Default::default()
152+
};
146153

147154
let transfer_tx = TracedTransaction { tx_env: transfer_tx_env };
148155

@@ -194,7 +201,7 @@ mod hex {
194201
}
195202

196203
pub(crate) fn decode(s: &str) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
197-
let s = if s.starts_with("0x") { &s[2..] } else { s };
204+
let s = s.strip_prefix("0x").map_or(s, |s| &s[2..]);
198205
if s.len() % 2 != 0 {
199206
return Err("Invalid hex string length".into());
200207
}

0 commit comments

Comments
 (0)