Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/distribution): add nil check in Params.ValidateBasic #17236

Merged
merged 6 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions x/distribution/types/params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"errors"
"fmt"

"cosmossdk.io/math"
Expand All @@ -18,6 +19,10 @@ func DefaultParams() Params {

// ValidateBasic performs basic validation on distribution parameters.
func (p Params) ValidateBasic() error {
if p.CommunityTax.IsNil() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using just doing return validateCommunityTax(p.CommunityTax) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I'll add an update

return errors.New("CommunityTax is nil")
}

if p.CommunityTax.IsNegative() || p.CommunityTax.GT(math.LegacyOneDec()) {
return fmt.Errorf(
"community tax should be non-negative and less than one: %s", p.CommunityTax,
Expand Down