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: cherry-pick some inj changes #17109

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
sync with group
  • Loading branch information
julienrbrt committed Jul 24, 2023
commit 4f28bbbca67492f860e3c7345b61529b922f2b4e
2 changes: 1 addition & 1 deletion x/gov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (k Keeper) assertMetadataLength(metadata string) error {
// is greater than a pre-defined 40*MaxMetadataLen.
func (keeper Keeper) assertSummaryLength(summary string) error {
if summary != "" && uint64(len(summary)) > 40*keeper.config.MaxMetadataLen {
return types.ErrMetadataTooLong.Wrapf("got summary with length %d", len(summary))
return types.ErrSummaryTooLong.Wrapf("got summary with length %d", len(summary))
}
return nil
}
1 change: 1 addition & 0 deletions x/gov/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ var (
ErrInvalidProposer = errors.Register(ModuleName, 18, "invalid proposer")
ErrVotingPeriodEnded = errors.Register(ModuleName, 20, "voting period already ended")
ErrInvalidProposal = errors.Register(ModuleName, 21, "invalid proposal")
ErrSummaryTooLong = errors.Register(ModuleName, 22, "summary too long")
)
11 changes: 10 additions & 1 deletion x/group/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (k Keeper) SubmitProposal(goCtx context.Context, msg *group.MsgSubmitPropos
return nil, err
}

if err := k.assertMetadataLength(msg.Summary, "proposal summary"); err != nil {
if err := k.assertSummaryLength(msg.Summary); err != nil {
return nil, err
}

Expand Down Expand Up @@ -1062,6 +1062,15 @@ func (k Keeper) assertMetadataLength(metadata, description string) error {
return nil
}

// assertSummaryLength returns an error if given summary length
// is greater than a pre-defined 40*MaxMetadataLen.
func (keeper Keeper) assertSummaryLength(summary string) error {
if summary != "" && uint64(len(summary)) > 40*keeper.config.MaxMetadataLen {
return errorsmod.Wrapf(errors.ErrMaxLimit, "proposal summary is too long")
}
return nil
}

// validateDecisionPolicies loops through all decision policies from the group,
// and calls each of their Validate() method.
func (k Keeper) validateDecisionPolicies(ctx sdk.Context, g group.GroupInfo) error {
Expand Down