Skip to content

Commit

Permalink
add kwarg nowarn=False to .at()
Browse files Browse the repository at this point in the history
sometimes you want to suppress the warning on purpose (like for minimal
proxy contracts)
  • Loading branch information
charles-cooper committed Jan 24, 2025
1 parent a8d5a6c commit 4b138e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions boa/contracts/vyper/vyper_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ def stomp(self, address: Any, data_section=None) -> "VyperContract":
return ret

# TODO: allow `env=` kwargs and so on
def at(self, address: Any) -> "VyperContract":
def at(self, address: Any, nowarn=False) -> "VyperContract":
address = Address(address)

ret = self.deploy(override_address=address, skip_initcode=True)
bytecode = ret.env.get_code(address)

ret._set_bytecode(bytecode)
ret._set_bytecode(bytecode, nowarn=nowarn)

ret.env.register_contract(address, ret)
return ret
Expand Down Expand Up @@ -604,12 +604,12 @@ def _deployment_source_map(self):
return source_map

# manually set the runtime bytecode, instead of using deploy
def _set_bytecode(self, bytecode: bytes) -> None:
def _set_bytecode(self, bytecode: bytes, nowarn=False) -> None:
to_check = bytecode
if self.data_section_size != 0:
to_check = bytecode[: -self.data_section_size]
assert isinstance(self.compiler_data, CompilerData)
if to_check != self.compiler_data.bytecode_runtime:
if to_check != self.compiler_data.bytecode_runtime and not nowarn:
warnings.warn(
f"casted bytecode does not match compiled bytecode at {self}",
stacklevel=2,
Expand Down
2 changes: 1 addition & 1 deletion boa/vm/py_evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def apply_create_message(cls, state, msg, tx_ctx, **kwargs):
proxied_address = extract_eip1167_address(runtime_bytecode)
proxied_contract = cls.env.lookup_contract(proxied_address)
if proxied_contract is not None and hasattr(proxied_contract, "deployer"):
contract = proxied_contract.deployer.at(contract_address)
contract = proxied_contract.deployer.at(contract_address, nowarn=True)
if hasattr(contract, "created_from"):
contract.created_from = Address(msg.sender)
cls.env.register_contract(contract_address, contract)
Expand Down

0 comments on commit 4b138e6

Please sign in to comment.