Skip to content

Commit

Permalink
refactor(x/gov): backport MinInitialDepositRatio validation from v0.5…
Browse files Browse the repository at this point in the history
…0 to v0.47 (#18190)
  • Loading branch information
julienrbrt authored Oct 20, 2023
1 parent 1a306fd commit d003fa1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x/gov/types/v1/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,16 @@ func (p Params) ValidateBasic() error {
return fmt.Errorf("voting period must be positive: %s", p.VotingPeriod)
}

minInitialDepositRatio, err := math.LegacyNewDecFromStr(p.MinInitialDepositRatio)
if err != nil {
return fmt.Errorf("invalid mininum initial deposit ratio of proposal: %w", err)
}
if minInitialDepositRatio.IsNegative() {
return fmt.Errorf("mininum initial deposit ratio of proposal must be positive: %s", minInitialDepositRatio)
}
if minInitialDepositRatio.GT(math.LegacyOneDec()) {
return fmt.Errorf("mininum initial deposit ratio of proposal is too large: %s", minInitialDepositRatio)
}

return nil
}

0 comments on commit d003fa1

Please sign in to comment.