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

chore(x/gov): clean validation code #18449

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
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
26 changes: 13 additions & 13 deletions x/gov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,22 @@ func (k Keeper) ModuleAccountAddress() sdk.AccAddress {
// validateProposalLengths checks message metadata, summary and title
// to have the expected length otherwise returns an error.
func (k Keeper) validateProposalLengths(metadata, title, summary string) error {
if err := k.assertMetadataLength(metadata); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

How come the spacing was wrong?
I believe we have gofmt as linter.
I'll need to check when reviewing the linters config. Nothing for you to do here, just noting.

return err
}
if err := k.assertSummaryLength(summary); err != nil {
return err
}
if err := k.assertTitleLength(title); err != nil {
return err
}
return nil
if err := k.assertMetadataLength(metadata); err != nil {
return err
}
if err := k.assertSummaryLength(summary); err != nil {
return err
}
if err := k.assertTitleLength(title); err != nil {
return err
}
return nil
}

// assertTitleLength returns an error if given title length
// is greater than a pre-defined MaxTitleLen.
func (k Keeper) assertTitleLength(title string) error {
if title != "" && uint64(len(title)) > k.config.MaxTitleLen {
if uint64(len(title)) > k.config.MaxTitleLen {
return types.ErrTitleTooLong.Wrapf("got title with length %d", len(title))
}
return nil
Expand All @@ -217,7 +217,7 @@ func (k Keeper) assertTitleLength(title string) error {
// assertMetadataLength returns an error if given metadata length
// is greater than a pre-defined MaxMetadataLen.
func (k Keeper) assertMetadataLength(metadata string) error {
if metadata != "" && uint64(len(metadata)) > k.config.MaxMetadataLen {
if uint64(len(metadata)) > k.config.MaxMetadataLen {
return types.ErrMetadataTooLong.Wrapf("got metadata with length %d", len(metadata))
}
return nil
Expand All @@ -226,7 +226,7 @@ func (k Keeper) assertMetadataLength(metadata string) error {
// assertSummaryLength returns an error if given summary length
// is greater than a pre-defined MaxSummaryLen.
func (k Keeper) assertSummaryLength(summary string) error {
if summary != "" && uint64(len(summary)) > k.config.MaxSummaryLen {
if uint64(len(summary)) > k.config.MaxSummaryLen {
return types.ErrSummaryTooLong.Wrapf("got summary with length %d", len(summary))
}
return nil
Expand Down
Loading