diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index fc643cea30d..7216ccb7fa8 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -105,7 +105,7 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability // GetActiveChannelID retrieves the active channelID from the store, keyed by the provided connectionID and portID func (k Keeper) GetActiveChannelID(ctx sdk.Context, connectionID, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := icatypes.KeyActiveChannel(connectionID, portID) + key := icatypes.KeyActiveChannel(portID, connectionID) if !store.Has(key) { return "", false @@ -141,8 +141,8 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { keySplit := strings.Split(string(iterator.Key()), "/") ch := icatypes.ActiveChannel{ - ConnectionId: keySplit[1], - PortId: keySplit[2], + ConnectionId: keySplit[2], + PortId: keySplit[1], ChannelId: string(iterator.Value()), } @@ -155,7 +155,7 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { // SetActiveChannelID stores the active channelID, keyed by the provided connectionID and portID func (k Keeper) SetActiveChannelID(ctx sdk.Context, connectionID, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(icatypes.KeyActiveChannel(connectionID, portID), []byte(channelID)) + store.Set(icatypes.KeyActiveChannel(portID, connectionID), []byte(channelID)) } // IsActiveChannel returns true if there exists an active channel for the provided connectionID and portID, otherwise false diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 598c68789fc..181153a0fb5 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -94,7 +94,7 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability // GetActiveChannelID retrieves the active channelID from the store keyed by the provided connectionID and portID func (k Keeper) GetActiveChannelID(ctx sdk.Context, connectionID, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := icatypes.KeyActiveChannel(connectionID, portID) + key := icatypes.KeyActiveChannel(portID, connectionID) if !store.Has(key) { return "", false @@ -130,8 +130,8 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { keySplit := strings.Split(string(iterator.Key()), "/") ch := icatypes.ActiveChannel{ - ConnectionId: keySplit[1], - PortId: keySplit[2], + ConnectionId: keySplit[2], + PortId: keySplit[1], ChannelId: string(iterator.Value()), } @@ -144,7 +144,7 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { // SetActiveChannelID stores the active channelID, keyed by the provided connectionID and portID func (k Keeper) SetActiveChannelID(ctx sdk.Context, connectionID, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(icatypes.KeyActiveChannel(connectionID, portID), []byte(channelID)) + store.Set(icatypes.KeyActiveChannel(portID, connectionID), []byte(channelID)) } // IsActiveChannel returns true if there exists an active channel for the provided connectionID and portID, otherwise false diff --git a/modules/apps/27-interchain-accounts/types/keys.go b/modules/apps/27-interchain-accounts/types/keys.go index 581aea8ae37..c2bde682551 100644 --- a/modules/apps/27-interchain-accounts/types/keys.go +++ b/modules/apps/27-interchain-accounts/types/keys.go @@ -39,8 +39,8 @@ var ( ) // KeyActiveChannel creates and returns a new key used for active channels store operations -func KeyActiveChannel(connectionID, portID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", ActiveChannelKeyPrefix, connectionID, portID)) +func KeyActiveChannel(portID, connectionID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", ActiveChannelKeyPrefix, portID, connectionID)) } // KeyOwnerAccount creates and returns a new key used for interchain account store operations diff --git a/modules/apps/27-interchain-accounts/types/keys_test.go b/modules/apps/27-interchain-accounts/types/keys_test.go index 4fe7b5a813f..02da485bf32 100644 --- a/modules/apps/27-interchain-accounts/types/keys_test.go +++ b/modules/apps/27-interchain-accounts/types/keys_test.go @@ -5,8 +5,8 @@ import ( ) func (suite *TypesTestSuite) TestKeyActiveChannel() { - key := types.KeyActiveChannel("connection-id", "port-id") - suite.Require().Equal("activeChannel/connection-id/port-id", string(key)) + key := types.KeyActiveChannel("port-id", "connection-id") + suite.Require().Equal("activeChannel/port-id/connection-id", string(key)) } func (suite *TypesTestSuite) TestKeyOwnerAccount() {