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