pub fn transfer_stable(
    deps: DepsMut,
    info: MessageInfo,
    recipient: String,
    amount: Uint128,
) -> StdResult<Response> {
    let config: Config = read_config(deps.storage)?;
    if config.owner != deps.api.addr_canonicalize(info.sender.as_str())? {
        return Err(StdError::generic_err("Unauthorized"));
    }

    // Validate recipient
    let recipient_address = deps.api.addr_validate(recipient.as_str())?;

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

    Ok(Response::new()
        .add_messages(vec![CosmosMsg::Bank(BankMsg::Send {
            to_address: recipient_address.to_string(),
            amount: vec![Coin {
                denom: config.stable_denom,
                amount,
            }],
        })])
        .add_attributes(vec![
            ("action", "spend"),
            ("recipient", recipient.as_str()),
            ("amount", &amount.to_string()),
        ]))
}
/// Transfer Stable
/// Owner (governance contract) can execute transfer stable operation to send
/// `amount` of UST to `recipient` for community purpose
Transfer Stable
Owner (governance contract) can execute transfer stable operation to send
`amount` of UST to `recipient` for community purpose
Transfer Stable Owner ( governance contract ) can execute transfer stable operation to send ` amount ` of UST to ` recipient ` for community purpose
pub fn transfer_stable(
    deps: DepsMut,
    info: MessageInfo,
    recipient: String,
    amount: Uint128,
) -> StdResult<Response> {
    let config: Config = read_config(deps.storage)?;
    if config.owner != deps.api.addr_canonicalize(info.sender.as_str())? {
        return Err(StdError::generic_err("Unauthorized"));
    }
    // Validate recipient
    let recipient_address = deps.api.addr_validate(recipient.as_str())?;
    if config.spend_limit < amount {
        return Err(StdError::generic_err("Cannot spend more than spend_limit"));
    }
    Ok(Response::new()
        .add_messages(vec![CosmosMsg::Bank(BankMsg::Send {
            to_address: recipient_address.to_string(),
            amount: vec![Coin {
                denom: config.stable_denom,
                amount,
            }],
        })])
        .add_attributes(vec![
            ("action", "spend"),
            ("recipient", recipient.as_str()),
            ("amount", &amount.to_string()),
        ]))
}
pub fn transfer_stable ( deps : DepsMut , info : MessageInfo , recipient : String , amount : Uint128 , ) -> StdResult < Response > { let config : Config = read_config ( deps . storage ) ? ; if config . owner != deps . api . addr_canonicalize ( info . sender . as_str ( ) ) ? { return Err ( StdError :: generic_err ( " " ) ) ; } // Validate recipient let recipient_address = deps . api . addr_validate ( recipient . as_str ( ) ) ? ; if config . spend_limit < amount { return Err ( StdError :: generic_err ( " " ) ) ; } Ok ( Response :: new ( ) . add_messages ( vec ! [ CosmosMsg Bank ( BankMsg Send { to_address recipient_address to_string ( ) amount vec [ Coin { denom config stable_denom amount } ] } ) ] ) . add_attributes ( vec ! [ ( " " " " ) ( " " recipient as_str ( ) ) ( " " amount to_string ( ) ) ] ) ) }
Transfer Stable
Owner (governance contract) can execute transfer stable operation to send
`amount` of UST to `recipient` for community purpose
Transfer Stable Owner ( governance contract ) can execute transfer stable operation to send ` amount ` of UST to ` recipient ` for community purpose
deps
DepsMut
info
MessageInfo
recipient
String
amount
Uint128
deps
DepsMut
info
MessageInfo
recipient
String
amount
Uint128