sdkmodule.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package ibc_hooks
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
  6. "github.com/cosmos/cosmos-sdk/client"
  7. "github.com/cosmos/cosmos-sdk/codec"
  8. "github.com/cosmos/cosmos-sdk/types/module"
  9. "github.com/gorilla/mux"
  10. "github.com/grpc-ecosystem/grpc-gateway/runtime"
  11. "github.com/spf13/cobra"
  12. "github.com/wormhole-foundation/wormchain/x/ibc-hooks/client/cli"
  13. "github.com/wormhole-foundation/wormchain/x/ibc-hooks/types"
  14. cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
  15. sdk "github.com/cosmos/cosmos-sdk/types"
  16. abci "github.com/tendermint/tendermint/abci/types"
  17. )
  18. var (
  19. _ module.AppModule = AppModule{}
  20. _ module.AppModuleBasic = AppModuleBasic{}
  21. )
  22. // AppModuleBasic defines the basic application module used by the ibc-hooks module.
  23. type AppModuleBasic struct{}
  24. var _ module.AppModuleBasic = AppModuleBasic{}
  25. // Name returns the ibc-hooks module's name.
  26. func (AppModuleBasic) Name() string {
  27. return types.ModuleName
  28. }
  29. // RegisterLegacyAminoCodec registers the ibc-hooks module's types on the given LegacyAmino codec.
  30. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
  31. // RegisterInterfaces registers the module's interface types.
  32. func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {}
  33. // DefaultGenesis returns default genesis state as raw bytes for the
  34. // module.
  35. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
  36. emptyString := "{}"
  37. return []byte(emptyString)
  38. }
  39. // ValidateGenesis performs genesis state validation for the ibc-hooks module.
  40. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
  41. return nil
  42. }
  43. // RegisterRESTRoutes registers the REST routes for the ibc-hooks module.
  44. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {}
  45. // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-hooks module.
  46. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}
  47. // GetTxCmd returns no root tx command for the ibc-hooks module.
  48. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil }
  49. // GetQueryCmd returns the root query command for the ibc-hooks module.
  50. func (AppModuleBasic) GetQueryCmd() *cobra.Command {
  51. return cli.GetQueryCmd()
  52. }
  53. // ___________________________________________________________________________
  54. // AppModule implements an application module for the ibc-hooks module.
  55. type AppModule struct {
  56. AppModuleBasic
  57. authKeeper authkeeper.AccountKeeper
  58. }
  59. // NewAppModule creates a new AppModule object.
  60. func NewAppModule(ak authkeeper.AccountKeeper) AppModule {
  61. return AppModule{
  62. AppModuleBasic: AppModuleBasic{},
  63. authKeeper: ak,
  64. }
  65. }
  66. // Name returns the ibc-hooks module's name.
  67. func (AppModule) Name() string {
  68. return types.ModuleName
  69. }
  70. // RegisterInvariants registers the ibc-hooks module invariants.
  71. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
  72. // Route returns the message routing key for the ibc-hooks module.
  73. func (AppModule) Route() sdk.Route { return sdk.Route{} }
  74. // QuerierRoute returns the module's querier route name.
  75. func (AppModule) QuerierRoute() string {
  76. return ""
  77. }
  78. // LegacyQuerierHandler returns the x/ibc-hooks module's sdk.Querier.
  79. func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
  80. return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) {
  81. return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName)
  82. }
  83. }
  84. // RegisterServices registers a gRPC query service to respond to the
  85. // module-specific gRPC queries.
  86. func (am AppModule) RegisterServices(cfg module.Configurator) {
  87. }
  88. // InitGenesis performs genesis initialization for the ibc-hooks module. It returns
  89. // no validator updates.
  90. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
  91. return []abci.ValidatorUpdate{}
  92. }
  93. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
  94. return json.RawMessage([]byte("{}"))
  95. }
  96. // BeginBlock returns the begin blocker for the ibc-hooks module.
  97. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
  98. }
  99. // EndBlock returns the end blocker for the ibc-hooks module. It returns no validator
  100. // updates.
  101. func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
  102. return []abci.ValidatorUpdate{}
  103. }
  104. // ConsensusVersion implements AppModule/ConsensusVersion.
  105. func (AppModule) ConsensusVersion() uint64 { return 1 }