Skip to content

Commit

Permalink
chore: remove UnwrapSDKContext grpc queries
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan committed Dec 18, 2024
1 parent ef54cd5 commit fe200cb
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions modules/apps/29-fee/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ func (k Keeper) IncentivizedPackets(ctx context.Context, req *types.QueryIncenti
}

// IncentivizedPacket implements the Query/IncentivizedPacket gRPC method
func (k Keeper) IncentivizedPacket(goCtx context.Context, req *types.QueryIncentivizedPacketRequest) (*types.QueryIncentivizedPacketResponse, error) {
func (k Keeper) IncentivizedPacket(ctx context.Context, req *types.QueryIncentivizedPacketRequest) (*types.QueryIncentivizedPacketResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx).WithBlockHeight(int64(req.QueryHeight))

feesInEscrow, exists := k.GetFeesInEscrow(ctx, req.PacketId)
if !exists {
return nil, status.Error(
Expand All @@ -70,7 +68,7 @@ func (k Keeper) IncentivizedPacket(goCtx context.Context, req *types.QueryIncent
}

// IncentivizedPacketsForChannel implements the Query/IncentivizedPacketsForChannel gRPC method
func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) {
func (k Keeper) IncentivizedPacketsForChannel(ctx context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand All @@ -79,8 +77,6 @@ func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types.
return nil, err
}

ctx := sdk.UnwrapSDKContext(goCtx).WithBlockHeight(int64(req.QueryHeight))

if !k.channelKeeper.HasChannel(ctx, req.PortId, req.ChannelId) {
return nil, status.Error(
codes.NotFound,
Expand Down Expand Up @@ -115,13 +111,11 @@ func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types.
}

// TotalRecvFees implements the Query/TotalRecvFees gRPC method
func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) {
func (k Keeper) TotalRecvFees(ctx 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(
Expand All @@ -141,13 +135,11 @@ func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFe
}

// TotalAckFees implements the Query/TotalAckFees gRPC method
func (k Keeper) TotalAckFees(goCtx context.Context, req *types.QueryTotalAckFeesRequest) (*types.QueryTotalAckFeesResponse, error) {
func (k Keeper) TotalAckFees(ctx context.Context, req *types.QueryTotalAckFeesRequest) (*types.QueryTotalAckFeesResponse, 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(
Expand All @@ -167,13 +159,11 @@ func (k Keeper) TotalAckFees(goCtx context.Context, req *types.QueryTotalAckFees
}

// TotalTimeoutFees implements the Query/TotalTimeoutFees gRPC method
func (k Keeper) TotalTimeoutFees(goCtx context.Context, req *types.QueryTotalTimeoutFeesRequest) (*types.QueryTotalTimeoutFeesResponse, error) {
func (k Keeper) TotalTimeoutFees(ctx context.Context, req *types.QueryTotalTimeoutFeesRequest) (*types.QueryTotalTimeoutFeesResponse, 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(
Expand All @@ -193,13 +183,11 @@ func (k Keeper) TotalTimeoutFees(goCtx context.Context, req *types.QueryTotalTim
}

// Payee implements the Query/Payee gRPC method and returns the registered payee address to which packet fees are paid out
func (k Keeper) Payee(goCtx context.Context, req *types.QueryPayeeRequest) (*types.QueryPayeeResponse, error) {
func (k Keeper) Payee(ctx context.Context, req *types.QueryPayeeRequest) (*types.QueryPayeeResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx)

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.Relayer, req.ChannelId)
Expand All @@ -211,13 +199,11 @@ func (k Keeper) Payee(goCtx context.Context, req *types.QueryPayeeRequest) (*typ
}

// 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) {
func (k Keeper) CounterpartyPayee(ctx context.Context, req *types.QueryCounterpartyPayeeRequest) (*types.QueryCounterpartyPayeeResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx)

counterpartyPayeeAddr, found := k.GetCounterpartyPayeeAddress(ctx, req.Relayer, req.ChannelId)
if !found {
return nil, status.Errorf(codes.NotFound, "counterparty payee address not found for address: %s on channel: %s", req.Relayer, req.ChannelId)
Expand Down Expand Up @@ -263,7 +249,7 @@ func (k Keeper) FeeEnabledChannels(ctx context.Context, req *types.QueryFeeEnabl

// FeeEnabledChannel implements the Query/FeeEnabledChannel gRPC method and returns true if the provided
// port and channel identifiers belong to a fee enabled channel
func (k Keeper) FeeEnabledChannel(goCtx context.Context, req *types.QueryFeeEnabledChannelRequest) (*types.QueryFeeEnabledChannelResponse, error) {
func (k Keeper) FeeEnabledChannel(ctx context.Context, req *types.QueryFeeEnabledChannelRequest) (*types.QueryFeeEnabledChannelResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand All @@ -272,8 +258,6 @@ func (k Keeper) FeeEnabledChannel(goCtx context.Context, req *types.QueryFeeEnab
return nil, err
}

ctx := sdk.UnwrapSDKContext(goCtx)

if !k.HasChannel(ctx, req.PortId, req.ChannelId) {
return nil, status.Error(
codes.NotFound,
Expand Down

0 comments on commit fe200cb

Please sign in to comment.