Skip to content

Commit

Permalink
fix/44 check amount is larger than zero in cross transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonAndell committed Nov 6, 2023
1 parent bca10dd commit 6786149
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/token-contracts/cw-hub-bnusd/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod execute {
use std::str::from_utf8;

use bytes::BytesMut;
use cosmwasm_std::{to_binary, Addr, CosmosMsg, SubMsg};
use cosmwasm_std::{to_binary, Addr, CosmosMsg, SubMsg, ensure};
use cw_common::network_address::NetId;
use cw_ibc_rlp_lib::rlp::{decode, encode};
use debug_print::debug_println;
Expand Down Expand Up @@ -257,6 +257,8 @@ mod execute {
if !to.validate_foreign_addresses() {
return Err(ContractError::InvalidNetworkAddress);
}
ensure!(amount > 0, ContractError::InvalidAmount);

let funds = info.funds.clone();
let nid = NID.load(deps.storage)?;
let hub_net: NetId = DESTINATION_TOKEN_NET.load(deps.storage)?;
Expand Down
2 changes: 2 additions & 0 deletions contracts/token-contracts/cw-hub-bnusd/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub enum ContractError {
WrongNetwork,
#[error("Invalid to Address")]
InvalidToAddress,
#[error("Token amount can't be zero")]
InvalidAmount,
#[error("OnlyCallService")]
OnlyCallService,
#[error("OnlyHub")]
Expand Down

0 comments on commit 6786149

Please sign in to comment.