diff --git a/ethers-core/src/types/mod.rs b/ethers-core/src/types/mod.rs index 2cf9d5fc..beedbe77 100644 --- a/ethers-core/src/types/mod.rs +++ b/ethers-core/src/types/mod.rs @@ -47,3 +47,6 @@ pub use txpool::*; mod trace; pub use trace::*; + +mod proof; +pub use proof::*; diff --git a/ethers-core/src/types/proof.rs b/ethers-core/src/types/proof.rs new file mode 100644 index 00000000..afb7ebe9 --- /dev/null +++ b/ethers-core/src/types/proof.rs @@ -0,0 +1,19 @@ +use crate::types::{Bytes, H256, U256}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] +pub struct StorageProof { + pub key: H256, + pub proof: Vec, + pub value: U256, +} + +#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] +pub struct EIP1186ProofResponse { + balance: U256, + code_hash: H256, + nonce: U256, + storage_hash: H256, + account_proof: Vec, + storage_proof: Vec, +} diff --git a/ethers-providers/src/lib.rs b/ethers-providers/src/lib.rs index a5a34013..5d2b9dd6 100644 --- a/ethers-providers/src/lib.rs +++ b/ethers-providers/src/lib.rs @@ -548,6 +548,18 @@ pub trait Middleware: Sync + Send + Debug { .map_err(FromErr::from) } + async fn get_proof + Send + Sync>( + &self, + from: T, + locations: Vec, + block: Option, + ) -> Result { + self.inner() + .get_proof(from, locations, block) + .await + .map_err(FromErr::from) + } + // Mempool inspection for Geth's API async fn txpool_content(&self) -> Result { diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index ea88cc06..99d56050 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -10,13 +10,12 @@ use ethers_core::{ abi::{self, Detokenize, ParamType}, types::{ transaction::{eip2718::TypedTransaction, eip2930::AccessListWithGasUsed}, - Address, Block, BlockId, BlockNumber, BlockTrace, Bytes, Filter, Log, NameOrAddress, - Selector, Signature, Trace, TraceFilter, TraceType, Transaction, TransactionReceipt, - TxHash, TxpoolContent, TxpoolInspect, TxpoolStatus, H256, U256, U64, + Address, Block, BlockId, BlockNumber, BlockTrace, Bytes, EIP1186ProofResponse, Filter, Log, + NameOrAddress, Selector, Signature, Trace, TraceFilter, TraceType, Transaction, + TransactionReceipt, TxHash, TxpoolContent, TxpoolInspect, TxpoolStatus, H256, U256, U64, }, utils, }; - #[cfg(feature = "celo")] use crate::CeloMiddleware; use crate::Middleware; @@ -582,6 +581,29 @@ impl Middleware for Provider

{ self.request("eth_getCode", [at, block]).await } + /// Returns the EIP-1186 proof response + /// https://github.com/ethereum/EIPs/issues/1186 + async fn get_proof + Send + Sync>( + &self, + from: T, + locations: Vec, + block: Option, + ) -> Result { + let from = match from.into() { + NameOrAddress::Name(ens_name) => self.resolve_name(&ens_name).await?, + NameOrAddress::Address(addr) => addr, + }; + + let from = utils::serialize(&from); + let locations = locations + .iter() + .map(|location| utils::serialize(&location)) + .collect(); + let block = utils::serialize(&block.unwrap_or_else(|| BlockNumber::Latest.into())); + + self.request("eth_getProof", [from, locations, block]).await + } + ////// Ethereum Naming Service // The Ethereum Naming Service (ENS) allows easy to remember and use names to // be assigned to Ethereum addresses. Any provider operation which takes an address diff --git a/ethers-providers/src/transports/quorum.rs b/ethers-providers/src/transports/quorum.rs index 6068ded4..d57984ee 100644 --- a/ethers-providers/src/transports/quorum.rs +++ b/ethers-providers/src/transports/quorum.rs @@ -171,6 +171,7 @@ impl QuorumProvider { | "eth_createAccessList" | "eth_getStorageAt" | "eth_getCode" + | "eth_getProof" | "trace_call" | "trace_block" => { // calls that include the block number in the params at the last index of json array