Skip to content

v1.0.0

Compare
Choose a tag to compare
@larry0x larry0x released this 08 Feb 19:27
· 51 commits to main since this release

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"]))?;
}