Skip to content

Commit

Permalink
fix lint, make some simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 2, 2024
1 parent 7a82844 commit 909c5ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
9 changes: 2 additions & 7 deletions boa/contracts/vvm/vvm_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
from functools import cached_property

from boa.contracts.abi.abi_contract import ABIContractFactory, ABIFunction
from boa.contracts.base_evm_contract import (
DEFAULT_BLUEPRINT_PREAMBLE,
generate_blueprint_bytecode,
)
from boa.environment import Env
from boa.util.eip5202 import generate_blueprint_bytecode

# TODO: maybe this doesn't detect release candidates
VERSION_RE = re.compile(r"\s*#\s*(pragma\s+version|@version)\s+(\d+\.\d+\.\d+)")
Expand Down Expand Up @@ -80,9 +77,7 @@ def _blueprint_deployer(self):
# TODO: add filename
return ABIContractFactory.from_abi_dict([])

def deploy_as_blueprint(
self, env=None, blueprint_preamble=DEFAULT_BLUEPRINT_PREAMBLE, **kwargs
):
def deploy_as_blueprint(self, env=None, blueprint_preamble=None, **kwargs):
"""
Deploy a new blueprint from this contract.
:param blueprint_preamble: The preamble to use for the blueprint.
Expand Down
15 changes: 7 additions & 8 deletions boa/contracts/vyper/vyper_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@

from boa import BoaError
from boa.contracts.base_evm_contract import (
DEFAULT_BLUEPRINT_PREAMBLE,
StackTrace,
_BaseEVMContract,
_handle_child_trace,
generate_blueprint_bytecode,
)
from boa.contracts.call_trace import TraceSource
from boa.contracts.vyper.ast_utils import get_fn_ancestor_from_node, reason_at
Expand All @@ -58,6 +56,7 @@
from boa.environment import Env
from boa.profiling import cache_gas_used_for_computation
from boa.util.abi import Address, abi_decode, abi_encode
from boa.util.eip5202 import generate_blueprint_bytecode
from boa.util.lrudict import lrudict
from boa.vm.gas_meters import ProfilingGasMeter
from boa.vm.utils import to_bytes, to_int
Expand Down Expand Up @@ -185,20 +184,20 @@ def __init__(
compiler_data,
env=None,
override_address=None,
blueprint_preamble=DEFAULT_BLUEPRINT_PREAMBLE,
blueprint_preamble=None,
filename=None,
gas=None,
):
# note slight code duplication with VyperContract ctor,
# maybe use common base class?
super().__init__(compiler_data, env, filename)

blueprint_bytecode = generate_blueprint_bytecode(
compiler_data.bytecode, blueprint_preamble
)

addr, computation = self.env.deploy(
bytecode=generate_blueprint_bytecode(
compiler_data.bytecode, blueprint_preamble
),
override_address=override_address,
gas=gas,
bytecode=blueprint_bytecode, override_address=override_address, gas=gas
)
if computation.is_error:
raise computation.error
Expand Down
4 changes: 2 additions & 2 deletions boa/util/eip5202.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from eth_utils import to_canonical_address, to_checksum_address
from vyper.utils import keccak256

DEFAULT_ERC5202_PREAMBLE = b"\xFE\x71\x00"
DEFAULT_BLUEPRINT_PREAMBLE = b"\xFE\x71\x00"


def generate_blueprint_bytecode(
contract_bytecode: bytes, blueprint_preamble: bytes = None
):
if blueprint_preamble is None:
blueprint_preamble = DEFAULT_ERC5202_PREAMBLE
blueprint_preamble = DEFAULT_BLUEPRINT_PREAMBLE

blueprint_bytecode = blueprint_preamble + contract_bytecode

Expand Down

0 comments on commit 909c5ee

Please sign in to comment.