Skip to content

Commit 959694b

Browse files
committed
refactor: wait for transaction receipt
check if receipt exist before returning ctx timeout err
1 parent b1453b2 commit 959694b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/utils/eth_client_utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ const sleepTime = 5 * time.Second
1818

1919
func WaitForTransactionReceipt(client eth.InstrumentedClient, ctx context.Context, txHash gethcommon.Hash) (*types.Receipt, error) {
2020
for i := 0; i < maxRetries; i++ {
21-
receipt, err := client.TransactionReceipt(ctx, txHash)
21+
receipt, _ := client.TransactionReceipt(ctx, txHash)
22+
if receipt != nil {
23+
return receipt, nil
24+
}
2225
// if context has timed out, return
2326
if ctx.Err() != nil {
2427
return nil, ctx.Err()
25-
}
26-
if err != nil {
27-
time.Sleep(sleepTime)
2828
} else {
29-
return receipt, nil
29+
time.Sleep(sleepTime)
3030
}
3131
}
3232
return nil, fmt.Errorf("transaction receipt not found for txHash: %s", txHash.String())

0 commit comments

Comments
 (0)