@@ -97,12 +97,14 @@ def _flush(self, future_result: Result = None) -> Any:
97
97
print (color .highlight (f"{ message } \n " ))
98
98
99
99
ContractCall .__call__ .__code__ = getattr (ContractCall , "__original_call_code" )
100
- results = self ._contract .tryAggregate ( # type: ignore
101
- False ,
102
- [_call .calldata for _call in pending_calls ],
103
- block_identifier = self ._block_number [get_ident ()],
104
- )
105
- ContractCall .__call__ .__code__ = getattr (ContractCall , "__proxy_call_code" )
100
+ try :
101
+ results = self ._contract .tryAggregate ( # type: ignore
102
+ False ,
103
+ [_call .calldata for _call in pending_calls ],
104
+ block_identifier = self ._block_number [get_ident ()],
105
+ )
106
+ finally :
107
+ ContractCall .__call__ .__code__ = getattr (ContractCall , "__proxy_call_code" )
106
108
107
109
for _call , result in zip (pending_calls , results ):
108
110
_call .__wrapped__ = _call .decoder (result [1 ]) if result [0 ] else None # type: ignore
@@ -133,8 +135,10 @@ def _proxy_call(*args: Tuple, **kwargs: Dict[str, Any]) -> Any:
133
135
134
136
# standard call we let pass through
135
137
ContractCall .__call__ .__code__ = getattr (ContractCall , "__original_call_code" )
136
- result = ContractCall .__call__ (* args , ** kwargs ) # type: ignore
137
- ContractCall .__call__ .__code__ = getattr (ContractCall , "__proxy_call_code" )
138
+ try :
139
+ result = ContractCall .__call__ (* args , ** kwargs ) # type: ignore
140
+ finally :
141
+ ContractCall .__call__ .__code__ = getattr (ContractCall , "__proxy_call_code" )
138
142
return result
139
143
140
144
def __enter__ (self ) -> "Multicall" :
0 commit comments