Skip to content

Commit

Permalink
chore: no need to check empty balance. Balance will be back while han…
Browse files Browse the repository at this point in the history
…dling tx which throws error
  • Loading branch information
jaeseung-bae committed Feb 15, 2024
1 parent 2addae4 commit 1efcd88
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions x/bankplus/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ func (k BaseKeeper) isInactiveAddr(addr sdk.AccAddress) bool {
return k.inactiveAddrs[addrString]
}

// SendCoins transfers amt coins from a sending account to a receiving account.
// This is wrapped bank the `SendKeeper` interface of `bank` module,
// and checks if `toAddr` is a inactiveAddr managed by the module.
func (k BaseKeeper) SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error {
// if toAddr is smart contract, check the status of contract.
if k.isInactiveAddr(toAddr) {
return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", toAddr)
}

return k.BaseSendKeeper.SendCoins(ctx, fromAddr, toAddr, amt)
}

// AddToInactiveAddr adds the address to `inactiveAddr`.
func (k BaseKeeper) AddToInactiveAddr(ctx context.Context, addr sdk.AccAddress) {
addrString, err := k.addrCdc.BytesToString(addr)
Expand Down
2 changes: 1 addition & 1 deletion x/bankplus/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (s *IntegrationTestSuite) verifySendAccountToModule() {
func (s *IntegrationTestSuite) TestInactiveAddrOfSendCoins() {
s.mintInitialBalances()
s.verifySendToBlockedAddr()
s.mintInitialBalances()
s.verifySendToBlockedAddrAfterRemoveIt()
}

Expand All @@ -205,7 +206,6 @@ func (s *IntegrationTestSuite) verifySendToBlockedAddr() {

err := s.cut.SendCoins(s.ctx, s.holderAcc.GetAddress(), s.blockedAcc.GetAddress(), initCoins)
s.Require().Contains(err.Error(), "is not allowed to receive funds")
s.Require().Equal(initCoins, s.cut.GetAllBalances(s.ctx, s.holderAcc.GetAddress()))
}

func (s *IntegrationTestSuite) verifySendToBlockedAddrAfterRemoveIt() {
Expand Down

0 comments on commit 1efcd88

Please sign in to comment.