Skip to content

Commit

Permalink
feat: update x/bank blocked addresses (#1493)
Browse files Browse the repository at this point in the history
* updates

* updates

* updates

* updates

Co-authored-by: lg <[email protected]>
  • Loading branch information
2 people authored and tokamak-git committed Jun 21, 2022
1 parent d4ca7fc commit 374472f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func NewGaiaApp(
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.ModuleAccountAddrs(),
app.BlockedModuleAccountAddrs(),
)

app.AuthzKeeper = authzkeeper.NewKeeper(
Expand Down Expand Up @@ -819,6 +819,20 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// BlockedModuleAccountAddrs returns all the app's blocked module account
// addresses.
func (app *GaiaApp) BlockedModuleAccountAddrs() map[string]bool {
modAccAddrs := app.ModuleAccountAddrs()

// remove module accounts that are ALLOWED to received funds
//
// TODO: Blocked on updating to v0.46.x
// delete(modAccAddrs, authtypes.NewModuleAddress(grouptypes.ModuleName).String())
delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())

return modAccAddrs
}

// LegacyAmino returns GaiaApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
Expand Down
38 changes: 38 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package gaia_test

import (
"testing"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db"

gaia "github.com/cosmos/gaia/v7/app"
)

type EmptyAppOptions struct{}

func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}

func TestGaiaApp_BlockedModuleAccountAddrs(t *testing.T) {
app := gaia.NewGaiaApp(
log.NewNopLogger(),
db.NewMemDB(),
nil,
true,
map[int64]bool{},
gaia.DefaultNodeHome,
0,
gaia.MakeEncodingConfig(),
EmptyAppOptions{},
)
blockedAddrs := app.BlockedModuleAccountAddrs()

// TODO: Blocked on updating to v0.46.x
// require.NotContains(t, blockedAddrs, authtypes.NewModuleAddress(grouptypes.ModuleName).String())
require.NotContains(t, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())
}

0 comments on commit 374472f

Please sign in to comment.