diff --git a/x/collection/module/module.go b/x/collection/module/module.go index 565c934d8d..ec06b38b6c 100644 --- a/x/collection/module/module.go +++ b/x/collection/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" - "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -26,9 +25,13 @@ import ( "github.com/Finschia/finschia-sdk/x/collection/keeper" ) +// ConsensusVersion defines the current x/collection module consensus version. +const ConsensusVersion = 2 + var ( _ module.AppModuleBasic = AppModule{} _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -44,6 +47,11 @@ func (AppModuleBasic) Name() string { // RegisterLegacyAminoCodec registers the collection types on the LegacyAmino codec func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +// RegisterInterfaces registers the collection module's interface types +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + collection.RegisterInterfaces(registry) +} + // DefaultGenesis returns default genesis state as raw bytes for the collection // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { @@ -77,10 +85,6 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.NewTxCmd() } -func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - collection.RegisterInterfaces(registry) -} - // ____________________________________________________________________________ // AppModule implements an application module for the collection module. @@ -90,12 +94,6 @@ type AppModule struct { keeper keeper.Keeper } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - -// IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() {} - // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { return AppModule{ @@ -103,8 +101,11 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { } } -// RegisterInvariants does nothing, there are no invariants to enforce -func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. @@ -113,11 +114,11 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { collection.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) m := keeper.NewMigrator(am.keeper) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { - panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err)) + if err := cfg.RegisterMigration(collection.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", collection.ModuleName, err)) } - if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { - panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", types.ModuleName, err)) + if err := cfg.RegisterMigration(collection.ModuleName, 2, m.Migrate2to3); err != nil { + panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", collection.ModuleName, err)) } } @@ -137,7 +138,11 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// +// App Wiring Setup +// func init() { appmodule.Register(&modulev1.Module{},