diff --git a/src/lib.rs b/src/lib.rs index b98755625f..e1a75a4011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,6 +258,19 @@ impl Client { &self.metadata } + /// Fetch the value under an unhashed storage key + pub async fn fetch_unhashed( + &self, + key: StorageKey, + hash: Option, + ) -> Result, Error> { + if let Some(data) = self.rpc.storage(&key, hash).await? { + Ok(Some(Decode::decode(&mut &data.0[..])?)) + } else { + Ok(None) + } + } + /// Fetch a StorageKey with an optional block hash. pub async fn fetch>( &self, @@ -265,11 +278,7 @@ impl Client { hash: Option, ) -> Result, Error> { let key = store.key(&self.metadata)?; - if let Some(data) = self.rpc.storage(&key, hash).await? { - Ok(Some(Decode::decode(&mut &data.0[..])?)) - } else { - Ok(None) - } + self.fetch_unhashed::(key, hash).await } /// Fetch a StorageKey that has a default value with an optional block hash.