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

chore: remove IsOpen and IsClosed channel methods #5691

Merged
merged 1 commit into from
Jan 23, 2024
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
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
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 @@ -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")
}

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 @@ -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 {
Expand Down
Loading