pub fn update_assets(
    deps: DepsMut,
    msg_info: MessageInfo,
    to_add: Vec<VaultAsset>,
    to_remove: Vec<AssetInfo>,
) -> TreasuryResult {
    // Only Admin can call this method
    ADMIN.assert_admin(deps.as_ref(), &msg_info.sender)?;

    // Check the vault size to be within the size limit to prevent running out of gas when doing lookups
    let current_vault_size = VAULT_ASSETS
        .keys(deps.storage, None, None, Ascending)
        .count();
    let delta: i128 = to_add.len() as i128 - to_remove.len() as i128;
    if current_vault_size as i128 + delta > LIST_SIZE_LIMIT as i128 {
        return Err(TreasuryError::AssetsLimitReached {});
    }

    for new_asset in to_add.into_iter() {
        let id = get_identifier(&new_asset.asset.info).as_str();
        // update function for new or existing keys
        let insert =
            |_vault_asset: Option<VaultAsset>| -> StdResult<VaultAsset> { Ok(new_asset.clone()) };
        VAULT_ASSETS.update(deps.storage, id, insert)?;
    }

    for asset_id in to_remove {
        VAULT_ASSETS.remove(deps.storage, get_identifier(&asset_id).as_str());
    }

    Ok(Response::new().add_attribute("action", "update_cw20_token_list"))
}
/// Update the stored vault asset information
Update the stored vault asset information
Update the stored vault asset information
pub fn update_assets(
    deps: DepsMut,
    msg_info: MessageInfo,
    to_add: Vec<VaultAsset>,
    to_remove: Vec<AssetInfo>,
) -> TreasuryResult {
    // Only Admin can call this method
    ADMIN.assert_admin(deps.as_ref(), &msg_info.sender)?;
    // Check the vault size to be within the size limit to prevent running out of gas when doing lookups
    let current_vault_size = VAULT_ASSETS
        .keys(deps.storage, None, None, Ascending)
        .count();
    let delta: i128 = to_add.len() as i128 - to_remove.len() as i128;
    if current_vault_size as i128 + delta > LIST_SIZE_LIMIT as i128 {
        return Err(TreasuryError::AssetsLimitReached {});
    }
    for new_asset in to_add.into_iter() {
        let id = get_identifier(&new_asset.asset.info).as_str();
        // update function for new or existing keys
        let insert =
            |_vault_asset: Option<VaultAsset>| -> StdResult<VaultAsset> { Ok(new_asset.clone()) };
        VAULT_ASSETS.update(deps.storage, id, insert)?;
    }
    for asset_id in to_remove {
        VAULT_ASSETS.remove(deps.storage, get_identifier(&asset_id).as_str());
    }
    Ok(Response::new().add_attribute("action", "update_cw20_token_list"))
}
pub fn update_assets ( deps : DepsMut , msg_info : MessageInfo , to_add : Vec < VaultAsset > , to_remove : Vec < AssetInfo > , ) -> TreasuryResult { // Only Admin can call this method ADMIN . assert_admin ( deps . as_ref ( ) , & msg_info . sender ) ? ; // Check the vault size to be within the size limit to prevent running out of gas when doing lookups let current_vault_size = VAULT_ASSETS . keys ( deps . storage , None , None , Ascending ) . count ( ) ; let delta : i128 = to_add . len ( ) as i128 - to_remove . len ( ) as i128 ; if current_vault_size as i128 + delta > LIST_SIZE_LIMIT as i128 { return Err ( TreasuryError :: AssetsLimitReached { } ) ; } for new_asset in to_add . into_iter ( ) { let id = get_identifier ( & new_asset . asset . info ) . as_str ( ) ; // update function for new or existing keys let insert = | _vault_asset : Option < VaultAsset > | -> StdResult < VaultAsset > { Ok ( new_asset . clone ( ) ) } ; VAULT_ASSETS . update ( deps . storage , id , insert ) ? ; } for asset_id in to_remove { VAULT_ASSETS . remove ( deps . storage , get_identifier ( & asset_id ) . as_str ( ) ) ; } Ok ( Response :: new ( ) . add_attribute ( " " , " " ) ) }
Update the stored vault asset information
Update the stored vault asset information
deps
DepsMut
msg_info
MessageInfo
to_add
Vec<VaultAsset>
to_remove
Vec<AssetInfo>
deps
DepsMut
msg_info
MessageInfo
to_add
Vec<VaultAsset>
to_remove
Vec<AssetInfo>