Skip to content

Commit

Permalink
polish, remove unneeded contract_name kwargs
Browse files Browse the repository at this point in the history
some other style things
move around arg order
  • Loading branch information
charles-cooper committed Oct 23, 2024
1 parent 06a6335 commit 2c84cba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
28 changes: 10 additions & 18 deletions boa/contracts/vyper/vyper_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ class _BaseVyperContract(_BaseEVMContract):
def __init__(
self,
compiler_data: CompilerData,
contract_name: Optional[str] = None,
env: Optional[Env] = None,
filename: Optional[str] = None,
contract_name: Optional[str] = None,
):
contract_name = (
contract_name if contract_name else Path(compiler_data.contract_path).stem
)
if contract_name is None:
contract_name = Path(compiler_data.contract_path).stem

super().__init__(contract_name, env, filename)
self.compiler_data = compiler_data

Expand Down Expand Up @@ -188,12 +188,11 @@ def __init__(
env=None,
override_address=None,
blueprint_preamble=None,
contract_name=None,
filename=None,
gas=None,
):
# note slight code duplication with VyperContract ctor,
# maybe use common base class?
super().__init__(compiler_data, env, filename)
super().__init__(compiler_data, contract_name, env, filename)

deploy_bytecode = generate_blueprint_bytecode(
compiler_data.bytecode, blueprint_preamble
Expand Down Expand Up @@ -519,11 +518,11 @@ def __init__(
# whether to skip constructor
skip_initcode=False,
created_from: Address = None,
contract_name=None,
filename: str = None,
gas=None,
contract_name=None,
):
super().__init__(compiler_data, env, filename, contract_name)
super().__init__(compiler_data, contract_name, env, filename)

self.created_from = created_from
self._computation = None
Expand All @@ -548,11 +547,7 @@ def __init__(
addr = Address(override_address)
else:
addr = self._run_init(
*args,
value=value,
override_address=override_address,
gas=gas,
contract_name=contract_name,
*args, value=value, override_address=override_address, gas=gas
)
self._address = addr

Expand All @@ -577,9 +572,7 @@ def __init__(

self.env.register_contract(self._address, self)

def _run_init(
self, *args, value=0, override_address=None, gas=None, contract_name=None
):
def _run_init(self, *args, value=0, override_address=None, gas=None):
encoded_args = b""
if self._ctor:
encoded_args = self._ctor.prepare_calldata(*args)
Expand All @@ -592,7 +585,6 @@ def _run_init(
override_address=override_address,
gas=gas,
contract=self,
contract_name=contract_name,
)

self._computation = computation
Expand Down
1 change: 0 additions & 1 deletion boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def deploy(
override_address: Optional[_AddressType] = None,
# the calling vyper contract
contract: Any = None,
contract_name: Optional[str] = None, # TODO: This isn't used
):
sender = self._get_sender(sender)

Expand Down
15 changes: 2 additions & 13 deletions boa/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,7 @@ def execute_code(

# OVERRIDES
def deploy(
self,
sender=None,
gas=None,
value=0,
bytecode=b"",
contract=None,
contract_name=None,
**kwargs,
self, sender=None, gas=None, value=0, bytecode=b"", contract=None, **kwargs
):
# reset to latest block for simulation
self._reset_fork()
Expand Down Expand Up @@ -409,11 +402,7 @@ def deploy(
print(f"contract deployed at {create_address}")

if (deployments_db := get_deployments_db()) is not None:
contract_name = (
contract_name
if contract_name
else getattr(contract, "contract_name", None)
)
contract_name = getattr(contract, "contract_name", None)
try:
source_bundle = get_verification_bundle(contract)
except Exception as e:
Expand Down

0 comments on commit 2c84cba

Please sign in to comment.