-
Notifications
You must be signed in to change notification settings - Fork 13
/
messages_params.go
48 lines (38 loc) · 1016 Bytes
/
messages_params.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var _ sdk.Msg = &MsgUpdateParams{}
func NewMsgUpdateParams(authority string, params Params) *MsgUpdateParams {
return &MsgUpdateParams{
Authority: authority,
Params: params,
}
}
func (msg *MsgUpdateParams) Route() string {
return RouterKey
}
func (msg *MsgUpdateParams) Type() string {
return "UpdateParams"
}
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
authority, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
panic(err)
}
return []sdk.AccAddress{authority}
}
func (msg *MsgUpdateParams) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (m *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
if err := m.Params.Validate(); err != nil {
return err
}
return nil
}