[R4R] Update bep3 module account permissions (#483)

* incoming swaps trigger acc registration

* move supply increment after recipient acc validation

* use expected keepers pattern

* remove expected keepers from alias

* update bep3 macc permissions

* clean supply keeper interface

* add module account check to genesis

* remove duplicated accountkeeper
This commit is contained in:
Denali Marsh 2020-05-06 13:23:13 -07:00 committed by GitHub
parent 7a904ddd6c
commit 611eff93cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 9 deletions

View File

@ -89,7 +89,7 @@ var (
cdp.ModuleName: {supply.Minter, supply.Burner},
cdp.LiquidatorMacc: {supply.Minter, supply.Burner},
cdp.SavingsRateMacc: {supply.Minter},
bep3.ModuleName: {supply.Minter, supply.Burner},
bep3.ModuleName: nil,
kavadist.ModuleName: {supply.Minter},
}
)

View File

@ -10,6 +10,12 @@ import (
// InitGenesis initializes the store state from a genesis state.
func InitGenesis(ctx sdk.Context, keeper Keeper, supplyKeeper types.SupplyKeeper, gs GenesisState) {
// Check if the module account exists
moduleAcc := supplyKeeper.GetModuleAccount(ctx, ModuleName)
if moduleAcc == nil {
panic(fmt.Sprintf("%s module account has not been set", ModuleName))
}
if err := gs.Validate(); err != nil {
panic(fmt.Sprintf("failed to validate %s genesis state: %s", ModuleName, err))
}

View File

@ -27,10 +27,6 @@ func NewKeeper(cdc *codec.Codec, key sdk.StoreKey,
sk types.SupplyKeeper, ak types.AccountKeeper,
paramstore subspace.Subspace,
) Keeper {
if addr := sk.GetModuleAddress(types.ModuleName); addr == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}

View File

@ -11,12 +11,8 @@ type SupplyKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI
SendCoinsFromModuleToModule(ctx sdk.Context, sender, recipient string, amt sdk.Coins) error
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
BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
}
// AccountKeeper defines the expected account keeper (noalias)