From e49cadd5f71be38dead79e6f5edaddcd0cb37612 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 23 Jan 2024 16:52:38 +0100 Subject: [PATCH] chore: remove IsOpen and IsClosed channel methods (#5691) --- .../27-interchain-accounts/controller/keeper/keeper.go | 4 ++-- .../apps/27-interchain-accounts/host/keeper/keeper.go | 2 +- modules/core/04-channel/keeper/handshake.go | 4 ++-- modules/core/04-channel/keeper/upgrade.go | 6 +++--- modules/core/04-channel/types/channel.go | 10 ---------- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 4e11ea993e7..d378863a0e5 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -150,7 +150,7 @@ func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID strin channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID) - if found && channel.IsOpen() { + if found && channel.State == channeltypes.OPEN { return channelID, true } @@ -165,7 +165,7 @@ func (k Keeper) IsActiveChannelClosed(ctx sdk.Context, connectionID, portID stri } channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID) - return found && channel.IsClosed() + return found && channel.State == channeltypes.CLOSED } // GetAllActiveChannels returns a list of all active interchain accounts controller channels and their associated connection and port identifiers diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 92055909a00..ce8bdad1234 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -152,7 +152,7 @@ func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID strin channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID) - if found && channel.IsOpen() { + if found && channel.State == channeltypes.OPEN { return channelID, true } diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 1f888596b90..48103fe97d2 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -385,7 +385,7 @@ func (k Keeper) ChanCloseInit( return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) } - if channel.IsClosed() { + if channel.State == types.CLOSED { return errorsmod.Wrap(types.ErrInvalidChannelState, "channel is already CLOSED") } @@ -442,7 +442,7 @@ func (k Keeper) ChanCloseConfirm( return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) } - if channel.IsClosed() { + if channel.State == types.CLOSED { return errorsmod.Wrap(types.ErrInvalidChannelState, "channel is already CLOSED") } diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 887772a05d5..cf3714acd2b 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -83,7 +83,7 @@ func (k Keeper) ChanUpgradeTry( return types.Channel{}, types.Upgrade{}, errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) } - if !channel.IsOpen() { + if channel.State != types.OPEN { return types.Channel{}, types.Upgrade{}, errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.OPEN, channel.State) } @@ -310,7 +310,7 @@ func (k Keeper) ChanUpgradeAck( // in the crossing hello case, we do not modify version that our TRY call returned and instead enforce // that both TRY calls returned the same version. It is possible that this will fail in the OnChanUpgradeAck // callback if the version is invalid. - if channel.IsOpen() { + if channel.State == types.OPEN { upgrade.Fields.Version = counterpartyUpgrade.Fields.Version } @@ -319,7 +319,7 @@ func (k Keeper) ChanUpgradeAck( return types.NewUpgradeError(channel.UpgradeSequence, err) } - if channel.IsOpen() { + if channel.State == types.OPEN { if err := k.startFlushing(ctx, portID, channelID, &upgrade); err != nil { return err } diff --git a/modules/core/04-channel/types/channel.go b/modules/core/04-channel/types/channel.go index ce05d293c94..6ce9d21619b 100644 --- a/modules/core/04-channel/types/channel.go +++ b/modules/core/04-channel/types/channel.go @@ -55,16 +55,6 @@ func (ch Channel) GetVersion() string { return ch.Version } -// IsOpen returns true if the channel state is OPEN -func (ch Channel) IsOpen() bool { - return ch.State == OPEN -} - -// IsClosed returns true if the channel state is CLOSED -func (ch Channel) IsClosed() bool { - return ch.State == CLOSED -} - // ValidateBasic performs a basic validation of the channel fields func (ch Channel) ValidateBasic() error { if ch.State == UNINITIALIZED {