From 3de375248759d57fb568b90d1bdb9a5ff9ef8a52 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 10 Mar 2021 17:31:21 -0500 Subject: [PATCH] Merge pull request from GHSA-mvm6-gfm2-89xj Co-authored-by: Alessio Treglia --- simapp/app.go | 18 +----------------- simapp/app_test.go | 7 +++++-- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 02aaa2297fe8..5eebfebb0f48 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -131,11 +131,6 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } - - // module accounts that are allowed to receive tokens - allowedReceivingModAcc = map[string]bool{ - distrtypes.ModuleName: true, - } ) var ( @@ -251,7 +246,7 @@ func NewSimApp( appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, ) app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(), + appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), ) stakingKeeper := stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), @@ -486,17 +481,6 @@ func (app *SimApp) ModuleAccountAddrs() map[string]bool { return modAccAddrs } -// BlockedAddrs returns all the app's module account addresses that are not -// allowed to receive external tokens. -func (app *SimApp) BlockedAddrs() map[string]bool { - blockedAddrs := make(map[string]bool) - for acc := range maccPerms { - blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc] - } - - return blockedAddrs -} - // LegacyAmino returns SimApp's amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable diff --git a/simapp/app_test.go b/simapp/app_test.go index 6543f94fd437..da5d8c8ec18a 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -18,8 +18,11 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{}) for acc := range maccPerms { - require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)), - "ensure that blocked addresses are properly set in bank keeper") + require.True( + t, + app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)), + "ensure that blocked addresses are properly set in bank keeper", + ) } genesisState := NewDefaultGenesisState(encCfg.Marshaler)