From c998866b9c2142124a0574937499e1c9b411ab78 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:00:17 -0700 Subject: [PATCH] validate denoms --- x/ccv/provider/types/proposal.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/x/ccv/provider/types/proposal.go b/x/ccv/provider/types/proposal.go index 47020ae696..b2286d4adf 100644 --- a/x/ccv/provider/types/proposal.go +++ b/x/ccv/provider/types/proposal.go @@ -10,6 +10,7 @@ import ( errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -273,5 +274,18 @@ func (crdp *ChangeRewardDenomsProposal) ValidateBasic() error { } } } + + // Return error if any denom is "invalid" + for _, denom := range crdp.DenomsToAdd { + if !sdk.NewCoin(denom, sdk.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + for _, denom := range crdp.DenomsToRemove { + if !sdk.NewCoin(denom, sdk.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + return nil }