mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-25 12:57:58 +00:00
Add block-centric Storage API (#774)
* blocks: Add storage method Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add support for runtime API calls and expose it to the blocks API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * storage: Add storage type for block centric API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust subxt to the new Storage interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -21,7 +21,12 @@ async fn storage_plain_lookup() -> Result<(), subxt::Error> {
|
||||
wait_for_blocks(&api).await;
|
||||
|
||||
let addr = node_runtime::storage().timestamp().now();
|
||||
let entry = api.storage().fetch_or_default(&addr, None).await?;
|
||||
let entry = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.await?
|
||||
.fetch_or_default(&addr)
|
||||
.await?;
|
||||
assert!(entry > 0);
|
||||
|
||||
Ok(())
|
||||
@@ -45,7 +50,12 @@ async fn storage_map_lookup() -> Result<(), subxt::Error> {
|
||||
|
||||
// Look up the nonce for the user (we expect it to be 1).
|
||||
let nonce_addr = node_runtime::storage().system().account(alice);
|
||||
let entry = api.storage().fetch_or_default(&nonce_addr, None).await?;
|
||||
let entry = api
|
||||
.storage()
|
||||
.at(None)
|
||||
.await?
|
||||
.fetch_or_default(&nonce_addr)
|
||||
.await?;
|
||||
assert_eq!(entry.nonce, 1);
|
||||
|
||||
Ok(())
|
||||
@@ -113,7 +123,7 @@ async fn storage_n_map_storage_lookup() -> Result<(), subxt::Error> {
|
||||
|
||||
// The actual test; look up this approval in storage:
|
||||
let addr = node_runtime::storage().assets().approvals(99, alice, bob);
|
||||
let entry = api.storage().fetch(&addr, None).await?;
|
||||
let entry = api.storage().at(None).await?.fetch(&addr).await?;
|
||||
assert_eq!(entry.map(|a| a.amount), Some(123));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user