Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,31 @@ impl EthApi {
}

/// Returns the account information including balance, nonce, code and storage
///
/// Note: This isn't support by all providers
pub async fn get_account_info(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<alloy_rpc_types::eth::AccountInfo> {
node_info!("eth_getAccountInfo");

if let Some(fork) = self.get_fork() {
// check if the number predates the fork, if in fork mode
if let BlockRequest::Number(number) = self.block_request(block_number).await?
&& fork.predates_fork(number)
{
// if this predates the fork we need to fetch balance, nonce, code individually
// because the provider might not support this endpoint
let balance = self.balance(address, Some(number.into()));
let code = self.get_code(address, Some(number.into()));
let nonce = self.get_transaction_count(address, Some(number.into()));
let (balance, code, nonce) = try_join!(balance, code, nonce)?;

return Ok(alloy_rpc_types::eth::AccountInfo { balance, nonce, code });
}
}

let account = self.get_account(address, block_number);
let code = self.get_code(address, block_number);
let (account, code) = try_join!(account, code)?;
Expand Down
Loading