From 9450085e6454fe99809de1a4bed74f3787507198 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 11 Oct 2021 11:39:29 +0200 Subject: [PATCH] chore: minor nits - renaming and error msgs (#464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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> --- modules/apps/27-interchain-accounts/keeper/account.go | 6 +++--- modules/apps/27-interchain-accounts/keeper/handshake.go | 4 ++-- modules/apps/27-interchain-accounts/types/errors.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/apps/27-interchain-accounts/keeper/account.go b/modules/apps/27-interchain-accounts/keeper/account.go index f10bd73e005..0c14be4ea97 100644 --- a/modules/apps/27-interchain-accounts/keeper/account.go +++ b/modules/apps/27-interchain-accounts/keeper/account.go @@ -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) } diff --git a/modules/apps/27-interchain-accounts/keeper/handshake.go b/modules/apps/27-interchain-accounts/keeper/handshake.go index b6d4f0c9284..52e179eff1d 100644 --- a/modules/apps/27-interchain-accounts/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/keeper/handshake.go @@ -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 @@ -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 diff --git a/modules/apps/27-interchain-accounts/types/errors.go b/modules/apps/27-interchain-accounts/types/errors.go index 6b05a626a82..77787281d1a 100644 --- a/modules/apps/27-interchain-accounts/types/errors.go +++ b/modules/apps/27-interchain-accounts/types/errors.go @@ -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")