paritytech / subxt

Interact with Substrate based nodes in Rust or WebAssembly
Other
407 stars 242 forks source link

Dynamic storage iter example no longer works #1517

Closed AurevoirXavier closed 5 months ago

AurevoirXavier commented 5 months ago

Always get Error: StorageAddress(TooManyBytes) with wss://rpc.polkadot.io.

use subxt::{config::polkadot::H256, OnlineClient, PolkadotConfig};

let api = <OnlineClient<PolkadotConfig>>::from_url("wss://rpc.polkadot.io").await?;
let storage_query = subxt::dynamic::storage("System", "Account", Vec::new());
let mut results = api.storage().at_latest().await?.iter(storage_query).await?;

while let Some(r) = results.next().await {
    match r {
        Ok(kv) => {
            println!("Keys decoded: {:?}", kv.keys);
            println!("Key: {}", array_bytes::bytes2hex("0x", &kv.key_bytes));
            println!("Value: {:?}", kv.value.to_value()?);
        },
        Err(e) => println!("Error: {e:?}"),
    }
}
AurevoirXavier commented 5 months ago

Relate to #1419.

jsdw commented 5 months ago

Thanks for raising the issue! We'll look into this.

jsdw commented 5 months ago

Just to add to the closed PR; we think that this is all fixed now and have done a patch release of Subxt, so updating your lockfile or Subxt version will hopefully fix the issue for you; we'd love to know either way :)