Skip to content

Commit

Permalink
chore: fix slices.Contains api usage, and remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan committed Sep 18, 2023
1 parent e01c3e3 commit fc4adde
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"encoding/json"
"fmt"
"slices"

"github.com/cosmos/gogoproto/proto"
"github.com/spf13/cobra"
Expand All @@ -12,7 +13,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"

"github.com/cosmos/ibc-go/v8/internal/collections"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
)

Expand Down Expand Up @@ -82,7 +82,7 @@ otherwise the encoding flag can be used in combination with either "proto3" or "
return err
}

if !slices.Contains(encoding, []string{icatypes.EncodingProtobuf, icatypes.EncodingProto3JSON}) {
if !slices.Contains([]string{icatypes.EncodingProtobuf, icatypes.EncodingProto3JSON}, encoding) {
return fmt.Errorf("unsupported encoding type: %s", encoding)
}

Expand Down
7 changes: 4 additions & 3 deletions modules/apps/27-interchain-accounts/types/metadata.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package types

import (
"slices"

errorsmod "cosmossdk.io/errors"

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

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

Expand Down Expand Up @@ -134,7 +135,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 {
return slices.Contains(encoding, getSupportedEncoding())
return slices.Contains(getSupportedEncoding(), encoding)
}

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

// isSupportedTxType returns true if the provided transaction type is supported, otherwise false
func isSupportedTxType(txType string) bool {
return slices.Contains(txType, getSupportedTxTypes())
return slices.Contains(getSupportedTxTypes(), txType)
}

// getSupportedTxTypes returns a string slice of supported transaction types
Expand Down
4 changes: 2 additions & 2 deletions modules/core/02-client/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package types

import (
"fmt"
"slices"
"strings"

"github.com/cosmos/ibc-go/v8/internal/collections"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
)

Expand All @@ -30,7 +30,7 @@ func (p Params) Validate() error {

// IsAllowedClient checks if the given client type is registered on the allowlist.
func (p Params) IsAllowedClient(clientType string) bool {
return slices.Contains(clientType, p.AllowedClients)
return slices.Contains(p.AllowedClients, clientType)
}

// validateClients checks that the given clients are not blank.
Expand Down
9 changes: 4 additions & 5 deletions modules/core/03-connection/types/version.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package types

import (
"slices"
"strings"

errorsmod "cosmossdk.io/errors"

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

var (
Expand Down Expand Up @@ -86,7 +85,7 @@ func (version Version) VerifyProposedVersion(proposedVersion *Version) error {
}

for _, proposedFeature := range proposedVersion.GetFeatures() {
if !slices.Contains(proposedFeature, version.GetFeatures()) {
if !slices.Contains(version.GetFeatures(), proposedFeature) {
return errorsmod.Wrapf(
ErrVersionNegotiationFailed,
"proposed feature (%s) is not a supported feature set (%s)", proposedFeature, version.GetFeatures(),
Expand All @@ -100,7 +99,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 {
return slices.Contains(feature, version.GetFeatures())
return slices.Contains(version.GetFeatures(), feature)
}

// GetCompatibleVersions returns a descending ordered set of compatible IBC
Expand Down Expand Up @@ -176,7 +175,7 @@ func PickVersion(supportedVersions, counterpartyVersions []*Version) (*Version,
// set for the counterparty version.
func GetFeatureSetIntersection(sourceFeatureSet, counterpartyFeatureSet []string) (featureSet []string) {
for _, feature := range sourceFeatureSet {
if slices.Contains(feature, counterpartyFeatureSet) {
if slices.Contains(counterpartyFeatureSet, feature) {
featureSet = append(featureSet, feature)
}
}
Expand Down
4 changes: 2 additions & 2 deletions testing/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package ibctesting

import (
"fmt"
"slices"
"strconv"

testifysuite "github.com/stretchr/testify/suite"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/ibc-go/v8/internal/collections"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
Expand Down Expand Up @@ -185,7 +185,7 @@ func AssertEvents(
for _, expectedAttr := range expectedEvent.Attributes {
// any expected attributes that are not contained in the actual events will cause this event
// not to match
attributeMatch = attributeMatch && slices.Contains(expectedAttr, actualEvent.Attributes)
attributeMatch = attributeMatch && slices.Contains(actualEvent.Attributes, expectedAttr)
}

if attributeMatch {
Expand Down

0 comments on commit fc4adde

Please sign in to comment.