diff --git a/CHANGELOG.md b/CHANGELOG.md index a3b0ddcb2a..4479669cfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [\#1313](https://github.com/Finschia/finschia-sdk/pull/1313) fix correctly coalesce coins even with repeated denominations(backport cosmos/cosmos-sdk#13265) * (x/crypto) [\#1316](https://github.com/Finschia/finschia-sdk/pull/1316) error if incorrect ledger public key (backport cosmos/cosmos-sdk#14460, cosmos/cosmos-sdk#19691) * (x/auth) [#1319](https://github.com/Finschia/finschia-sdk/pull/1319) prevent signing from wrong key in multisig +* (x/mint, x/slashing) [\#1323](https://github.com/Finschia/finschia-sdk/pull/1323) add missing nil check for params validation ### Removed diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 8a9ce49325..b323abae0d 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" sdk "github.com/Finschia/finschia-sdk/types" paramtypes "github.com/Finschia/finschia-sdk/x/params/types" @@ -120,7 +120,9 @@ func validateInflationRateChange(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("inflation rate change cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("inflation rate change cannot be negative: %s", v) } @@ -136,7 +138,9 @@ func validateInflationMax(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("max inflation cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("max inflation cannot be negative: %s", v) } @@ -152,7 +156,9 @@ func validateInflationMin(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("min inflation cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("min inflation cannot be negative: %s", v) } @@ -168,7 +174,9 @@ func validateGoalBonded(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("goal bonded cannot be nil: %s", v) + } if v.IsNegative() || v.IsZero() { return fmt.Errorf("goal bonded must be positive: %s", v) } diff --git a/x/slashing/types/params.go b/x/slashing/types/params.go index 5d7fd6bcab..6f60e2ca41 100644 --- a/x/slashing/types/params.go +++ b/x/slashing/types/params.go @@ -85,7 +85,9 @@ func validateMinSignedPerWindow(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("min signed per window cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("min signed per window cannot be negative: %s", v) } @@ -114,7 +116,9 @@ func validateSlashFractionDoubleSign(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("double sign slash fraction cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("double sign slash fraction cannot be negative: %s", v) } @@ -130,7 +134,9 @@ func validateSlashFractionDowntime(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - + if v.IsNil() { + return fmt.Errorf("downtime slash fraction cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("downtime slash fraction cannot be negative: %s", v) }