From 1538e65478d83d743d6887cddfde805f79debf78 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Thu, 23 Jul 2020 22:45:34 -0400 Subject: [PATCH] Fix module interface registration (#6834) --- CHANGELOG.md | 1 + simapp/encoding.go | 2 +- tests/mocks/tendermint_tm_db_DB.go | 14 +++--- tests/mocks/types_module_module.go | 69 +++++++++++++++++++++++------- types/module/interface_module.go | 24 ----------- types/module/module.go | 9 ++++ types/module/module_test.go | 5 +++ x/auth/module.go | 5 +-- x/bank/module.go | 5 +-- x/capability/module.go | 5 +++ x/crisis/module.go | 4 +- x/distribution/module.go | 5 +-- x/evidence/module.go | 3 +- x/genutil/module.go | 4 ++ x/gov/module.go | 5 +-- x/ibc-transfer/module.go | 4 +- x/ibc/module.go | 4 +- x/mint/module.go | 4 ++ x/params/module.go | 3 +- x/slashing/module.go | 6 +++ x/slashing/types/codec.go | 7 +++ x/staking/module.go | 6 +++ x/staking/types/codec.go | 12 ++++++ x/upgrade/module.go | 7 ++- 24 files changed, 139 insertions(+), 74 deletions(-) delete mode 100644 types/module/interface_module.go diff --git a/CHANGELOG.md b/CHANGELOG.md index cdd6b20307..ff4b4cad4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -151,6 +151,7 @@ be used to retrieve the actual proposal `Content`. Also the `NewMsgSubmitProposa * The `SigVerifiableTx` interface now has a `GetSignaturesV2() ([]signing.SignatureV2, error)` method and no longer has the `GetSignBytes` method. * (client/flags) [\#6632](https://github.com/cosmos/cosmos-sdk/pull/6632) Remove NewCompletionCmd(), the function is now available in tendermint. * (crypto) [\#6780](https://github.com/cosmos/cosmos-sdk/issues/6780) Move ledger code to its own package. +* (modules) [\#6834](https://github.com/cosmos/cosmos-sdk/issues/6834) Add `RegisterInterfaces` method to `AppModuleBasic` to support registration of protobuf interface types. ### Features diff --git a/simapp/encoding.go b/simapp/encoding.go index 7bb939bb77..120d1e7438 100644 --- a/simapp/encoding.go +++ b/simapp/encoding.go @@ -11,6 +11,6 @@ func MakeEncodingConfig() params.EncodingConfig { std.RegisterCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) ModuleBasics.RegisterCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaceModules(encodingConfig.InterfaceRegistry) + ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } diff --git a/tests/mocks/tendermint_tm_db_DB.go b/tests/mocks/tendermint_tm_db_DB.go index bed59a498d..cdf5e5ab0a 100644 --- a/tests/mocks/tendermint_tm_db_DB.go +++ b/tests/mocks/tendermint_tm_db_DB.go @@ -6,7 +6,7 @@ package mocks import ( gomock "github.com/golang/mock/gomock" - tm_db "github.com/tendermint/tm-db" + db "github.com/tendermint/tm-db" reflect "reflect" ) @@ -106,10 +106,10 @@ func (mr *MockDBMockRecorder) Has(arg0 interface{}) *gomock.Call { } // Iterator mocks base method -func (m *MockDB) Iterator(arg0, arg1 []byte) (tm_db.Iterator, error) { +func (m *MockDB) Iterator(arg0, arg1 []byte) (db.Iterator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Iterator", arg0, arg1) - ret0, _ := ret[0].(tm_db.Iterator) + ret0, _ := ret[0].(db.Iterator) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -121,10 +121,10 @@ func (mr *MockDBMockRecorder) Iterator(arg0, arg1 interface{}) *gomock.Call { } // NewBatch mocks base method -func (m *MockDB) NewBatch() tm_db.Batch { +func (m *MockDB) NewBatch() db.Batch { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewBatch") - ret0, _ := ret[0].(tm_db.Batch) + ret0, _ := ret[0].(db.Batch) return ret0 } @@ -149,10 +149,10 @@ func (mr *MockDBMockRecorder) Print() *gomock.Call { } // ReverseIterator mocks base method -func (m *MockDB) ReverseIterator(arg0, arg1 []byte) (tm_db.Iterator, error) { +func (m *MockDB) ReverseIterator(arg0, arg1 []byte) (db.Iterator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReverseIterator", arg0, arg1) - ret0, _ := ret[0].(tm_db.Iterator) + ret0, _ := ret[0].(db.Iterator) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index d9ec3980b9..947b750d94 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -8,12 +8,13 @@ import ( json "encoding/json" client "github.com/cosmos/cosmos-sdk/client" codec "github.com/cosmos/cosmos-sdk/codec" - types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/codec/types" + types0 "github.com/cosmos/cosmos-sdk/types" grpc "github.com/gogo/protobuf/grpc" gomock "github.com/golang/mock/gomock" mux "github.com/gorilla/mux" cobra "github.com/spf13/cobra" - types0 "github.com/tendermint/tendermint/abci/types" + types1 "github.com/tendermint/tendermint/abci/types" reflect "reflect" ) @@ -66,6 +67,18 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterCodec(arg0 interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterCodec), arg0) } +// RegisterInterfaces mocks base method +func (m *MockAppModuleBasic) RegisterInterfaces(arg0 types.InterfaceRegistry) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RegisterInterfaces", arg0) +} + +// RegisterInterfaces indicates an expected call of RegisterInterfaces +func (mr *MockAppModuleBasicMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterInterfaces), arg0) +} + // DefaultGenesis mocks base method func (m *MockAppModuleBasic) DefaultGenesis(arg0 codec.JSONMarshaler) json.RawMessage { m.ctrl.T.Helper() @@ -183,6 +196,18 @@ func (mr *MockAppModuleGenesisMockRecorder) RegisterCodec(arg0 interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterCodec), arg0) } +// RegisterInterfaces mocks base method +func (m *MockAppModuleGenesis) RegisterInterfaces(arg0 types.InterfaceRegistry) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RegisterInterfaces", arg0) +} + +// RegisterInterfaces indicates an expected call of RegisterInterfaces +func (mr *MockAppModuleGenesisMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterInterfaces), arg0) +} + // DefaultGenesis mocks base method func (m *MockAppModuleGenesis) DefaultGenesis(arg0 codec.JSONMarshaler) json.RawMessage { m.ctrl.T.Helper() @@ -252,10 +277,10 @@ func (mr *MockAppModuleGenesisMockRecorder) GetQueryCmd() *gomock.Call { } // InitGenesis mocks base method -func (m *MockAppModuleGenesis) InitGenesis(arg0 types.Context, arg1 codec.JSONMarshaler, arg2 json.RawMessage) []types0.ValidatorUpdate { +func (m *MockAppModuleGenesis) InitGenesis(arg0 types0.Context, arg1 codec.JSONMarshaler, arg2 json.RawMessage) []types1.ValidatorUpdate { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2) - ret0, _ := ret[0].([]types0.ValidatorUpdate) + ret0, _ := ret[0].([]types1.ValidatorUpdate) return ret0 } @@ -266,7 +291,7 @@ func (mr *MockAppModuleGenesisMockRecorder) InitGenesis(arg0, arg1, arg2 interfa } // ExportGenesis mocks base method -func (m *MockAppModuleGenesis) ExportGenesis(arg0 types.Context, arg1 codec.JSONMarshaler) json.RawMessage { +func (m *MockAppModuleGenesis) ExportGenesis(arg0 types0.Context, arg1 codec.JSONMarshaler) json.RawMessage { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1) ret0, _ := ret[0].(json.RawMessage) @@ -328,6 +353,18 @@ func (mr *MockAppModuleMockRecorder) RegisterCodec(arg0 interface{}) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModule)(nil).RegisterCodec), arg0) } +// RegisterInterfaces mocks base method +func (m *MockAppModule) RegisterInterfaces(arg0 types.InterfaceRegistry) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RegisterInterfaces", arg0) +} + +// RegisterInterfaces indicates an expected call of RegisterInterfaces +func (mr *MockAppModuleMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModule)(nil).RegisterInterfaces), arg0) +} + // DefaultGenesis mocks base method func (m *MockAppModule) DefaultGenesis(arg0 codec.JSONMarshaler) json.RawMessage { m.ctrl.T.Helper() @@ -397,10 +434,10 @@ func (mr *MockAppModuleMockRecorder) GetQueryCmd() *gomock.Call { } // InitGenesis mocks base method -func (m *MockAppModule) InitGenesis(arg0 types.Context, arg1 codec.JSONMarshaler, arg2 json.RawMessage) []types0.ValidatorUpdate { +func (m *MockAppModule) InitGenesis(arg0 types0.Context, arg1 codec.JSONMarshaler, arg2 json.RawMessage) []types1.ValidatorUpdate { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2) - ret0, _ := ret[0].([]types0.ValidatorUpdate) + ret0, _ := ret[0].([]types1.ValidatorUpdate) return ret0 } @@ -411,7 +448,7 @@ func (mr *MockAppModuleMockRecorder) InitGenesis(arg0, arg1, arg2 interface{}) * } // ExportGenesis mocks base method -func (m *MockAppModule) ExportGenesis(arg0 types.Context, arg1 codec.JSONMarshaler) json.RawMessage { +func (m *MockAppModule) ExportGenesis(arg0 types0.Context, arg1 codec.JSONMarshaler) json.RawMessage { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1) ret0, _ := ret[0].(json.RawMessage) @@ -425,7 +462,7 @@ func (mr *MockAppModuleMockRecorder) ExportGenesis(arg0, arg1 interface{}) *gomo } // RegisterInvariants mocks base method -func (m *MockAppModule) RegisterInvariants(arg0 types.InvariantRegistry) { +func (m *MockAppModule) RegisterInvariants(arg0 types0.InvariantRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInvariants", arg0) } @@ -437,10 +474,10 @@ func (mr *MockAppModuleMockRecorder) RegisterInvariants(arg0 interface{}) *gomoc } // Route mocks base method -func (m *MockAppModule) Route() types.Route { +func (m *MockAppModule) Route() types0.Route { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Route") - ret0, _ := ret[0].(types.Route) + ret0, _ := ret[0].(types0.Route) return ret0 } @@ -465,10 +502,10 @@ func (mr *MockAppModuleMockRecorder) QuerierRoute() *gomock.Call { } // NewQuerierHandler mocks base method -func (m *MockAppModule) NewQuerierHandler() types.Querier { +func (m *MockAppModule) NewQuerierHandler() types0.Querier { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewQuerierHandler") - ret0, _ := ret[0].(types.Querier) + ret0, _ := ret[0].(types0.Querier) return ret0 } @@ -491,7 +528,7 @@ func (mr *MockAppModuleMockRecorder) RegisterQueryService(arg0 interface{}) *gom } // BeginBlock mocks base method -func (m *MockAppModule) BeginBlock(arg0 types.Context, arg1 types0.RequestBeginBlock) { +func (m *MockAppModule) BeginBlock(arg0 types0.Context, arg1 types1.RequestBeginBlock) { m.ctrl.T.Helper() m.ctrl.Call(m, "BeginBlock", arg0, arg1) } @@ -503,10 +540,10 @@ func (mr *MockAppModuleMockRecorder) BeginBlock(arg0, arg1 interface{}) *gomock. } // EndBlock mocks base method -func (m *MockAppModule) EndBlock(arg0 types.Context, arg1 types0.RequestEndBlock) []types0.ValidatorUpdate { +func (m *MockAppModule) EndBlock(arg0 types0.Context, arg1 types1.RequestEndBlock) []types1.ValidatorUpdate { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EndBlock", arg0, arg1) - ret0, _ := ret[0].([]types0.ValidatorUpdate) + ret0, _ := ret[0].([]types1.ValidatorUpdate) return ret0 } diff --git a/types/module/interface_module.go b/types/module/interface_module.go deleted file mode 100644 index 69524d2d6b..0000000000 --- a/types/module/interface_module.go +++ /dev/null @@ -1,24 +0,0 @@ -package module - -import ( - "github.com/cosmos/cosmos-sdk/codec/types" -) - -// InterfaceModule is an interface that modules can implement in order to -// register their interfaces and implementations in an InterfaceRegistry -type InterfaceModule interface { - RegisterInterfaceTypes(registry types.InterfaceRegistry) -} - -// RegisterInterfaceModules calls RegisterInterfaceTypes with the registry -// parameter on all of the modules which implement InterfaceModule in the manager -func (bm BasicManager) RegisterInterfaceModules(registry types.InterfaceRegistry) { - for _, m := range bm { - im, ok := m.(InterfaceModule) - if !ok { - continue - } - - im.RegisterInterfaceTypes(registry) - } -} diff --git a/types/module/module.go b/types/module/module.go index a344f7d6b3..a56842992b 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -39,6 +39,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -48,6 +49,7 @@ import ( type AppModuleBasic interface { Name() string RegisterCodec(*codec.Codec) + RegisterInterfaces(codectypes.InterfaceRegistry) DefaultGenesis(codec.JSONMarshaler) json.RawMessage ValidateGenesis(codec.JSONMarshaler, json.RawMessage) error @@ -77,6 +79,13 @@ func (bm BasicManager) RegisterCodec(cdc *codec.Codec) { } } +// RegisterInterfaces registers all module interface types +func (bm BasicManager) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + for _, m := range bm { + m.RegisterInterfaces(registry) + } +} + // DefaultGenesis provides default genesis information for all modules func (bm BasicManager) DefaultGenesis(cdc codec.JSONMarshaler) map[string]json.RawMessage { genesis := make(map[string]json.RawMessage) diff --git a/types/module/module_test.go b/types/module/module_test.go index 91ad8d8596..cc4fc9af32 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -5,6 +5,8 @@ import ( "errors" "testing" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/golang/mock/gomock" "github.com/gorilla/mux" "github.com/spf13/cobra" @@ -24,6 +26,7 @@ func TestBasicManager(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) cdc := codec.New() + interfaceRegistry := types.NewInterfaceRegistry() clientCtx := client.Context{} clientCtx = clientCtx.WithCodec(cdc) wantDefaultGenesis := map[string]json.RawMessage{"mockAppModuleBasic1": json.RawMessage(``)} @@ -35,6 +38,7 @@ func TestBasicManager(t *testing.T) { mockAppModuleBasic1.EXPECT().ValidateGenesis(gomock.Eq(cdc), gomock.Eq(wantDefaultGenesis["mockAppModuleBasic1"])).Times(1).Return(errFoo) mockAppModuleBasic1.EXPECT().RegisterRESTRoutes(gomock.Eq(client.Context{}), gomock.Eq(&mux.Router{})).Times(1) mockAppModuleBasic1.EXPECT().RegisterCodec(gomock.Eq(cdc)).Times(1) + mockAppModuleBasic1.EXPECT().RegisterInterfaces(gomock.Eq(interfaceRegistry)).Times(1) mockAppModuleBasic1.EXPECT().GetTxCmd().Times(1).Return(nil) mockAppModuleBasic1.EXPECT().GetQueryCmd().Times(1).Return(nil) @@ -42,6 +46,7 @@ func TestBasicManager(t *testing.T) { require.Equal(t, mm["mockAppModuleBasic1"], mockAppModuleBasic1) mm.RegisterCodec(cdc) + mm.RegisterInterfaces(interfaceRegistry) require.Equal(t, wantDefaultGenesis, mm.DefaultGenesis(cdc)) diff --git a/x/auth/module.go b/x/auth/module.go index e6bf51f496..7ca63827ed 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -28,7 +28,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // AppModuleBasic defines the basic application module used by the auth module. @@ -75,8 +74,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaceTypes registers interfaces and implementations of the auth module. -func (AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +// RegisterInterfaces registers interfaces and implementations of the auth module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/bank/module.go b/x/bank/module.go index f15ea15850..cafa7a0f7d 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -27,7 +27,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // AppModuleBasic defines the basic application module used by the bank module. @@ -72,8 +71,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaceTypes registers interfaces and implementations of the bank module. -func (AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +// RegisterInterfaces registers interfaces and implementations of the bank module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/capability/module.go b/x/capability/module.go index 70f7159d46..06ee437103 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -5,6 +5,8 @@ import ( "fmt" "math/rand" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/gogo/protobuf/grpc" "github.com/gorilla/mux" "github.com/spf13/cobra" @@ -49,6 +51,9 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { types.RegisterCodec(cdc) } +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + // DefaultGenesis returns the capability module's default genesis state. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) diff --git a/x/crisis/module.go b/x/crisis/module.go index 975f2849cf..40af92e03c 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -64,9 +64,9 @@ func (b AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns no root query command for the crisis module. func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } -// RegisterInterfaceTypes registers interfaces and implementations of the crisis +// RegisterInterfaces registers interfaces and implementations of the crisis // module. -func (AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/distribution/module.go b/x/distribution/module.go index 475d0e46b3..fe20c76de2 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -29,7 +29,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // AppModuleBasic defines the basic application module used by the distribution module. @@ -78,8 +77,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaceTypes implements InterfaceModule -func (b AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) { +// RegisterInterfaces implements InterfaceModule +func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/evidence/module.go b/x/evidence/module.go index d2331dceab..5ef5bd17d9 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -30,7 +30,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // ---------------------------------------------------------------------------- @@ -101,7 +100,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -func (AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/genutil/module.go b/x/genutil/module.go index dfc2d00073..06f16c93d2 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -32,6 +33,9 @@ func (AppModuleBasic) Name() string { // RegisterCodec registers the genutil module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {} +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + // DefaultGenesis returns default genesis state as raw bytes for the genutil // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { diff --git a/x/gov/module.go b/x/gov/module.go index ccc2533178..d0dcde556f 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -32,7 +32,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // AppModuleBasic defines the basic application module used by the gov module. @@ -99,8 +98,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaceTypes implements InterfaceModule.RegisterInterfaceTypes -func (a AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +// RegisterInterfaces implements InterfaceModule.RegisterInterfaces +func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index 0c73c08985..cb1c362946 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -80,8 +80,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } -// RegisterInterfaceTypes registers module concrete types into protobuf Any. -func (AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) { +// RegisterInterfaces registers module concrete types into protobuf Any. +func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/ibc/module.go b/x/ibc/module.go index b1920fe3a7..34d16dd0ba 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -78,8 +78,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaceTypes registers module concrete types into protobuf Any. -func (AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) { +// RegisterInterfaces registers module concrete types into protobuf Any. +func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/mint/module.go b/x/mint/module.go index ef80570606..e88ab00fc4 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -43,6 +44,9 @@ func (AppModuleBasic) Name() string { // RegisterCodec registers the mint module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {} +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + // DefaultGenesis returns default genesis state as raw bytes for the mint // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { diff --git a/x/params/module.go b/x/params/module.go index 0ed332c06f..249e92e794 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -27,7 +27,6 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} - _ module.InterfaceModule = AppModuleBasic{} ) // AppModuleBasic defines the basic application module used by the params module. @@ -61,7 +60,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.NewQueryCmd() } -func (am AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +func (am AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { proposal.RegisterInterfaces(registry) } diff --git a/x/slashing/module.go b/x/slashing/module.go index 8fbf4e462e..c24f28bd9d 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -48,6 +49,11 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { types.RegisterCodec(cdc) } +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + // DefaultGenesis returns default genesis state as raw bytes for the slashing // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 5d52f7cb26..256e39f5aa 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" ) // RegisterCodec registers concrete types on codec @@ -11,6 +12,12 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil) } +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUnjail{}, + ) +} + var ( amino = codec.New() diff --git a/x/staking/module.go b/x/staking/module.go index bde3165f24..2b58af18dd 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -46,6 +47,11 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { types.RegisterCodec(cdc) } +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + // DefaultGenesis returns default genesis state as raw bytes for the staking // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 3f402945d6..57d77e15d1 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" ) // RegisterCodec registers the necessary x/staking interfaces and concrete types @@ -16,6 +17,17 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) } +// RegisterInterfaces registers the x/staking interfaces types with the interface registry +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateValidator{}, + &MsgEditValidator{}, + &MsgDelegate{}, + &MsgUndelegate{}, + &MsgBeginRedelegate{}, + ) +} + var ( amino = codec.New() diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 015d780bc7..c1ef30f73a 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -29,9 +29,8 @@ func init() { } var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.InterfaceModule = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} ) // AppModuleBasic implements the sdk.AppModuleBasic interface @@ -62,7 +61,7 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } -func (b AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) }