Skip to content

Commit

Permalink
primitives: add utility function AccountInfo::from_bytecode (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyke-bot authored Jun 30, 2024
1 parent b6f80af commit 28d082d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/primitives/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ impl AccountInfo {
..Default::default()
}
}

pub fn from_bytecode(bytecode: Bytecode) -> Self {
let hash = bytecode.hash_slow();

AccountInfo {
balance: U256::ZERO,
nonce: 1,
code: Some(bytecode),
code_hash: hash,
}
}
}

#[cfg(test)]
Expand Down

0 comments on commit 28d082d

Please sign in to comment.