Skip to content

Commit

Permalink
fix bytecode override
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 19, 2024
1 parent 3f302ed commit da7467e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions boa/contracts/abi/abi_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def __call__(self, *args, value=0, gas=None, sender=None, **kwargs):
if not self.contract or not self.contract.env:
raise Exception(f"Cannot call {self} without deploying contract.")

override_bytecode = None
if hasattr(self, "_override_bytecode"):
override_bytecode = self._override_bytecode

computation = self.contract.env.execute_code(
to_address=self.contract.address,
sender=sender,
Expand All @@ -132,6 +136,7 @@ def __call__(self, *args, value=0, gas=None, sender=None, **kwargs):
gas=gas,
is_modifying=self.is_mutable,
contract=self.contract,
override_bytecode=override_bytecode,
)

match self.contract.marshal_to_python(computation, self.return_type):
Expand Down
11 changes: 2 additions & 9 deletions boa/contracts/vvm/vvm_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@ def source_code(self) -> str:
"""
raise NotImplementedError

def __call__(self, *args, **kwargs):
env = self.contract.env
assert isinstance(self.contract, VVMContract) # help mypy
env.set_code(self.contract.address, self._override_bytecode)
try:
return super().__call__(*args, **kwargs)
finally:
env.set_code(self.contract.address, self.contract.bytecode_runtime)


class VVMInternalFunction(_VVMInternal):
"""
Expand Down Expand Up @@ -324,6 +315,8 @@ def __init__(self, name, spec, contract):
self.contract = contract

def get(self, *args):
# get the value of the storage variable. note that this is
# different from the behavior of VyperContract storage variables!
return self.__call__(*args)

@cached_property
Expand Down

0 comments on commit da7467e

Please sign in to comment.