mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
Fix optional store items. (#120)
* Fix optional store items. * Support querying a block hash.
This commit is contained in:
+5
-12
@@ -132,22 +132,15 @@ impl<T: System> Rpc<T> {
|
||||
}
|
||||
|
||||
/// Fetch a storage key
|
||||
pub async fn storage<V: Decode>(
|
||||
pub async fn storage(
|
||||
&self,
|
||||
key: StorageKey,
|
||||
hash: Option<T::Hash>,
|
||||
) -> Result<Option<V>, Error> {
|
||||
) -> Result<Option<StorageData>, Error> {
|
||||
let params = Params::Array(vec![to_json_value(key)?, to_json_value(hash)?]);
|
||||
let data: Option<StorageData> =
|
||||
self.client.request("state_getStorage", params).await?;
|
||||
match data {
|
||||
Some(data) => {
|
||||
log::debug!("state_getStorage {:?}", data.0);
|
||||
let value = Decode::decode(&mut &data.0[..])?;
|
||||
Ok(Some(value))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
let data = self.client.request("state_getStorage", params).await?;
|
||||
log::debug!("state_getStorage {:?}", data);
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
/// Query historical storage entries
|
||||
|
||||
Reference in New Issue
Block a user