feat: handle additional x/auth module app config parameters (#13684)
This commit is contained in:
parent
84bd246e64
commit
0d8787c3bd
@ -197,16 +197,29 @@ func NewSimApp(
|
||||
// supply the application options
|
||||
appOpts,
|
||||
|
||||
// ADVANCED CONFIGURATION
|
||||
|
||||
//
|
||||
// AUTH
|
||||
//
|
||||
|
||||
// For providing a custom function required in auth to generate custom account types
|
||||
// add it below. By default the auth module uses simulation.RandomGenesisAccounts.
|
||||
//
|
||||
// authtypes.RandomGenesisAccountsFn(simulation.RandomGenesisAccounts),
|
||||
|
||||
// For providing a custom a base account type add it below.
|
||||
// By default the auth module uses authtypes.ProtoBaseAccount().
|
||||
//
|
||||
// func() authtypes.AccountI { return authtypes.ProtoBaseAccount() },
|
||||
|
||||
//
|
||||
// MINT
|
||||
//
|
||||
|
||||
// For providing a custom inflation function for x/mint add here your
|
||||
// custom function that implements the minttypes.InflationCalculationFn
|
||||
// interface.
|
||||
|
||||
// For providing a custom authority to a module simply add it below. By
|
||||
// default the governance module is the default authority.
|
||||
//
|
||||
// map[string]sdk.AccAddress{
|
||||
// minttypes.ModuleName: authtypes.NewModuleAddress(authtypes.ModuleName),
|
||||
// },
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
@ -140,6 +140,9 @@ var (
|
||||
Config: appconfig.WrapAny(&authmodulev1.Module{
|
||||
Bech32Prefix: "cosmos",
|
||||
ModuleAccountPermissions: moduleAccPerms,
|
||||
// By default modules authority is the governance module. This is configurable with the following:
|
||||
// Authority: "group", // A custom module authority can be set using a module name
|
||||
// Authority: "cosmos1cwwv22j5ca08ggdv9c2uky355k908694z577tv", // or a specific address
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
||||
@ -179,7 +179,7 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
@ -199,6 +199,9 @@ type AuthInputs struct {
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
|
||||
RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"`
|
||||
AccountI func() types.AccountI `optional:"true"`
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
LegacySubspace exported.Subspace `optional:"true"`
|
||||
}
|
||||
@ -216,8 +219,22 @@ func ProvideModule(in AuthInputs) AuthOutputs {
|
||||
maccPerms[permission.Account] = permission.Permissions
|
||||
}
|
||||
|
||||
k := keeper.NewAccountKeeper(in.Cdc, in.Key, types.ProtoBaseAccount, maccPerms, in.Config.Bech32Prefix, types.NewModuleAddress(govtypes.ModuleName).String())
|
||||
m := NewAppModule(in.Cdc, k, simulation.RandomGenesisAccounts, in.LegacySubspace)
|
||||
// default to governance authority if not provided
|
||||
authority := types.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = types.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
if in.RandomGenesisAccountsFn == nil {
|
||||
in.RandomGenesisAccountsFn = simulation.RandomGenesisAccounts
|
||||
}
|
||||
|
||||
if in.AccountI == nil {
|
||||
in.AccountI = types.ProtoBaseAccount
|
||||
}
|
||||
|
||||
k := keeper.NewAccountKeeper(in.Cdc, in.Key, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String())
|
||||
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn, in.LegacySubspace)
|
||||
|
||||
return AuthOutputs{AccountKeeper: k, Module: runtime.WrapAppModule(m)}
|
||||
}
|
||||
|
||||
@ -160,6 +160,17 @@ func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
|
||||
return unpacker.UnpackAny(acc.PubKey, &pubKey)
|
||||
}
|
||||
|
||||
// NewModuleAddressOrAddress gets an input string and returns an AccAddress.
|
||||
// If the input is a valid address, it returns the address.
|
||||
// If the input is a module name, it returns the module address.
|
||||
func NewModuleAddressOrBech32Address(input string) sdk.AccAddress {
|
||||
if addr, err := sdk.AccAddressFromBech32(input); err == nil {
|
||||
return addr
|
||||
}
|
||||
|
||||
return NewModuleAddress(input)
|
||||
}
|
||||
|
||||
// NewModuleAddress creates an AccAddress from the hash of the module's name
|
||||
func NewModuleAddress(name string) sdk.AccAddress {
|
||||
return sdk.AccAddress(crypto.AddressHash([]byte(name)))
|
||||
|
||||
@ -214,3 +214,9 @@ func TestGenesisAccountsContains(t *testing.T) {
|
||||
genAccounts = append(genAccounts, acc)
|
||||
require.True(t, genAccounts.Contains(acc.GetAddress()))
|
||||
}
|
||||
|
||||
func TestNewModuleAddressOrBech32Address(t *testing.T) {
|
||||
input := "cosmos1cwwv22j5ca08ggdv9c2uky355k908694z577tv"
|
||||
require.Equal(t, input, types.NewModuleAddressOrBech32Address(input).String())
|
||||
require.Equal(t, "cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl", types.NewModuleAddressOrBech32Address("distribution").String())
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMe
|
||||
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
|
||||
@ -192,7 +192,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
)
|
||||
}
|
||||
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
|
||||
func init() {
|
||||
appmodule.Register(&modulev1.Module{},
|
||||
@ -208,13 +208,11 @@ func ProvideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type BankInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Config *modulev1.Module
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
Config *modulev1.Module
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
LegacySubspace exported.Subspace `optional:"true"`
|
||||
@ -244,10 +242,10 @@ func ProvideModule(in BankInputs) BankOutputs {
|
||||
}
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
bankKeeper := keeper.NewBaseKeeper(
|
||||
|
||||
@ -170,7 +170,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
|
||||
@ -134,10 +134,9 @@ func ProvideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type ConsensusParamInputs struct {
|
||||
depinject.In
|
||||
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
Config *modulev1.Module
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
}
|
||||
|
||||
type ConsensusParamOutputs struct {
|
||||
@ -149,10 +148,10 @@ type ConsensusParamOutputs struct {
|
||||
}
|
||||
|
||||
func ProvideModule(in ConsensusParamInputs) ConsensusParamOutputs {
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.Key, authority.String())
|
||||
|
||||
@ -175,7 +175,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
|
||||
func init() {
|
||||
appmodule.Register(
|
||||
@ -187,12 +187,10 @@ func init() {
|
||||
type CrisisInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
AppOpts servertypes.AppOptions `optional:"true"`
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
AppOpts servertypes.AppOptions `optional:"true"`
|
||||
|
||||
BankKeeper types.SupplyKeeper
|
||||
|
||||
@ -222,10 +220,10 @@ func ProvideModule(in CrisisInputs) CrisisOutputs {
|
||||
feeCollectorName = authtypes.FeeCollectorName
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(
|
||||
|
||||
@ -196,7 +196,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
@ -212,11 +212,9 @@ func ProvideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type DistrInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
BankKeeper types.BankKeeper
|
||||
@ -240,10 +238,10 @@ func ProvideModule(in DistrInputs) DistrOutputs {
|
||||
feeCollectorName = authtypes.FeeCollectorName
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(
|
||||
|
||||
@ -185,7 +185,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
|
||||
@ -166,7 +166,6 @@ type GovInputs struct {
|
||||
Key *store.KVStoreKey
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
MsgServiceRouter *baseapp.MsgServiceRouter
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
|
||||
AccountKeeper govtypes.AccountKeeper
|
||||
BankKeeper govtypes.BankKeeper
|
||||
@ -190,9 +189,10 @@ func ProvideModule(in GovInputs) GovOutputs {
|
||||
kConfig.MaxMetadataLen = in.Config.MaxMetadataLen
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(
|
||||
|
||||
@ -148,6 +148,39 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ____________________________________________________________________________
|
||||
|
||||
// AppModuleSimulation functions
|
||||
|
||||
// GenerateGenesisState creates a randomized GenState of the group module.
|
||||
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
||||
simulation.RandomizedGenState(simState)
|
||||
}
|
||||
|
||||
// ProposalContents returns all the group content functions used to
|
||||
// simulate governance proposals.
|
||||
func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder registers a decoder for group module's types
|
||||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
sdr[group.StoreKey] = simulation.NewDecodeStore(am.cdc)
|
||||
}
|
||||
|
||||
// WeightedOperations returns the all the gov module operations with their respective weights.
|
||||
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
|
||||
return simulation.WeightedOperations(
|
||||
am.registry,
|
||||
simState.AppParams, simState.Cdc,
|
||||
am.accKeeper, am.bankKeeper, am.keeper, am.cdc,
|
||||
)
|
||||
}
|
||||
|
||||
//
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
appmodule.Register(
|
||||
&modulev1.Module{},
|
||||
@ -192,32 +225,3 @@ func ProvideModule(in GroupInputs) GroupOutputs {
|
||||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry)
|
||||
return GroupOutputs{GroupKeeper: k, Module: runtime.WrapAppModule(m)}
|
||||
}
|
||||
|
||||
// ____________________________________________________________________________
|
||||
|
||||
// AppModuleSimulation functions
|
||||
|
||||
// GenerateGenesisState creates a randomized GenState of the group module.
|
||||
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
||||
simulation.RandomizedGenState(simState)
|
||||
}
|
||||
|
||||
// ProposalContents returns all the group content functions used to
|
||||
// simulate governance proposals.
|
||||
func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder registers a decoder for group module's types
|
||||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
sdr[group.StoreKey] = simulation.NewDecodeStore(am.cdc)
|
||||
}
|
||||
|
||||
// WeightedOperations returns the all the gov module operations with their respective weights.
|
||||
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
|
||||
return simulation.WeightedOperations(
|
||||
am.registry,
|
||||
simState.AppParams, simState.Cdc,
|
||||
am.accKeeper, am.bankKeeper, am.keeper, am.cdc,
|
||||
)
|
||||
}
|
||||
|
||||
@ -197,9 +197,9 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte
|
||||
return nil
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// New App Wiring Setup
|
||||
// ============================================================================
|
||||
//
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
appmodule.Register(&modulev1.Module{},
|
||||
@ -218,7 +218,6 @@ type MintInputs struct {
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
InflationCalculationFn types.InflationCalculationFn `optional:"true"`
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
@ -242,10 +241,10 @@ func ProvideModule(in MintInputs) MintOutputs {
|
||||
feeCollectorName = authtypes.FeeCollectorName
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(
|
||||
|
||||
@ -173,7 +173,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
|
||||
@ -129,7 +129,7 @@ func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONCodec) json.RawMess
|
||||
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
@ -15,12 +14,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
slashingtestutil "github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
|
||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
slashingtestutil "github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
@ -52,10 +49,10 @@ func (s *KeeperTestSuite) SetupTest() {
|
||||
encCfg.Amino,
|
||||
key,
|
||||
s.stakingKeeper,
|
||||
sdk.AccAddress(crypto.AddressHash([]byte(govtypes.ModuleName))).String(),
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
// set test params
|
||||
s.slashingKeeper.SetParams(ctx, testutil.TestParams())
|
||||
s.slashingKeeper.SetParams(ctx, slashingtestutil.TestParams())
|
||||
|
||||
slashingtypes.RegisterInterfaces(encCfg.InterfaceRegistry)
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry)
|
||||
|
||||
@ -192,9 +192,9 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
)
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// New App Wiring Setup
|
||||
// ============================================================================
|
||||
//
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
appmodule.Register(
|
||||
@ -213,11 +213,10 @@ func ProvideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type SlashingInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
LegacyAmino *codec.LegacyAmino
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
BankKeeper types.BankKeeper
|
||||
@ -236,10 +235,10 @@ type SlashingOutputs struct {
|
||||
}
|
||||
|
||||
func ProvideModule(in SlashingInputs) SlashingOutputs {
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.Key, in.StakingKeeper, authority.String())
|
||||
|
||||
@ -205,8 +205,7 @@ type StakingInputs struct {
|
||||
BankKeeper types.BankKeeper
|
||||
Cdc codec.Codec
|
||||
Key *store.KVStoreKey
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
LegacySubspace exported.Subspace
|
||||
}
|
||||
@ -220,10 +219,10 @@ type StakingOutputs struct {
|
||||
}
|
||||
|
||||
func ProvideModule(in StakingInputs) StakingOutputs {
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
k := keeper.NewKeeper(
|
||||
|
||||
@ -139,7 +139,7 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
||||
}
|
||||
|
||||
//
|
||||
// New App Wiring Setup
|
||||
// App Wiring Setup
|
||||
//
|
||||
|
||||
func init() {
|
||||
@ -155,13 +155,11 @@ func ProvideModuleBasic() runtime.AppModuleBasicWrapper {
|
||||
type UpgradeInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleKey depinject.OwnModuleKey
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
Config *modulev1.Module
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
|
||||
AppOpts servertypes.AppOptions `optional:"true"`
|
||||
Authority map[string]sdk.AccAddress `optional:"true"`
|
||||
AppOpts servertypes.AppOptions `optional:"true"`
|
||||
}
|
||||
|
||||
type UpgradeOutputs struct {
|
||||
@ -186,10 +184,10 @@ func ProvideModule(in UpgradeInputs) UpgradeOutputs {
|
||||
homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome))
|
||||
}
|
||||
|
||||
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
|
||||
if !ok {
|
||||
// default to governance authority if not provided
|
||||
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
||||
if in.Config.Authority != "" {
|
||||
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
||||
}
|
||||
|
||||
// set the governance module account as the authority for conducting upgrades
|
||||
|
||||
Loading…
Reference in New Issue
Block a user