-
Notifications
You must be signed in to change notification settings - Fork 231
/
module.go
58 lines (49 loc) · 1.55 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
package auth
import (
"encoding/json"
"github.com/forbole/bdjuno/database"
"github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
authttypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/desmos-labs/juno/modules"
"github.com/desmos-labs/juno/modules/messages"
juno "github.com/desmos-labs/juno/types"
tmtypes "github.com/tendermint/tendermint/types"
)
var (
_ modules.Module = &Module{}
_ modules.GenesisModule = &Module{}
_ modules.MessageModule = &Module{}
)
// Module represents the x/auth module
type Module struct {
messagesParser messages.MessageAddressesParser
encodingConfig *params.EncodingConfig
authClient authttypes.QueryClient
db *database.Db
}
// NewModule builds a new Module instance
func NewModule(
messagesParser messages.MessageAddressesParser,
authClient authttypes.QueryClient,
encodingConfig *params.EncodingConfig, db *database.Db,
) *Module {
return &Module{
messagesParser: messagesParser,
encodingConfig: encodingConfig,
authClient: authClient,
db: db,
}
}
// Name implements modules.Module
func (m *Module) Name() string {
return "auth"
}
// HandleGenesis implements modules.GenesisModule
func (m *Module) HandleGenesis(_ *tmtypes.GenesisDoc, appState map[string]json.RawMessage) error {
return Handler(appState, m.encodingConfig.Marshaler, m.db)
}
// HandleMsg implements modules.MessageModule
func (m *Module) HandleMsg(_ int, msg sdk.Msg, _ *juno.Tx) error {
return HandleMsg(msg, m.messagesParser, m.encodingConfig.Marshaler, m.db)
}