github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/icamauth/module.go (about)

     1  package icamauth
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  
     7  	"github.com/fibonacci-chain/fbc/x/icamauth/keeper"
     8  
     9  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
    10  	abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types"
    11  
    12  	"github.com/fibonacci-chain/fbc/x/icamauth/client/cli"
    13  
    14  	clictx "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
    15  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
    16  	interfacetypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec/types"
    17  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module"
    18  	"github.com/fibonacci-chain/fbc/x/icamauth/types"
    19  	"github.com/gorilla/mux"
    20  	"github.com/grpc-ecosystem/grpc-gateway/runtime"
    21  	"github.com/spf13/cobra"
    22  )
    23  
    24  var (
    25  	_ module.AppModuleAdapter      = AppModule{}
    26  	_ module.AppModuleBasicAdapter = AppModuleBasic{}
    27  )
    28  
    29  // AppModuleBasic implements the AppModuleBasic interface for the capability module.
    30  type AppModuleBasic struct {
    31  	cdc *codec.CodecProxy
    32  }
    33  
    34  func NewAppModuleBasic(cdc *codec.CodecProxy) AppModuleBasic {
    35  	return AppModuleBasic{cdc: cdc}
    36  }
    37  
    38  func (a AppModuleBasic) Name() string {
    39  	return types.ModuleName
    40  }
    41  
    42  func (a AppModuleBasic) RegisterCodec(c *codec.Codec) {
    43  	types.RegisterCodec(c)
    44  }
    45  
    46  func (a AppModuleBasic) DefaultGenesis() json.RawMessage {
    47  	return nil
    48  }
    49  
    50  func (a AppModuleBasic) ValidateGenesis(message json.RawMessage) error {
    51  	return nil
    52  }
    53  
    54  func (a AppModuleBasic) RegisterRESTRoutes(context clictx.CLIContext, router *mux.Router) {}
    55  
    56  func (a AppModuleBasic) GetTxCmd(c *codec.Codec) *cobra.Command {
    57  	return nil
    58  }
    59  
    60  func (a AppModuleBasic) GetQueryCmd(c *codec.Codec) *cobra.Command {
    61  	return nil
    62  }
    63  
    64  func (a AppModuleBasic) RegisterInterfaces(registry interfacetypes.InterfaceRegistry) {
    65  	types.RegisterInterfaces(registry)
    66  }
    67  
    68  func (a AppModuleBasic) RegisterGRPCGatewayRoutes(ctx clictx.CLIContext, mux *runtime.ServeMux) {
    69  	err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(ctx))
    70  	if err != nil {
    71  		panic(err)
    72  	}
    73  }
    74  
    75  func (a AppModuleBasic) GetTxCmdV2(cdc *codec.CodecProxy, reg interfacetypes.InterfaceRegistry) *cobra.Command {
    76  	return cli.GetTxCmd(cdc, reg)
    77  }
    78  
    79  func (a AppModuleBasic) GetQueryCmdV2(cdc *codec.CodecProxy, reg interfacetypes.InterfaceRegistry) *cobra.Command {
    80  	return cli.GetQueryCmd(cdc, reg)
    81  }
    82  
    83  func (a AppModuleBasic) RegisterRouterForGRPC(cliCtx clictx.CLIContext, r *mux.Router) {}
    84  
    85  type AppModule struct {
    86  	AppModuleBasic
    87  	keeper keeper.Keeper
    88  }
    89  
    90  func NewAppModule(cdc *codec.CodecProxy, keeper keeper.Keeper) AppModule {
    91  	return AppModule{
    92  		AppModuleBasic: NewAppModuleBasic(cdc),
    93  		keeper:         keeper,
    94  	}
    95  }
    96  
    97  func (a AppModule) Route() string {
    98  	return types.RouterKey
    99  }
   100  
   101  func (a AppModule) InitGenesis(s sdk.Context, message json.RawMessage) []abci.ValidatorUpdate {
   102  	return nil
   103  }
   104  
   105  func (a AppModule) ExportGenesis(s sdk.Context) json.RawMessage {
   106  	return nil
   107  }
   108  
   109  func (a AppModule) NewHandler() sdk.Handler {
   110  	return NewHandler(keeper.NewMsgServerImpl(a.keeper))
   111  }
   112  
   113  func (a AppModule) QuerierRoute() string {
   114  	return types.QuerierRoute
   115  }
   116  
   117  func (a AppModule) NewQuerierHandler() sdk.Querier {
   118  	return nil
   119  }
   120  
   121  func (a AppModule) BeginBlock(s sdk.Context, block abci.RequestBeginBlock) {}
   122  
   123  func (a AppModule) EndBlock(s sdk.Context, block abci.RequestEndBlock) []abci.ValidatorUpdate {
   124  	return nil
   125  }
   126  
   127  func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {}
   128  
   129  func (a AppModule) RegisterServices(cfg module.Configurator) {
   130  	types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(a.keeper))
   131  	types.RegisterQueryServer(cfg.QueryServer(), a.keeper)
   132  }