Fix module interface registration (#6834)

This commit is contained in:
Aaron Craelius 2020-07-23 22:45:34 -04:00 committed by GitHub
parent b20b26d8d1
commit 1538e65478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 139 additions and 74 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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))

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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())

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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 {

View File

@ -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()

View File

@ -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 {

View File

@ -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()

View File

@ -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)
}