diff --git a/UPGRADING.md b/UPGRADING.md index fcd949e96e6b..3b4c55587b74 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -343,7 +343,7 @@ The return type of the interface method `TxConfig.SignModeHandler()` has been ch * `x/slashing` * `x/upgrade` -* BeginBlock and EndBlock have changed their signature, so it is important that any module implementing them are updated accordingly. +* `BeginBlock` and `EndBlock` have changed their signature, so it is important that any module implementing them are updated accordingly. ```diff - BeginBlock(sdk.Context, abci.RequestBeginBlock) @@ -355,18 +355,38 @@ The return type of the interface method `TxConfig.SignModeHandler()` has been ch + EndBlock(context.Context) error ``` -In case a module requires to return `abci.ValidatorUpdate` from `EndBlock`, it can use the `HasABCIEndblock` interface instead. +In case a module requires to return `abci.ValidatorUpdate` from `EndBlock`, it can use the `HasABCIEndBlock` interface instead. ```diff - EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate + EndBlock(context.Context) ([]abci.ValidatorUpdate, error) ``` -`GetSigners()` is no longer required to be implemented on `Msg` types. The SDK will automatically infer the signers from the `Signer` field on the message. The signer field is required on all messages unless using a custom signer function. +:::tip +It is possible to ensure that a module implements the correct interfaces by using compiler assertions in your `x/{moduleName}/module.go`: + +```go +var ( + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) + ... +) +``` + +Read more on those interfaces [here](https://docs.cosmos.network/v0.50/building-modules/module-manager#application-module-interfaces). +::: -To find out more please read the [signer field](./05-protobuf-annotations.md#signer) & [here](https://github.com/cosmos/cosmos-sdk/blob/7352d0bce8e72121e824297df453eb1059c28da8/docs/docs/build/building-modules/02-messages-and-queries.md#L40)documentation. +* `GetSigners()` is no longer required to be implemented on `Msg` types. The SDK will automatically infer the signers from the `Signer` field on the message. The signer field is required on all messages unless using a custom signer function. + +To find out more please read the [signer field](./05-protobuf-annotations.md#signer) & [here](https://github.com/cosmos/cosmos-sdk/blob/7352d0bce8e72121e824297df453eb1059c28da8/docs/docs/build/building-modules/02-messages-and-queries.md#L40) documentation. + #### `x/auth` For ante handler construction via `ante.NewAnteHandler`, the field `ante.HandlerOptions.SignModeHandler` has been updated to `x/tx/signing/HandlerMap` from `x/auth/signing/SignModeHandler`. Callers typically fetch this value from `client.TxConfig.SignModeHandler()` (which is also changed) so this change should be transparent to most users. diff --git a/docs/docs/build/building-modules/01-module-manager.md b/docs/docs/build/building-modules/01-module-manager.md index 7b0cc9974441..570a60c0b41e 100644 --- a/docs/docs/build/building-modules/01-module-manager.md +++ b/docs/docs/build/building-modules/01-module-manager.md @@ -42,7 +42,7 @@ The above interfaces are mostly embedding smaller interfaces (extension interfac * [`appmodule.HasPrecommit`](#hasprecommit): The extension interface that contains information about the `AppModule` and `Precommit`. * [`appmodule.HasPrepareCheckState`](#haspreparecheckstate): The extension interface that contains information about the `AppModule` and `PrepareCheckState`. * [`appmodule.HasService` / `module.HasServices`](#hasservices): The extension interface for modules to register services. -* [`module.HasABCIEndblock`](#hasabciendblock): The extension interface that contains information about the `AppModule`, `EndBlock` and returns an updated validator set. +* [`module.HasABCIEndBlock`](#hasabciendblock): The extension interface that contains information about the `AppModule`, `EndBlock` and returns an updated validator set. * (legacy) [`module.HasInvariants`](#hasinvariants): The extension interface for registering invariants. * (legacy) [`module.HasConsensusVersion`](#hasconsensusversion): The extension interface for declaring a module consensus version. @@ -198,7 +198,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/core/appmodule/module. ### `HasEndBlocker` -The `HasEndBlocker` is an extension interface from `appmodule.AppModule`. All modules that have an `EndBlock` method implement this interface. If a module need to return validator set updates (staking), they can use `HasABCIEndblock` +The `HasEndBlocker` is an extension interface from `appmodule.AppModule`. All modules that have an `EndBlock` method implement this interface. If a module need to return validator set updates (staking), they can use `HasABCIEndBlock` ```go reference https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/core/appmodule/module.go#L66-L72 @@ -206,9 +206,9 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/core/appmodule/module. * `EndBlock(context.Context) error`: This method gives module developers the option to implement logic that is automatically triggered at the end of each block. -### `HasABCIEndblock` +### `HasABCIEndBlock` -The `HasABCIEndblock` is an extension interface from `module.AppModule`. All modules that have an `EndBlock` which return validator set updates implement this interface. +The `HasABCIEndBlock` is an extension interface from `module.AppModule`. All modules that have an `EndBlock` which return validator set updates implement this interface. ```go reference https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L222-L225 @@ -309,7 +309,7 @@ The module manager is used throughout the application whenever an action on a co * `ExportGenesisForModules(ctx context.Context, cdc codec.JSONCodec, modulesToExport []string)`: Behaves the same as `ExportGenesis`, except takes a list of modules to export. * `BeginBlock(ctx context.Context) error`: At the beginning of each block, this function is called from [`BaseApp`](../../develop/advanced/00-baseapp.md#beginblock) and, in turn, calls the [`BeginBlock`](./05-beginblock-endblock.md) function of each modules implementing the `appmodule.HasBeginBlocker` interface, in the order defined in `OrderBeginBlockers`. It creates a child [context](../../develop/advanced/02-context.md) with an event manager to aggregate [events](../../develop/advanced/08-events.md) emitted from each modules. * `EndBlock(ctx context.Context) error`: At the end of each block, this function is called from [`BaseApp`](../../develop/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./05-beginblock-endblock.md) function of each modules implementing the `appmodule.HasEndBlocker` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../develop/advanced/02-context.md) with an event manager to aggregate [events](../../develop/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any). -* `EndBlock(context.Context) ([]abci.ValidatorUpdate, error)`: At the end of each block, this function is called from [`BaseApp`](../../develop/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./05-beginblock-endblock.md) function of each modules implementing the `module.HasABCIEndblock` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../develop/advanced/02-context.md) with an event manager to aggregate [events](../../develop/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any). +* `EndBlock(context.Context) ([]abci.ValidatorUpdate, error)`: At the end of each block, this function is called from [`BaseApp`](../../develop/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./05-beginblock-endblock.md) function of each modules implementing the `module.HasABCIEndBlock` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../develop/advanced/02-context.md) with an event manager to aggregate [events](../../develop/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any). * `Precommit(ctx context.Context)`: During [`Commit`](../../develop/advanced/00-baseapp.md#commit), this function is called from `BaseApp` immediately before the [`deliverState`](../../develop/advanced/00-baseapp.md#state-updates) is written to the underlying [`rootMultiStore`](../../develop/advanced/04-store.md#commitmultistore) and, in turn calls the `Precommit` function of each modules implementing the `HasPrecommit` interface, in the order defined in `OrderPrecommiters`. It creates a child [context](../../develop/advanced/02-context.md) where the underlying `CacheMultiStore` is that of the newly committed block's [`finalizeblockstate`](../../develop/advanced/00-baseapp.md#state-updates). * `PrepareCheckState(ctx context.Context)`: During [`Commit`](../../develop/advanced/00-baseapp.md#commit), this function is called from `BaseApp` immediately after the [`deliverState`](../../develop/advanced/00-baseapp.md#state-updates) is written to the underlying [`rootMultiStore`](../../develop/advanced/04-store.md#commitmultistore) and, in turn calls the `PrepareCheckState` function of each module implementing the `HasPrepareCheckState` interface, in the order defined in `OrderPrepareCheckStaters`. It creates a child [context](../../develop/advanced/02-context.md) where the underlying `CacheMultiStore` is that of the next block's [`checkState`](../../develop/advanced/00-baseapp.md#state-updates). Writes to this state will be present in the [`checkState`](../../develop/advanced/00-baseapp.md#state-updates) of the next block, and therefore this method can be used to prepare the `checkState` for the next block. diff --git a/docs/docs/build/building-modules/06-beginblock-endblock.md b/docs/docs/build/building-modules/06-beginblock-endblock.md index 9472b0b759eb..35b5bb350b2e 100644 --- a/docs/docs/build/building-modules/06-beginblock-endblock.md +++ b/docs/docs/build/building-modules/06-beginblock-endblock.md @@ -20,7 +20,7 @@ sidebar_position: 1 In 0.47.0, Prepare and Process Proposal were added that allow app developers to do arbitrary work at those phases, but they do not influence the work that will be done in BeginBlock. If an application required `BeginBlock` to execute prior to any sort of work is done then this is not possible today (0.50.0). -When needed, `BeginBlocker` and `EndBlocker` are implemented as part of the [`HasBeginBlocker`, `HasABCIEndblocker` and `EndBlocker` interfaces](./01-module-manager.md#appmodule). This means either can be left-out if not required. The `BeginBlock` and `EndBlock` methods of the interface implemented in `module.go` generally defer to `BeginBlocker` and `EndBlocker` methods respectively, which are usually implemented in `abci.go`. +When needed, `BeginBlocker` and `EndBlocker` are implemented as part of the [`HasBeginBlocker`, `HasABCIEndBlocker` and `EndBlocker` interfaces](./01-module-manager.md#appmodule). This means either can be left-out if not required. The `BeginBlock` and `EndBlock` methods of the interface implemented in `module.go` generally defer to `BeginBlocker` and `EndBlocker` methods respectively, which are usually implemented in `abci.go`. The actual implementation of `BeginBlocker` and `EndBlocker` in `abci.go` are very similar to that of a [`Msg` service](./03-msg-services.md): diff --git a/testutil/mock/types_mock_appmodule.go b/testutil/mock/types_mock_appmodule.go index c1d22f377963..48cc6f49a35a 100644 --- a/testutil/mock/types_mock_appmodule.go +++ b/testutil/mock/types_mock_appmodule.go @@ -541,35 +541,125 @@ func (mr *MockCoreAppModuleMockRecorder) ValidateGenesis(arg0 interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockCoreAppModule)(nil).ValidateGenesis), arg0) } -// MockCoreModuleWithPreBlock is a mock of CoreModuleWithPreBlock interface. -type MockCoreModuleWithPreBlock struct { - MockCoreAppModule - recorder *MockCoreModuleWithPreBlockMockRecorder +// MockCoreAppModuleWithPreBlock is a mock of CoreAppModuleWithPreBlock interface. +type MockCoreAppModuleWithPreBlock struct { + ctrl *gomock.Controller + recorder *MockCoreAppModuleWithPreBlockMockRecorder } -// MockCoreModuleWithPreBlockMockRecorder is the mock recorder for MockCoreModuleWithPreBlock. -type MockCoreModuleWithPreBlockMockRecorder struct { - mock *MockCoreModuleWithPreBlock +// MockCoreAppModuleWithPreBlockMockRecorder is the mock recorder for MockCoreAppModuleWithPreBlock. +type MockCoreAppModuleWithPreBlockMockRecorder struct { + mock *MockCoreAppModuleWithPreBlock } -// NewMockCoreModuleWithPreBlock creates a new mock instance. -func NewMockCoreModuleWithPreBlock(ctrl *gomock.Controller) *MockCoreModuleWithPreBlock { - mock := &MockCoreModuleWithPreBlock{ - MockCoreAppModule: MockCoreAppModule{ - ctrl: ctrl, - }, - } - mock.recorder = &MockCoreModuleWithPreBlockMockRecorder{mock} +// NewMockCoreAppModuleWithPreBlock creates a new mock instance. +func NewMockCoreAppModuleWithPreBlock(ctrl *gomock.Controller) *MockCoreAppModuleWithPreBlock { + mock := &MockCoreAppModuleWithPreBlock{ctrl: ctrl} + mock.recorder = &MockCoreAppModuleWithPreBlockMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCoreModuleWithPreBlock) EXPECT() *MockCoreModuleWithPreBlockMockRecorder { +func (m *MockCoreAppModuleWithPreBlock) EXPECT() *MockCoreAppModuleWithPreBlockMockRecorder { return m.recorder } +// BeginBlock mocks base method. +func (m *MockCoreAppModuleWithPreBlock) BeginBlock(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BeginBlock", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// BeginBlock indicates an expected call of BeginBlock. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) BeginBlock(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeginBlock", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).BeginBlock), arg0) +} + +// DefaultGenesis mocks base method. +func (m *MockCoreAppModuleWithPreBlock) DefaultGenesis(arg0 appmodule.GenesisTarget) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DefaultGenesis", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// DefaultGenesis indicates an expected call of DefaultGenesis. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) DefaultGenesis(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultGenesis", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).DefaultGenesis), arg0) +} + +// EndBlock mocks base method. +func (m *MockCoreAppModuleWithPreBlock) EndBlock(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EndBlock", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// EndBlock indicates an expected call of EndBlock. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) EndBlock(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlock", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).EndBlock), arg0) +} + +// ExportGenesis mocks base method. +func (m *MockCoreAppModuleWithPreBlock) ExportGenesis(arg0 context.Context, arg1 appmodule.GenesisTarget) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// ExportGenesis indicates an expected call of ExportGenesis. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) ExportGenesis(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportGenesis", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).ExportGenesis), arg0, arg1) +} + +// InitGenesis mocks base method. +func (m *MockCoreAppModuleWithPreBlock) InitGenesis(arg0 context.Context, arg1 appmodule.GenesisSource) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// InitGenesis indicates an expected call of InitGenesis. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) InitGenesis(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).InitGenesis), arg0, arg1) +} + +// IsAppModule mocks base method. +func (m *MockCoreAppModuleWithPreBlock) IsAppModule() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IsAppModule") +} + +// IsAppModule indicates an expected call of IsAppModule. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) IsAppModule() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAppModule", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).IsAppModule)) +} + +// IsOnePerModuleType mocks base method. +func (m *MockCoreAppModuleWithPreBlock) IsOnePerModuleType() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IsOnePerModuleType") +} + +// IsOnePerModuleType indicates an expected call of IsOnePerModuleType. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) IsOnePerModuleType() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOnePerModuleType", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).IsOnePerModuleType)) +} + // PreBlock mocks base method. -func (m *MockCoreModuleWithPreBlock) PreBlock(arg0 context.Context) (appmodule.ResponsePreBlock, error) { +func (m *MockCoreAppModuleWithPreBlock) PreBlock(arg0 context.Context) (appmodule.ResponsePreBlock, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PreBlock", arg0) ret0, _ := ret[0].(appmodule.ResponsePreBlock) @@ -578,7 +668,49 @@ func (m *MockCoreModuleWithPreBlock) PreBlock(arg0 context.Context) (appmodule.R } // PreBlock indicates an expected call of PreBlock. -func (mr *MockCoreModuleWithPreBlockMockRecorder) PreBlock(arg0 interface{}) *gomock.Call { +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) PreBlock(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PreBlock", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).PreBlock), arg0) +} + +// Precommit mocks base method. +func (m *MockCoreAppModuleWithPreBlock) Precommit(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Precommit", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Precommit indicates an expected call of Precommit. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) Precommit(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Precommit", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).Precommit), arg0) +} + +// PrepareCheckState mocks base method. +func (m *MockCoreAppModuleWithPreBlock) PrepareCheckState(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PrepareCheckState", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// PrepareCheckState indicates an expected call of PrepareCheckState. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) PrepareCheckState(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareCheckState", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).PrepareCheckState), arg0) +} + +// ValidateGenesis mocks base method. +func (m *MockCoreAppModuleWithPreBlock) ValidateGenesis(arg0 appmodule.GenesisSource) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ValidateGenesis", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// ValidateGenesis indicates an expected call of ValidateGenesis. +func (mr *MockCoreAppModuleWithPreBlockMockRecorder) ValidateGenesis(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PreBlock", reflect.TypeOf((*MockCoreModuleWithPreBlock)(nil).PreBlock), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockCoreAppModuleWithPreBlock)(nil).ValidateGenesis), arg0) } diff --git a/testutil/mock/types_module_module.go b/testutil/mock/types_module_module.go index 9859d1212b32..186cd4d7ca7f 100644 --- a/testutil/mock/types_module_module.go +++ b/testutil/mock/types_module_module.go @@ -516,31 +516,31 @@ func (mr *MockHasConsensusVersionMockRecorder) ConsensusVersion() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsensusVersion", reflect.TypeOf((*MockHasConsensusVersion)(nil).ConsensusVersion)) } -// MockHasABCIEndblock is a mock of HasABCIEndblock interface. -type MockHasABCIEndblock struct { +// MockHasABCIEndBlock is a mock of HasABCIEndBlock interface. +type MockHasABCIEndBlock struct { ctrl *gomock.Controller - recorder *MockHasABCIEndblockMockRecorder + recorder *MockHasABCIEndBlockMockRecorder } -// MockHasABCIEndblockMockRecorder is the mock recorder for MockHasABCIEndblock. -type MockHasABCIEndblockMockRecorder struct { - mock *MockHasABCIEndblock +// MockHasABCIEndBlockMockRecorder is the mock recorder for MockHasABCIEndBlock. +type MockHasABCIEndBlockMockRecorder struct { + mock *MockHasABCIEndBlock } -// NewMockHasABCIEndblock creates a new mock instance. -func NewMockHasABCIEndblock(ctrl *gomock.Controller) *MockHasABCIEndblock { - mock := &MockHasABCIEndblock{ctrl: ctrl} - mock.recorder = &MockHasABCIEndblockMockRecorder{mock} +// NewMockHasABCIEndBlock creates a new mock instance. +func NewMockHasABCIEndBlock(ctrl *gomock.Controller) *MockHasABCIEndBlock { + mock := &MockHasABCIEndBlock{ctrl: ctrl} + mock.recorder = &MockHasABCIEndBlockMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHasABCIEndblock) EXPECT() *MockHasABCIEndblockMockRecorder { +func (m *MockHasABCIEndBlock) EXPECT() *MockHasABCIEndBlockMockRecorder { return m.recorder } // EndBlock mocks base method. -func (m *MockHasABCIEndblock) EndBlock(arg0 context.Context) ([]types.ValidatorUpdate, error) { +func (m *MockHasABCIEndBlock) EndBlock(arg0 context.Context) ([]types.ValidatorUpdate, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EndBlock", arg0) ret0, _ := ret[0].([]types.ValidatorUpdate) @@ -549,13 +549,13 @@ func (m *MockHasABCIEndblock) EndBlock(arg0 context.Context) ([]types.ValidatorU } // EndBlock indicates an expected call of EndBlock. -func (mr *MockHasABCIEndblockMockRecorder) EndBlock(arg0 interface{}) *gomock.Call { +func (mr *MockHasABCIEndBlockMockRecorder) EndBlock(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlock", reflect.TypeOf((*MockHasABCIEndblock)(nil).EndBlock), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlock", reflect.TypeOf((*MockHasABCIEndBlock)(nil).EndBlock), arg0) } // Name mocks base method. -func (m *MockHasABCIEndblock) Name() string { +func (m *MockHasABCIEndBlock) Name() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Name") ret0, _ := ret[0].(string) @@ -563,45 +563,45 @@ func (m *MockHasABCIEndblock) Name() string { } // Name indicates an expected call of Name. -func (mr *MockHasABCIEndblockMockRecorder) Name() *gomock.Call { +func (mr *MockHasABCIEndBlockMockRecorder) Name() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasABCIEndblock)(nil).Name)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasABCIEndBlock)(nil).Name)) } // RegisterGRPCGatewayRoutes mocks base method. -func (m *MockHasABCIEndblock) RegisterGRPCGatewayRoutes(arg0 client.Context, arg1 *runtime.ServeMux) { +func (m *MockHasABCIEndBlock) RegisterGRPCGatewayRoutes(arg0 client.Context, arg1 *runtime.ServeMux) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterGRPCGatewayRoutes", arg0, arg1) } // RegisterGRPCGatewayRoutes indicates an expected call of RegisterGRPCGatewayRoutes. -func (mr *MockHasABCIEndblockMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHasABCIEndBlockMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterGRPCGatewayRoutes", reflect.TypeOf((*MockHasABCIEndblock)(nil).RegisterGRPCGatewayRoutes), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterGRPCGatewayRoutes", reflect.TypeOf((*MockHasABCIEndBlock)(nil).RegisterGRPCGatewayRoutes), arg0, arg1) } // RegisterInterfaces mocks base method. -func (m *MockHasABCIEndblock) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockHasABCIEndBlock) RegisterInterfaces(arg0 types0.InterfaceRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } // RegisterInterfaces indicates an expected call of RegisterInterfaces. -func (mr *MockHasABCIEndblockMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call { +func (mr *MockHasABCIEndBlockMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockHasABCIEndblock)(nil).RegisterInterfaces), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockHasABCIEndBlock)(nil).RegisterInterfaces), arg0) } // RegisterLegacyAminoCodec mocks base method. -func (m *MockHasABCIEndblock) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) { +func (m *MockHasABCIEndBlock) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterLegacyAminoCodec", arg0) } // RegisterLegacyAminoCodec indicates an expected call of RegisterLegacyAminoCodec. -func (mr *MockHasABCIEndblockMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) *gomock.Call { +func (mr *MockHasABCIEndBlockMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockHasABCIEndblock)(nil).RegisterLegacyAminoCodec), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockHasABCIEndBlock)(nil).RegisterLegacyAminoCodec), arg0) } // MockgenesisOnlyModule is a mock of genesisOnlyModule interface. diff --git a/types/module/mock_appmodule_test.go b/types/module/mock_appmodule_test.go index 27049cf54000..07c9c6389f51 100644 --- a/types/module/mock_appmodule_test.go +++ b/types/module/mock_appmodule_test.go @@ -14,7 +14,7 @@ type AppModuleWithAllExtensions interface { module.HasGenesis module.HasInvariants module.HasConsensusVersion - module.HasABCIEndblock + module.HasABCIEndBlock module.HasName } @@ -25,7 +25,7 @@ type AppModuleWithAllExtensionsABCI interface { module.HasABCIGenesis module.HasInvariants module.HasConsensusVersion - module.HasABCIEndblock + module.HasABCIEndBlock module.HasName } @@ -39,3 +39,8 @@ type CoreAppModule interface { appmodule.HasPrecommit appmodule.HasPrepareCheckState } + +type CoreAppModuleWithPreBlock interface { + CoreAppModule + appmodule.HasPreBlocker +} diff --git a/types/module/module.go b/types/module/module.go index 086e281a7cf6..a3c7b2ed62f0 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -197,6 +197,7 @@ type HasABCIGenesis interface { // AppModule is the form for an application module. Most of // its functionality has been moved to extension interfaces. +// Deprecated: use appmodule.AppModule with a combination of extension interfaes interfaces instead. type AppModule interface { AppModuleBasic } @@ -222,7 +223,12 @@ type HasConsensusVersion interface { ConsensusVersion() uint64 } -type HasABCIEndblock interface { +// HasABCIEndblock is a released typo of HasABCIEndBlock. +// Deprecated: use HasABCIEndBlock instead. +type HasABCIEndblock HasABCIEndBlock + +// HasABCIEndBlock is the interface for modules that need to run code at the end of the block. +type HasABCIEndBlock interface { AppModule EndBlock(context.Context) ([]abci.ValidatorUpdate, error) } @@ -397,7 +403,7 @@ func (m *Manager) SetOrderEndBlockers(moduleNames ...string) { return !hasEndBlock } - _, hasABCIEndBlock := module.(HasABCIEndblock) + _, hasABCIEndBlock := module.(HasABCIEndBlock) return !hasABCIEndBlock }) m.OrderEndBlockers = moduleNames @@ -788,7 +794,7 @@ func (m *Manager) EndBlock(ctx sdk.Context) (sdk.EndBlock, error) { if err != nil { return sdk.EndBlock{}, err } - } else if module, ok := m.Modules[moduleName].(HasABCIEndblock); ok { + } else if module, ok := m.Modules[moduleName].(HasABCIEndBlock); ok { moduleValUpdates, err := module.EndBlock(ctx) if err != nil { return sdk.EndBlock{}, err diff --git a/types/module/module_test.go b/types/module/module_test.go index bd5111a6692b..2a348667eb3a 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -95,7 +95,7 @@ func TestBasicManager(t *testing.T) { func TestAssertNoForgottenModules(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) - mockAppModule1 := mock.NewMockHasABCIEndblock(mockCtrl) + mockAppModule1 := mock.NewMockHasABCIEndBlock(mockCtrl) mockAppModule3 := mock.NewMockCoreAppModule(mockCtrl) mockAppModule1.EXPECT().Name().Times(2).Return("module1") @@ -320,8 +320,8 @@ func TestManager_EndBlock(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) - mockAppModule1 := mock.NewMockHasABCIEndblock(mockCtrl) - mockAppModule2 := mock.NewMockHasABCIEndblock(mockCtrl) + mockAppModule1 := mock.NewMockHasABCIEndBlock(mockCtrl) + mockAppModule2 := mock.NewMockHasABCIEndBlock(mockCtrl) mockAppModule3 := mock.NewMockAppModule(mockCtrl) mockAppModule1.EXPECT().Name().Times(2).Return("module1") mockAppModule2.EXPECT().Name().Times(2).Return("module2") @@ -473,7 +473,7 @@ func TestCoreAPIManager_PreBlock(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) - mockAppModule1 := mock.NewMockCoreModuleWithPreBlock(mockCtrl) + mockAppModule1 := mock.NewMockCoreAppModuleWithPreBlock(mockCtrl) mm := module.NewManagerFromMap(map[string]appmodule.AppModule{ "module1": mockAppModule1, "module2": mock.NewMockCoreAppModule(mockCtrl), diff --git a/x/auth/module.go b/x/auth/module.go index ae942a774e5c..52e9b93cac85 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" - abci "github.com/cometbft/cometbft/abci/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" @@ -33,9 +32,12 @@ const ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the auth module. @@ -92,8 +94,6 @@ type AppModule struct { legacySubspace exported.Subspace } -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -110,11 +110,6 @@ func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAc } } -// Name returns the auth module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { @@ -141,11 +136,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs genesis initialization for the auth module. It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) am.accountKeeper.InitGenesis(ctx, genesisState) - return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the auth diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 98a411c01105..139efb1af0de 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -24,8 +24,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasServices = AppModule{} ) // AppModuleBasic defines the basic application module used by the sub-vesting @@ -87,11 +89,6 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} diff --git a/x/authz/module/module.go b/x/authz/module/module.go index a933d4fa7d91..248a75b8584b 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -29,8 +29,13 @@ import ( ) var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the authz module. @@ -97,6 +102,7 @@ func (ab AppModuleBasic) GetTxCmd() *cobra.Command { // AppModule implements the sdk.AppModule interface type AppModule struct { AppModuleBasic + keeper keeper.Keeper accountKeeper authz.AccountKeeper bankKeeper authz.BankKeeper @@ -114,23 +120,12 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak authz.AccountKeeper, } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the authz module's name. -func (AppModule) Name() string { - return authz.ModuleName -} - // InitGenesis performs genesis initialization for the authz module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { diff --git a/x/bank/module.go b/x/bank/module.go index 2a1fc8105321..4de21846524b 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -36,10 +36,13 @@ import ( const ConsensusVersion = 4 var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the bank module. @@ -103,8 +106,6 @@ type AppModule struct { legacySubspace exported.Subspace } -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -140,9 +141,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.Acc } } -// Name returns the bank module's name. -func (AppModule) Name() string { return types.ModuleName } - // RegisterInvariants registers the bank module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) diff --git a/x/circuit/module.go b/x/circuit/module.go index 182e81737692..dd49a874e7ce 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -33,8 +33,11 @@ import ( const ConsensusVersion = 1 var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the circuit module. @@ -90,8 +93,6 @@ type AppModule struct { keeper keeper.Keeper } -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} diff --git a/x/consensus/module.go b/x/consensus/module.go index 3a962b5b12b3..4df4c60ba3d2 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -27,8 +27,10 @@ import ( const ConsensusVersion = 1 var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasServices = AppModule{} ) // AppModuleBasic defines the basic application module used by the consensus module. @@ -63,11 +65,6 @@ type AppModule struct { keeper keeper.Keeper } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -89,9 +86,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { } } -// Name returns the consensus module's name. -func (AppModule) Name() string { return types.ModuleName } - // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } diff --git a/x/crisis/module.go b/x/crisis/module.go index a40698d8a6cb..87bb60efa273 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -35,7 +35,14 @@ import ( // ConsensusVersion defines the current x/crisis module consensus version. const ConsensusVersion = 2 -var _ module.AppModuleBasic = AppModuleBasic{} +var ( + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} +) // Module init related flags const ( @@ -114,12 +121,6 @@ func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool, ss exported } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -131,11 +132,6 @@ func AddModuleInitFlags(startCmd *cobra.Command) { startCmd.Flags().Bool(FlagSkipGenesisInvariants, false, "Skip x/crisis invariants check on startup") } -// Name returns the crisis module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) diff --git a/x/distribution/module.go b/x/distribution/module.go index 4fb70658a94a..533a54fbbe4c 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -33,8 +33,14 @@ import ( const ConsensusVersion = 4 var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the distribution module. @@ -114,23 +120,12 @@ func NewAppModule( } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the distribution module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterInvariants registers the distribution module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) diff --git a/x/evidence/module.go b/x/evidence/module.go index 12a24b75cb02..d9bb011ba57c 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -30,8 +30,13 @@ import ( ) var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // ---------------------------------------------------------------------------- @@ -117,24 +122,12 @@ func NewAppModule(keeper keeper.Keeper) AppModule { } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the evidence module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { types.RegisterMsgServer(registrar, keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 287daa903f60..82103c7a81cd 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -28,8 +28,13 @@ import ( ) var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasGenesis = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} ) // ---------------------------------------------------------------------------- @@ -104,6 +109,7 @@ func (ab AppModuleBasic) GetTxCmd() *cobra.Command { // AppModule implements an application module for the feegrant module. type AppModule struct { AppModuleBasic + keeper keeper.Keeper accountKeeper feegrant.AccountKeeper bankKeeper feegrant.BankKeeper @@ -121,23 +127,12 @@ func NewAppModule(cdc codec.Codec, ak feegrant.AccountKeeper, bk feegrant.BankKe } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the feegrant module's name. -func (AppModule) Name() string { - return feegrant.ModuleName -} - // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) { diff --git a/x/genutil/module.go b/x/genutil/module.go index 11d613d3c7c3..5d3337ba24ab 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -21,8 +21,10 @@ import ( ) var ( + _ module.AppModuleBasic = AppModule{} _ module.HasABCIGenesis = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the genutil module. @@ -91,8 +93,6 @@ func NewAppModule(accountKeeper types.AccountKeeper, }) } -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (AppModule) IsOnePerModuleType() {} diff --git a/x/gov/module.go b/x/gov/module.go index 0309564f466a..a30b718ca1e2 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -42,6 +42,11 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the gov module. @@ -148,11 +153,6 @@ func NewAppModule( } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -267,11 +267,6 @@ func InvokeSetHooks(keeper *keeper.Keeper, govHooks map[string]govtypes.GovHooks return nil } -// Name returns the gov module's name. -func (AppModule) Name() string { - return govtypes.ModuleName -} - // RegisterInvariants registers module invariants func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper, am.bankKeeper) diff --git a/x/group/module/module.go b/x/group/module/module.go index 46bfa2a583c0..889d22ab1787 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -31,8 +31,14 @@ import ( const ConsensusVersion = 2 var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} ) type AppModule struct { @@ -54,12 +60,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak group.AccountKeeper, } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -113,11 +113,6 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { group.RegisterLegacyAminoCodec(cdc) } -// Name returns the group module's name. -func (AppModule) Name() string { - return group.ModuleName -} - // RegisterInvariants does nothing, there are no invariants to enforce func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) diff --git a/x/mint/module.go b/x/mint/module.go index 6eeb04e9e387..5a90a517b1c3 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -29,8 +29,13 @@ import ( const ConsensusVersion = 2 var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the mint module. @@ -38,8 +43,6 @@ type AppModuleBasic struct { cdc codec.Codec } -var _ module.AppModuleBasic = AppModuleBasic{} - // Name returns the mint module's name. func (AppModuleBasic) Name() string { return types.ModuleName @@ -115,23 +118,12 @@ func NewAppModule( } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the mint module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 5f75d0ff08fd..9338870b0dbd 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -28,9 +28,12 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasServices = AppModule{} ) // AppModuleBasic defines the basic application module used by the nft module. @@ -109,23 +112,12 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak nft.AccountKeeper, b } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the nft module's name. -func (AppModule) Name() string { - return nft.ModuleName -} - // InitGenesis performs genesis initialization for the nft module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { diff --git a/x/params/module.go b/x/params/module.go index ada51ae1e7dd..8dfe121bea9b 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -22,9 +22,11 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // ConsensusVersion defines the current x/params module consensus version. @@ -69,8 +71,6 @@ func NewAppModule(k keeper.Keeper) AppModule { } } -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} diff --git a/x/slashing/module.go b/x/slashing/module.go index 8d8af2e505bb..93a954835c7f 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -33,8 +33,13 @@ import ( const ConsensusVersion = 4 var ( - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the slashing module. @@ -42,8 +47,6 @@ type AppModuleBasic struct { cdc codec.Codec } -var _ module.AppModuleBasic = AppModuleBasic{} - // Name returns the slashing module's name. func (AppModuleBasic) Name() string { return types.ModuleName @@ -122,23 +125,12 @@ func NewAppModule( } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the slashing module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/staking/module.go b/x/staking/module.go index 1e0809cf1d3e..196114037ca7 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -36,11 +36,15 @@ const ( ) var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ module.HasABCIEndblock = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + _ module.HasABCIGenesis = AppModule{} + _ module.HasABCIEndBlock = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the staking module. @@ -49,8 +53,6 @@ type AppModuleBasic struct { ak types.AccountKeeper } -var _ module.AppModuleBasic = AppModuleBasic{} - // Name returns the staking module's name. func (AppModuleBasic) Name() string { return types.ModuleName @@ -123,22 +125,12 @@ func NewAppModule( } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -// Name returns the staking module's name. -func (AppModule) Name() string { - return types.ModuleName -} - // RegisterInvariants registers the staking module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 7d73cfc2e80e..d96566f3d242 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -38,7 +38,14 @@ func init() { // ConsensusVersion defines the current x/upgrade module consensus version. const ConsensusVersion uint64 = 3 -var _ module.AppModuleBasic = AppModuleBasic{} +var ( + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasPreBlocker = AppModule{} +) // AppModuleBasic implements the sdk.AppModuleBasic interface type AppModuleBasic struct { @@ -86,12 +93,6 @@ func NewAppModule(keeper *keeper.Keeper, ac address.Codec) AppModule { } } -var ( - _ appmodule.AppModule = AppModule{} - _ appmodule.HasPreBlocker = AppModule{} - _ module.HasGenesis = AppModule{} -) - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {}