forked from forbole/callisto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
81 lines (66 loc) · 2.35 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
package gov
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/simapp/params"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"google.golang.org/grpc"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/desmos-labs/juno/modules"
"github.com/desmos-labs/juno/types"
"github.com/go-co-op/gocron"
tmctypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/faddat/bdjuno/database"
)
var _ modules.Module = &Module{}
// Module represent x/gov module
type Module struct {
encodingConfig *params.EncodingConfig
govClient govtypes.QueryClient
authClient authtypes.QueryClient
bankClient banktypes.QueryClient
db *database.BigDipperDb
}
// NewModule returns a new Module instance
func NewModule(encodingConfig *params.EncodingConfig, grpcConnection *grpc.ClientConn, db *database.BigDipperDb) *Module {
return &Module{
encodingConfig: encodingConfig,
govClient: govtypes.NewQueryClient(grpcConnection),
authClient: authtypes.NewQueryClient(grpcConnection),
bankClient: banktypes.NewQueryClient(grpcConnection),
db: db,
}
}
// Name implements modules.Module
func (m *Module) Name() string {
return "gov"
}
// RunAdditionalOperations implements modules.Module
func (m *Module) RunAdditionalOperations() error {
return nil
}
// RunAsyncOperations implements modules.Module
func (m *Module) RunAsyncOperations() {
}
// RegisterPeriodicOperations implements modules.Module
func (m *Module) RegisterPeriodicOperations(*gocron.Scheduler) error {
return nil
}
// HandleGenesis implements modules.Module
func (m *Module) HandleGenesis(_ *tmtypes.GenesisDoc, appState map[string]json.RawMessage) error {
return HandleGenesis(appState, m.encodingConfig.Marshaler, m.govClient, m.db)
}
// HandleBlock implements modules.Module
func (m *Module) HandleBlock(*tmctypes.ResultBlock, []*types.Tx, *tmctypes.ResultValidators) error {
return nil
}
// HandleTx implements modules.Module
func (m *Module) HandleTx(*types.Tx) error {
return nil
}
// HandleMsg implements modules.Module
func (m *Module) HandleMsg(_ int, msg sdk.Msg, tx *types.Tx) error {
return HandleMsg(tx, msg, m.govClient, m.authClient, m.bankClient, m.encodingConfig.Marshaler, m.db)
}