Skip to content

Commit

Permalink
Added a check to ensure that SendEnabled is set on the denoms.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Witkowski committed Sep 29, 2022
1 parent ed56c0b commit b7b489c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (k Keeper) SendTransfer(
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to send funds", sender)
}

if err := k.bankKeeper.IsSendEnabledCoins(ctx, sdk.NewCoins(token)...); err != nil {
return err
}

sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel)
if !found {
return sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
Expand Down
13 changes: 13 additions & 0 deletions modules/apps/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
Expand Down Expand Up @@ -105,6 +106,18 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
}, true, false,
},
{
"send coin failed - send coin is disabled",
func() {
suite.coordinator.CreateTransferChannels(path)
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))

// Disable SendEnabled
params := suite.chainA.GetSimApp().BankKeeper.GetParams(suite.chainA.GetContext())
params.SendEnabled = append(params.SendEnabled, banktypes.NewSendEnabled(sdk.DefaultBondDenom, false))
suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(), params)
}, true, false,
},
}

for _, tc := range testCases {
Expand Down
1 change: 1 addition & 0 deletions modules/apps/transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type BankKeeper interface {
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
BlockedAddr(addr sdk.AccAddress) bool
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
}

// ICS4Wrapper defines the expected ICS4Wrapper for middleware
Expand Down

0 comments on commit b7b489c

Please sign in to comment.