/
msg.go
82 lines (68 loc) · 1.88 KB
/
msg.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
hmTypes "github.com/maticnetwork/heimdall/types"
)
//
// Propose Span Msg
//
var _ sdk.Msg = &MsgProposeSpan{}
// MsgProposeSpan creates msg propose span
type MsgProposeSpan struct {
ID uint64 `json:"span_id"`
Proposer hmTypes.HeimdallAddress `json:"proposer"`
StartBlock uint64 `json:"start_block"`
EndBlock uint64 `json:"end_block"`
ChainID string `json:"bor_chain_id"`
Seed common.Hash `json:"seed"`
}
// NewMsgProposeSpan creates new propose span message
func NewMsgProposeSpan(
id uint64,
proposer hmTypes.HeimdallAddress,
startBlock uint64,
endBlock uint64,
chainID string,
seed common.Hash,
) MsgProposeSpan {
return MsgProposeSpan{
ID: id,
Proposer: proposer,
StartBlock: startBlock,
EndBlock: endBlock,
ChainID: chainID,
Seed: seed,
}
}
// Type returns message type
func (msg MsgProposeSpan) Type() string {
return "propose-span"
}
// Route returns route for message
func (msg MsgProposeSpan) Route() string {
return RouterKey
}
// GetSigners returns address of the signer
func (msg MsgProposeSpan) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{hmTypes.HeimdallAddressToAccAddress(msg.Proposer)}
}
// GetSignBytes returns sign bytes for proposeSpan message type
func (msg MsgProposeSpan) GetSignBytes() []byte {
b, err := ModuleCdc.MarshalJSON(msg)
if err != nil {
panic(err)
}
return sdk.MustSortJSON(b)
}
// ValidateBasic validates the message and returns error
func (msg MsgProposeSpan) ValidateBasic() sdk.Error {
if msg.Proposer.Empty() {
return sdk.ErrInvalidAddress(msg.Proposer.String())
}
return nil
}
// GetSideSignBytes returns side sign bytes
func (msg MsgProposeSpan) GetSideSignBytes() []byte {
return nil
}