Skip to content

Commit

Permalink
feat: Add GetParamSetIfExists to prevent panic on breaking param chan…
Browse files Browse the repository at this point in the history
…ges (backport cosmos#12615) (cosmos#12792)

* feat: Add GetParamSetIfExists to prevent panic on breaking param changes (cosmos#12615)

* imp(params): Add GetParamSetIfExists to prevent panic on breaking param changes

* changelog

* test

Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit 2932e11)

# Conflicts:
#	CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 4759df5 commit 0c89957
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (x/params) [#12615](https://github.com/cosmos/cosmos-sdk/pull/12615) Add `GetParamSetIfExists` function to params `Subspace` to prevent panics on breaking changes.
* (x/bank) [#12674](https://github.com/cosmos/cosmos-sdk/pull/12674) Add convenience function `CreatePrefixedAccountStoreKey()` to construct key to access account's balance for a given denom.

## [v0.46.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0) - 2022-07-26
Expand Down
9 changes: 9 additions & 0 deletions x/params/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ func (p *paramsV2) ParamSetPairs() types.ParamSetPairs {
}
}

func (p *paramsV2) ParamSetPairs() types.ParamSetPairs {
return types.ParamSetPairs{
{keyUnbondingTime, &p.UnbondingTime, validateUnbondingTime},
{keyMaxValidators, &p.MaxValidators, validateMaxValidators},
{keyBondDenom, &p.BondDenom, validateBondDenom},
{keyMaxRedelegationEntries, &p.MaxRedelegationEntries, validateMaxRedelegationEntries},
}
}

func paramKeyTable() types.KeyTable {
return types.NewKeyTable().RegisterParamSet(&params{})
}

0 comments on commit 0c89957

Please sign in to comment.