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

add kwarg nowarn=False to .at() #376

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO more specific is better

Suggested change
def at(self, address: Any, nowarn=False) -> "VyperContract":
def at(self, address: Any, check_bytecode=True) -> "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
Loading