/
msg_update_validator.go
41 lines (32 loc) · 1.11 KB
/
msg_update_validator.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
package v1
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var _ sdk.Msg = &MsgUpdateValidator{}
// ValidateBasic performs stateless validation on MsgUpdateValidator.
func (m MsgUpdateValidator) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Address); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("address: %s", err)
}
if m.NewMetadata == "" {
return sdkerrors.ErrInvalidRequest.Wrap("new metadata: empty string is not allowed")
}
if len(m.NewMetadata) > MetadataMaxLength {
return sdkerrors.ErrInvalidRequest.Wrapf("new metadata: exceeds max length %d", MetadataMaxLength)
}
return nil
}
// GetSigners returns the expected signers for MsgUpdateValidator.
func (m MsgUpdateValidator) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Address)
return []sdk.AccAddress{addr}
}
// Route implements the LegacyMsg interface.
func (m MsgUpdateValidator) Route() string {
return sdk.MsgTypeURL(&m)
}
// Type implements the LegacyMsg interface.
func (m MsgUpdateValidator) Type() string {
return sdk.MsgTypeURL(&m)
}