Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use collections.Contains in metadata, version. #4197

Merged
merged 6 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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