From 34550d9211d120590697909b421261bc7254ff63 Mon Sep 17 00:00:00 2001 From: Brock Elmore Date: Thu, 30 Jul 2020 22:56:28 -0400 Subject: [PATCH] Add get_storage_at --- ethers-providers/src/provider.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index b21817ae..7f61388c 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -398,7 +398,27 @@ impl Provider

{ .map_err(Into::into)?) } - // TODO: get_storage_at + /// Get the storage of an address for a particular slot location + pub async fn get_storage_at( + &self, + from: impl Into, + location: H256, + 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 location = utils::serialize(&location); + let block = utils::serialize(&block.unwrap_or(BlockNumber::Latest)); + Ok(self + .0 + .request("eth_getStorageAt", [from, location, block]) + .await + .map_err(Into::into)?) + } /// Returns the deployed code at a given address pub async fn get_code(