Expose properties and per-era preferences

This commit is contained in:
Demi M. Obenour
2020-08-11 21:24:46 -04:00
parent 7bad6c6909
commit da3667572b
4 changed files with 52 additions and 5 deletions
+20
View File
@@ -96,6 +96,18 @@ impl From<u32> for BlockNumber {
}
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
/// System properties for a Substrate-based runtime
pub struct Properties {
/// The address format
pub ss58_format: u8,
/// The number of digits after the decimal point in the native token
pub token_decimals: u8,
/// The symbol of the native token
pub token_symbol: String,
}
/// Client for substrate rpc interfaces
pub struct Rpc<T: Runtime> {
client: Client,
@@ -208,6 +220,14 @@ impl<T: Runtime> Rpc<T> {
Ok(metadata)
}
/// Fetch system properties
pub async fn properties(&self) -> Result<Properties, Error> {
Ok(self
.client
.request("system_properties", Params::None)
.await?)
}
/// Get a header
pub async fn header(
&self,