Skip to content

Commit

Permalink
fix: allow chainId without hyphen. Fixes #974 (#976)
Browse files Browse the repository at this point in the history
* fix: allow chainId without hyphen. Fixes #974

* fix: allow chainId without hyphen in interchainquery. Fixes #974

---------

Co-authored-by: Jacob Gadikian <[email protected]>
  • Loading branch information
Joe Bowman and faddat authored Dec 29, 2023
1 parent 3c0ae1d commit 8ff511f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
7 changes: 2 additions & 5 deletions x/interchainquery/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"errors"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down Expand Up @@ -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 {
Expand Down
20 changes: 0 additions & 20 deletions x/participationrewards/types/protocol_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 0 additions & 10 deletions x/participationrewards/types/submodule_liquid.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
"strings"

"github.com/ingenuity-build/multierror"
)

Expand All @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions x/participationrewards/types/submodule_osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package types
import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/ingenuity-build/multierror"
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 8ff511f

Please sign in to comment.