pub fn spend(
    deps: DepsMut,
    info: MessageInfo,
    recipient: String,
    amount: Uint128,
) -> StdResult<Response> {
    let config: Config = read_config(deps.storage)?;
    let sender_raw = deps.api.addr_canonicalize(info.sender.as_str())?;

    if !config.whitelist.into_iter().any(|w| w == sender_raw) {
        return Err(StdError::generic_err("unauthorized"));
    }

    if config.spend_limit < amount {
        return Err(StdError::generic_err("Cannot spend more than spend_limit"));
    }

    let glow_token = deps.api.addr_humanize(&config.glow_token)?.to_string();
    Ok(Response::new()
        .add_messages(vec![CosmosMsg::Wasm(WasmMsg::Execute {
            contract_addr: glow_token,
            funds: vec![],
            msg: to_binary(&Cw20ExecuteMsg::Transfer {
                recipient: recipient.clone(),
                amount,
            })?,
        })])
        .add_attributes(vec![
            ("action", "spend"),
            ("recipient", recipient.as_str()),
            ("amount", amount.to_string().as_str()),
        ]))
}
/// Spend
/// Owner can execute spend operation to send
/// `amount` of GLOW token to `recipient` for community purposes
Spend
Owner can execute spend operation to send
`amount` of GLOW token to `recipient` for community purposes
Spend Owner can execute spend operation to send ` amount ` of GLOW token to ` recipient ` for community purposes
pub fn spend(
    deps: DepsMut,
    info: MessageInfo,
    recipient: String,
    amount: Uint128,
) -> StdResult<Response> {
    let config: Config = read_config(deps.storage)?;
    let sender_raw = deps.api.addr_canonicalize(info.sender.as_str())?;
    if !config.whitelist.into_iter().any(|w| w == sender_raw) {
        return Err(StdError::generic_err("unauthorized"));
    }
    if config.spend_limit < amount {
        return Err(StdError::generic_err("Cannot spend more than spend_limit"));
    }
    let glow_token = deps.api.addr_humanize(&config.glow_token)?.to_string();
    Ok(Response::new()
        .add_messages(vec![CosmosMsg::Wasm(WasmMsg::Execute {
            contract_addr: glow_token,
            funds: vec![],
            msg: to_binary(&Cw20ExecuteMsg::Transfer {
                recipient: recipient.clone(),
                amount,
            })?,
        })])
        .add_attributes(vec![
            ("action", "spend"),
            ("recipient", recipient.as_str()),
            ("amount", amount.to_string().as_str()),
        ]))
}
pub fn spend ( deps : DepsMut , info : MessageInfo , recipient : String , amount : Uint128 , ) -> StdResult < Response > { let config : Config = read_config ( deps . storage ) ? ; let sender_raw = deps . api . addr_canonicalize ( info . sender . as_str ( ) ) ? ; if ! config . whitelist . into_iter ( ) . any ( | w | w == sender_raw ) { return Err ( StdError :: generic_err ( " " ) ) ; } if config . spend_limit < amount { return Err ( StdError :: generic_err ( " " ) ) ; } let glow_token = deps . api . addr_humanize ( & config . glow_token ) ? . to_string ( ) ; Ok ( Response :: new ( ) . add_messages ( vec ! [ CosmosMsg Wasm ( WasmMsg Execute { contract_addr glow_token funds vec [ ] msg to_binary ( Cw20ExecuteMsg Transfer { recipient recipient clone ( ) amount } ) } ) ] ) . add_attributes ( vec ! [ ( " " " " ) ( " " recipient as_str ( ) ) ( " " amount to_string ( ) as_str ( ) ) ] ) ) }
Spend
Owner can execute spend operation to send
`amount` of GLOW token to `recipient` for community purposes
Spend Owner can execute spend operation to send ` amount ` of GLOW token to ` recipient ` for community purposes
deps
DepsMut
info
MessageInfo
recipient
String
amount
Uint128
deps
DepsMut
info
MessageInfo
recipient
String
amount
Uint128