From dd2dd86d24af1e3f09541db58b3ce2ac3de7163e Mon Sep 17 00:00:00 2001 From: Mdaiki0730 Date: Thu, 9 Feb 2023 19:07:20 +0900 Subject: [PATCH 1/3] Map Ostracon:ErrTxInMap to lbm-sdk:ErrTxInMempoolCache --- client/broadcast.go | 7 +++++++ client/broadcast_test.go | 1 + 2 files changed, 8 insertions(+) diff --git a/client/broadcast.go b/client/broadcast.go index d2e96ed3c1..8720b506e9 100644 --- a/client/broadcast.go +++ b/client/broadcast.go @@ -77,6 +77,13 @@ func CheckTendermintError(err error, tx octypes.Tx) *sdk.TxResponse { TxHash: txHash, } + case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInMap.Error())): + return &sdk.TxResponse{ + Code: sdkerrors.ErrTxInMempoolCache.ABCICode(), + Codespace: sdkerrors.ErrTxInMempoolCache.Codespace(), + TxHash: txHash, + } + default: return nil } diff --git a/client/broadcast_test.go b/client/broadcast_test.go index b699080594..347ab44453 100644 --- a/client/broadcast_test.go +++ b/client/broadcast_test.go @@ -44,6 +44,7 @@ func CreateContextWithErrorAndMode(err error, mode string) Context { func TestBroadcastError(t *testing.T) { errors := map[error]uint32{ mempool.ErrTxInCache: sdkerrors.ErrTxInMempoolCache.ABCICode(), + mempool.ErrTxInMap: sdkerrors.ErrTxInMempoolCache.ABCICode(), mempool.ErrTxTooLarge{}: sdkerrors.ErrTxTooLarge.ABCICode(), mempool.ErrMempoolIsFull{}: sdkerrors.ErrMempoolIsFull.ABCICode(), } From 915081ce4fd15497b74aa5e40fb399a579efa13e Mon Sep 17 00:00:00 2001 From: Mdaiki0730 Date: Thu, 9 Feb 2023 19:49:26 +0900 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f2b0cfd57..0b6140ce6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (cosmovisor) [\#792](https://github.com/line/lbm-sdk/pull/792) Use upstream's cosmovisor * (server) [\#821](https://github.com/line/lbm-sdk/pull/821) Get validator pubkey considering KMS +* (client) [\#890](https://github.com/line/lbm-sdk/pull/890) Map Ostracon:ErrTxInMap to lbm-sdk:ErrTxInMempoolCache ### Bug Fixes * (client) [\#817](https://github.com/line/lbm-sdk/pull/817) remove support for composite (BLS) type From 1a653b147291fc4f3a7f4454ee79b7ae73bb5619 Mon Sep 17 00:00:00 2001 From: Mdaiki0730 Date: Fri, 10 Feb 2023 13:12:26 +0900 Subject: [PATCH 3/3] Refactor switch case --- client/broadcast.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/client/broadcast.go b/client/broadcast.go index 8720b506e9..bebe94c33c 100644 --- a/client/broadcast.go +++ b/client/broadcast.go @@ -56,7 +56,8 @@ func CheckTendermintError(err error, tx octypes.Tx) *sdk.TxResponse { txHash := fmt.Sprintf("%X", tx.Hash()) switch { - case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())): + case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())), + strings.Contains(errStr, strings.ToLower(mempool.ErrTxInMap.Error())): return &sdk.TxResponse{ Code: sdkerrors.ErrTxInMempoolCache.ABCICode(), Codespace: sdkerrors.ErrTxInMempoolCache.Codespace(), @@ -77,13 +78,6 @@ func CheckTendermintError(err error, tx octypes.Tx) *sdk.TxResponse { TxHash: txHash, } - case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInMap.Error())): - return &sdk.TxResponse{ - Code: sdkerrors.ErrTxInMempoolCache.ABCICode(), - Codespace: sdkerrors.ErrTxInMempoolCache.Codespace(), - TxHash: txHash, - } - default: return nil }