diff --git a/examples/fetch_all_accounts.rs b/examples/fetch_all_accounts.rs new file mode 100644 index 0000000000..cb0147bd72 --- /dev/null +++ b/examples/fetch_all_accounts.rs @@ -0,0 +1,35 @@ +// Copyright 2019-2020 Parity Technologies (UK) Ltd. +// This file is part of substrate-subxt. +// +// subxt is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// subxt is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with substrate-subxt. If not, see . + +use sp_keyring::AccountKeyring; +use substrate_subxt::{ + system, + system::*, + ClientBuilder, + DefaultNodeRuntime, + PairSigner, +}; + +#[async_std::main] +async fn main() -> Result<(), Box> { + env_logger::init(); + + let _client = ClientBuilder::::new().build().await?; + // for (key, account) in client.accounts_iter() { + // println!("{}: {}", key, account) + // } + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs index b3c823b235..db38f43a7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -228,9 +228,9 @@ impl Client { } } - /// Fetch up to `count` keys for a storage map in lexicographic order. - /// - /// Supports pagination by passing a value to `start_key`. + /// Fetch up to `count` keys for a storage map in lexicographic order. + /// + /// Supports pagination by passing a value to `start_key`. pub async fn fetch_keys>( &self, count: u32, @@ -238,7 +238,10 @@ impl Client { hash: Option, ) -> Result, Error> { let prefix = >::prefix(&self.metadata)?; - let keys = self.rpc.storage_keys_paged(Some(prefix), count, start_key, hash).await?; + let keys = self + .rpc + .storage_keys_paged(Some(prefix), count, start_key, hash) + .await?; Ok(keys) } @@ -630,7 +633,10 @@ mod tests { #[async_std::test] async fn test_fetch_keys() { let (client, _) = test_client().await; - let keys = client.fetch_keys::>(4, None, None).await.unwrap(); + let keys = client + .fetch_keys::>(4, None, None) + .await + .unwrap(); assert_eq!(keys.len(), 4) } } diff --git a/src/rpc.rs b/src/rpc.rs index ecb2a055bf..f2defc6b89 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -132,8 +132,8 @@ impl Rpc { } /// Returns the keys with prefix with pagination support. - /// Up to `count` keys will be returned. - /// If `start_key` is passed, return next keys in storage in lexicographic order. + /// Up to `count` keys will be returned. + /// If `start_key` is passed, return next keys in storage in lexicographic order. pub async fn storage_keys_paged( &self, prefix: Option,