From ce7ac2e2f09d537d491686d928981a9a47a224e9 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 10 May 2022 09:22:58 +0200 Subject: [PATCH] chore: renaming KeyForwardRelayerAddress to KeyRelayerAddressForAsyncAck (#1343) * renaming KeyForwardRelayerAddress to KeyRelayerAddressForAsyncAck * adding changelog entry Co-authored-by: Carlos Rodriguez --- CHANGELOG.md | 1 + modules/apps/29-fee/keeper/keeper.go | 8 ++++---- modules/apps/29-fee/types/keys.go | 8 ++++---- modules/apps/29-fee/types/keys_test.go | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65274b8fa95..b38ee315afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (transfer) [\#1250](https://github.com/cosmos/ibc-go/pull/1250) Deprecate `GetTransferAccount` since the `transfer` module account is never used. * (modules/29-fee)[\#1338](https://github.com/cosmos/ibc-go/pull/1338) Renaming `Result` field in `IncentivizedAcknowledgement` to `AppAcknowledgement`. +* (modules/29-fee)[\#1343](https://github.com/cosmos/ibc-go/pull/1343) Renaming `KeyForwardRelayerAddress` to `KeyRelayerAddressForAsyncAck`, and `ParseKeyForwardRelayerAddress` to `ParseKeyRelayerAddressForAsyncAck`. ### State Machine Breaking diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index e0317d3660a..da24e5a2772 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -191,13 +191,13 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye // SetRelayerAddressForAsyncAck sets the forward relayer address during OnRecvPacket in case of async acknowledgement func (k Keeper) SetRelayerAddressForAsyncAck(ctx sdk.Context, packetID channeltypes.PacketId, address string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyForwardRelayerAddress(packetID), []byte(address)) + store.Set(types.KeyRelayerAddressForAsyncAck(packetID), []byte(address)) } // GetRelayerAddressForAsyncAck gets forward relayer address for a particular packet func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetID channeltypes.PacketId) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyForwardRelayerAddress(packetID) + key := types.KeyRelayerAddressForAsyncAck(packetID) if !store.Has(key) { return "", false } @@ -214,7 +214,7 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRe var forwardRelayerAddr []types.ForwardRelayerAddress for ; iterator.Valid(); iterator.Next() { - packetID, err := types.ParseKeyForwardRelayerAddress(string(iterator.Key())) + packetID, err := types.ParseKeyRelayerAddressForAsyncAck(string(iterator.Key())) if err != nil { panic(err) } @@ -233,7 +233,7 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRe // Deletes the forwardRelayerAddr associated with the packetID func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetID channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) - key := types.KeyForwardRelayerAddress(packetID) + key := types.KeyRelayerAddressForAsyncAck(packetID) store.Delete(key) } diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 87318496a37..cf93967f84a 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -87,13 +87,13 @@ func ParseKeyCounterpartyRelayer(key string) (address string, channelID string, return keySplit[1], keySplit[2], nil } -// KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping -func KeyForwardRelayerAddress(packetID channeltypes.PacketId) []byte { +// KeyRelayerAddressForAsyncAck returns the key for packetID -> forwardAddress mapping +func KeyRelayerAddressForAsyncAck(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%s/%s/%d", ForwardRelayerPrefix, packetID.PortId, packetID.ChannelId, packetID.Sequence)) } -// ParseKeyForwardRelayerAddress parses the key used to store the forward relayer address and returns the packetID -func ParseKeyForwardRelayerAddress(key string) (channeltypes.PacketId, error) { +// ParseKeyRelayerAddressForAsyncAck parses the key used to store the forward relayer address and returns the packetID +func ParseKeyRelayerAddressForAsyncAck(key string) (channeltypes.PacketId, error) { keySplit := strings.Split(key, "/") if len(keySplit) != 4 { return channeltypes.PacketId{}, sdkerrors.Wrapf( diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index 22dc91b6a57..1bd229b57a3 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -113,7 +113,7 @@ func TestParseKeyForwardRelayerAddress(t *testing.T) { }{ { "success", - string(types.KeyForwardRelayerAddress(validPacketID)), + string(types.KeyRelayerAddressForAsyncAck(validPacketID)), true, }, { @@ -129,7 +129,7 @@ func TestParseKeyForwardRelayerAddress(t *testing.T) { } for _, tc := range testCases { - packetID, err := types.ParseKeyForwardRelayerAddress(tc.key) + packetID, err := types.ParseKeyRelayerAddressForAsyncAck(tc.key) if tc.expPass { require.NoError(t, err)