mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: eth_getProof response (#12370)
This commit is contained in:
@ -122,7 +122,7 @@ pub trait EthState: LoadState + SpawnBlocking {
|
||||
let proof = state
|
||||
.proof(Default::default(), address, &storage_keys)
|
||||
.map_err(Self::Error::from_eth_err)?;
|
||||
Ok(from_primitive_account_proof(proof))
|
||||
Ok(from_primitive_account_proof(proof, keys))
|
||||
})
|
||||
.await
|
||||
})
|
||||
|
||||
@ -5,16 +5,18 @@ use alloy_rpc_types_eth::{EIP1186AccountProofResponse, EIP1186StorageProof};
|
||||
use reth_trie_common::{AccountProof, StorageProof};
|
||||
|
||||
/// Creates a new rpc storage proof from a primitive storage proof type.
|
||||
pub fn from_primitive_storage_proof(proof: StorageProof) -> EIP1186StorageProof {
|
||||
EIP1186StorageProof {
|
||||
key: JsonStorageKey::Hash(proof.key),
|
||||
value: proof.value,
|
||||
proof: proof.proof,
|
||||
}
|
||||
pub fn from_primitive_storage_proof(
|
||||
proof: StorageProof,
|
||||
slot: JsonStorageKey,
|
||||
) -> EIP1186StorageProof {
|
||||
EIP1186StorageProof { key: slot, value: proof.value, proof: proof.proof }
|
||||
}
|
||||
|
||||
/// Creates a new rpc account proof from a primitive account proof type.
|
||||
pub fn from_primitive_account_proof(proof: AccountProof) -> EIP1186AccountProofResponse {
|
||||
pub fn from_primitive_account_proof(
|
||||
proof: AccountProof,
|
||||
slots: Vec<JsonStorageKey>,
|
||||
) -> EIP1186AccountProofResponse {
|
||||
let info = proof.info.unwrap_or_default();
|
||||
EIP1186AccountProofResponse {
|
||||
address: proof.address,
|
||||
@ -23,6 +25,13 @@ pub fn from_primitive_account_proof(proof: AccountProof) -> EIP1186AccountProofR
|
||||
nonce: info.nonce,
|
||||
storage_hash: proof.storage_root,
|
||||
account_proof: proof.proof,
|
||||
storage_proof: proof.storage_proofs.into_iter().map(from_primitive_storage_proof).collect(),
|
||||
storage_proof: proof
|
||||
.storage_proofs
|
||||
.into_iter()
|
||||
.filter_map(|proof| {
|
||||
let input_slot = slots.iter().find(|s| s.as_b256() == proof.key)?;
|
||||
Some(from_primitive_storage_proof(proof, *input_slot))
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user