cosmos-sdk/x/ibc-transfer/client/utils/utils.go
SaReN 39f53ac22f
client: rename CliContext to Context (#6290)
* Refactor CliContext as Context

* Fix lint issues

* Fix goimports

* Fix gov tests

* Resolved ci-lint issues

* Add changelog

* Rename cliCtx to clientCtx

* Fix mocks and routes

* Add changelog

* Update changelog

* Apply suggestions from code review

Co-authored-by: Alessio Treglia <alessio@tendermint.com>

* merge client/rpc/ro{ot,utes}.go

* Update docs

* client/rpc: remove redundant client/rpc.RegisterRPCRoutes

* regenerate mocks

* Update ADRs

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-06-01 12:46:03 +00:00

34 lines
890 B
Go

package utils
import (
"encoding/binary"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/cosmos/cosmos-sdk/client"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
)
// QueryNextSequenceRecv queries the store to get the next receive sequence and
// a merkle proof.
func QueryNextSequenceRecv(
clientCtx client.Context, portID, channelID string, prove bool,
) (channeltypes.RecvResponse, error) {
req := abci.RequestQuery{
Path: "store/ibc/key",
Data: host.KeyNextSequenceRecv(portID, channelID),
Prove: prove,
}
res, err := clientCtx.QueryABCI(req)
if err != nil {
return channeltypes.RecvResponse{}, err
}
sequence := binary.BigEndian.Uint64(res.Value)
sequenceRes := channeltypes.NewRecvResponse(portID, channelID, sequence, res.Proof, res.Height)
return sequenceRes, nil
}