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