Skip to content

Commit 0ee902e

Browse files
committed
v0.1.45 fixed deepcopy order for Web3Advanced
1 parent 8dc17db commit 0ee902e

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,33 @@ def __init__(
7777

7878
def __deepcopy__(self, memo):
7979
# create new instance, but only call init of Web3.py, not our custom one.
80-
new_instance = self.__class__.__new__(self.__class__)
81-
memo[id(self)] = new_instance
82-
Web3.__init__(new_instance, provider=self._construct_provider(node_url=self.node_url), modules=self._get_modules())
80+
new = self.__class__.__new__(self.__class__)
81+
memo[id(self)] = new
8382

8483
# Copy over all our custom data instead of running the lengthy checks of our init again
85-
new_instance.manager.middleware_onion = self.manager.middleware_onion
86-
new_instance.node_url = self.node_url
87-
new_instance.should_retry = self.should_retry
88-
new_instance.unstable_blocks = self.unstable_blocks
89-
new_instance.latest_seen_block = self.latest_seen_block
90-
new_instance.filter_block_range = self.filter_block_range
91-
new_instance.rpc_batch_max_size = self.rpc_batch_max_size
92-
new_instance.revert_reason_available = self.revert_reason_available
93-
new_instance.is_archive = self.is_archive
94-
new_instance.overwrites_available = self.overwrites_available
95-
new_instance.subsquid_available = self.subsquid_available
96-
97-
return new_instance
84+
new.node_url = self.node_url
85+
new.should_retry = self.should_retry
86+
new.unstable_blocks = self.unstable_blocks
87+
new.latest_seen_block = self.latest_seen_block
88+
new.filter_block_range = self.filter_block_range
89+
new.rpc_batch_max_size = self.rpc_batch_max_size
90+
new.revert_reason_available = self.revert_reason_available
91+
new.is_archive = self.is_archive
92+
new.overwrites_available = self.overwrites_available
93+
new.subsquid_available = self.subsquid_available
94+
95+
# only call Web3.py init, not init of Web3Advanced
96+
Web3.__init__(
97+
new,
98+
provider=self._construct_provider(node_url=self.node_url),
99+
modules=self._get_modules()
100+
)
101+
102+
# initialize custom middlewares
103+
new.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0, name="poa")
104+
new.middleware_onion.inject(BatchRetryMiddleware, layer=0, name="batch_retry")
105+
106+
return new
98107

99108
@staticmethod
100109
def _get_modules():

0 commit comments

Comments
 (0)