diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index 171c88d435f..1802b2f4a1e 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -555,26 +555,13 @@ func (k Keeper) NextSequenceSend(c context.Context, req *types.QueryNextSequence ctx := sdk.UnwrapSDKContext(c) - channel, found := k.GetChannel(ctx, req.PortId, req.ChannelId) + sequence, found := k.GetNextSequenceSend(ctx, req.PortId, req.ChannelId) if !found { return nil, status.Error( codes.NotFound, - errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), + errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), ) } - - // Return the next sequence send for ordered channels. Unordered channels - // do not make use of the next sequence send. - var sequence uint64 - if channel.Ordering != types.UNORDERED { - sequence, found = k.GetNextSequenceSend(ctx, req.PortId, req.ChannelId) - if !found { - return nil, status.Error( - codes.NotFound, - errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(), - ) - } - } selfHeight := clienttypes.GetSelfHeight(ctx) return types.NewQueryNextSequenceSendResponse(sequence, nil, selfHeight), nil } diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 725b6d1655a..00937161d97 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -1620,12 +1620,14 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { false, }, { - "basic success on unordered channel returns zero", + "basic success on unordered channel returns the set send sequence", func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - expSeq = 0 + expSeq = 42 + seq := uint64(42) + suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, seq) req = &types.QueryNextSequenceSendRequest{ PortId: path.EndpointA.ChannelConfig.PortID, ChannelId: path.EndpointA.ChannelID,