Skip to content

Commit

Permalink
revert: bank change module to account change (#20427)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle authored May 21, 2024
1 parent 1f06f5b commit c2f6c19
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion store/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type (
func NewCommitKVStoreCache(store types.CommitKVStore, size uint) *CommitKVStoreCache {
cache, err := lru.NewARC(int(size))
if err != nil {
panic(fmt.Errorf("failed to create KVStore cache: %s", err))
panic(fmt.Errorf("failed to create KVStore cache: %w", err))
}

return &CommitKVStoreCache{
Expand Down
6 changes: 3 additions & 3 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"io"
"math"
"math"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -834,7 +834,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error {
keys := keysFromStoreKeyMap(rs.stores)
for _, key := range keys {
switch store := rs.GetCommitKVStore(key).(type) {
case *iavl.Store:
case *iavl.Store:
stores = append(stores, namedStore{name: key.Name(), Store: store})
case *transient.Store, *mem.Store:
// Non-persisted stores shouldn't be snapshotted
Expand All @@ -854,7 +854,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error {
// are demarcated by new SnapshotStore items.
for _, store := range stores {
rs.logger.Debug("starting snapshot", "store", store.name, "height", height)
exporter, err := store.Export(int64(height))
exporter, err := store.Export(int64(height))
if err != nil {
rs.logger.Error("snapshot failed; exporter error", "store", store.name, "err", err)
return err
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/accounts/base_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ func bechify(t *testing.T, app *simapp.SimApp, addr []byte) string {

func fundAccount(t *testing.T, app *simapp.SimApp, ctx sdk.Context, addr sdk.AccAddress, amt string) {
require.NoError(t, testutil.FundAccount(ctx, app.BankKeeper, addr, coins(t, amt)))

}
3 changes: 2 additions & 1 deletion testutil/testdata/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package testdata
import (
"context"
"fmt"
"github.com/cosmos/gogoproto/types/any/test"
"testing"

"github.com/cosmos/gogoproto/types/any/test"

"github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc"
"gotest.tools/v3/assert"
Expand Down
1 change: 0 additions & 1 deletion x/bank/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Consensus Breaking Changes

* [#19188](https://github.com/cosmos/cosmos-sdk/pull/19188) Remove creation of `BaseAccount` when sending a message to an account that does not exist
* [#20343](https://github.com/cosmos/cosmos-sdk/pull/20343) Add a check in send moduleaccount to account to prevent module accounts from sending disabled tokens to accounts
7 changes: 0 additions & 7 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,6 @@ func (k BaseKeeper) SendCoinsFromModuleToAccount(
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)
}

for _, coin := range amt {
sendEnabled, found := k.getSendEnabled(ctx, coin.Denom)
if found && !sendEnabled {
return fmt.Errorf("denom: %s, is prohibited from being sent at this time", coin.Denom)
}
}

if k.BlockedAddr(recipientAddr) {
return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", recipientAddr)
}
Expand Down
18 changes: 0 additions & 18 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,24 +389,6 @@ func (suite *KeeperTestSuite) TestSendCoinsFromModuleToAccount_Blocklist() {
))
}

func (suite *KeeperTestSuite) TestSendCoinsFromModuleToAccount_CoinSendDisabled() {
ctx := suite.ctx
require := suite.Require()
keeper := suite.bankKeeper

suite.mockMintCoins(mintAcc)
require.NoError(keeper.MintCoins(ctx, banktypes.MintModuleName, initCoins))

keeper.SetSendEnabled(ctx, sdk.DefaultBondDenom, false)

suite.authKeeper.EXPECT().GetModuleAddress(mintAcc.Name).Return(mintAcc.GetAddress())
err := keeper.SendCoinsFromModuleToAccount(
ctx, banktypes.MintModuleName, accAddrs[2], initCoins,
)
require.Contains(err.Error(), "stake, is prohibited from being sent at this time")
keeper.SetSendEnabled(ctx, sdk.DefaultBondDenom, true)
}

func (suite *KeeperTestSuite) TestSupply_DelegateUndelegateCoins() {
ctx := suite.ctx
require := suite.Require()
Expand Down

0 comments on commit c2f6c19

Please sign in to comment.