Skip to content

Commit

Permalink
Update to non-option Cw20ReceiveMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Apr 26, 2021
1 parent c4a4b12 commit 078b7f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 2 additions & 8 deletions contracts/cw4-stake/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,15 @@
"type": "object",
"required": [
"amount",
"msg",
"sender"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"msg": {
"anyOf": [
{
"$ref": "#/definitions/Binary"
},
{
"type": "null"
}
]
"$ref": "#/definitions/Binary"
},
"sender": {
"type": "string"
Expand Down
7 changes: 2 additions & 5 deletions contracts/cw4-stake/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ pub fn execute_receive(
// wrapper.sender is the address of the user that requested the cw20 contract to send this.
// This cannot be fully trusted (the cw20 contract can fake it), so only use it for actions
// in the address's favor (like paying/bonding tokens, not withdrawls)
let msg: ReceiveMsg = match wrapper.msg {
Some(bin) => Ok(from_slice(&bin)?),
None => Err(ContractError::NoData {}),
}?;
let msg: ReceiveMsg = from_slice(&wrapper.msg)?;
let balance = Balance::Cw20(Cw20CoinVerified {
address: info.sender,
amount: wrapper.amount,
Expand Down Expand Up @@ -463,7 +460,7 @@ mod tests {
let msg = ExecuteMsg::Receive(Cw20ReceiveMsg {
sender: addr.to_string(),
amount: Uint128(*stake),
msg: Some(to_binary(&ReceiveMsg::Bond {}).unwrap()),
msg: to_binary(&ReceiveMsg::Bond {}).unwrap(),
});
let info = mock_info(CW20_ADDRESS, &[]);
execute(deps.branch(), env.clone(), info, msg).unwrap();
Expand Down

0 comments on commit 078b7f2

Please sign in to comment.