/
msg_distr_proposal.go
56 lines (47 loc) · 1.84 KB
/
msg_distr_proposal.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
package types
import (
sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
"github.com/fibonacci-chain/fbc/libs/tendermint/global"
"github.com/fibonacci-chain/fbc/libs/tendermint/types"
)
// ensure Msg interface compliance at compile time
var (
_ sdk.Msg = &MsgEditValidatorCommissionRate{}
)
// MsgEditValidatorCommissionRate - struct for editing a validator commission rate
type MsgEditValidatorCommissionRate struct {
CommissionRate sdk.Dec `json:"commission_rate" yaml:"commission_rate"`
ValidatorAddress sdk.ValAddress `json:"address" yaml:"address"`
}
// NewMsgEditValidatorCommissionRate creates a msg of edit-validator-commission-rate
func NewMsgEditValidatorCommissionRate(valAddr sdk.ValAddress, newRate sdk.Dec) MsgEditValidatorCommissionRate {
return MsgEditValidatorCommissionRate{
CommissionRate: newRate,
ValidatorAddress: valAddr,
}
}
// nolint
func (msg MsgEditValidatorCommissionRate) Route() string { return RouterKey }
func (msg MsgEditValidatorCommissionRate) Type() string { return "edit_validator_commission_rate" }
func (msg MsgEditValidatorCommissionRate) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddress)}
}
// GetSignBytes gets the bytes for the message signer to sign on
func (msg MsgEditValidatorCommissionRate) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
// ValidateBasic gives a quick validity check
func (msg MsgEditValidatorCommissionRate) ValidateBasic() error {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr()
}
if msg.CommissionRate.GT(sdk.OneDec()) || msg.CommissionRate.IsNegative() {
return ErrInvalidCommissionRate()
}
//will delete it after upgrade venus2
if !types.HigherThanVenus2(global.GetGlobalHeight()) {
return ErrCodeNotSupportEditValidatorCommissionRate()
}
return nil
}