From 79df9e50774758f53330c02ea803dedef7ffb069 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Thu, 30 May 2024 11:03:25 +0000 Subject: [PATCH] refactor(assets,delegation): check case with flag --- x/assets/types/genesis.go | 2 +- x/assets/types/keys.go | 5 ++--- x/delegation/types/genesis.go | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index 4f3342067..ac2a5630e 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -136,7 +136,7 @@ func (gs GenesisState) Validate() error { // validate the stakerID var stakerClientChainID uint64 var err error - if _, stakerClientChainID, err = ValidateID(stakerID, true); err != nil { + if _, stakerClientChainID, err = ValidateID(stakerID, true, true); err != nil { return errorsmod.Wrapf( ErrInvalidGenesisData, "invalid stakerID: %s", diff --git a/x/assets/types/keys.go b/x/assets/types/keys.go index 3e00795e7..f0acdbbab 100644 --- a/x/assets/types/keys.go +++ b/x/assets/types/keys.go @@ -124,9 +124,8 @@ func ParseID(key string) (string, uint64, error) { return keys[0], id, nil } -func ValidateID(key string, validateEth bool) (string, uint64, error) { - // check lowercase - if key != strings.ToLower(key) { +func ValidateID(key string, checkLowercase bool, validateEth bool) (string, uint64, error) { + if checkLowercase && key != strings.ToLower(key) { return "", 0, errorsmod.Wrapf(ErrParseAssetsStateKey, "ID not lowercase: %s", key) } // parse it diff --git a/x/delegation/types/genesis.go b/x/delegation/types/genesis.go index 571cb0c10..4171c2262 100644 --- a/x/delegation/types/genesis.go +++ b/x/delegation/types/genesis.go @@ -33,7 +33,9 @@ func (gs GenesisState) Validate() error { // validate staker ID var stakerClientChainID uint64 var err error - if _, stakerClientChainID, err = assetstypes.ValidateID(stakerID, true); err != nil { + if _, stakerClientChainID, err = assetstypes.ValidateID( + stakerID, true, true, + ); err != nil { return errorsmod.Wrapf( ErrInvalidGenesisData, "invalid staker ID %s: %s", stakerID, err, ) @@ -53,7 +55,9 @@ func (gs GenesisState) Validate() error { assets[assetID] = struct{}{} // validate asset ID var assetClientChainID uint64 - if _, assetClientChainID, err = assetstypes.ValidateID(assetID, true); err != nil { + if _, assetClientChainID, err = assetstypes.ValidateID( + assetID, true, true, + ); err != nil { return errorsmod.Wrapf( ErrInvalidGenesisData, "invalid asset ID %s: %s", assetID, err, )