Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicall - reset call code even if call reverts #1746

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading