Skip to content

Commit

Permalink
fix: prevent panic in BindPort
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Apr 18, 2022
1 parent c384a41 commit 5df86b0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions golang/cosmos/x/vibc/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"fmt"

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

Expand Down Expand Up @@ -152,6 +154,10 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
// BindPort defines a wrapper function for the port Keeper's function in
// order to expose it to the vibc IBC handler.
func (k Keeper) BindPort(ctx sdk.Context, portID string) error {
_, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID))
if ok {
return fmt.Errorf("port %s is already bound", portID)
}
cap := k.portKeeper.BindPort(ctx, portID)
return k.ClaimCapability(ctx, cap, host.PortPath(portID))
}
Expand Down

0 comments on commit 5df86b0

Please sign in to comment.