Breaking changes
- The
check
function, which converts an "unchecked" type to a "checked" one, now takes a second, optional parameter optional_whitelist
of Option<&[&str]>
type. This parameter allows user to specify a list of native coin denoms that the asset must belong to.
use cosmwasm_std::Api;
use cw_asset::AssetInfoUnchecked;
fn check_example(api: &dyn Api) {
let unchecked = AssetInfoUnchecked::native("uusd");
// legacy syntax, should fail because the optional whitelist parameter is not provided
let checked = unchecked.check(api)?;
// do not specify a whitelist; should succeed
let checked = unchecked.check(api, None)?;
// specify a whitelist, and the asset's denom is in the list; should succeed
let checked = unchecked.check(api, Some(&["uluna", "uusd", "ukrw"]))?;
// specify a whitelist, and the asset's denom is NOT in the list; should fail
let checked = unchecked.check(api, Some(&["uatom", "uosmo"]))?;
}