Skip to content

Commit

Permalink
fix(x/staking): use staking bonddenom in check (#22646)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Nov 26, 2024
1 parent 8c00b86 commit a60dfda
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions x/staking/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (p Params) Validate() error {
return err
}

if err := validateKeyRotationFee(p.KeyRotationFee); err != nil {
if err := validateKeyRotationFee(p.BondDenom, p.KeyRotationFee); err != nil {
return err
}

Expand Down Expand Up @@ -215,17 +215,13 @@ func validateMinCommissionRate(i interface{}) error {
return nil
}

func validateKeyRotationFee(i interface{}) error {
v, ok := i.(sdk.Coin)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
func validateKeyRotationFee(bondDenom string, coin sdk.Coin) error {
if coin.IsNil() {
return fmt.Errorf("cons pubkey rotation fee cannot be nil: %s", coin)
}

if v.IsNil() {
return fmt.Errorf("cons pubkey rotation fee cannot be nil: %s", v)
}
if v.IsLTE(sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)) {
return fmt.Errorf("cons pubkey rotation fee cannot be negative or zero: %s", v)
if coin.IsLTE(sdk.NewInt64Coin(bondDenom, 0)) {
return fmt.Errorf("cons pubkey rotation fee cannot be negative or zero: %s", coin)
}

return nil
Expand Down

0 comments on commit a60dfda

Please sign in to comment.