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 asview_state
.- Query
Chunk - Query object used to query for chunk related details at a specific
ChunkReference
which consists of either a chunkCryptoHash
, or aBlockShardId
(which consists ofShardId
and either blockCryptoHash
orBlockHeight
). - View
Access Key - View
Access KeyList - View
Account - View
Block - View
Code - View
Function - View
State
Traits§
- Process
Query - 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.