/
msg-sidechain-slash.go
50 lines (40 loc) · 1.35 KB
/
msg-sidechain-slash.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
package msg
import (
"fmt"
"github.com/Sotatek-huytran2/go-sdk/common/types"
)
const (
TypeMsgSideChainUnjail = "side_chain_unjail"
SideChainSlashMsgRoute = "slashing"
)
type MsgSideChainUnjail struct {
ValidatorAddr types.ValAddress `json:"address"`
SideChainId string `json:"side_chain_id"`
}
func NewMsgSideChainUnjail(validatorAddr types.ValAddress, sideChainId string) MsgSideChainUnjail {
return MsgSideChainUnjail{
ValidatorAddr: validatorAddr,
SideChainId: sideChainId,
}
}
func (msg MsgSideChainUnjail) Route() string { return SideChainSlashMsgRoute }
func (msg MsgSideChainUnjail) Type() string { return TypeMsgSideChainUnjail }
func (msg MsgSideChainUnjail) GetSigners() []types.AccAddress {
return []types.AccAddress{types.AccAddress(msg.ValidatorAddr)}
}
func (msg MsgSideChainUnjail) GetSignBytes() []byte {
b := MsgCdc.MustMarshalJSON(msg)
return MustSortJSON(b)
}
func (msg MsgSideChainUnjail) ValidateBasic() error {
if msg.ValidatorAddr == nil {
return fmt.Errorf("validator does not exist for that address")
}
if len(msg.SideChainId) == 0 || len(msg.SideChainId) > MaxSideChainIdLength {
return fmt.Errorf(fmt.Sprintf("side chain id must be included and max length is %d bytes", MaxSideChainIdLength))
}
return nil
}
func (msg MsgSideChainUnjail) GetInvolvedAddresses() []types.AccAddress {
return msg.GetSigners()
}