Skip to content

Commit

Permalink
fix: reset call code even if call reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 18, 2024
1 parent 405a3e4 commit 8b77a6a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions brownie/network/multicall.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ def _flush(self, future_result: Result = None) -> Any:
print(color.highlight(f"{message}\n"))

ContractCall.__call__.__code__ = getattr(ContractCall, "__original_call_code")
results = self._contract.tryAggregate( # type: ignore
False,
[_call.calldata for _call in pending_calls],
block_identifier=self._block_number[get_ident()],
)
ContractCall.__call__.__code__ = getattr(ContractCall, "__proxy_call_code")
try:
results = self._contract.tryAggregate( # type: ignore
False,
[_call.calldata for _call in pending_calls],
block_identifier=self._block_number[get_ident()],
)
finally:
ContractCall.__call__.__code__ = getattr(ContractCall, "__proxy_call_code")

for _call, result in zip(pending_calls, results):
_call.__wrapped__ = _call.decoder(result[1]) if result[0] else None # type: ignore
Expand Down Expand Up @@ -133,8 +135,10 @@ def _proxy_call(*args: Tuple, **kwargs: Dict[str, Any]) -> Any:

# standard call we let pass through
ContractCall.__call__.__code__ = getattr(ContractCall, "__original_call_code")
result = ContractCall.__call__(*args, **kwargs) # type: ignore
ContractCall.__call__.__code__ = getattr(ContractCall, "__proxy_call_code")
try:
result = ContractCall.__call__(*args, **kwargs) # type: ignore
finally:
ContractCall.__call__.__code__ = getattr(ContractCall, "__proxy_call_code")
return result

def __enter__(self) -> "Multicall":
Expand Down

0 comments on commit 8b77a6a

Please sign in to comment.