pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> StdResult<Response> {
    let config: Config = CONFIG.load(deps.storage)?;

    match from_binary(&cw20_msg.msg) {
        Ok(Cw20HookMsg::Bond {}) => {
            // only staking token contract can execute this message
            if config.staking_token != info.sender.as_str() {
                return Err(StdError::generic_err("unauthorized"));
            }
            let cw20_sender = deps.api.addr_validate(&cw20_msg.sender)?;
            bond(deps, env, cw20_sender, cw20_msg.amount)
        }
        Ok(Cw20HookMsg::UpdateRewardSchedule {
            period_start,
            period_finish,
            amount,
        }) => {
            // Only WHALE token contract can execute this message
            if config.whale_token != info.sender.as_str() {
                return Err(StdError::generic_err(
                    "Unauthorized : Only WHALE Token is allowed",
                ));
            }
            // Only owner can update the schedule
            if config.owner != cw20_msg.sender {
                return Err(StdError::generic_err("Only owner can update the schedule"));
            }
            update_reward_schedule(
                deps,
                env,
                info,
                period_start,
                period_finish,
                amount,
                cw20_msg.amount,
            )
        }

        Err(_) => Err(StdError::generic_err("data should be given")),
    }
}
/// Only WHALE-UST LP Token can be sent to this contract via the Cw20ReceiveMsg Hook
/// @dev Increases user's staked LP Token balance via the Bond Function
Only WHALE-UST LP Token can be sent to this contract via the Cw20ReceiveMsg Hook
Only WHALE - UST LP Token can be sent to this contract via the Cw20ReceiveMsg Hook
pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> StdResult<Response> {
    let config: Config = CONFIG.load(deps.storage)?;
    match from_binary(&cw20_msg.msg) {
        Ok(Cw20HookMsg::Bond {}) => {
            // only staking token contract can execute this message
            if config.staking_token != info.sender.as_str() {
                return Err(StdError::generic_err("unauthorized"));
            }
            let cw20_sender = deps.api.addr_validate(&cw20_msg.sender)?;
            bond(deps, env, cw20_sender, cw20_msg.amount)
        }
        Ok(Cw20HookMsg::UpdateRewardSchedule {
            period_start,
            period_finish,
            amount,
        }) => {
            // Only WHALE token contract can execute this message
            if config.whale_token != info.sender.as_str() {
                return Err(StdError::generic_err(
                    "Unauthorized : Only WHALE Token is allowed",
                ));
            }
            // Only owner can update the schedule
            if config.owner != cw20_msg.sender {
                return Err(StdError::generic_err("Only owner can update the schedule"));
            }
            update_reward_schedule(
                deps,
                env,
                info,
                period_start,
                period_finish,
                amount,
                cw20_msg.amount,
            )
        }
        Err(_) => Err(StdError::generic_err("data should be given")),
    }
}
pub fn receive_cw20 ( deps : DepsMut , env : Env , info : MessageInfo , cw20_msg : Cw20ReceiveMsg , ) -> StdResult < Response > { let config : Config = CONFIG . load ( deps . storage ) ? ; match from_binary ( & cw20_msg . msg ) { Ok ( Cw20HookMsg :: Bond { } ) => { // only staking token contract can execute this message if config . staking_token != info . sender . as_str ( ) { return Err ( StdError :: generic_err ( " " ) ) ; } let cw20_sender = deps . api . addr_validate ( & cw20_msg . sender ) ? ; bond ( deps , env , cw20_sender , cw20_msg . amount ) } Ok ( Cw20HookMsg :: UpdateRewardSchedule { period_start , period_finish , amount , } ) => { // Only WHALE token contract can execute this message if config . whale_token != info . sender . as_str ( ) { return Err ( StdError :: generic_err ( " " , ) ) ; } // Only owner can update the schedule if config . owner != cw20_msg . sender { return Err ( StdError :: generic_err ( " " ) ) ; } update_reward_schedule ( deps , env , info , period_start , period_finish , amount , cw20_msg . amount , ) } Err ( _ ) => Err ( StdError :: generic_err ( " " ) ) , } }
Only WHALE-UST LP Token can be sent to this contract via the Cw20ReceiveMsg Hook
Only WHALE - UST LP Token can be sent to this contract via the Cw20ReceiveMsg Hook
deps
DepsMut
env
Env
info
MessageInfo
cw20_msg
Cw20ReceiveMsg
deps
DepsMut
env
Env
info
MessageInfo
cw20_msg
Cw20ReceiveMsg
dev
Increases user's staked LP Token balance via the Bond Function
Increases user ' s staked LP Token balance via the Bond Function