From f4e27034328a587a1b70ea469659d4a432f85ee0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 20 Oct 2023 14:00:54 +0200 Subject: [PATCH] refactor: backport MinInitialDepositRatio validation from v0.50 to v0.47 --- x/gov/types/v1/params.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/x/gov/types/v1/params.go b/x/gov/types/v1/params.go index c54957b540c9..ef72de653412 100644 --- a/x/gov/types/v1/params.go +++ b/x/gov/types/v1/params.go @@ -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 }