-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathmsg.go
More file actions
114 lines (86 loc) · 3.19 KB
/
msg.go
File metadata and controls
114 lines (86 loc) · 3.19 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package uibc
import (
"encoding/json"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/umee-network/umee/v4/util/checkers"
)
var (
_ sdk.Msg = &MsgGovUpdateQuota{}
_ sdk.Msg = &MsgGovSetIBCPause{}
)
// GetTitle implements govv1b1.Content interface.
func (msg *MsgGovUpdateQuota) GetTitle() string { return msg.Title }
// GetDescription implements govv1b1.Content interface.
func (msg *MsgGovUpdateQuota) GetDescription() string { return msg.Description }
// Route implements Msg
func (msg MsgGovUpdateQuota) Route() string { return RouterKey }
// Type implements Msg
func (msg MsgGovUpdateQuota) Type() string { return sdk.MsgTypeURL(&msg) }
// String implements the Stringer interface.
func (msg *MsgGovUpdateQuota) String() string {
out, _ := json.Marshal(msg)
return string(out)
}
// ValidateBasic implements Msg
func (msg *MsgGovUpdateQuota) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
if msg.Total.IsNil() || !msg.Total.IsPositive() {
return sdkerrors.ErrInvalidRequest.Wrap("total quota must be positive")
}
if msg.PerDenom.IsNil() || !msg.PerDenom.IsPositive() {
return sdkerrors.ErrInvalidRequest.Wrap("quota per denom must be positive")
}
return checkers.ValidateProposal(msg.Title, msg.Description, msg.Authority)
}
// GetSignBytes implements Msg
func (msg *MsgGovUpdateQuota) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg))
}
// GetSigners implements Msg
func (msg *MsgGovUpdateQuota) GetSigners() []sdk.AccAddress {
return checkers.Signers(msg.Authority)
}
// GetTitle implements govv1b1.Content interface.
func (msg *MsgGovSetIBCPause) GetTitle() string { return msg.Title }
// GetDescription implements govv1b1.Content interface.
func (msg *MsgGovSetIBCPause) GetDescription() string { return msg.Description }
// Route implements Msg
func (msg MsgGovSetIBCPause) Route() string { return RouterKey }
// Type implements Msg
func (msg MsgGovSetIBCPause) Type() string { return sdk.MsgTypeURL(&msg) }
// String implements the Stringer interface.
func (msg *MsgGovSetIBCPause) String() string {
out, _ := json.Marshal(msg)
return string(out)
}
// ValidateBasic implements Msg
func (msg *MsgGovSetIBCPause) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
if err := validateIBCTransferStatus(msg.IbcPauseStatus); err != nil {
return err
}
return checkers.ValidateProposal(msg.Title, msg.Description, msg.Authority)
}
// GetSignBytes implements Msg
func (msg *MsgGovSetIBCPause) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (msg *MsgGovSetIBCPause) GetSigners() []sdk.AccAddress {
return checkers.Signers(msg.Authority)
}
func (q *Quota) Validate() error {
if len(q.IbcDenom) == 0 {
return sdkerrors.ErrInvalidRequest.Wrap("ibc denom shouldn't be empty")
}
if q.OutflowSum.IsNil() || q.OutflowSum.IsNegative() {
return sdkerrors.ErrInvalidRequest.Wrap("ibc denom quota expires shouldn't be empty")
}
return nil
}