forked from forbole/juno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
38 lines (30 loc) · 885 Bytes
/
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
package messages
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spike-engine/juno/database"
"github.com/spike-engine/juno/modules"
"github.com/spike-engine/juno/types"
)
var _ modules.Module = &Module{}
// Module represents the module allowing to store messages properly inside a dedicated table
type Module struct {
parser MessageAddressesParser
cdc codec.Codec
db database.Database
}
func NewModule(parser MessageAddressesParser, cdc codec.Codec, db database.Database) *Module {
return &Module{
parser: parser,
cdc: cdc,
db: db,
}
}
// Name implements modules.Module
func (m *Module) Name() string {
return "messages"
}
// HandleMsg implements modules.MessageModule
func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *types.Tx) error {
return HandleMsg(index, msg, tx, m.parser, m.cdc, m.db)
}