Skip to content

Commit

Permalink
chore: remove IsOpen and IsClosed channel methods (#5691)
Browse files Browse the repository at this point in the history
(cherry picked from commit e49cadd)
  • Loading branch information
damiannolan authored and mergify[bot] committed Jan 23, 2024
1 parent 43b985c commit 370be19
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions modules/core/04-channel/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -459,7 +459,7 @@ func (k Keeper) ChanCloseConfirmWithCounterpartyUpgradeSequence(
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")
}

Expand Down
6 changes: 3 additions & 3 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions modules/core/04-channel/types/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,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 {
Expand Down

0 comments on commit 370be19

Please sign in to comment.