Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename CounterpartyAddress query to CounterpartyPayee #1522

Merged
merged 18 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6e65707
renaming counterparty address rpc to counterparty payee
damiannolan Jun 8, 2022
81e912d
rename genesis types for registered counterparty payees
damiannolan Jun 8, 2022
4f11285
renaming counterparty address query to counterparty payee
damiannolan Jun 8, 2022
6ef0b44
updating counterparty payee cli
damiannolan Jun 9, 2022
cea4938
Merge branch 'main' into damian/rename-counterparty-payee-rpc
damiannolan Jun 9, 2022
679e0ee
reorder cli cmd list
damiannolan Jun 9, 2022
6121ec0
Apply suggestions from code review
damiannolan Jun 9, 2022
ac2dd48
removing address suffix from msg fields, updating protodoc and godoc
damiannolan Jun 9, 2022
473b113
updating cli args naming convention to align
damiannolan Jun 9, 2022
7af30a6
Merge branch 'main' into damian/rename-counterparty-payee-rpc
damiannolan Jun 9, 2022
c9fadf0
Merge branch 'damian/rename-counterparty-payee-rpc' into damian/renam…
damiannolan Jun 9, 2022
49f585b
propagating renaming of fields to genesis state
damiannolan Jun 9, 2022
c1ac13c
Merge branch 'damian/rename-genesis-register-counterparty-addr' into …
damiannolan Jun 9, 2022
0363a56
Merge branch 'main' into damian/rename-genesis-register-counterparty-…
damiannolan Jun 14, 2022
d2dcb30
rename GetAllx funcs and updating godocs
damiannolan Jun 14, 2022
76c9bf9
Merge branch 'damian/rename-genesis-register-counterparty-addr' into …
damiannolan Jun 14, 2022
63e12cd
aligning naming of GetAll functions
damiannolan Jun 14, 2022
0a71631
Merge branch 'main' into damian/rename-counterparty-addr-query
damiannolan Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions docs/client/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,24 +1046,26 @@ paths:
format: uint64
tags:
- Query
'/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer_address}/counterparty_address':
'/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer}/counterparty_payee':
get:
summary: >-
CounterpartyAddress returns the registered counterparty address for
forward relaying
operationId: CounterpartyAddress
CounterpartyPayee returns the registered counterparty payee for forward
relaying
operationId: CounterpartyPayee
responses:
'200':
description: A successful response.
schema:
type: object
properties:
counterparty_address:
counterparty_payee:
type: string
title: the counterparty address used to compensate forward relaying
title: >-
the counterparty payee address used to compensate forward
relaying
title: >-
QueryCounterpartyAddressResponse defines the response type for the
CounterpartyAddress rpc
QueryCounterpartyPayeeResponse defines the response type for the
CounterpartyPayee rpc
default:
description: An unexpected error response
schema:
Expand Down Expand Up @@ -1259,14 +1261,14 @@ paths:
in: path
required: true
type: string
- name: relayer_address
- name: relayer
description: the relayer address to which the counterparty is registered
in: path
required: true
type: string
tags:
- Query
'/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer_address}/payee':
'/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer}/payee':
get:
summary: >-
Payee returns the registered payee address for a specific channel given
Expand Down Expand Up @@ -1477,7 +1479,7 @@ paths:
in: path
required: true
type: string
- name: relayer_address
- name: relayer
description: the relayer address to which the distribution address is registered
in: path
required: true
Expand Down Expand Up @@ -13524,15 +13526,15 @@ definitions:
title: >-
PacketFee contains ICS29 relayer fees, refund address and optional list of
permitted relayers
ibc.applications.fee.v1.QueryCounterpartyAddressResponse:
ibc.applications.fee.v1.QueryCounterpartyPayeeResponse:
type: object
properties:
counterparty_address:
counterparty_payee:
type: string
title: the counterparty address used to compensate forward relaying
title: the counterparty payee address used to compensate forward relaying
title: >-
QueryCounterpartyAddressResponse defines the response type for the
CounterpartyAddress rpc
QueryCounterpartyPayeeResponse defines the response type for the
CounterpartyPayee rpc
ibc.applications.fee.v1.QueryFeeEnabledChannelResponse:
type: object
properties:
Expand Down
26 changes: 13 additions & 13 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
- [Metadata](#ibc.applications.fee.v1.Metadata)

- [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto)
- [QueryCounterpartyAddressRequest](#ibc.applications.fee.v1.QueryCounterpartyAddressRequest)
- [QueryCounterpartyAddressResponse](#ibc.applications.fee.v1.QueryCounterpartyAddressResponse)
- [QueryCounterpartyPayeeRequest](#ibc.applications.fee.v1.QueryCounterpartyPayeeRequest)
- [QueryCounterpartyPayeeResponse](#ibc.applications.fee.v1.QueryCounterpartyPayeeResponse)
- [QueryFeeEnabledChannelRequest](#ibc.applications.fee.v1.QueryFeeEnabledChannelRequest)
- [QueryFeeEnabledChannelResponse](#ibc.applications.fee.v1.QueryFeeEnabledChannelResponse)
- [QueryFeeEnabledChannelsRequest](#ibc.applications.fee.v1.QueryFeeEnabledChannelsRequest)
Expand Down Expand Up @@ -940,31 +940,31 @@ See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-



<a name="ibc.applications.fee.v1.QueryCounterpartyAddressRequest"></a>
<a name="ibc.applications.fee.v1.QueryCounterpartyPayeeRequest"></a>

### QueryCounterpartyAddressRequest
QueryCounterpartyAddressRequest defines the request type for the CounterpartyAddress rpc
### QueryCounterpartyPayeeRequest
QueryCounterpartyPayeeRequest defines the request type for the CounterpartyPayee rpc


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `channel_id` | [string](#string) | | unique channel identifier |
| `relayer_address` | [string](#string) | | the relayer address to which the counterparty is registered |
| `relayer` | [string](#string) | | the relayer address to which the counterparty is registered |






<a name="ibc.applications.fee.v1.QueryCounterpartyAddressResponse"></a>
<a name="ibc.applications.fee.v1.QueryCounterpartyPayeeResponse"></a>

### QueryCounterpartyAddressResponse
QueryCounterpartyAddressResponse defines the response type for the CounterpartyAddress rpc
### QueryCounterpartyPayeeResponse
QueryCounterpartyPayeeResponse defines the response type for the CounterpartyPayee rpc


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `counterparty_address` | [string](#string) | | the counterparty address used to compensate forward relaying |
| `counterparty_payee` | [string](#string) | | the counterparty payee address used to compensate forward relaying |



Expand Down Expand Up @@ -1138,7 +1138,7 @@ QueryPayeeRequest defines the request type for the Payee rpc
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `channel_id` | [string](#string) | | unique channel identifier |
| `relayer_address` | [string](#string) | | the relayer address to which the distribution address is registered |
| `relayer` | [string](#string) | | the relayer address to which the distribution address is registered |



Expand Down Expand Up @@ -1269,8 +1269,8 @@ Query defines the ICS29 gRPC querier service.
| `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/channels/{packet_id.channel_id}/ports/{packet_id.port_id}/sequences/{packet_id.sequence}/total_recv_fees|
| `TotalAckFees` | [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) | [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) | TotalAckFees returns the total acknowledgement fees for a packet given its identifier | GET|/ibc/apps/fee/v1/channels/{packet_id.channel_id}/ports/{packet_id.port_id}/sequences/{packet_id.sequence}/total_ack_fees|
| `TotalTimeoutFees` | [QueryTotalTimeoutFeesRequest](#ibc.applications.fee.v1.QueryTotalTimeoutFeesRequest) | [QueryTotalTimeoutFeesResponse](#ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse) | TotalTimeoutFees returns the total timeout fees for a packet given its identifier | GET|/ibc/apps/fee/v1/channels/{packet_id.channel_id}/ports/{packet_id.port_id}/sequences/{packet_id.sequence}/total_timeout_fees|
| `Payee` | [QueryPayeeRequest](#ibc.applications.fee.v1.QueryPayeeRequest) | [QueryPayeeResponse](#ibc.applications.fee.v1.QueryPayeeResponse) | Payee returns the registered payee address for a specific channel given the relayer address | GET|/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer_address}/payee|
| `CounterpartyAddress` | [QueryCounterpartyAddressRequest](#ibc.applications.fee.v1.QueryCounterpartyAddressRequest) | [QueryCounterpartyAddressResponse](#ibc.applications.fee.v1.QueryCounterpartyAddressResponse) | CounterpartyAddress returns the registered counterparty address for forward relaying | GET|/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer_address}/counterparty_address|
| `Payee` | [QueryPayeeRequest](#ibc.applications.fee.v1.QueryPayeeRequest) | [QueryPayeeResponse](#ibc.applications.fee.v1.QueryPayeeResponse) | Payee returns the registered payee address for a specific channel given the relayer address | GET|/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer}/payee|
| `CounterpartyPayee` | [QueryCounterpartyPayeeRequest](#ibc.applications.fee.v1.QueryCounterpartyPayeeRequest) | [QueryCounterpartyPayeeResponse](#ibc.applications.fee.v1.QueryCounterpartyPayeeResponse) | CounterpartyPayee returns the registered counterparty payee for forward relaying | GET|/ibc/apps/fee/v1/channels/{channel_id}/relayers/{relayer}/counterparty_payee|
| `FeeEnabledChannels` | [QueryFeeEnabledChannelsRequest](#ibc.applications.fee.v1.QueryFeeEnabledChannelsRequest) | [QueryFeeEnabledChannelsResponse](#ibc.applications.fee.v1.QueryFeeEnabledChannelsResponse) | FeeEnabledChannels returns a list of all fee enabled channels | GET|/ibc/apps/fee/v1/fee_enabled|
| `FeeEnabledChannel` | [QueryFeeEnabledChannelRequest](#ibc.applications.fee.v1.QueryFeeEnabledChannelRequest) | [QueryFeeEnabledChannelResponse](#ibc.applications.fee.v1.QueryFeeEnabledChannelResponse) | FeeEnabledChannel returns true if the provided port and channel identifiers belong to a fee enabled channel | GET|/ibc/apps/fee/v1/channels/{channel_id}/ports/{port_id}/fee_enabled|

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdTotalTimeoutFees(),
GetCmdIncentivizedPacketsForChannel(),
GetCmdPayee(),
GetCmdCounterpartyAddress(),
GetCmdCounterpartyPayee(),
GetCmdFeeEnabledChannel(),
GetCmdFeeEnabledChannels(),
)
Expand Down
26 changes: 13 additions & 13 deletions modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func GetCmdTotalTimeoutFees() *cobra.Command {
// GetCmdPayee returns the command handler for the Query/Payee rpc.
func GetCmdPayee() *cobra.Command {
cmd := &cobra.Command{
Use: "payee [channel-id] [relayer-address]",
Use: "payee [channel-id] [relayer]",
Short: "Query the relayer payee address on a given channel",
Long: "Query the relayer payee address on a given channel",
Args: cobra.ExactArgs(2),
Expand All @@ -260,8 +260,8 @@ func GetCmdPayee() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryPayeeRequest{
ChannelId: args[0],
RelayerAddress: args[1],
ChannelId: args[0],
Relayer: args[1],
}

res, err := queryClient.Payee(cmd.Context(), req)
Expand All @@ -278,14 +278,14 @@ func GetCmdPayee() *cobra.Command {
return cmd
}

// GetCmdCounterpartyAddress returns the command handler for the Query/CounterpartyAddress rpc.
func GetCmdCounterpartyAddress() *cobra.Command {
// GetCmdCounterpartyPayee returns the command handler for the Query/CounterpartyPayee rpc.
func GetCmdCounterpartyPayee() *cobra.Command {
cmd := &cobra.Command{
Use: "counterparty-address [channel-id] [address]",
Short: "Query the relayer counterparty address on a given channel",
Long: "Query the relayer counterparty address on a given channel",
Use: "counterparty-payee [channel-id] [relayer]",
Short: "Query the relayer counterparty payee on a given channel",
Long: "Query the relayer counterparty payee on a given channel",
Args: cobra.ExactArgs(2),
Example: fmt.Sprintf("%s query ibc-fee counterparty-address channel-5 cosmos1layxcsmyye0dc0har9sdfzwckaz8sjwlfsj8zs", version.AppName),
Example: fmt.Sprintf("%s query ibc-fee counterparty-payee channel-5 cosmos1layxcsmyye0dc0har9sdfzwckaz8sjwlfsj8zs", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand All @@ -298,12 +298,12 @@ func GetCmdCounterpartyAddress() *cobra.Command {

queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryCounterpartyAddressRequest{
ChannelId: args[0],
RelayerAddress: args[1],
req := &types.QueryCounterpartyPayeeRequest{
ChannelId: args[0],
Relayer: args[1],
}

res, err := queryClient.CounterpartyAddress(cmd.Context(), req)
res, err := queryClient.CounterpartyPayee(cmd.Context(), req)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return &types.GenesisState{
IdentifiedFees: k.GetAllIdentifiedPacketFees(ctx),
FeeEnabledChannels: k.GetAllFeeEnabledChannels(ctx),
RegisteredPayees: k.GetAllPayeeAddresses(ctx),
RegisteredPayees: k.GetAllPayees(ctx),
RegisteredCounterpartyPayees: k.GetAllCounterpartyPayees(ctx),
ForwardRelayers: k.GetAllForwardRelayerAddresses(ctx),
}
Expand Down
16 changes: 8 additions & 8 deletions modules/apps/29-fee/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,31 @@ func (k Keeper) Payee(goCtx context.Context, req *types.QueryPayeeRequest) (*typ

ctx := sdk.UnwrapSDKContext(goCtx)

payeeAddr, found := k.GetPayeeAddress(ctx, req.RelayerAddress, req.ChannelId)
payeeAddr, found := k.GetPayeeAddress(ctx, req.Relayer, req.ChannelId)
if !found {
return nil, status.Errorf(codes.NotFound, "payee address not found for address: %s on channel: %s", req.RelayerAddress, req.ChannelId)
return nil, status.Errorf(codes.NotFound, "payee address not found for address: %s on channel: %s", req.Relayer, req.ChannelId)
}

return &types.QueryPayeeResponse{
PayeeAddress: payeeAddr,
}, nil
}

// CounterpartyAddress implements the Query/CounterpartyAddress gRPC method and returns the registered counterparty address for forward relaying
func (k Keeper) CounterpartyAddress(goCtx context.Context, req *types.QueryCounterpartyAddressRequest) (*types.QueryCounterpartyAddressResponse, error) {
// CounterpartyPayee implements the Query/CounterpartyPayee gRPC method and returns the registered counterparty payee address for forward relaying
func (k Keeper) CounterpartyPayee(goCtx context.Context, req *types.QueryCounterpartyPayeeRequest) (*types.QueryCounterpartyPayeeResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx)

counterpartyAddr, found := k.GetCounterpartyPayeeAddress(ctx, req.RelayerAddress, req.ChannelId)
counterpartyPayeeAddr, found := k.GetCounterpartyPayeeAddress(ctx, req.Relayer, req.ChannelId)
if !found {
return nil, status.Errorf(codes.NotFound, "counterparty address not found for address: %s on channel: %s", req.RelayerAddress, req.ChannelId)
return nil, status.Errorf(codes.NotFound, "counterparty payee address not found for address: %s on channel: %s", req.Relayer, req.ChannelId)
}

return &types.QueryCounterpartyAddressResponse{
CounterpartyAddress: counterpartyAddr,
return &types.QueryCounterpartyPayeeResponse{
CounterpartyPayee: counterpartyPayeeAddr,
}, nil
}

Expand Down
26 changes: 13 additions & 13 deletions modules/apps/29-fee/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (suite *KeeperTestSuite) TestQueryPayee() {
{
"payee address not found: invalid relayer address",
func() {
req.RelayerAddress = "invalid-addr"
req.Relayer = "invalid-addr"
},
false,
},
Expand All @@ -453,8 +453,8 @@ func (suite *KeeperTestSuite) TestQueryPayee() {
)

req = &types.QueryPayeeRequest{
ChannelId: suite.path.EndpointA.ChannelID,
RelayerAddress: suite.chainA.SenderAccount.GetAddress().String(),
ChannelId: suite.path.EndpointA.ChannelID,
Relayer: suite.chainA.SenderAccount.GetAddress().String(),
}

tc.malleate()
Expand All @@ -472,8 +472,8 @@ func (suite *KeeperTestSuite) TestQueryPayee() {
}
}

func (suite *KeeperTestSuite) TestQueryCounterpartyAddress() {
var req *types.QueryCounterpartyAddressRequest
func (suite *KeeperTestSuite) TestQueryCounterpartyPayee() {
var req *types.QueryCounterpartyPayeeRequest

testCases := []struct {
name string
Expand All @@ -495,7 +495,7 @@ func (suite *KeeperTestSuite) TestQueryCounterpartyAddress() {
{
"counterparty address not found: invalid address",
func() {
req.RelayerAddress = "invalid-addr"
req.Relayer = "invalid-addr"
},
false,
},
Expand All @@ -506,28 +506,28 @@ func (suite *KeeperTestSuite) TestQueryCounterpartyAddress() {
suite.SetupTest() // reset

pk := secp256k1.GenPrivKey().PubKey()
expectedCounterpartyAddr := sdk.AccAddress(pk.Address())
expCounterpartyPayeeAddr := sdk.AccAddress(pk.Address())

suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(
suite.chainA.GetContext(),
suite.chainA.SenderAccount.GetAddress().String(),
expectedCounterpartyAddr.String(),
expCounterpartyPayeeAddr.String(),
suite.path.EndpointA.ChannelID,
)

req = &types.QueryCounterpartyAddressRequest{
ChannelId: suite.path.EndpointA.ChannelID,
RelayerAddress: suite.chainA.SenderAccount.GetAddress().String(),
req = &types.QueryCounterpartyPayeeRequest{
ChannelId: suite.path.EndpointA.ChannelID,
Relayer: suite.chainA.SenderAccount.GetAddress().String(),
}

tc.malleate()

ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.queryClient.CounterpartyAddress(ctx, req)
res, err := suite.queryClient.CounterpartyPayee(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(expectedCounterpartyAddr.String(), res.CounterpartyAddress)
suite.Require().Equal(expCounterpartyPayeeAddr.String(), res.CounterpartyPayee)
} else {
suite.Require().Error(err)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (k Keeper) SetPayeeAddress(ctx sdk.Context, relayerAddr, payeeAddr, channel
store.Set(types.KeyPayee(relayerAddr, channelID), []byte(payeeAddr))
}

// GetAllPayeeAddresses returns all registered payees addresses
func (k Keeper) GetAllPayeeAddresses(ctx sdk.Context) []types.RegisteredPayee {
// GetAllPayees returns all registered payees addresses
func (k Keeper) GetAllPayees(ctx sdk.Context) []types.RegisteredPayee {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.PayeeKeyPrefix))
defer iterator.Close()
Expand Down
Loading