Skip to content

Commit

Permalink
fix: NameError
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored May 10, 2023
1 parent ccc4905 commit 40b5895
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions dank_mids/brownie_patch/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ async def _encode_input(self: ContractCall, *args: Tuple[Any,...]) -> str:

async def _decode_output(self: ContractCall, data: str) -> Any:
return await run_in_subprocess(__decode_output, data, self.abi)

async def coroutine(
self: ContractCall,
*args: Tuple[Any,...],
block_identifier: Optional[Union[int, str, bytes]] = None,
override: Optional[Dict[str, str]] = None
) -> Any:
if override:
raise ValueError("Cannot use state override with `coroutine`.")

async with brownie_call_semaphore:
try:
return await self._decode_output(
await w3.eth.call({"to": self._address, "data": await self._encode_input(*args)}, block_identifier) # type: ignore
)
except ValueError as e:
try:
raise VirtualMachineError(e) from None
except:
raise e

def _patch_call(call: ContractCall, w3: Web3) -> None:
async def coroutine(
self: ContractCall,
*args: Tuple[Any,...],
block_identifier: Optional[Union[int, str, bytes]] = None,
override: Optional[Dict[str, str]] = None
) -> Any:
if override:
raise ValueError("Cannot use state override with `coroutine`.")

async with brownie_call_semaphore:
try:
return await self._decode_output(
await w3.eth.call({"to": self._address, "data": await self._encode_input(*args)}, block_identifier) # type: ignore
)
except ValueError as e:
try:
raise VirtualMachineError(e) from None
except:
raise e

call.coroutine = MethodType(coroutine, call)
call._encode_input = MethodType(_encode_input, call)
call._decode_output = MethodType(_decode_output, call)

0 comments on commit 40b5895

Please sign in to comment.