Skip to content

Commit

Permalink
propagate error
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkr8os committed Dec 29, 2023
1 parent 074740f commit 1e26b73
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions crates/revm/src/db/ethersdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<M: Middleware> EthersDB<M> {
}

impl<M: Middleware> DatabaseRef for EthersDB<M> {
type Error = ();
type Error = M::Error;

fn basic_ref(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
let add = eH160::from(address.0 .0);
Expand All @@ -62,17 +62,13 @@ impl<M: Middleware> DatabaseRef for EthersDB<M> {
};
let (nonce, balance, code) = self.block_on(f);

if nonce.is_err() || balance.is_err() {
// If we can't get nonce or balance, we can't get the account
return Ok(None);
}

let bytecode = code.unwrap_or(Bytes::from_str("").unwrap());
let bytecode = Bytecode::new_raw(bytecode.0.into());
let balance = U256::from_limbs(balance?.0);
let nonce = nonce?.as_u64();
let bytecode = Bytecode::new_raw(code?.0.into());
let code_hash = bytecode.hash_slow();
Ok(Some(AccountInfo::new(
U256::from_limbs(balance.unwrap().0),
nonce.unwrap().as_u64(),
balance,
nonce,
code_hash,
bytecode,
)))
Expand Down Expand Up @@ -115,7 +111,7 @@ impl<M: Middleware> DatabaseRef for EthersDB<M> {
}

impl<M: Middleware> Database for EthersDB<M> {
type Error = ();
type Error = M::Error;

#[inline]
fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
Expand Down

0 comments on commit 1e26b73

Please sign in to comment.