pub fn add_to_whitelist(
    deps: DepsMut,
    msg_info: MessageInfo,
    contract_addr: String,
) -> VaultResult<Response> {
    // Only the admin should be able to call this
    ADMIN.assert_admin(deps.as_ref(), &msg_info.sender)?;

    let mut state = STATE.load(deps.storage)?;
    // Check if contract is already in whitelist
    if state
        .whitelisted_contracts
        .contains(&deps.api.addr_validate(&contract_addr)?)
    {
        return Err(LunaVaultError::AlreadyWhitelisted {});
    }

    // This is a limit to prevent potentially running out of gas when doing lookups on the whitelist
    if state.whitelisted_contracts.len() >= LIST_SIZE_LIMIT {
        return Err(LunaVaultError::WhitelistLimitReached {});
    }

    // Add contract to whitelist.
    state
        .whitelisted_contracts
        .push(deps.api.addr_validate(&contract_addr)?);
    STATE.save(deps.storage, &state)?;

    // Respond and note the change
    Ok(Response::new().add_attribute("Added contract to whitelist: ", contract_addr))
}
/// Adds a contract to the whitelist
Adds a contract to the whitelist
Adds a contract to the whitelist
pub fn add_to_whitelist(
    deps: DepsMut,
    msg_info: MessageInfo,
    contract_addr: String,
) -> VaultResult<Response> {
    // Only the admin should be able to call this
    ADMIN.assert_admin(deps.as_ref(), &msg_info.sender)?;
    let mut state = STATE.load(deps.storage)?;
    // Check if contract is already in whitelist
    if state
        .whitelisted_contracts
        .contains(&deps.api.addr_validate(&contract_addr)?)
    {
        return Err(LunaVaultError::AlreadyWhitelisted {});
    }
    // This is a limit to prevent potentially running out of gas when doing lookups on the whitelist
    if state.whitelisted_contracts.len() >= LIST_SIZE_LIMIT {
        return Err(LunaVaultError::WhitelistLimitReached {});
    }
    // Add contract to whitelist.
    state
        .whitelisted_contracts
        .push(deps.api.addr_validate(&contract_addr)?);
    STATE.save(deps.storage, &state)?;
    // Respond and note the change
    Ok(Response::new().add_attribute("Added contract to whitelist: ", contract_addr))
}
pub fn add_to_whitelist ( deps : DepsMut , msg_info : MessageInfo , contract_addr : String , ) -> VaultResult < Response > { // Only the admin should be able to call this ADMIN . assert_admin ( deps . as_ref ( ) , & msg_info . sender ) ? ; let mut state = STATE . load ( deps . storage ) ? ; // Check if contract is already in whitelist if state . whitelisted_contracts . contains ( & deps . api . addr_validate ( & contract_addr ) ? ) { return Err ( LunaVaultError :: AlreadyWhitelisted { } ) ; } // This is a limit to prevent potentially running out of gas when doing lookups on the whitelist if state . whitelisted_contracts . len ( ) >= LIST_SIZE_LIMIT { return Err ( LunaVaultError :: WhitelistLimitReached { } ) ; } // Add contract to whitelist. state . whitelisted_contracts . push ( deps . api . addr_validate ( & contract_addr ) ? ) ; STATE . save ( deps . storage , & state ) ? ; // Respond and note the change Ok ( Response :: new ( ) . add_attribute ( " " , contract_addr ) ) }
Adds a contract to the whitelist
Adds a contract to the whitelist
deps
DepsMut
msg_info
MessageInfo
contract_addr
String
deps
DepsMut
msg_info
MessageInfo
contract_addr
String