Skip to content

Commit

Permalink
Merge PR #1317: Added tx hash to query output in LCD
Browse files Browse the repository at this point in the history
* added tx hash
* changelog
  • Loading branch information
faboweb authored and Adrian Brink committed Jul 2, 2018
1 parent 281f014 commit ccb385c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions client/tx/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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"`
Expand Down

0 comments on commit ccb385c

Please sign in to comment.