Skip to content

Commit

Permalink
validate denoms
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Sep 11, 2023
1 parent 3e823c3 commit c998866
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions x/ccv/provider/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}

0 comments on commit c998866

Please sign in to comment.