mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
added at_latest (#900)
* added at_latest * change some documentation * remove inline
This commit is contained in:
@@ -29,8 +29,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// For storage requests, we can join futures together to
|
||||
// await multiple futures concurrently:
|
||||
let a_fut = api.storage().at(None).await?.fetch(&staking_bonded);
|
||||
let b_fut = api.storage().at(None).await?.fetch(&staking_ledger);
|
||||
let a_fut = api.storage().at_latest().await?.fetch(&staking_bonded);
|
||||
let b_fut = api.storage().at_latest().await?.fetch(&staking_ledger);
|
||||
let (a, b) = join!(a_fut, b_fut);
|
||||
|
||||
println!("{a:?}, {b:?}");
|
||||
|
||||
@@ -61,7 +61,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
);
|
||||
let account = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch_or_default(&storage_address)
|
||||
.await?
|
||||
@@ -73,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let storage_address = subxt::dynamic::storage_root("System", "Account");
|
||||
let mut iter = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.iter(storage_address, 10)
|
||||
.await?;
|
||||
|
||||
@@ -23,7 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let address = polkadot::storage().system().account_root();
|
||||
|
||||
let mut iter = api.storage().at(None).await?.iter(address, 10).await?;
|
||||
let mut iter = api.storage().at_latest().await?.iter(address, 10).await?;
|
||||
|
||||
while let Some((key, account)) = iter.next().await? {
|
||||
println!("{}: {}", hex::encode(key), account.data.free);
|
||||
|
||||
@@ -27,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let active_era_addr = polkadot::storage().staking().active_era();
|
||||
let era = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch(&active_era_addr)
|
||||
.await?
|
||||
@@ -51,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let controller_acc_addr = polkadot::storage().staking().bonded(&alice_stash_id);
|
||||
let controller_acc = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch(&controller_acc_addr)
|
||||
.await?
|
||||
@@ -61,7 +61,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
|
||||
let era_result = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch(&era_reward_addr)
|
||||
.await?;
|
||||
|
||||
@@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
{
|
||||
let key_addr = polkadot::storage().xcm_pallet().version_notifiers_root();
|
||||
|
||||
let mut iter = api.storage().at(None).await?.iter(key_addr, 10).await?;
|
||||
let mut iter = api.storage().at_latest().await?.iter(key_addr, 10).await?;
|
||||
|
||||
println!("\nExample 1. Obtained keys:");
|
||||
while let Some((key, value)) = iter.next().await? {
|
||||
@@ -45,7 +45,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Fetch at most 10 keys from below the prefix XcmPallet' VersionNotifiers.
|
||||
let keys = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch_keys(&key_addr.to_root_bytes(), 10, None)
|
||||
.await?;
|
||||
@@ -54,7 +54,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
for key in keys.iter() {
|
||||
println!("Key: 0x{}", hex::encode(key));
|
||||
|
||||
if let Some(storage_data) = api.storage().at(None).await?.fetch_raw(&key.0).await? {
|
||||
if let Some(storage_data) = api.storage().at_latest().await?.fetch_raw(&key.0).await? {
|
||||
// We know the return value to be `QueryId` (`u64`) from inspecting either:
|
||||
// - polkadot code
|
||||
// - polkadot.rs generated file under `version_notifiers()` fn
|
||||
@@ -85,7 +85,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let keys = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch_keys(&query_key, 10, None)
|
||||
.await?;
|
||||
@@ -94,7 +94,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
for key in keys.iter() {
|
||||
println!("Key: 0x{}", hex::encode(key));
|
||||
|
||||
if let Some(storage_data) = api.storage().at(None).await?.fetch_raw(&key.0).await? {
|
||||
if let Some(storage_data) = api.storage().at_latest().await?.fetch_raw(&key.0).await? {
|
||||
// We know the return value to be `QueryId` (`u64`) from inspecting either:
|
||||
// - polkadot code
|
||||
// - polkadot.rs generated file under `version_notifiers()` fn
|
||||
|
||||
Reference in New Issue
Block a user