@@ -766,12 +766,31 @@ impl EthApi {
766
766
}
767
767
768
768
/// Returns the account information including balance, nonce, code and storage
769
+ ///
770
+ /// Note: This isn't support by all providers
769
771
pub async fn get_account_info (
770
772
& self ,
771
773
address : Address ,
772
774
block_number : Option < BlockId > ,
773
775
) -> Result < alloy_rpc_types:: eth:: AccountInfo > {
774
776
node_info ! ( "eth_getAccountInfo" ) ;
777
+
778
+ if let Some ( fork) = self . get_fork ( ) {
779
+ // check if the number predates the fork, if in fork mode
780
+ if let BlockRequest :: Number ( number) = self . block_request ( block_number) . await ?
781
+ && fork. predates_fork ( number)
782
+ {
783
+ // if this predates the fork we need to fetch balance, nonce, code individually
784
+ // because the provider might not support this endpoint
785
+ let balance = self . balance ( address, Some ( number. into ( ) ) ) ;
786
+ let code = self . get_code ( address, Some ( number. into ( ) ) ) ;
787
+ let nonce = self . get_transaction_count ( address, Some ( number. into ( ) ) ) ;
788
+ let ( balance, code, nonce) = try_join ! ( balance, code, nonce) ?;
789
+
790
+ return Ok ( alloy_rpc_types:: eth:: AccountInfo { balance, nonce, code } ) ;
791
+ }
792
+ }
793
+
775
794
let account = self . get_account ( address, block_number) ;
776
795
let code = self . get_code ( address, block_number) ;
777
796
let ( account, code) = try_join ! ( account, code) ?;
0 commit comments