/
msg.go
63 lines (52 loc) · 1.58 KB
/
msg.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/mesg-foundation/engine/ext/xvalidator"
)
// Route should return the name of the module.
func (msg MsgCreate) Route() string {
return ModuleName
}
// Type returns the action.
func (msg MsgCreate) Type() string {
return "create"
}
// ValidateBasic runs stateless checks on the message.
func (msg MsgCreate) ValidateBasic() error {
if err := xvalidator.Struct(msg); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
return nil
}
// GetSignBytes encodes the message for signing.
func (msg MsgCreate) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg))
}
// GetSigners defines whose signature is required.
func (msg MsgCreate) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Signer}
}
// Route should return the name of the module.
func (msg MsgUpdate) Route() string {
return ModuleName
}
// Type returns the action.
func (msg MsgUpdate) Type() string {
return "update"
}
// ValidateBasic runs stateless checks on the message.
func (msg MsgUpdate) ValidateBasic() error {
if err := xvalidator.Struct(msg); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
return nil
}
// GetSignBytes encodes the message for signing.
func (msg MsgUpdate) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg))
}
// GetSigners defines whose signature is required.
func (msg MsgUpdate) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Executor}
}