Struct provwasm_std::ProvenanceQuerier[][src]

pub struct ProvenanceQuerier<'a> { /* fields omitted */ }

A type for simplifying provenance custom queries.

Implementations

impl<'a> ProvenanceQuerier<'a>[src]

pub fn new(querier: &'a QuerierWrapper<'_>) -> Self[src]

Creates a new provenance querier

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

Resolve the address for a name.

Example

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

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

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

Lookup all names bound to the given address.

Example

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

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

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

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};

// Query all attributes added to an account.
pub fn try_query_attributes(deps: Deps, 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!()
}

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

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;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

// Query all label attributes added to an account.
pub fn query_labels(deps: Deps, 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,
}

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

Get a marker by address.

Example

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

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

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

Get a marker by denomination.

Example

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

// Query a marker by denom.
fn try_get_marker_by_denom(deps: Deps, denom: String) -> StdResult<QueryResponse> {
    let querier = ProvenanceQuerier::new(&deps.querier);
    let marker: Marker = querier.get_marker_by_denom(&denom)?;
    // Do something with marker ...
    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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.