From 8ff511ff12f9275db976a390c914300025661aaa Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 29 Dec 2023 17:09:59 +0000 Subject: [PATCH] fix: allow chainId without hyphen. Fixes #974 (#976) * fix: allow chainId without hyphen. Fixes #974 * fix: allow chainId without hyphen in interchainquery. Fixes #974 --------- Co-authored-by: Jacob Gadikian --- x/interchainquery/types/msgs.go | 7 ++----- .../types/protocol_data_test.go | 20 ------------------- .../types/submodule_liquid.go | 10 ---------- .../types/submodule_osmosis.go | 3 +-- 4 files changed, 3 insertions(+), 37 deletions(-) diff --git a/x/interchainquery/types/msgs.go b/x/interchainquery/types/msgs.go index 636135a7a..1845b8cf0 100644 --- a/x/interchainquery/types/msgs.go +++ b/x/interchainquery/types/msgs.go @@ -2,7 +2,6 @@ package types import ( "errors" - "strings" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -31,10 +30,8 @@ func (msg MsgSubmitQueryResponse) ValidateBasic() error { return errors.New("height must be non-negative") } - // TODO: is there a chain validation spec in ICS? - chainParts := strings.Split(msg.ChainId, "-") - if len(chainParts) < 2 && msg.ChainId != "provider" { - return errors.New("chainID must be of form XXXX-N") + if len(msg.ChainId) < 2 { + return errors.New("invalid chain id") } if len(msg.QueryId) != 64 { diff --git a/x/participationrewards/types/protocol_data_test.go b/x/participationrewards/types/protocol_data_test.go index f31070856..73b853d17 100644 --- a/x/participationrewards/types/protocol_data_test.go +++ b/x/participationrewards/types/protocol_data_test.go @@ -81,26 +81,6 @@ func TestLiquidProtocolData_ValidateBasic(t *testing.T) { }, false, }, - { - "liquid_invalid_chainid", - types.LiquidAllowedDenomProtocolData{ - ChainID: "badzone", - IbcDenom: "ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3", - QAssetDenom: "uqstake", - RegisteredZoneChainID: "testzone-1", - }, - true, - }, - { - "liquid_invalid_rzchainid", - types.LiquidAllowedDenomProtocolData{ - ChainID: "somechain-1", - IbcDenom: "ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3", - QAssetDenom: "uqstake", - RegisteredZoneChainID: "badzone", - }, - true, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/participationrewards/types/submodule_liquid.go b/x/participationrewards/types/submodule_liquid.go index c1edc0ced..89ccdacad 100644 --- a/x/participationrewards/types/submodule_liquid.go +++ b/x/participationrewards/types/submodule_liquid.go @@ -1,8 +1,6 @@ package types import ( - "strings" - "github.com/ingenuity-build/multierror" ) @@ -26,18 +24,10 @@ func (lpd *LiquidAllowedDenomProtocolData) ValidateBasic() error { errs["ChainID"] = ErrUndefinedAttribute } - if len(strings.Split(lpd.ChainID, "-")) < 2 { - errs["ChainID"] = ErrInvalidChainID - } - if lpd.RegisteredZoneChainID == "" { errs["RegisteredZoneChainID"] = ErrUndefinedAttribute } - if len(strings.Split(lpd.RegisteredZoneChainID, "-")) < 2 { - errs["RegisteredZoneChainID"] = ErrInvalidChainID - } - if lpd.QAssetDenom == "" { errs["QAssetDenom"] = ErrUndefinedAttribute } diff --git a/x/participationrewards/types/submodule_osmosis.go b/x/participationrewards/types/submodule_osmosis.go index c7213a847..2cb304df2 100644 --- a/x/participationrewards/types/submodule_osmosis.go +++ b/x/participationrewards/types/submodule_osmosis.go @@ -3,7 +3,6 @@ package types import ( "encoding/json" "fmt" - "strings" "time" "github.com/ingenuity-build/multierror" @@ -95,7 +94,7 @@ func (opd *OsmosisPoolProtocolData) ValidateBasic() error { for _, ibcdenom := range utils.Keys(opd.Denoms) { el := fmt.Sprintf("Denoms[%s]", ibcdenom) - if opd.Denoms[ibcdenom].ChainID == "" || len(strings.Split(opd.Denoms[ibcdenom].ChainID, "-")) < 2 { + if opd.Denoms[ibcdenom].ChainID == "" { errs[el+" key"] = fmt.Errorf("%w, chainID", ErrInvalidChainID) }