pub struct ProvenanceQuerier<'a> { /* private fields */ }
Expand description

A type for simplifying provenance custom queries.

Implementations

Creates a new provenance querier

Resolve the address for a name.

Example
// Imports required
use cosmwasm_std::{Deps, QueryResponse, StdResult};
use provwasm_std::{Name, ProvenanceQuerier, ProvenanceQuery};

// Resolve the address for a name.
fn query_resolve_name(deps: Deps<ProvenanceQuery>, name: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let name: Name = querier.resolve_name(&name)?;
    // Do something with name.address ...
    todo!()
}

Lookup all names bound to the given address.

Example
// Imports required
use cosmwasm_std::{Addr, Deps, QueryResponse, StdResult};
use provwasm_std::{Names, ProvenanceQuerier, ProvenanceQuery};

// Lookup all names bound to an address.
fn query_lookup_names(deps: Deps<ProvenanceQuery>, address: Addr) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let names: Names = querier.lookup_names(address)?;
    // Do something with names.records ...
    todo!()
}

Get attributes for an account. If the name parameter is None, all attributes are returned.

Example
// Imports required
use cosmwasm_std::{Addr, Deps, QueryResponse, StdResult};
use provwasm_std::{Attributes, ProvenanceQuerier, ProvenanceQuery};

// Query all attributes added to an account.
pub fn try_query_attributes(deps: Deps<ProvenanceQuery>, address: Addr) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let none: Option<String> = None;
    let res: Attributes = querier.get_attributes(address, none)?;
    // Do something with res.attributes ...
    todo!()
}

Get named JSON attributes from an account and deserialize the values. Attribute values with the same name must be able to be deserialized to the same type.

Example
// Imports required
use cosmwasm_std::{Addr, Deps, QueryResponse, StdResult};
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

// Query all label attributes added to an account.
pub fn query_labels(deps: Deps<ProvenanceQuery>, address: Addr) -> StdResult<QueryResponse> {
    let attr_name = String::from("label.my-contract.sc.pb");
    let querier = ProvenanceQuerier::new(&deps.querier);
    let labels: Vec<Label> = querier.get_json_attributes(address, &attr_name)?;
    // Do something with labels...
    todo!()
}

// Text with timestamp.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Label {
    pub text: String,
    pub timestamp: u64,
}

Get a marker by address.

Example
// Imports required
use provwasm_std::{ProvenanceQuerier, Marker, ProvenanceQuery};
use cosmwasm_std::{Addr, Deps, QueryResponse, StdResult};

// Query a marker by address.
fn try_get_marker_by_address(deps: Deps<ProvenanceQuery>, address: Addr) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let marker: Marker = querier.get_marker_by_address(address)?;
    // Do something with marker ...
    todo!()
}

Get a marker by denomination.

Example
// Imports required
use cosmwasm_std::{Deps, QueryResponse, StdResult};
use provwasm_std::{ProvenanceQuerier, Marker, ProvenanceQuery};

// Query a marker by denom.
fn try_get_marker_by_denom(deps: Deps<ProvenanceQuery>, denom: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let marker: Marker = querier.get_marker_by_denom(&denom)?;
    // Do something with marker ...
    todo!()
}

Get a scope by metadata ID (bech32 address string).

Example
// Imports required
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery, Scope};
use cosmwasm_std::{Deps, QueryResponse, StdResult};

// Query a scope by id.
fn try_get_scope(deps: Deps<ProvenanceQuery>, scope_id: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let scope: Scope = querier.get_scope(scope_id)?;
    // Do something with scope ...
    todo!()
}

Get all scope sessions.

Example
// Imports required
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery, Sessions};
use cosmwasm_std::{Deps, QueryResponse, StdResult};

// Query all sessions for a scope.
fn try_get_sessions(deps: Deps<ProvenanceQuery>, scope_id: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let res: Sessions = querier.get_sessions(scope_id)?;
    // Do something with res.sessions ...
    todo!()
}

Get all scope records.

Example
// Imports required
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery, Records};
use cosmwasm_std::{Deps, QueryResponse, StdResult};

// Query all records for a scope.
fn try_get_records(deps: Deps<ProvenanceQuery>, scope_id: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let res: Records = querier.get_records(scope_id)?;
    // Do something with res.records ...
    todo!()
}

Get a scope record with the given name.

Example
// Imports required
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery, Record};
use cosmwasm_std::{Deps, QueryResponse, StdResult};

// Query a loan record for a scope.
fn try_get_loan_record(deps: Deps<ProvenanceQuery>, scope_id: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let record: Record = querier.get_record_by_name(scope_id, "loan")?;
    // Do something with record ...
    todo!()
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.