Skip to content

Commit

Permalink
added minimum withdraw amount to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Jun 20, 2024
1 parent ca9dad9 commit 7b122eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ func ValidateZrc20WithdrawEvent(event *zrc20.ZRC20Withdrawal, chainID int64) err

if chains.IsBitcoinChain(chainID) {
if event.Value.Cmp(big.NewInt(constant.BTCWithdrawalDustAmount)) < 0 {
return fmt.Errorf("ParseZRC20WithdrawalEvent: invalid amount %s", event.Value.String())
return fmt.Errorf("ParseZRC20WithdrawalEvent: withdraw amount %s is less than minimum amount %d",
event.Value.String(), constant.BTCWithdrawalDustAmount)
}
addr, err := chains.DecodeBtcAddress(string(event.To), chainID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/evm_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) {
// 999 satoshis cannot be withdrawn
btcMainNetWithdrawalEvent.Value = big.NewInt(constant.BTCWithdrawalDustAmount - 1)
err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId)
require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount")
require.ErrorContains(t, err, "less than minimum amount")
})

t.Run("unable to validate a event with an invalid chain ID", func(t *testing.T) {
Expand Down

0 comments on commit 7b122eb

Please sign in to comment.