Skip to content

Commit

Permalink
chore: renaming KeyForwardRelayerAddress to KeyRelayerAddressForAsync…
Browse files Browse the repository at this point in the history
…Ack (#1343)

* renaming KeyForwardRelayerAddress to KeyRelayerAddressForAsyncAck

* adding changelog entry

Co-authored-by: Carlos Rodriguez <[email protected]>
  • Loading branch information
damiannolan and Carlos Rodriguez authored May 10, 2022
1 parent af3d522 commit ce7ac2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions modules/apps/29-fee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions modules/apps/29-fee/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestParseKeyForwardRelayerAddress(t *testing.T) {
}{
{
"success",
string(types.KeyForwardRelayerAddress(validPacketID)),
string(types.KeyRelayerAddressForAsyncAck(validPacketID)),
true,
},
{
Expand All @@ -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)
Expand Down

0 comments on commit ce7ac2e

Please sign in to comment.