cosmos-sdk/x/slashing/msg.go
Dev Ojha 65137f6331 Merge PR #2343: Add a name field to the message type
This is to facillitate ease of implementing #1406. (Tags for messages
could then be added dynamically)

Ultimately once we make the router support hiearchical routing, (#770)
we can then remove the name field and just the parse info for tags from that.

Until then, we can parse the tag name as
`fmt.Sprintf("%s %s", msg.Type(), msg.Name())`
2018-09-17 22:34:06 +08:00

50 lines
1.1 KiB
Go

package slashing
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var cdc = codec.New()
// name to identify transaction types
const MsgType = "slashing"
// verify interface at compile time
var _ sdk.Msg = &MsgUnjail{}
// MsgUnjail - struct for unjailing jailed validator
type MsgUnjail struct {
ValidatorAddr sdk.ValAddress `json:"address"` // address of the validator operator
}
func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail {
return MsgUnjail{
ValidatorAddr: validatorAddr,
}
}
//nolint
func (msg MsgUnjail) Type() string { return MsgType }
func (msg MsgUnjail) Name() string { return "unjail" }
func (msg MsgUnjail) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddr)}
}
// get the bytes for the message signer to sign on
func (msg MsgUnjail) GetSignBytes() []byte {
b, err := cdc.MarshalJSON(msg)
if err != nil {
panic(err)
}
return sdk.MustSortJSON(b)
}
// quick validity check
func (msg MsgUnjail) ValidateBasic() sdk.Error {
if msg.ValidatorAddr == nil {
return ErrBadValidatorAddr(DefaultCodespace)
}
return nil
}