-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg_upgrade.go
51 lines (42 loc) · 1009 Bytes
/
msg_upgrade.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
package types
import (
sdk "github.com/ci123chain/ci123chain/pkg/abci/types"
)
type MsgUpgrade struct {
FromAddress sdk.AccAddress `json:"from_address"`
Type string `json:"type"`
Height int64 `json:"height"`
Name string `json:"name"`
}
func NewMsgUpgrade(from sdk.AccAddress, t, name string, height int64) *MsgUpgrade{
return &MsgUpgrade{
FromAddress: from,
Type:t,
Height:height,
Name:name,
}
}
func (msg *MsgUpgrade) Route() string { return RouteKey }
func (msg *MsgUpgrade) MsgType() string { return "upgrade"}
func (msg *MsgUpgrade) ValidateBasic() error {
if len(msg.Type) == 0 {
return ErrCheckParams
}
if msg.Height < 0 {
return ErrCheckParams
}
if len(msg.Name) == 0 {
return ErrCheckParams
}
return nil
}
func (msg *MsgUpgrade) Bytes() []byte {
bytes, err := ModuleCdc.MarshalBinaryLengthPrefixed(msg)
if err != nil {
panic(err)
}
return bytes
}
func (msg *MsgUpgrade) GetFromAddress() sdk.AccAddress {
return msg.FromAddress
}