Skip to content

Commit

Permalink
chore: module code style
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed Feb 8, 2024
1 parent 8e3d439 commit d6ec9cf
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions x/collection/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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{}
)
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -90,21 +94,18 @@ 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{
keeper: keeper,
}
}

// 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.
Expand All @@ -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))
}
}

Expand All @@ -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{},
Expand Down

0 comments on commit d6ec9cf

Please sign in to comment.