Skip to content

Commit

Permalink
chore: minor nits - renaming and error msgs (#464)
Browse files Browse the repository at this point in the history
* update ErrPortAlreadyBound error string - remove for address

* rename RegisterInterchainAccount api portID -> counterpartyPortID

* wrap claim capability errors in handshake

* Update modules/apps/27-interchain-accounts/keeper/account.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* adding channel and port id in error msg

* correcting error wording

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
  • Loading branch information
damiannolan and colin-axner authored Oct 11, 2021
1 parent 9595948 commit 9450085
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/keeper/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ func (k Keeper) InitInterchainAccount(ctx sdk.Context, connectionID, counterpart

// RegisterInterchainAccount attempts to create a new account using the provided address and stores it in state keyed by the provided port identifier
// If an account for the provided address already exists this function returns early (no-op)
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, accAddr sdk.AccAddress, portID string) {
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, accAddr sdk.AccAddress, controllerPortID string) {
if acc := k.accountKeeper.GetAccount(ctx, accAddr); acc != nil {
return
}

interchainAccount := types.NewInterchainAccount(
authtypes.NewBaseAccountWithAddress(accAddr),
portID,
controllerPortID,
)

k.accountKeeper.NewAccount(ctx, interchainAccount)
k.accountKeeper.SetAccount(ctx, interchainAccount)
k.SetInterchainAccountAddress(ctx, portID, interchainAccount.Address)
k.SetInterchainAccountAddress(ctx, controllerPortID, interchainAccount.Address)
}
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (k Keeper) OnChanOpenInit(

// Claim channel capability passed back by IBC module
if err := k.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, err.Error())
return sdkerrors.Wrapf(err, "failed to claim capability for channel %s on port %s", channelID, portID)
}

return nil
Expand Down Expand Up @@ -118,7 +118,7 @@ func (k Keeper) OnChanOpenTry(
// On the host chain the capability may only be claimed during the OnChanOpenTry
// The capability being claimed in OpenInit is for a controller chain (the port is different)
if err := k.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
return err
return sdkerrors.Wrapf(err, "failed to claim capability for channel %s on port %s", channelID, portID)
}

// Check to ensure that the version string contains the expected address generated from the Counterparty portID
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
var (
ErrUnknownPacketData = sdkerrors.Register(ModuleName, 2, "unknown packet data")
ErrAccountAlreadyExist = sdkerrors.Register(ModuleName, 3, "account already exist")
ErrPortAlreadyBound = sdkerrors.Register(ModuleName, 4, "port is already bound for address")
ErrPortAlreadyBound = sdkerrors.Register(ModuleName, 4, "port is already bound")
ErrUnsupportedChain = sdkerrors.Register(ModuleName, 5, "unsupported chain")
ErrInvalidOutgoingData = sdkerrors.Register(ModuleName, 6, "invalid outgoing data")
ErrInvalidRoute = sdkerrors.Register(ModuleName, 7, "invalid route")
Expand Down

0 comments on commit 9450085

Please sign in to comment.