/
msg_update_validator_description.go
66 lines (57 loc) · 1.57 KB
/
msg_update_validator_description.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
64
65
66
package types
import (
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const TypeMsgUpdateValidatorDescription = "update_validator_description"
var _ sdk.Msg = &MsgUpdateValidatorDescription{}
func NewMsgUpdateValidatorDescription(
address,
identity,
moniker,
website,
securityContact,
details string,
) *MsgUpdateValidatorDescription {
return &MsgUpdateValidatorDescription{
Address: address,
Description: ValidatorDescription{
Identity: identity,
Moniker: moniker,
Website: website,
SecurityContact: securityContact,
Details: details,
},
}
}
func (msg *MsgUpdateValidatorDescription) Route() string {
return RouterKey
}
func (msg *MsgUpdateValidatorDescription) Type() string {
return TypeMsgUpdateValidatorDescription
}
func (msg *MsgUpdateValidatorDescription) GetSigners() []sdk.AccAddress {
address, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
panic(err)
}
return []sdk.AccAddress{address}
}
func (msg *MsgUpdateValidatorDescription) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (msg *MsgUpdateValidatorDescription) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
return sdkerrors.Wrap(ErrInvalidValAddress, err.Error())
}
if msg.Description.Details == "" &&
msg.Description.Moniker == "" &&
msg.Description.Identity == "" &&
msg.Description.Website == "" &&
msg.Description.SecurityContact == "" {
return sdkerrors.Wrap(ErrEmptyDescription, msg.Address)
}
return nil
}