-
Notifications
You must be signed in to change notification settings - Fork 44
/
msgs.go
54 lines (42 loc) · 1.4 KB
/
msgs.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
package types
import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// Sudo Message called on the contracts
EndBlockSudoMessage = `{"clock_end_block":{}}`
)
// == MsgUpdateParams ==
const TypeMsgUpdateParams = "update_clock_params"
var _ sdk.Msg = &MsgUpdateParams{}
// NewMsgUpdateParams creates new instance of MsgUpdateParams
func NewMsgUpdateParams(
sender sdk.Address,
contracts []string,
) *MsgUpdateParams {
return &MsgUpdateParams{
Authority: sender.String(),
Params: Params{ContractAddresses: contracts},
}
}
// Route returns the name of the module
func (msg MsgUpdateParams) Route() string { return RouterKey }
// Type returns the the action
func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams }
// GetSignBytes implements the LegacyMsg interface.
func (msg MsgUpdateParams) GetSignBytes() []byte {
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
}
// GetSigners returns the expected signers for a MsgUpdateParams message.
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{addr}
}
// ValidateBasic does a sanity check on the provided data.
func (msg *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return errors.Wrap(err, "invalid authority address")
}
return msg.Params.Validate()
}