/
module.go
155 lines (129 loc) · 4.59 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package feesplit
import (
"encoding/json"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/upgrade"
"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/base"
abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types"
tmtypes "github.com/fibonacci-chain/fbc/libs/tendermint/types"
"github.com/fibonacci-chain/fbc/x/feesplit/client/cli"
"github.com/fibonacci-chain/fbc/x/feesplit/keeper"
"github.com/fibonacci-chain/fbc/x/feesplit/types"
)
// type check to ensure the interface is properly implemented
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ upgrade.UpgradeModule = AppModule{}
)
// AppModuleBasic type for the fees module
type AppModuleBasic struct{}
// Name returns the fees module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
}
// RegisterCodec registers types for module
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
types.RegisterCodec(cdc)
}
// DefaultGenesis is json default structure
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
//return types.ModuleCdc.MustMarshalJSON(types.DefaultGenesisState())
return nil
}
// ValidateGenesis is the validation check of the Genesis
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
if len(bz) > 0 {
var genesisState types.GenesisState
err := types.ModuleCdc.UnmarshalJSON(bz, &genesisState)
if err != nil {
return err
}
return genesisState.Validate()
}
return nil
}
// RegisterRESTRoutes Registers rest routes
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) {
}
// GetQueryCmd Gets the root query command of this module
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetQueryCmd(types.ModuleName, cdc)
}
// GetTxCmd returns the root tx command for the swap module.
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetTxCmd(cdc)
}
// ___________________________________________________________________________
// AppModule implements the AppModule interface for the fees module.
type AppModule struct {
AppModuleBasic
*base.BaseIBCUpgradeModule
keeper keeper.Keeper
}
// NewAppModule creates a new AppModule Object
func NewAppModule(k keeper.Keeper) AppModule {
m := AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: k,
}
m.BaseIBCUpgradeModule = base.NewBaseIBCUpgradeModule(m)
return m
}
// Name returns the fees module's name.
func (AppModule) Name() string {
return types.ModuleName
}
// RegisterInvariants registers the fees module's invariants.
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
// NewHandler returns nil - fees module doesn't expose tx gRPC endpoints
func (am AppModule) NewHandler() sdk.Handler {
return NewHandler(am.keeper)
}
// Route returns the fees module's message routing key.
func (am AppModule) Route() string {
return types.RouterKey
}
// QuerierRoute returns the claim module's query routing key.
func (am AppModule) QuerierRoute() string {
return types.RouterKey
}
// NewQuerierHandler sets up new querier handler for module
func (am AppModule) NewQuerierHandler() sdk.Querier {
return keeper.NewQuerier(am.keeper)
}
// BeginBlock executes all ABCI BeginBlock logic respective to the fees module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {
if tmtypes.DownloadDelta {
types.GetParamsCache().SetNeedParamsUpdate()
}
}
// EndBlock executes all ABCI EndBlock logic respective to the fees module. It
// returns no validator updates.
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
// InitGenesis performs the fees module's genesis initialization. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
//var genesisState types.GenesisState
//
//types.ModuleCdc.MustUnmarshalJSON(data, &genesisState)
//InitGenesis(ctx, am.keeper, genesisState)
//return []abci.ValidatorUpdate{}
return nil
}
// ExportGenesis returns the fees module's exported genesis state as raw JSON bytes.
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
if !tmtypes.HigherThanVenus3(ctx.BlockHeight()) {
return nil
}
gs := ExportGenesis(ctx, am.keeper)
return types.ModuleCdc.MustMarshalJSON(gs)
return nil
}