Merge PR #3264: Return an empty TxResponse when nil

This commit is contained in:
Alexander Bezobchuk 2019-02-12 11:23:03 -05:00 committed by Christopher Goes
parent 2216f4716e
commit 22bdc1778b
2 changed files with 14 additions and 0 deletions

View File

@ -54,6 +54,8 @@ BUG FIXES
* Gaia * Gaia
* [\#3585] Fix setting the tx hash in `NewResponseFormatBroadcastTxCommit`. * [\#3585] Fix setting the tx hash in `NewResponseFormatBroadcastTxCommit`.
* [\#3585] Return an empty `TxResponse` when Tendermint returns an empty
`ResultBroadcastTx`.
* SDK * SDK
* [\#3582](https://github.com/cosmos/cosmos-sdk/pull/3582) Running `make test_unit was failing due to a missing tag * [\#3582](https://github.com/cosmos/cosmos-sdk/pull/3582) Running `make test_unit was failing due to a missing tag

View File

@ -55,6 +55,10 @@ type TxResponse struct {
} }
func NewResponseResultTx(res *ctypes.ResultTx, tx Tx) TxResponse { func NewResponseResultTx(res *ctypes.ResultTx, tx Tx) TxResponse {
if res == nil {
return TxResponse{}
}
return TxResponse{ return TxResponse{
TxHash: res.Hash.String(), TxHash: res.Hash.String(),
Height: res.Height, Height: res.Height,
@ -70,6 +74,10 @@ func NewResponseResultTx(res *ctypes.ResultTx, tx Tx) TxResponse {
} }
func NewResponseFormatBroadcastTxCommit(res *ctypes.ResultBroadcastTxCommit) TxResponse { func NewResponseFormatBroadcastTxCommit(res *ctypes.ResultBroadcastTxCommit) TxResponse {
if res == nil {
return TxResponse{}
}
var txHash string var txHash string
if res.Hash != nil { if res.Hash != nil {
txHash = res.Hash.String() txHash = res.Hash.String()
@ -90,6 +98,10 @@ func NewResponseFormatBroadcastTxCommit(res *ctypes.ResultBroadcastTxCommit) TxR
} }
func NewResponseFormatBroadcastTx(res *ctypes.ResultBroadcastTx) TxResponse { func NewResponseFormatBroadcastTx(res *ctypes.ResultBroadcastTx) TxResponse {
if res == nil {
return TxResponse{}
}
return TxResponse{ return TxResponse{
Code: res.Code, Code: res.Code,
Data: res.Data.Bytes(), Data: res.Data.Bytes(),