/
module.go
117 lines (92 loc) · 2.88 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
package currencies
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
codec "github.com/tendermint/go-amino"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/dfinance/dnode/x/core"
"github.com/dfinance/dnode/x/currencies/client"
"github.com/dfinance/dnode/x/currencies/client/rest"
types "github.com/dfinance/dnode/x/currencies/types"
)
var (
_ core.AppMsModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
)
type AppModuleBasic struct{}
// Module name.
func (AppModuleBasic) Name() string {
return types.ModuleName
}
// Registering codecs.
func (module AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
RegisterCodec(cdc)
}
// Validate exists genesis.
func (AppModuleBasic) ValidateGenesis(json.RawMessage) error {
return nil
}
// Generate default genesis.
func (module AppModuleBasic) DefaultGenesis() json.RawMessage {
return nil
}
// Register REST routes.
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, r *mux.Router) {
rest.RegisterRoutes(ctx, r)
}
// Get transaction commands for CLI.
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return client.GetTxCmd(cdc)
}
// Get query commands for CLI.
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
return client.GetQueryCmd(cdc)
}
// PoA module.
type AppModule struct {
AppModuleBasic
ccKeeper Keeper
}
// Create new PoA module.
func NewAppMsModule(ccKeeper Keeper) core.AppMsModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
ccKeeper: ccKeeper,
}
}
// Get name of module.
func (AppModule) Name() string {
return types.ModuleName
}
// Register module invariants.
func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
// Base route of module (for handler).
func (AppModule) Route() string { return types.Router }
// Create new handler.
func (app AppModule) NewHandler() sdk.Handler { return NewHandler(app.ccKeeper) }
// Create new multisignature handler.
func (app AppModule) NewMsHandler() core.MsHandler { return NewMsHandler(app.ccKeeper) }
// Get route for querier.
func (AppModule) QuerierRoute() string { return types.RouterKey }
// Get new querier for PoA module.
func (app AppModule) NewQuerierHandler() sdk.Querier {
return NewQuerier(app.ccKeeper)
}
// Process begin block (abci).
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
// Process end block (abci).
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
// Initialize genesis.
func (app AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
// Export genesis.
func (app AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
return nil
}