Skip to content

Commit

Permalink
fixed error of zero denom
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 15, 2024
1 parent 63093a5 commit 30ba230
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion contracts/cosmwasm/executor/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,12 @@ pub fn interpret_transfer(
let mut coin = deps
.querier
.query_balance(env.contract.address.clone(), denom)?;
coin.amount = balance.apply(coin.amount.into())?.into();
let transfer_amount = balance.apply(coin.amount.into())?.into();
if transfer_amount.is_zero() {
// after cross chain route 1% of total can become zero, so it is not error
continue;
}
coin.amount = transfer_amount;
response.add_message(BankMsg::Send {
to_address: recipient.clone(),
amount: vec![coin],
Expand All @@ -497,6 +502,9 @@ pub fn interpret_transfer(
&contract.0,
&env.contract.address,
)?;
if transfer_amount.is_zero() {
continue;
}
response.add_message(contract.call(Cw20ExecuteMsg::Transfer {
recipient: recipient.clone(),
amount: transfer_amount.into(),
Expand Down

0 comments on commit 30ba230

Please sign in to comment.