From d52f5e8642a438becb51880beb4e12b729001fd7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 09:36:18 +0100 Subject: [PATCH] fix(x/staking): use staking bonddenom in check (backport #22646) (#22649) Co-authored-by: Julien Robert --- x/staking/types/params.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/x/staking/types/params.go b/x/staking/types/params.go index 72e6df6c91..083fbcaa7a 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -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 } @@ -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