Skip to content

Commit

Permalink
[11859]: Remove the authority field that is only needed for governanc…
Browse files Browse the repository at this point in the history
…e stuff (in the other PR).
  • Loading branch information
dwedul-figure committed May 18, 2022
1 parent f6e72cd commit 93f4148
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 46 deletions.
8 changes: 3 additions & 5 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,12 @@ func NewSimApp(
// their scoped modules in `NewApp` with `ScopeToModule`
app.CapabilityKeeper.Seal()

govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), govModuleAddr,
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),
Expand Down Expand Up @@ -321,11 +319,11 @@ func NewSimApp(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)
// set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, govModuleAddr)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())

// RegisterUpgradeHandlers is used for registering any on-chain upgrades
app.RegisterUpgradeHandlers()
Expand Down
10 changes: 0 additions & 10 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ type Keeper interface {
DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error

// GetAuthority Gets the address capable of executing governance proposal messages. Usually the gov module account.
GetAuthority() string

types.QueryServer
}

Expand All @@ -61,15 +58,10 @@ type BaseKeeper struct {
storeKey storetypes.StoreKey
paramSpace paramtypes.Subspace
mintCoinsRestrictionFn MintingRestrictionFn
authority string
}

type MintingRestrictionFn func(ctx sdk.Context, coins sdk.Coins) error

func (k BaseKeeper) GetAuthority() string {
return k.authority
}

// GetPaginatedTotalSupply queries for the supply, ignoring 0 coins, with a given pagination
func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) {
store := ctx.KVStore(k.storeKey)
Expand Down Expand Up @@ -107,7 +99,6 @@ func NewBaseKeeper(
ak types.AccountKeeper,
paramSpace paramtypes.Subspace,
blockedAddrs map[string]bool,
authority string,
) BaseKeeper {

// set KeyTable if it has not already been set
Expand All @@ -122,7 +113,6 @@ func NewBaseKeeper(
storeKey: storeKey,
paramSpace: paramSpace,
mintCoinsRestrictionFn: func(ctx sdk.Context, coins sdk.Coins) error { return nil },
authority: authority,
}
}

Expand Down
31 changes: 0 additions & 31 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

Expand Down Expand Up @@ -93,7 +92,6 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str
keeper := keeper.NewBaseKeeper(
appCodec, app.GetKey(types.StoreKey), authKeeper,
app.GetSubspace(types.ModuleName), blockedAddrs,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

return authKeeper, keeper
Expand All @@ -115,33 +113,6 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.queryClient = queryClient
}

func (suite *IntegrationTestSuite) TestGetAuthority() {
createKeeperWithAuthority := func(authority string) keeper.BaseKeeper {
return keeper.NewBaseKeeper(
simapp.MakeTestEncodingConfig().Codec,
suite.app.GetKey(types.StoreKey),
nil,
suite.app.GetSubspace(types.ModuleName),
nil,
authority,
)
}

tests := []string{"", "authority1", "someotherthing"}

for _, tc := range tests {
name := tc
if len(name) == 0 {
name = "empty"
}
suite.T().Run(name, func(t *testing.T) {
kpr := createKeeperWithAuthority(tc)
actual := kpr.GetAuthority()
assert.Equal(t, tc, actual)
})
}
}

func (suite *IntegrationTestSuite) TestSupply() {
ctx := suite.ctx

Expand Down Expand Up @@ -1088,7 +1059,6 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() {

suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey),
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// set account with multiple permissions
Expand Down Expand Up @@ -1251,7 +1221,6 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() {
for _, test := range tests {
suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey),
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn))
for _, testCase := range test.testCases {
if testCase.expectPass {
Expand Down

0 comments on commit 93f4148

Please sign in to comment.