-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
msgs.go
68 lines (53 loc) · 2.06 KB
/
msgs.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)
var (
_, _ sdk.Msg = &MsgSoftwareUpgrade{}, &MsgCancelUpgrade{}
_, _ legacytx.LegacyMsg = &MsgSoftwareUpgrade{}, &MsgCancelUpgrade{}
)
// Route implements the LegacyMsg interface.
func (m MsgSoftwareUpgrade) Route() string { return sdk.MsgTypeURL(&m) }
// Type implements the LegacyMsg interface.
func (m MsgSoftwareUpgrade) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes implements the LegacyMsg interface.
func (m MsgSoftwareUpgrade) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// ValidateBasic does a sanity check on the provided data.
func (m *MsgSoftwareUpgrade) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return sdkerrors.Wrap(err, "authority")
}
if err := m.Plan.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "plan")
}
return nil
}
// GetSigners returns the expected signers for MsgSoftwareUpgrade.
func (m *MsgSoftwareUpgrade) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}
// Route implements the LegacyMsg interface.
func (m MsgCancelUpgrade) Route() string { return sdk.MsgTypeURL(&m) }
// Type implements the LegacyMsg interface.
func (m MsgCancelUpgrade) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes implements the LegacyMsg interface.
func (m MsgCancelUpgrade) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// ValidateBasic does a sanity check on the provided data.
func (m *MsgCancelUpgrade) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return sdkerrors.Wrap(err, "authority")
}
return nil
}
// GetSigners returns the expected signers for MsgCancelUpgrade.
func (m *MsgCancelUpgrade) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}