Skip to content

Commit 12279c5

Browse files
committed
v0.1.25 properly handling RPC error returns for single calls in RPC batching as well.
1 parent 2bbbf8f commit 12279c5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

IceCreamSwapWeb3/BatchRetryMiddleware.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ def middleware(requests_info) -> list:
1515
# early return if batch to request is empty
1616
return []
1717

18-
if self._w3.rpc_batch_max_size == 0 or len(requests_info) == 1:
19-
# if RPC does not support batch requests or single request in batch, make individual requests
20-
return [
21-
exponential_retry(method)(make_batch_request.__self__.make_request)(
22-
method,
23-
params,
24-
no_retry=not self._w3.should_retry
25-
)
26-
for method, params in requests_info
27-
]
28-
2918
if len(requests_info) > self._w3.rpc_batch_max_size:
3019
response = []
3120
for start in range(0, len(requests_info), self._w3.rpc_batch_max_size):
3221
response += middleware(requests_info[start:start + self._w3.rpc_batch_max_size])
3322
return response
3423

3524
try:
36-
response = make_batch_request(requests_info)
25+
if self._w3.rpc_batch_max_size == 0 or len(requests_info) == 1:
26+
# if RPC does not support batch requests or single request in batch, make individual requests
27+
response = [
28+
exponential_retry(method)(make_batch_request.__self__.make_request)(
29+
method,
30+
params,
31+
no_retry=not self._w3.should_retry
32+
)
33+
for method, params in requests_info
34+
]
35+
else:
36+
response = make_batch_request(requests_info)
3737
except Exception as e:
3838
assert len(requests_info) > 1
3939
print(f"batch RPC call with {len(requests_info)} requests got exception {repr(e)}, splitting and retrying")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
VERSION = '0.1.24'
3+
VERSION = '0.1.25'
44
DESCRIPTION = 'IceCreamSwap Web3.py wrapper'
55
LONG_DESCRIPTION = 'IceCreamSwap Web3.py wrapper with automatic retries, multicall and other advanced functionality'
66

0 commit comments

Comments
 (0)