From f8b43454222afb4ef10f518f0f6540dd0d5f435d Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 1 Mar 2022 09:15:55 +0000 Subject: [PATCH] feat: grpc query total recv packet fees (#1015) * adding query for total packet recv fees to proto query server * adding total packet recv fee query impl and tests * updating doc comments --- docs/ibc/proto-docs.md | 33 ++ modules/apps/29-fee/keeper/grpc_query.go | 26 + modules/apps/29-fee/keeper/grpc_query_test.go | 64 +++ modules/apps/29-fee/types/query.pb.go | 478 ++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 160 ++++++ proto/ibc/applications/fee/v1/query.proto | 27 +- 6 files changed, 750 insertions(+), 38 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index eb2ddc97e3a..eda1ca9bf69 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -49,6 +49,8 @@ - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) + - [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) + - [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) - [Query](#ibc.applications.fee.v1.Query) @@ -983,6 +985,36 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + + + +### QueryTotalRecvFeesRequest +QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | the packet identifier for the associated fees | + + + + + + + + +### QueryTotalRecvFeesResponse +QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `recv_fees` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the total packet receive fees | + + + + + @@ -999,6 +1031,7 @@ Query provides defines the gRPC querier service. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `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/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 3d4852831ad..dfaa5d86a35 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -65,3 +65,29 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz IncentivizedPacket: types.NewIdentifiedPacketFees(req.PacketId, feesInEscrow.PacketFees), }, nil } + +// TotalRecvFees implements the Query/TotalRecvFees gRPC method +func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) + if !found { + return nil, status.Errorf( + codes.NotFound, + sdkerrors.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), + ) + } + + var recvFees sdk.Coins + for _, packetFee := range feesInEscrow.PacketFees { + recvFees = recvFees.Add(packetFee.Fee.RecvFee...) + } + + return &types.QueryTotalRecvFeesResponse{ + RecvFees: recvFees, + }, nil +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 37626b40bac..c9df54665f0 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -139,3 +139,67 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { }) } } + +func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { + var ( + req *types.QueryTotalRecvFeesRequest + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "packet not found", + func() { + req.PacketId = channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 100) + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow three packet fees for the same packet + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + suite.Require().NoError(err) + } + + req = &types.QueryTotalRecvFeesRequest{ + PacketId: packetID, + } + + tc.malleate() + + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.queryClient.TotalRecvFees(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + // expected total is three times the default recv fee + expectedFees := defaultReceiveFee.Add(defaultReceiveFee...).Add(defaultReceiveFee...) + suite.Require().Equal(expectedFees, res.RecvFees) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index ef1b0512d25..fdbaa9766c8 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -6,6 +6,8 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" types "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" @@ -233,11 +235,105 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() IdentifiedPack return IdentifiedPacketFees{} } +// QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc +type QueryTotalRecvFeesRequest struct { + // the packet identifier for the associated fees + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` +} + +func (m *QueryTotalRecvFeesRequest) Reset() { *m = QueryTotalRecvFeesRequest{} } +func (m *QueryTotalRecvFeesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalRecvFeesRequest) ProtoMessage() {} +func (*QueryTotalRecvFeesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{4} +} +func (m *QueryTotalRecvFeesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalRecvFeesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalRecvFeesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalRecvFeesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalRecvFeesRequest.Merge(m, src) +} +func (m *QueryTotalRecvFeesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalRecvFeesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalRecvFeesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalRecvFeesRequest proto.InternalMessageInfo + +func (m *QueryTotalRecvFeesRequest) GetPacketId() types.PacketId { + if m != nil { + return m.PacketId + } + return types.PacketId{} +} + +// QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc +type QueryTotalRecvFeesResponse struct { + // the total packet receive fees + RecvFees github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=recv_fees,json=recvFees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"recv_fees" yaml:"recv_fees"` +} + +func (m *QueryTotalRecvFeesResponse) Reset() { *m = QueryTotalRecvFeesResponse{} } +func (m *QueryTotalRecvFeesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalRecvFeesResponse) ProtoMessage() {} +func (*QueryTotalRecvFeesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{5} +} +func (m *QueryTotalRecvFeesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalRecvFeesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalRecvFeesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalRecvFeesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalRecvFeesResponse.Merge(m, src) +} +func (m *QueryTotalRecvFeesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalRecvFeesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalRecvFeesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalRecvFeesResponse proto.InternalMessageInfo + +func (m *QueryTotalRecvFeesResponse) GetRecvFees() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.RecvFees + } + return nil +} + func init() { proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") + proto.RegisterType((*QueryTotalRecvFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesRequest") + proto.RegisterType((*QueryTotalRecvFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesResponse") } func init() { @@ -245,42 +341,51 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0xb4, 0x55, 0x74, 0xe2, 0x69, 0x52, 0x30, 0x04, 0xdd, 0xa6, 0x11, 0x35, 0x08, 0x99, - 0x21, 0x29, 0x62, 0x7b, 0x93, 0x1e, 0x8a, 0x39, 0x59, 0x73, 0xf4, 0x12, 0x76, 0x67, 0x5f, 0x36, - 0x83, 0xc9, 0xce, 0x36, 0x33, 0x59, 0x68, 0xb5, 0x97, 0x82, 0x08, 0xd2, 0x83, 0xe0, 0xaf, 0xf1, - 0x1f, 0xf4, 0x58, 0xf4, 0xe2, 0x49, 0x24, 0xf1, 0x87, 0xc8, 0xec, 0xce, 0xc6, 0x85, 0x64, 0xb1, - 0xed, 0x6d, 0xf7, 0xbd, 0xef, 0x7b, 0xdf, 0xb7, 0xdf, 0x9b, 0x1d, 0xfc, 0x48, 0x78, 0x9c, 0xb9, - 0x51, 0x34, 0x12, 0xdc, 0xd5, 0x42, 0x86, 0x8a, 0x0d, 0x00, 0x58, 0xdc, 0x66, 0x47, 0x53, 0x98, - 0x1c, 0xd3, 0x68, 0x22, 0xb5, 0x24, 0xf7, 0x85, 0xc7, 0x69, 0x1e, 0x44, 0x07, 0x00, 0x34, 0x6e, - 0xd7, 0x36, 0x03, 0x19, 0xc8, 0x04, 0xc3, 0xcc, 0x53, 0x0a, 0xaf, 0x6d, 0x17, 0xcd, 0x34, 0xac, - 0x14, 0xf2, 0x20, 0x90, 0x32, 0x18, 0x01, 0x73, 0x23, 0xc1, 0xdc, 0x30, 0x94, 0xda, 0xce, 0xcd, - 0x0d, 0xe0, 0x72, 0x02, 0x8c, 0x0f, 0xdd, 0x30, 0x84, 0x91, 0x21, 0xdb, 0x47, 0x0b, 0x79, 0xc6, - 0xa5, 0x1a, 0x4b, 0xc5, 0x3c, 0x57, 0x41, 0xea, 0x95, 0xc5, 0x6d, 0x0f, 0xb4, 0xdb, 0x66, 0x91, - 0x1b, 0x88, 0x30, 0x99, 0x97, 0x62, 0x1b, 0xe7, 0x08, 0x6f, 0xbd, 0x31, 0x90, 0x6e, 0xc8, 0x21, - 0xd4, 0x22, 0x16, 0x27, 0xe0, 0x1f, 0xba, 0xfc, 0x1d, 0x68, 0xd5, 0x83, 0xa3, 0x29, 0x28, 0x4d, - 0x0e, 0x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 0xe7, 0xeb, 0xda, 0x53, 0xf2, 0x98, 0xd9, 0xbf, - 0x6b, 0xf1, 0x57, 0xad, 0x3a, 0x27, 0xe4, 0x7c, 0x0d, 0x93, 0xe5, 0x71, 0xe4, 0xc5, 0x75, 0x0d, - 0x64, 0xce, 0x77, 0xaf, 0x4f, 0xb4, 0xc6, 0xcf, 0x50, 0xe2, 0xfc, 0x03, 0x39, 0xb9, 0x8a, 0x73, - 0x16, 0xc9, 0x89, 0x66, 0xef, 0x17, 0x07, 0x8e, 0x9a, 0xf7, 0xbe, 0xf0, 0x4f, 0x17, 0x57, 0x41, - 0xae, 0x67, 0x4b, 0x49, 0x5b, 0x19, 0xa3, 0x21, 0x87, 0x7c, 0x3f, 0xab, 0x9d, 0xee, 0xbf, 0xbe, - 0x98, 0x39, 0xe8, 0x72, 0xe6, 0xa0, 0xdf, 0x33, 0x07, 0x7d, 0x99, 0x3b, 0xa5, 0xcb, 0xb9, 0x53, - 0xfa, 0x39, 0x77, 0x4a, 0x6f, 0x9f, 0x07, 0x42, 0x0f, 0xa7, 0x1e, 0xe5, 0x72, 0xcc, 0xec, 0x9d, - 0x22, 0x3c, 0xde, 0x0a, 0x24, 0x8b, 0x77, 0xd8, 0x58, 0xfa, 0xd3, 0x11, 0xa8, 0xd4, 0x74, 0x67, - 0xaf, 0x65, 0x7c, 0xeb, 0xe3, 0x08, 0x94, 0x77, 0x3b, 0xb9, 0x5a, 0x76, 0xfe, 0x06, 0x00, 0x00, - 0xff, 0xff, 0xcd, 0x07, 0x8a, 0x55, 0x40, 0x05, 0x00, 0x00, + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x41, 0x6b, 0x13, 0x4d, + 0x18, 0xc7, 0x33, 0x7d, 0xdb, 0x97, 0x76, 0xfa, 0xbe, 0x20, 0xd3, 0x82, 0x6d, 0xd0, 0x4d, 0xba, + 0xa2, 0x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0x2d, 0x17, 0x33, 0x4b, 0x3a, 0x2c, 0x14, 0x68, 0x48, 0x68, 0x3e, 0x9e, 0xae, + 0xed, 0xa0, 0xef, 0x00, 0xfe, 0x7f, 0x62, 0xd8, 0x50, 0xed, 0xd7, 0x0d, 0x0d, 0x9a, 0xfc, 0xe2, + 0xc2, 0x99, 0x72, 0x4c, 0xff, 0xcf, 0x75, 0xfb, 0x4f, 0x51, 0xdc, 0xd7, 0xbe, 0x54, 0xfa, 0x46, + 0x36, 0xb0, 0x7f, 0xa7, 0xf5, 0xe5, 0x07, 0xfb, 0x47, 0x16, 0x38, 0x38, 0xb2, 0xc0, 0x97, 0x23, + 0x0b, 0xbc, 0x3e, 0xb6, 0x0a, 0x07, 0xc7, 0x56, 0xe1, 0xd3, 0xb1, 0x55, 0x78, 0x7c, 0xb3, 0xff, + 0x74, 0x30, 0x8f, 0x54, 0x03, 0x8e, 0xe3, 0x05, 0xdc, 0xe1, 0x7e, 0xaf, 0x4d, 0x45, 0x02, 0x5c, + 0x5b, 0xaa, 0x2a, 0x66, 0x7d, 0x60, 0xbc, 0x7f, 0xf5, 0x3f, 0xca, 0xc2, 0x8f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xdd, 0x79, 0x2b, 0x91, 0x57, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -300,6 +405,8 @@ type QueryClient interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) + // TotalRecvFees returns the total receive fees for a packet given its identifier + TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) } type queryClient struct { @@ -328,6 +435,15 @@ func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivi return out, nil } +func (c *queryClient) TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) { + out := new(QueryTotalRecvFeesResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TotalRecvFees", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Gets all incentivized packets @@ -335,6 +451,8 @@ type QueryServer interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) + // TotalRecvFees returns the total receive fees for a packet given its identifier + TotalRecvFees(context.Context, *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -347,6 +465,9 @@ func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *Q func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacket not implemented") } +func (*UnimplementedQueryServer) TotalRecvFees(ctx context.Context, req *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalRecvFees not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -388,6 +509,24 @@ func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_TotalRecvFees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalRecvFeesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalRecvFees(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/TotalRecvFees", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalRecvFees(ctx, req.(*QueryTotalRecvFeesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), @@ -400,6 +539,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "IncentivizedPacket", Handler: _Query_IncentivizedPacket_Handler, }, + { + MethodName: "TotalRecvFees", + Handler: _Query_TotalRecvFees_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/fee/v1/query.proto", @@ -553,6 +696,76 @@ func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryTotalRecvFeesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalRecvFeesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalRecvFeesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalRecvFeesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalRecvFeesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalRecvFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecvFees) > 0 { + for iNdEx := len(m.RecvFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecvFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -620,6 +833,32 @@ func (m *QueryIncentivizedPacketResponse) Size() (n int) { return n } +func (m *QueryTotalRecvFeesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalRecvFeesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecvFees) > 0 { + for _, e := range m.RecvFees { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1000,6 +1239,173 @@ func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTotalRecvFeesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalRecvFeesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalRecvFeesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalRecvFeesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalRecvFeesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalRecvFeesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecvFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecvFees = append(m.RecvFees, types1.Coin{}) + if err := m.RecvFees[len(m.RecvFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 3a9b3d581b2..e9626d2a08e 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -183,6 +183,122 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run } +var ( + filter_Query_TotalRecvFees_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} +) + +func request_Query_TotalRecvFees_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalRecvFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalRecvFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TotalRecvFees(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalRecvFees_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalRecvFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalRecvFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TotalRecvFees(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -229,6 +345,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalRecvFees_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalRecvFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -310,6 +446,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalRecvFees_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalRecvFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -317,10 +473,14 @@ var ( pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TotalRecvFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_recv_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_IncentivizedPackets_0 = runtime.ForwardResponseMessage forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage + + forward_Query_TotalRecvFees_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index a588240a285..65b677c2fdb 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -5,10 +5,11 @@ package ibc.applications.fee.v1; option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; -import "ibc/applications/fee/v1/fee.proto"; import "google/api/annotations.proto"; -import "ibc/core/channel/v1/channel.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/applications/fee/v1/fee.proto"; +import "ibc/core/channel/v1/channel.proto"; // Query provides defines the gRPC querier service. service Query { @@ -24,6 +25,12 @@ service Query { "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" "{packet_id.sequence}"; } + + // TotalRecvFees returns the total receive fees for a packet given its identifier + rpc TotalRecvFees(QueryTotalRecvFeesRequest) returns (QueryTotalRecvFeesResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/" + "{packet_id.channel_id}/sequence/{packet_id.sequence}"; + } } // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets @@ -53,3 +60,19 @@ message QueryIncentivizedPacketResponse { // Incentivized_packet ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packet = 1 [(gogoproto.nullable) = false]; } + +// QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc +message QueryTotalRecvFeesRequest { + // the packet identifier for the associated fees + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; +} + +// QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc +message QueryTotalRecvFeesResponse { + // the total packet receive fees + repeated cosmos.base.v1beta1.Coin recv_fees = 1 [ + (gogoproto.moretags) = "yaml:\"recv_fees\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +}