Skip to content

Commit

Permalink
updates based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishn1412 committed Nov 28, 2024
1 parent 404cf1a commit 97fa23f
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions crates/core/src/interpreter/backend/resolve_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,45 +71,38 @@ async fn get_account(
for field in &fields {
match field {
AccountField::Balance => {
match provider.get_balance(*address).await {
Ok(balance) => account.balance = Some(balance),
Err(e) => {
error!("Failed to fetch balance for address {}: {:?}", address, e);
account.balance = None;
}
if let Ok(balance) = provider.get_balance(*address).await {
account.balance = Some(balance);
} else {
account.balance = None;
}
}
AccountField::Nonce => {
match provider.get_transaction_count(*address).await {
Ok(nonce) => account.nonce = Some(nonce),
Err(e) => {
error!("Failed to fetch nonce for address {}: {:?}", address, e);
account.nonce = None;
}
if let Ok(nonce) = provider.get_transaction_count(*address).await {
account.nonce = Some(nonce);
} else {
account.nonce = None;
}
}
AccountField::Address => {
account.address = Some(*address); // Always succeeds
account.address = Some(*address);
}
AccountField::Code => {
match provider.get_code_at(*address).await {
Ok(code) => account.code = Some(code),
Err(e) => {
error!("Failed to fetch code for address {}: {:?}", address, e);
account.code = None;
}
if let Ok(code) = provider.get_code_at(*address).await {
account.code = Some(code);
} else {
account.code = None;
}
}
AccountField::Chain => {
account.chain = Some(chain.clone()); // Always succeeds
account.chain = Some(chain.clone());
}
}
}

Ok(account)
}


async fn to_address(name: &String) -> Result<Address> {
let rpc_url = Chain::Ethereum.rpc_url()?;
let provider = ProviderBuilder::new().on_http(rpc_url);
Expand Down

0 comments on commit 97fa23f

Please sign in to comment.