Struct provwasm_std::ProvenanceQuerier[][src]

pub struct ProvenanceQuerier<'a> { /* fields omitted */ }
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};

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

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

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

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

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

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

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

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Should always be Self

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

Attempts to convert self into a target type. Read more

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.