Skip to content

Commit

Permalink
leveraging ParseKeyFeesInEscrow to obtain packet id in query
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan committed Feb 24, 2022
1 parent b4ac164 commit 2418546
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions modules/apps/29-fee/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package keeper

import (
"context"
"strconv"
"strings"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -14,7 +12,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
)

var _ types.QueryServer = Keeper{}
Expand All @@ -30,17 +27,12 @@ func (k Keeper) IncentivizedPackets(c context.Context, req *types.QueryIncentivi
var identifiedPackets []types.IdentifiedPacketFees
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.FeesInEscrowPrefix))
_, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
keySplit := strings.Split(string(key), "/")

channelID, portID := keySplit[2], keySplit[1]
seq, err := strconv.ParseUint(keySplit[3], 10, 64)
packetID, err := types.ParseKeyFeesInEscrow(types.FeesInEscrowPrefix + string(key))
if err != nil {
panic(err)
return err
}

packetID := channeltypes.NewPacketId(channelID, portID, seq)
packetFees := k.MustUnmarshalFees(value)

identifiedPackets = append(identifiedPackets, types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees))
return nil
})
Expand Down

0 comments on commit 2418546

Please sign in to comment.