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

A type for simplifying provenance custom queries.

Implementations§

source§

impl<'a> ProvenanceQuerier<'a>

source

pub fn new(querier: &'a QuerierWrapper<'a, ProvenanceQuery>) -> Self

Creates a new provenance querier

source

pub fn resolve_name<S: Into<String>>(&self, name: S) -> StdResult<Name>

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!()
}
source

pub fn lookup_names<H: Into<Addr>>(&self, address: H) -> StdResult<Names>

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!()
}
source

pub fn get_attributes<H: Into<Addr>, S: Into<String>>( &self, address: H, name: Option<S> ) -> StdResult<Attributes>

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!()
}
source

pub fn get_json_attributes<H: Into<Addr>, S: Into<String>, T: DeserializeOwned>( &self, address: H, name: S ) -> StdResult<Vec<T>>

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, Eq, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Label {
    pub text: String,
    pub timestamp: u64,
}
source

pub fn get_marker_by_address<H: Into<Addr>>( &self, address: H ) -> StdResult<Marker>

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!()
}
source

pub fn get_marker_by_denom<S: Into<String>>( &self, denom: S ) -> StdResult<Marker>

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!()
}
source

pub fn get_scope<S: Into<String>>(&self, scope_id: S) -> StdResult<Scope>

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!()
}
source

pub fn get_sessions<S: Into<String>>(&self, scope_id: S) -> StdResult<Sessions>

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!()
}
source

pub fn get_records<S: Into<String>>(&self, scope_id: S) -> StdResult<Records>

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!()
}
source

pub fn get_record_by_name<S: Into<String>, T: Into<String>>( &self, scope_id: S, name: T ) -> StdResult<Record>

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§

§

impl<'a> !RefUnwindSafe for ProvenanceQuerier<'a>

§

impl<'a> !Send for ProvenanceQuerier<'a>

§

impl<'a> !Sync for ProvenanceQuerier<'a>

§

impl<'a> Unpin for ProvenanceQuerier<'a>

§

impl<'a> !UnwindSafe for ProvenanceQuerier<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.