Skip to content

Commit 064c894

Browse files
committed
added patch for batch properties being on class level rather than on instance level. Monkey patching ethereum/web3.py#3661
1 parent 42366ac commit 064c894

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
from .Subsquid import get_endpoints
1414
from .Web3ErrorHandlerPatch import patch_error_formatters
1515
from .FastChecksumAddress import to_checksum_address
16+
from .Web3ProviderPatch import patch_batching
17+
18+
patch_error_formatters()
19+
patch_batching()
1620

1721

1822
class Web3Advanced(Web3):
@@ -55,7 +59,6 @@ def __init__(
5559
should_retry: bool = True,
5660
unstable_blocks: int = int(os.getenv("UNSTABLE_BLOCKS", 5)), # not all nodes might have latest n blocks, these are seen as unstable
5761
):
58-
patch_error_formatters()
5962
self.node_url = node_url
6063
self.should_retry = should_retry
6164
self.unstable_blocks = unstable_blocks

IceCreamSwapWeb3/Web3ProviderPatch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from web3 import JSONBaseProvider
2+
3+
def patch_batching():
4+
# make sure batching attributes are instance attributes, not class level attributes
5+
6+
original_init = JSONBaseProvider.__init__
7+
8+
def patched_init(self, *args, **kwargs):
9+
original_init(self, *args, **kwargs)
10+
self._is_batching = False
11+
self._batch_request_func_cache = (None, None)
12+
13+
JSONBaseProvider.__init__ = patched_init

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.48'
3+
VERSION = '0.1.49'
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)