Module query

Source
Expand description

This module defines a bunch of internal types used solely for querying into RPC methods to retrieve info about what’s on the chain. Note that the types defined are exposed as-is for users to reference in their own functions or structs as needed. These types cannot be created outside of workspaces. To use them, refer to surface level types like Account, Contract and Worker.

For example, to query into downloading contract state:

use unc_workspaces::{AccountId, Network, Worker};
use unc_workspaces::rpc::query::{Query, ViewState};

async fn my_func(worker: &Worker<impl Network>) -> anyhow::Result<()> {
    let contract_id: AccountId = "some-contract.unc".parse()?;
    let query: Query<'_, ViewState> = worker.view_state(&contract_id);
    let bytes = query.await?;
    Ok(())
}

But most of the time, we do not need to worry about these types as they are meant to be transitory, and only exist while calling into their immediate methods. So the above example should look more like the following:

async fn my_func(worker: &Worker<impl Network>) -> anyhow::Result<()> {
    let contract_id: AccountId = "some-contract.unc".parse()?;
    let bytes = worker.view_state(&contract_id).await?;
    Ok(())
}

Structs§

GasPrice
Query
Query object allows creating queries into the network of our choice. This object is usually given from making calls from other functions such as view_state.
QueryChunk
Query object used to query for chunk related details at a specific ChunkReference which consists of either a chunk CryptoHash, or a BlockShardId (which consists of ShardId and either block CryptoHash or BlockHeight).
ViewAccessKey
ViewAccessKeyList
ViewAccount
ViewBlock
ViewCode
ViewFunction
ViewState

Traits§

ProcessQuery
Trait used as a converter from WorkspaceRequest to unc-rpc request, and from unc-rpc response to a WorkspaceResult. Mostly used internally to facilitate syntax sugar for performing RPC requests with async builders.