Skip to content

Commit

Permalink
nit: use collections.Contains when checking for supported encoding, t…
Browse files Browse the repository at this point in the history
…x and feature. (#4197)
  • Loading branch information
DimitrisJim authored Jul 31, 2023
1 parent 47b27ed commit 8be3049
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
17 changes: 3 additions & 14 deletions modules/apps/27-interchain-accounts/types/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v7/internal/collections"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
)

Expand Down Expand Up @@ -133,13 +134,7 @@ func ValidateHostMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, connecti

// isSupportedEncoding returns true if the provided encoding is supported, otherwise false
func isSupportedEncoding(encoding string) bool {
for _, enc := range getSupportedEncoding() {
if enc == encoding {
return true
}
}

return false
return collections.Contains(encoding, getSupportedEncoding())
}

// getSupportedEncoding returns a string slice of supported encoding formats
Expand All @@ -149,13 +144,7 @@ func getSupportedEncoding() []string {

// isSupportedTxType returns true if the provided transaction type is supported, otherwise false
func isSupportedTxType(txType string) bool {
for _, t := range getSupportedTxTypes() {
if t == txType {
return true
}
}

return false
return collections.Contains(txType, getSupportedTxTypes())
}

// getSupportedTxTypes returns a string slice of supported transaction types
Expand Down
9 changes: 2 additions & 7 deletions modules/core/03-connection/types/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

errorsmod "cosmossdk.io/errors"

collections "github.com/cosmos/ibc-go/v7/internal/collections"
"github.com/cosmos/ibc-go/v7/internal/collections"
)

var (
Expand Down Expand Up @@ -100,12 +100,7 @@ func (version Version) VerifyProposedVersion(proposedVersion *Version) error {
// VerifySupportedFeature takes in a version and feature string and returns
// true if the feature is supported by the version and false otherwise.
func VerifySupportedFeature(version *Version, feature string) bool {
for _, f := range version.GetFeatures() {
if f == feature {
return true
}
}
return false
return collections.Contains(feature, version.GetFeatures())
}

// GetCompatibleVersions returns a descending ordered set of compatible IBC
Expand Down

0 comments on commit 8be3049

Please sign in to comment.