Skip to content

Commit ef82040

Browse files
authored
Use string matching instead of errors.Is (#81)
RPC errors can contain more than the core error string.
1 parent 729fd9a commit ef82040

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

eth/transactor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ func (t *Transactor) transact(
150150
signer.Nonce = nonceInt
151151
tx, err := method(client, signer)
152152
if err != nil {
153-
if errors.Is(err, core.ErrNonceTooLow) || errors.Is(err, txpool.ErrReplaceUnderpriced) { // retryable nonce errors
153+
errStr := err.Error()
154+
if strings.Contains(errStr, core.ErrNonceTooLow.Error()) || strings.Contains(errStr, txpool.ErrReplaceUnderpriced.Error()) { // retryable nonce errors
154155
if !(txopts.noNonceRetry && txopts.nonce != 0) { // retry allowed (either flag not set or nonce not explicitly provided)
155156
nonce++
156157
log.Debugf("TxMethod nonce err: %s, retrying with nonce %d", err, nonce)
@@ -231,7 +232,7 @@ func (t *Transactor) waitTxAsync(
231232
if handler.OnError != nil {
232233
handler.OnError(tx, err)
233234
}
234-
if errors.Is(err, ethereum.NotFound) && pendingNonce > 0 {
235+
if strings.Contains(err.Error(), ethereum.NotFound.Error()) && pendingNonce > 0 {
235236
// reset transactor nonce to pending nonce
236237
// this means pending txs after this will probably fail
237238
t.lock.Lock()

0 commit comments

Comments
 (0)