mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
[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:
parent
7a904ddd6c
commit
611eff93cf
@ -89,7 +89,7 @@ var (
|
|||||||
cdp.ModuleName: {supply.Minter, supply.Burner},
|
cdp.ModuleName: {supply.Minter, supply.Burner},
|
||||||
cdp.LiquidatorMacc: {supply.Minter, supply.Burner},
|
cdp.LiquidatorMacc: {supply.Minter, supply.Burner},
|
||||||
cdp.SavingsRateMacc: {supply.Minter},
|
cdp.SavingsRateMacc: {supply.Minter},
|
||||||
bep3.ModuleName: {supply.Minter, supply.Burner},
|
bep3.ModuleName: nil,
|
||||||
kavadist.ModuleName: {supply.Minter},
|
kavadist.ModuleName: {supply.Minter},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,12 @@ import (
|
|||||||
|
|
||||||
// InitGenesis initializes the store state from a genesis state.
|
// InitGenesis initializes the store state from a genesis state.
|
||||||
func InitGenesis(ctx sdk.Context, keeper Keeper, supplyKeeper types.SupplyKeeper, gs GenesisState) {
|
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 {
|
if err := gs.Validate(); err != nil {
|
||||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", ModuleName, err))
|
panic(fmt.Sprintf("failed to validate %s genesis state: %s", ModuleName, err))
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ func NewKeeper(cdc *codec.Codec, key sdk.StoreKey,
|
|||||||
sk types.SupplyKeeper, ak types.AccountKeeper,
|
sk types.SupplyKeeper, ak types.AccountKeeper,
|
||||||
paramstore subspace.Subspace,
|
paramstore subspace.Subspace,
|
||||||
) Keeper {
|
) Keeper {
|
||||||
if addr := sk.GetModuleAddress(types.ModuleName); addr == nil {
|
|
||||||
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !paramstore.HasKeyTable() {
|
if !paramstore.HasKeyTable() {
|
||||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,8 @@ type SupplyKeeper interface {
|
|||||||
GetModuleAddress(name string) sdk.AccAddress
|
GetModuleAddress(name string) sdk.AccAddress
|
||||||
GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI
|
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
|
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
|
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)
|
// AccountKeeper defines the expected account keeper (noalias)
|
||||||
|
Loading…
Reference in New Issue
Block a user