github.com/Finschia/finschia-sdk@v0.49.1/x/auth/vesting/module.go (about)

     1  package vesting
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/grpc-ecosystem/grpc-gateway/runtime"
     7  	"github.com/spf13/cobra"
     8  	abci "github.com/tendermint/tendermint/abci/types"
     9  
    10  	"github.com/Finschia/finschia-sdk/client"
    11  	"github.com/Finschia/finschia-sdk/codec"
    12  	codectypes "github.com/Finschia/finschia-sdk/codec/types"
    13  	sdk "github.com/Finschia/finschia-sdk/types"
    14  	"github.com/Finschia/finschia-sdk/types/module"
    15  	"github.com/Finschia/finschia-sdk/x/auth/keeper"
    16  	"github.com/Finschia/finschia-sdk/x/auth/vesting/client/cli"
    17  	"github.com/Finschia/finschia-sdk/x/auth/vesting/types"
    18  )
    19  
    20  var (
    21  	_ module.AppModule      = AppModule{}
    22  	_ module.AppModuleBasic = AppModuleBasic{}
    23  )
    24  
    25  // AppModuleBasic defines the basic application module used by the sub-vesting
    26  // module. The module itself contain no special logic or state other than message
    27  // handling.
    28  type AppModuleBasic struct{}
    29  
    30  // Name returns the module's name.
    31  func (AppModuleBasic) Name() string {
    32  	return types.ModuleName
    33  }
    34  
    35  // RegisterCodec registers the module's types with the given codec.
    36  func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
    37  	types.RegisterLegacyAminoCodec(cdc)
    38  }
    39  
    40  // RegisterInterfaces registers the module's interfaces and implementations with
    41  // the given interface registry.
    42  func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
    43  	types.RegisterInterfaces(registry)
    44  }
    45  
    46  // DefaultGenesis returns the module's default genesis state as raw bytes.
    47  func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage {
    48  	return []byte("{}")
    49  }
    50  
    51  // ValidateGenesis performs genesis state validation. Currently, this is a no-op.
    52  func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
    53  	return nil
    54  }
    55  
    56  // RegisterGRPCGatewayRoutes registers the module's gRPC Gateway routes. Currently, this
    57  // is a no-op.
    58  func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {}
    59  
    60  // GetTxCmd returns the root tx command for the auth module.
    61  func (AppModuleBasic) GetTxCmd() *cobra.Command {
    62  	return cli.GetTxCmd()
    63  }
    64  
    65  // GetQueryCmd returns the module's root query command. Currently, this is a no-op.
    66  func (AppModuleBasic) GetQueryCmd() *cobra.Command {
    67  	return nil
    68  }
    69  
    70  // AppModule extends the AppModuleBasic implementation by implementing the
    71  // AppModule interface.
    72  type AppModule struct {
    73  	AppModuleBasic
    74  
    75  	accountKeeper keeper.AccountKeeper
    76  	bankKeeper    types.BankKeeper
    77  }
    78  
    79  func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule {
    80  	return AppModule{
    81  		AppModuleBasic: AppModuleBasic{},
    82  		accountKeeper:  ak,
    83  		bankKeeper:     bk,
    84  	}
    85  }
    86  
    87  // RegisterInvariants performs a no-op; there are no invariants to enforce.
    88  func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
    89  
    90  // Route returns the module's message router and handler.
    91  func (am AppModule) Route() sdk.Route {
    92  	return sdk.NewRoute(types.RouterKey, NewHandler(am.accountKeeper, am.bankKeeper))
    93  }
    94  
    95  // QuerierRoute returns an empty string as the module contains no query
    96  // functionality.
    97  func (AppModule) QuerierRoute() string { return "" }
    98  
    99  // RegisterServices registers module services.
   100  func (am AppModule) RegisterServices(cfg module.Configurator) {
   101  	types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(am.accountKeeper, am.bankKeeper))
   102  }
   103  
   104  // LegacyQuerierHandler performs a no-op.
   105  func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
   106  	return nil
   107  }
   108  
   109  // InitGenesis performs a no-op.
   110  func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate {
   111  	return []abci.ValidatorUpdate{}
   112  }
   113  
   114  // ExportGenesis is always empty, as InitGenesis does nothing either.
   115  func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage {
   116  	return am.DefaultGenesis(cdc)
   117  }
   118  
   119  // ConsensusVersion implements AppModule/ConsensusVersion.
   120  func (AppModule) ConsensusVersion() uint64 { return 1 }