-
Notifications
You must be signed in to change notification settings - Fork 657
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
Defensive checks for active channel #785
Changes from all commits
7cce63a
8ee1528
14502d1
02556f8
d64398e
f0ecd5a
85a8c2a
ddaddd7
7fccc5c
e5df89a
94f9fea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
|
||
"github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" | ||
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" | ||
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" | ||
host "github.com/cosmos/ibc-go/v3/modules/core/24-host" | ||
) | ||
|
||
|
@@ -102,6 +103,22 @@ func (k Keeper) GetActiveChannelID(ctx sdk.Context, connectionID, portID string) | |
return string(store.Get(key)), true | ||
} | ||
|
||
// GetOpenActiveChannel retrieves the active channelID from the store, keyed by the provided connectionID and portID & checks if the channel in question is in state OPEN | ||
func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID string) (string, bool) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just change the Afaik, the only place Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the separation of concerns. Usually |
||
channelID, found := k.GetActiveChannelID(ctx, connectionID, portID) | ||
if !found { | ||
return "", false | ||
} | ||
|
||
channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID) | ||
|
||
if found && channel.State == channeltypes.OPEN { | ||
return channelID, true | ||
} | ||
|
||
return "", false | ||
} | ||
|
||
// GetAllActiveChannels returns a list of all active interchain accounts host channels and their associated connection and port identifiers | ||
func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { | ||
store := ctx.KVStore(k.storeKey) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include the connectionID in the error msg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessary since the active channel is returned, but might be nice to have