Skip to content

Commit cd25f88

Browse files
fix(query): get next send sequence for transfer packets (#4706)
* feat(packet): get next send sequence for transfer packets * chore(channels): fixed tests for unordered sequence * Update modules/core/04-channel/keeper/grpc_query_test.go Co-authored-by: Carlos Rodriguez <carlos@interchain.io> * chore: removed useless error handling --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
1 parent c66d1e2 commit cd25f88

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

modules/core/04-channel/keeper/grpc_query.go

+2-15
Original file line numberDiff line numberDiff line change
@@ -555,26 +555,13 @@ func (k Keeper) NextSequenceSend(c context.Context, req *types.QueryNextSequence
555555

556556
ctx := sdk.UnwrapSDKContext(c)
557557

558-
channel, found := k.GetChannel(ctx, req.PortId, req.ChannelId)
558+
sequence, found := k.GetNextSequenceSend(ctx, req.PortId, req.ChannelId)
559559
if !found {
560560
return nil, status.Error(
561561
codes.NotFound,
562-
errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(),
562+
errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(),
563563
)
564564
}
565-
566-
// Return the next sequence send for ordered channels. Unordered channels
567-
// do not make use of the next sequence send.
568-
var sequence uint64
569-
if channel.Ordering != types.UNORDERED {
570-
sequence, found = k.GetNextSequenceSend(ctx, req.PortId, req.ChannelId)
571-
if !found {
572-
return nil, status.Error(
573-
codes.NotFound,
574-
errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(),
575-
)
576-
}
577-
}
578565
selfHeight := clienttypes.GetSelfHeight(ctx)
579566
return types.NewQueryNextSequenceSendResponse(sequence, nil, selfHeight), nil
580567
}

modules/core/04-channel/keeper/grpc_query_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1620,12 +1620,14 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() {
16201620
false,
16211621
},
16221622
{
1623-
"basic success on unordered channel returns zero",
1623+
"basic success on unordered channel returns the set send sequence",
16241624
func() {
16251625
path := ibctesting.NewPath(suite.chainA, suite.chainB)
16261626
suite.coordinator.Setup(path)
16271627

1628-
expSeq = 0
1628+
expSeq = 42
1629+
seq := uint64(42)
1630+
suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, seq)
16291631
req = &types.QueryNextSequenceSendRequest{
16301632
PortId: path.EndpointA.ChannelConfig.PortID,
16311633
ChannelId: path.EndpointA.ChannelID,

0 commit comments

Comments
 (0)