Skip to content

Commit

Permalink
renamings in state
Browse files Browse the repository at this point in the history
  • Loading branch information
masapr committed Feb 8, 2023
1 parent 6a05e98 commit 361b616
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/examples/get_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn main() {
let mut api = Api::<_, _, PlainTipExtrinsicParams<Runtime>, Runtime>::new(client).unwrap();

// get some plain storage value
let result: u128 = api.get_storage_value("Balances", "TotalIssuance", None).unwrap().unwrap();
let result: u128 = api.get_storage("Balances", "TotalIssuance", None).unwrap().unwrap();
println!("[+] TotalIssuance is {}", result);

let proof = api.get_storage_value_proof("Balances", "TotalIssuance", None).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions examples/examples/staking_batch_payout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ async fn main() {
let validator_stash =
AccountId32::from_ss58check("5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY").unwrap();

let active_era: ActiveEraInfo =
api.get_storage_value("Staking", "ActiveEra", None).unwrap().unwrap();
let active_era: ActiveEraInfo = api.get_storage("Staking", "ActiveEra", None).unwrap().unwrap();
println!("{:?}", active_era);
let current_era_index = active_era.index;

Expand Down
8 changes: 4 additions & 4 deletions src/api/rpc_api/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use serde::de::DeserializeOwned;

/// Generic interface to substrate storage.
pub trait GetStorage<Hash> {
fn get_storage_value<V: Decode>(
fn get_storage<V: Decode>(
&self,
pallet: &'static str,
key: &'static str,
Expand Down Expand Up @@ -121,7 +121,7 @@ where
Runtime: FrameSystemConfig,
Params: ExtrinsicParams<Runtime::Index, Runtime::Hash>,
{
fn get_storage_value<V: Decode>(
fn get_storage<V: Decode>(
&self,
pallet: &'static str,
key: &'static str,
Expand Down Expand Up @@ -184,14 +184,14 @@ where

fn get_storage_keys_paged(
&self,
storage_key: Option<StorageKey>,
prefix: Option<StorageKey>,
count: u32,
start_key: Option<StorageKey>,
at_block: Option<Runtime::Hash>,
) -> Result<Vec<StorageKey>> {
let storage = self
.client()
.request("state_getKeysPaged", rpc_params![storage_key, count, start_key, at_block])?;
.request("state_getKeysPaged", rpc_params![prefix, count, start_key, at_block])?;
Ok(storage)
}

Expand Down
8 changes: 3 additions & 5 deletions testing/examples/state_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ async fn main() {

// Tests
let _total_issuance: Balance =
api.get_storage_value("Balances", "TotalIssuance", None).unwrap().unwrap();
let _total_issuance: Balance = api
.get_storage_value("Balances", "TotalIssuance", Some(block_hash))
.unwrap()
.unwrap();
api.get_storage("Balances", "TotalIssuance", None).unwrap().unwrap();
let _total_issuance: Balance =
api.get_storage("Balances", "TotalIssuance", Some(block_hash)).unwrap().unwrap();
let _account_info: AccountData =
api.get_storage_map("System", "Account", &alice, None).unwrap().unwrap();
let _era_stakers: ErasStakers = api
Expand Down

0 comments on commit 361b616

Please sign in to comment.