-
Notifications
You must be signed in to change notification settings - Fork 182
/
module.go
88 lines (72 loc) · 2.04 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
package token
import (
"encoding/json"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/okex/exchain/x/common/version"
tokenTypes "github.com/okex/exchain/x/token/types"
)
var (
_ module.AppModule = AppModule{}
)
// AppModule app module
type AppModule struct {
AppModuleBasic
keeper Keeper
supplyKeeper authTypes.SupplyKeeper
version version.ProtocolVersionType
}
// NewAppModule creates a new AppModule object
func NewAppModule(v version.ProtocolVersionType, keeper Keeper, supplyKeeper authTypes.SupplyKeeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
supplyKeeper: supplyKeeper,
version: v,
}
}
// nolint
func (AppModule) Name() string {
return tokenTypes.ModuleName
}
// nolint
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
}
// Route module message route name
func (AppModule) Route() string {
return tokenTypes.RouterKey
}
// nolint
func (am AppModule) NewHandler() sdk.Handler {
return NewTokenHandler(am.keeper, am.version)
}
// nolint
func (AppModule) QuerierRoute() string {
return tokenTypes.QuerierRoute
}
// nolint
func (am AppModule) NewQuerierHandler() sdk.Querier {
return NewQuerier(am.keeper)
}
// nolint
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState GenesisState
tokenTypes.ModuleCdc.MustUnmarshalJSON(data, &genesisState)
initGenesis(ctx, am.keeper, genesisState)
return []abci.ValidatorUpdate{}
}
// nolint
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
gs := ExportGenesis(ctx, am.keeper)
return tokenTypes.ModuleCdc.MustMarshalJSON(gs)
}
// nolint
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
beginBlocker(ctx, am.keeper)
}
// nolint
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}