chore(x/staking,x/upgrade): replace fmt.Errorf without parameters with errors.New (#21004)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
@@ -40,41 +40,41 @@ func ValidateGenesis(gs *GenesisState) error {
|
||||
|
||||
func validateBudget(bp Budget) error {
|
||||
if bp.RecipientAddress == "" {
|
||||
return fmt.Errorf("recipient cannot be empty")
|
||||
return errors.New("recipient cannot be empty")
|
||||
}
|
||||
|
||||
// Validate BudgetPerTranche
|
||||
if bp.BudgetPerTranche == nil || bp.BudgetPerTranche.IsZero() {
|
||||
return fmt.Errorf("budget per tranche cannot be zero")
|
||||
return errors.New("budget per tranche cannot be zero")
|
||||
}
|
||||
if err := bp.BudgetPerTranche.Validate(); err != nil {
|
||||
return errors.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String())
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String())
|
||||
}
|
||||
|
||||
if bp.TranchesLeft == 0 {
|
||||
return fmt.Errorf("invalid budget proposal: tranches must be greater than zero")
|
||||
return errors.New("invalid budget proposal: tranches must be greater than zero")
|
||||
}
|
||||
|
||||
if bp.Period == nil || *bp.Period == 0 {
|
||||
return fmt.Errorf("invalid budget proposal: period length should be greater than zero")
|
||||
return errors.New("invalid budget proposal: period length should be greater than zero")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateContinuousFund(cf ContinuousFund) error {
|
||||
if cf.Recipient == "" {
|
||||
return fmt.Errorf("recipient cannot be empty")
|
||||
return errors.New("recipient cannot be empty")
|
||||
}
|
||||
|
||||
// Validate percentage
|
||||
if cf.Percentage.IsNil() || cf.Percentage.IsZero() {
|
||||
return fmt.Errorf("percentage cannot be zero or empty")
|
||||
return errors.New("percentage cannot be zero or empty")
|
||||
}
|
||||
if cf.Percentage.IsNegative() {
|
||||
return fmt.Errorf("percentage cannot be negative")
|
||||
return errors.New("percentage cannot be negative")
|
||||
}
|
||||
if cf.Percentage.GT(math.LegacyOneDec()) {
|
||||
return fmt.Errorf("percentage cannot be greater than one")
|
||||
return errors.New("percentage cannot be greater than one")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user