-
Notifications
You must be signed in to change notification settings - Fork 41
/
messenger.go
42 lines (38 loc) · 1.35 KB
/
messenger.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
package wasm
import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types"
commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper"
"github.com/elys-network/elys/x/masterchef/keeper"
parameterkeeper "github.com/elys-network/elys/x/parameter/keeper"
)
// Messenger handles messages for the Masterchef module.
type Messenger struct {
keeper *keeper.Keeper
stakingKeeper *stakingkeeper.Keeper
commitmentKeeper *commitmentkeeper.Keeper
parameterKeeper *parameterkeeper.Keeper
}
func NewMessenger(
keeper *keeper.Keeper,
stakingKeeper *stakingkeeper.Keeper,
commitmentKeeper *commitmentkeeper.Keeper,
parameterKeeper *parameterkeeper.Keeper,
) *Messenger {
return &Messenger{
keeper: keeper,
stakingKeeper: stakingKeeper,
commitmentKeeper: commitmentKeeper,
parameterKeeper: parameterKeeper,
}
}
func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) {
switch {
case msg.MasterchefClaimRewards != nil:
return m.msgClaimRewards(ctx, contractAddr, msg.MasterchefClaimRewards)
default:
// This handler cannot handle the message
return nil, nil, wasmbindingstypes.ErrCannotHandleMsg
}
}