Merge PR #1317: Added tx hash to query output in LCD

* added tx hash
* changelog
This commit is contained in:
Fabian 2018-06-21 10:21:58 -07:00 committed by Christopher Goes
parent 81c773c8bf
commit 4884747662
3 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,7 @@ BREAKING CHANGES
FEATURES
* [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag
* [lcd] Queried TXs now include the tx hash to identify each tx
* [mockapp] CompleteSetup() no longer takes a testing parameter
FIXES

View File

@ -16,6 +16,7 @@ import (
cryptoKeys "github.com/tendermint/go-crypto/keys"
p2p "github.com/tendermint/tendermint/p2p"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tmlibs/common"
client "github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/client/keys"
@ -309,6 +310,7 @@ func TestTxs(t *testing.T) {
require.Equal(t, http.StatusOK, res.StatusCode, body)
type txInfo struct {
Hash common.HexBytes `json:"hash"`
Height int64 `json:"height"`
Tx sdk.Tx `json:"tx"`
Result abci.ResponseDeliverTx `json:"result"`
@ -324,6 +326,10 @@ func TestTxs(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, 1, len(indexedTxs))
// XXX should this move into some other testfile for txs in general?
// test if created TX hash is the correct hash
assert.Equal(t, resultTx.Hash, indexedTxs[0].Hash)
// query sender
// also tests url decoding
addrBech := sdk.MustBech32ifyAcc(addr)

View File

@ -7,6 +7,8 @@ import (
"net/http"
"strconv"
"github.com/tendermint/tmlibs/common"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -81,6 +83,7 @@ func formatTxResult(cdc *wire.Codec, res *ctypes.ResultTx) (txInfo, error) {
}
info := txInfo{
Hash: res.Hash,
Height: res.Height,
Tx: tx,
Result: res.TxResult,
@ -90,6 +93,7 @@ func formatTxResult(cdc *wire.Codec, res *ctypes.ResultTx) (txInfo, error) {
// txInfo is used to prepare info to display
type txInfo struct {
Hash common.HexBytes `json:"hash"`
Height int64 `json:"height"`
Tx sdk.Tx `json:"tx"`
Result abci.ResponseDeliverTx `json:"result"`