diff --git a/src/rpc.rs b/src/rpc.rs index 3e9fbedeb9..1cbd404713 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -86,10 +86,16 @@ impl Rpc { ) -> impl Future, Error = Error> { self.state .storage(key, None) - .map(|data| { - data.map(|d| Decode::decode(&mut &d.0[..]).expect("Valid storage key")) - }) .map_err(Into::into) + .and_then(|data| { + match data { + Some(data) => { + let value = Decode::decode(&mut &data.0[..])?; + Ok(Some(value)) + } + None => Ok(None), + } + }) } /// Fetch the genesis hash