-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.go
144 lines (111 loc) · 4.06 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
package fee
import (
"context"
"encoding/json"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/upgrade"
"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/common"
"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/29-fee/client/cli"
"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/29-fee/keeper"
cliCtx "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
anytypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec/types"
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/ibc-go/modules/apps/29-fee/types"
abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
)
var (
_ module.AppModuleAdapter = AppModule{}
_ module.AppModuleBasicAdapter = AppModuleBasic{}
_ upgrade.UpgradeModule = AppModule{}
)
// AppModuleBasic is the 29-fee AppModuleBasic
type AppModuleBasic struct{}
func (b AppModuleBasic) RegisterCodec(codec *codec.Codec) {
types.RegisterLegacyAminoCodec(codec)
}
func (b AppModuleBasic) DefaultGenesis() json.RawMessage {
return nil
}
func (b AppModuleBasic) ValidateGenesis(message json.RawMessage) error {
return nil
}
func (b AppModuleBasic) RegisterRESTRoutes(context cliCtx.CLIContext, router *mux.Router) {}
func (b AppModuleBasic) GetTxCmd(codec *codec.Codec) *cobra.Command {
return nil
}
func (b AppModuleBasic) GetQueryCmd(codec *codec.Codec) *cobra.Command {
return nil
}
func (b AppModuleBasic) RegisterInterfaces(registry anytypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
}
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(ctx cliCtx.CLIContext, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(ctx))
}
func (b AppModuleBasic) GetTxCmdV2(cdc *codec.CodecProxy, reg anytypes.InterfaceRegistry) *cobra.Command {
return cli.NewTxCmd(cdc, reg)
}
func (b AppModuleBasic) GetQueryCmdV2(cdc *codec.CodecProxy, reg anytypes.InterfaceRegistry) *cobra.Command {
return cli.GetQueryCmd(cdc, reg)
}
func (b AppModuleBasic) RegisterRouterForGRPC(cliCtx cliCtx.CLIContext, r *mux.Router) {}
// Name implements AppModuleBasic interface
func (AppModuleBasic) Name() string {
return types.ModuleName
}
type AppModule struct {
*common.Veneus3BaseUpgradeModule
AppModuleBasic
keeper keeper.Keeper
}
func NewAppModule(k keeper.Keeper) AppModule {
ret := AppModule{
keeper: k,
}
ret.Veneus3BaseUpgradeModule = common.NewVeneus3BaseUpgradeModule(ret)
return ret
}
func (a AppModule) InitGenesis(s sdk.Context, message json.RawMessage) []abci.ValidatorUpdate {
return nil
}
func (a AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
return nil
}
func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {}
func (a AppModule) Route() string {
return types.RouterKey
}
func (a AppModule) NewHandler() sdk.Handler {
return NewHandler(a.keeper)
}
func (a AppModule) QuerierRoute() string {
return types.QuerierRoute
}
func (a AppModule) NewQuerierHandler() sdk.Querier {
return nil
}
func (a AppModule) BeginBlock(s sdk.Context, block abci.RequestBeginBlock) {}
func (a AppModule) EndBlock(s sdk.Context, block abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
func (a AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), a.keeper)
types.RegisterQueryServer(cfg.QueryServer(), a.keeper)
}
func (a AppModule) RegisterTask() upgrade.HeightTask {
return upgrade.NewHeightTask(5, func(ctx sdk.Context) error {
data := ModuleCdc.MustMarshalJSON(types.DefaultGenesisState())
a.initGenesis(ctx, data)
return nil
})
}
func (am AppModule) initGenesis(ctx sdk.Context, message json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
ModuleCdc.MustUnmarshalJSON(message, &genesisState)
am.keeper.InitGenesis(ctx, genesisState)
return []abci.ValidatorUpdate{}
}