Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Oct 9, 2024
1 parent 2dbc9ec commit f8593c1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
4 changes: 3 additions & 1 deletion boa_zksync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def set_zksync_env(url, nickname=None):


def set_zksync_test_env(node_args=(), nickname=None):
return boa.set_env(ZksyncEnv(rpc=EraTestNode(node_args=node_args), nickname=nickname))
return boa.set_env(
ZksyncEnv(rpc=EraTestNode(node_args=node_args), nickname=nickname)
)


def set_zksync_fork(url, nickname=None, *args, **kwargs):
Expand Down
2 changes: 0 additions & 2 deletions boa_zksync/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from boa_zksync.compiler_utils import get_compiler_output
from boa_zksync.types import ZksyncCompilerData

import warnings


def compile_zksync(
contract_name: str, filename: str, compiler_args=None, source_code=None
Expand Down
19 changes: 15 additions & 4 deletions boa_zksync/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
generate_source_for_internal_fn,
)
from boa_zksync.types import ZksyncCompilerData

if TYPE_CHECKING:
from boa_zksync import ZksyncEnv

Expand Down Expand Up @@ -66,7 +67,14 @@ def __init__(
)

# only now initialize the ABI contract
super().__init__(name=name, abi=compiler_data.abi, functions=functions, address=address, filename=filename, env=env)
super().__init__(
name=name,
abi=compiler_data.abi,
functions=functions,
address=address,
filename=filename,
env=env,
)
self.env.register_contract(address, self)

def _run_init(self, *args, value=0, override_address=None, gas=None):
Expand All @@ -89,8 +97,9 @@ def _ctor(self) -> Optional[ABIFunction]:
:raises: StopIteration if the constructor is not found.
"""
ctor_abi = next((i for i in self.abi if i["type"] == "constructor"), None)
if ctor_abi:
return ABIFunction(ctor_abi, contract_name=self.contract_name)
if ctor_abi is None:
return None
return ABIFunction(ctor_abi, contract_name=self.contract_name)

def eval(self, code):
return ZksyncEval(code, self)()
Expand All @@ -103,10 +112,11 @@ def override_vyper_namespace(self):
@cached_property
def deployer(self):
from boa_zksync.deployer import ZksyncDeployer

return ZksyncDeployer(
self.compiler_data.vyper,
filename=self.filename,
zkvyper_data=self.compiler_data
zkvyper_data=self.compiler_data,
)

@cached_property
Expand Down Expand Up @@ -170,6 +180,7 @@ class ZksyncBlueprint(ZksyncContract):
In zkSync, any contract can be used as a blueprint.
The only difference here is that we don't need to run the constructor.
"""

@property
def _ctor(self) -> Optional[ABIFunction]:
return None
Expand Down
15 changes: 12 additions & 3 deletions boa_zksync/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vyper.compiler.output import build_solc_json

from boa_zksync.compile import compile_zksync, compile_zksync_source
from boa_zksync.contract import ZksyncContract, ZksyncBlueprint
from boa_zksync.contract import ZksyncBlueprint, ZksyncContract
from boa_zksync.types import ZksyncCompilerData

if TYPE_CHECKING:
Expand Down Expand Up @@ -45,7 +45,12 @@ def from_abi_dict(cls, abi, name="<anonymous contract>", filename=None):

def deploy(self, *args, **kwargs) -> ZksyncContract:
return ZksyncContract(
self.zkvyper_data, self._name, self.functions, *args, filename=self.filename, **kwargs
self.zkvyper_data,
self._name,
self.functions,
*args,
filename=self.filename,
**kwargs,
)

def at(self, address: Address | str) -> ZksyncContract:
Expand All @@ -60,7 +65,11 @@ def deploy_as_blueprint(self, **kwargs) -> ZksyncContract:
The only difference here is that we don't need to run the constructor.
"""
return ZksyncBlueprint(
self.zkvyper_data, self._name, self.functions, filename=self.filename, **kwargs
self.zkvyper_data,
self._name,
self.functions,
filename=self.filename,
**kwargs,
)

@property
Expand Down
2 changes: 1 addition & 1 deletion boa_zksync/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from boa_zksync.node import EraTestNode
from boa_zksync.types import (
CONTRACT_DEPLOYER_ADDRESS,
DEFAULT_SALT,
ZERO_ADDRESS,
DeployTransaction,
ZksyncComputation,
ZksyncMessage,
DEFAULT_SALT,
)

with open(Path(__file__).parent / "IContractDeployer.json") as f:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import boa
import pytest
from boa.deployments import DeploymentsDB, set_deployments_db
from eth_account import Account

import boa_zksync
from boa_zksync import EraTestNode
from boa_zksync.deployer import ZksyncDeployer
from boa.deployments import DeploymentsDB, set_deployments_db

STARTING_SUPPLY = 100

Expand Down
2 changes: 1 addition & 1 deletion tests/test_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_deployer_deploys(zksync_deployer):
contract = zksync_deployer.deploy()
zk_data = zksync_deployer.zkvyper_data
db = get_deployments_db()
deployment, = list(db.get_deployments())
(deployment,) = list(db.get_deployments())
assert isinstance(contract, ZksyncContract)
deployed_code = deployment.source_code["sources"]["<unknown>"]["content"]
assert deployed_code == zk_data.source_code
Expand Down

0 comments on commit f8593c1

Please sign in to comment.