github.com/Finschia/finschia-sdk@v0.48.1/x/stakingplus/module/module.go (about)

     1  package module
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	ocabci "github.com/Finschia/ostracon/abci/types"
     7  	abci "github.com/tendermint/tendermint/abci/types"
     8  
     9  	"github.com/Finschia/finschia-sdk/codec"
    10  	"github.com/Finschia/finschia-sdk/types/module"
    11  
    12  	codectypes "github.com/Finschia/finschia-sdk/codec/types"
    13  	sdk "github.com/Finschia/finschia-sdk/types"
    14  
    15  	"github.com/Finschia/finschia-sdk/x/stakingplus"
    16  	"github.com/Finschia/finschia-sdk/x/stakingplus/keeper"
    17  
    18  	"github.com/Finschia/finschia-sdk/x/staking"
    19  	stakingkeeper "github.com/Finschia/finschia-sdk/x/staking/keeper"
    20  	stakingtypes "github.com/Finschia/finschia-sdk/x/staking/types"
    21  )
    22  
    23  var (
    24  	_ module.AppModule           = AppModule{}
    25  	_ module.AppModuleBasic      = AppModuleBasic{}
    26  	_ module.BeginBlockAppModule = AppModule{}
    27  	_ module.EndBlockAppModule   = AppModule{}
    28  )
    29  
    30  // AppModuleBasic defines the basic application module used by the stakingplus module.
    31  type AppModuleBasic struct {
    32  	staking.AppModuleBasic
    33  }
    34  
    35  func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
    36  	b.AppModuleBasic.RegisterInterfaces(registry)
    37  	stakingplus.RegisterInterfaces(registry)
    38  }
    39  
    40  //____________________________________________________________________________
    41  
    42  // AppModule implements an application module for the stakingplus module.
    43  type AppModule struct {
    44  	AppModuleBasic
    45  	impl staking.AppModule
    46  
    47  	keeper stakingkeeper.Keeper
    48  	ak     stakingtypes.AccountKeeper
    49  	bk     stakingtypes.BankKeeper
    50  	fk     stakingplus.FoundationKeeper
    51  }
    52  
    53  // NewAppModule creates a new AppModule object
    54  func NewAppModule(cdc codec.Codec, keeper stakingkeeper.Keeper, ak stakingtypes.AccountKeeper, bk stakingtypes.BankKeeper, fk stakingplus.FoundationKeeper) AppModule {
    55  	impl := staking.NewAppModule(cdc, keeper, ak, bk)
    56  	return AppModule{
    57  		AppModuleBasic: AppModuleBasic{
    58  			impl.AppModuleBasic,
    59  		},
    60  		impl:   impl,
    61  		keeper: keeper,
    62  		ak:     ak,
    63  		bk:     bk,
    64  		fk:     fk,
    65  	}
    66  }
    67  
    68  // RegisterInvariants does nothing, there are no invariants to enforce
    69  func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
    70  	am.impl.RegisterInvariants(ir)
    71  }
    72  
    73  // Route is empty, as we do not handle Messages (just proposals)
    74  func (am AppModule) Route() sdk.Route {
    75  	return am.impl.Route()
    76  }
    77  
    78  // QuerierRoute returns the route we respond to for abci queries
    79  func (am AppModule) QuerierRoute() string {
    80  	return am.impl.QuerierRoute()
    81  }
    82  
    83  // LegacyQuerierHandler registers a query handler to respond to the module-specific queries
    84  func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
    85  	return am.impl.LegacyQuerierHandler(legacyQuerierCdc)
    86  }
    87  
    88  // RegisterServices registers module services.
    89  func (am AppModule) RegisterServices(cfg module.Configurator) {
    90  	stakingtypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper, am.fk))
    91  	querier := stakingkeeper.Querier{Keeper: am.keeper}
    92  	stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier)
    93  }
    94  
    95  // InitGenesis performs genesis initialization for the stakingplus module. It returns
    96  // no validator updates.
    97  func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
    98  	return am.impl.InitGenesis(ctx, cdc, data)
    99  }
   100  
   101  // ExportGenesis returns the exported genesis state as raw bytes for the stakingplus
   102  // module.
   103  func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
   104  	return am.impl.ExportGenesis(ctx, cdc)
   105  }
   106  
   107  // ConsensusVersion implements AppModule/ConsensusVersion.
   108  func (am AppModule) ConsensusVersion() uint64 {
   109  	return am.impl.ConsensusVersion()
   110  }
   111  
   112  // BeginBlock returns the begin blocker for the stakingplus module.
   113  func (am AppModule) BeginBlock(ctx sdk.Context, req ocabci.RequestBeginBlock) {
   114  	am.impl.BeginBlock(ctx, req)
   115  }
   116  
   117  // EndBlock returns the end blocker for the stakingplus module. It returns no validator
   118  // updates.
   119  func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
   120  	return am.impl.EndBlock(ctx, req)
   121  }