diff --git a/boa/contracts/abi/abi_contract.py b/boa/contracts/abi/abi_contract.py index 47f8b382..2579f68f 100644 --- a/boa/contracts/abi/abi_contract.py +++ b/boa/contracts/abi/abi_contract.py @@ -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, @@ -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): diff --git a/boa/contracts/vvm/vvm_contract.py b/boa/contracts/vvm/vvm_contract.py index 195892b9..b6a2ba8a 100644 --- a/boa/contracts/vvm/vvm_contract.py +++ b/boa/contracts/vvm/vvm_contract.py @@ -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): """ @@ -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