Skip to content

Commit

Permalink
Clean emergency button module interface: remove deprecated and empty …
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
iKapitonau committed Feb 28, 2024
1 parent 6f5a5fe commit daae840
Showing 1 changed file with 11 additions and 46 deletions.
57 changes: 11 additions & 46 deletions x/emergencybutton/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@ import (

"github.com/scrtlabs/SecretNetwork/x/emergencybutton/client/grpc"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"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"
"github.com/cosmos/cosmos-sdk/types/module"
ibcswitchclient "github.com/scrtlabs/SecretNetwork/x/emergencybutton/client"
abci "github.com/tendermint/tendermint/abci/types"

ibcswitchcli "github.com/scrtlabs/SecretNetwork/x/emergencybutton/client/cli"
"github.com/scrtlabs/SecretNetwork/x/emergencybutton/types"
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.HasName = AppModule{}
_ module.HasServices = AppModule{}
_ module.HasGenesis = AppModule{}
)

type AppModuleBasic struct{}
Expand All @@ -50,21 +48,11 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncoding

// ---------------------------------------
// Interfaces.
func (b AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
}

func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck
}

func (b AppModuleBasic) GetTxCmd() *cobra.Command {
return ibcswitchcli.GetTxCmd()
}

func (b AppModuleBasic) GetQueryCmd() *cobra.Command {
return ibcswitchcli.GetQueryCmd()
}

// RegisterInterfaces registers interfaces and implementations of the emergencybutton module.
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
Expand Down Expand Up @@ -93,40 +81,20 @@ func (am AppModule) Name() string {
return am.AppModuleBasic.Name()
}

// Route returns the txfees module's message routing key.
func (am AppModule) Route() sdk.Route {
return sdk.Route{}
}

// QuerierRoute returns the emergencybutton module's query routing key.
func (AppModule) QuerierRoute() string { return types.RouterKey }

// LegacyQuerierHandler is a no-op. Needed to meet AppModule interface.
func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) {
return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName)
}
}

// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(*am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: ibcswitchclient.Querier{K: *am.keeper}})
}

// RegisterInvariants registers the txfees module's invariants.
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

// InitGenesis performs the txfees module's genesis initialization It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) {
var genState types.GenesisState
// Initialize global index to index in genesis state
cdc.MustUnmarshalJSON(gs, &genState)
am.keeper.InitGenesis(ctx, genState)

return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the txfees module's exported genesis state as raw JSON bytes.
Expand All @@ -135,14 +103,11 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(genState)
}

// BeginBlock executes all ABCI BeginBlock logic respective to the txfees module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

// EndBlock executes all ABCI EndBlock logic respective to the txfees module. It
// returns no validator updates.
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) IsOnePerModuleType() {}

0 comments on commit daae840

Please sign in to comment.