-
Notifications
You must be signed in to change notification settings - Fork 182
/
module_basic.go
62 lines (50 loc) · 1.56 KB
/
module_basic.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
package token
import (
"encoding/json"
"github.com/okex/exchain/libs/cosmos-sdk/client/context"
"github.com/okex/exchain/libs/cosmos-sdk/codec"
"github.com/okex/exchain/libs/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/okex/exchain/x/token/client/cli"
"github.com/okex/exchain/x/token/client/rest"
tokenTypes "github.com/okex/exchain/x/token/types"
)
var (
_ module.AppModuleBasic = AppModuleBasic{}
)
// nolint
type AppModuleBasic struct{}
// nolint
func (AppModuleBasic) Name() string {
return tokenTypes.ModuleName
}
// nolint
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
RegisterCodec(cdc)
}
// nolint
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
return tokenTypes.ModuleCdc.MustMarshalJSON(defaultGenesisState())
}
// validateGenesis module validate genesis from json raw message
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
var data GenesisState
err := tokenTypes.ModuleCdc.UnmarshalJSON(bz, &data)
if err != nil {
return err
}
return validateGenesis(data)
}
// RegisterRESTRoutes register rest routes
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) {
rest.RegisterRoutes(ctx, rtr, ModuleName)
}
// GetTxCmd gets the root tx command of this module
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetTxCmd(tokenTypes.StoreKey, cdc)
}
// GetQueryCmd gets the root query command of this module
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetQueryCmd(tokenTypes.StoreKey, cdc)
}