client: update client error handling to use tx hash from tendermint (#9462)
This commit is contained in:
parent
ec3e2b4d0d
commit
069514e4d6
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
"github.com/tendermint/tendermint/mempool"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
|
@ -46,13 +46,13 @@ func (ctx Context) BroadcastTx(txBytes []byte) (res *sdk.TxResponse, err error)
|
|||
// TODO: Avoid brittle string matching in favor of error matching. This requires
|
||||
// a change to Tendermint's RPCError type to allow retrieval or matching against
|
||||
// a concrete error type.
|
||||
func CheckTendermintError(err error, txBytes []byte) *sdk.TxResponse {
|
||||
func CheckTendermintError(err error, tx tmtypes.Tx) *sdk.TxResponse {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
errStr := strings.ToLower(err.Error())
|
||||
txHash := fmt.Sprintf("%X", tmhash.Sum(txBytes))
|
||||
txHash := fmt.Sprintf("%X", tx.Hash())
|
||||
|
||||
switch {
|
||||
case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())):
|
||||
|
|
Loading…
Reference in New Issue