Add get_storage_at

This commit is contained in:
Brock Elmore 2020-07-30 22:56:28 -04:00
parent 6f02bb5436
commit 34550d9211
1 changed files with 21 additions and 1 deletions

View File

@ -398,7 +398,27 @@ impl<P: JsonRpcClient> Provider<P> {
.map_err(Into::into)?) .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<NameOrAddress>,
location: H256,
block: Option<BlockNumber>,
) -> Result<H256, ProviderError> {
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 /// Returns the deployed code at a given address
pub async fn get_code( pub async fn get_code(