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
impl AssetListUnchecked
sourcepub fn check(
&self,
api: &dyn Api,
optional_whitelist: Option<&[&str]>,
) -> Result<AssetList, AssetError>
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),
}
}