Type Alias cw_asset::AssetListUnchecked

source ·
pub type AssetListUnchecked = AssetListBase<String>;
Expand description

Represents an asset list instance that may contain unverified data; to be used in messages.

Aliased Type§

struct AssetListUnchecked(/* private fields */);

Implementations§

source§

impl AssetListUnchecked

source

pub fn check( &self, api: &dyn Api, optional_whitelist: Option<&[&str]>, ) -> Result<AssetList, AssetError>

Validate data contained in an unchecked asset list instance, return a new checked asset list instance:

  • For CW20 tokens, assert the contract address is valid
  • For SDK coins, assert that the denom is included in a given whitelist; skip if the whitelist is not provided
use cosmwasm_std::{Addr, Api, StdResult};
use cw_asset::{Asset, AssetList, AssetListUnchecked, AssetUnchecked};

fn validate_assets(api: &dyn Api, list_unchecked: &AssetListUnchecked) {
    match list_unchecked.check(api, Some(&["uatom", "uluna"])) {
        Ok(list) => println!("asset list is valid: {}", list.to_string()),
        Err(err) => println!("asset list is invalid! reason: {}", err),
    }
}

Trait Implementations§

source§

impl From<AssetListBase<Addr>> for AssetListUnchecked

source§

fn from(list: AssetList) -> Self

Converts to this type from the input type.
source§

impl FromStr for AssetListUnchecked

§

type Err = AssetError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more