diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d74f37f..71960fa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,11 +27,11 @@ jobs: echo "Installing zkvyper and era_test_node" # Install zkvyper and era_test_node from binary repositories - curl --location https://raw.githubusercontent.com/matter-labs/zkvyper-bin/a0d3b90c93d8fba176233fdef074694add25a682/linux-amd64/zkvyper-linux-amd64-musl-v1.5.0 \ + curl --location https://raw.githubusercontent.com/matter-labs/zkvyper-bin/v1.5.2/linux-amd64/zkvyper-linux-amd64-musl-v1.5.2 \ --silent --output /usr/local/bin/zkvyper && \ chmod +x /usr/local/bin/zkvyper && \ zkvyper --version - curl --location https://github.com/matter-labs/era-test-node/releases/download/v0.1.0-alpha.23/era_test_node-v0.1.0-alpha.23-x86_64-unknown-linux-gnu.tar.gz \ + curl --location https://github.com/matter-labs/era-test-node/releases/download/v0.1.0-alpha.25/era_test_node-v0.1.0-alpha.25-x86_64-unknown-linux-gnu.tar.gz \ --silent --output era_test_node.tar.gz && \ tar --extract --file=era_test_node.tar.gz && \ mv era_test_node /usr/local/bin/era_test_node && \ diff --git a/boa_zksync/deployer.py b/boa_zksync/deployer.py index 4e7048c..2299f85 100644 --- a/boa_zksync/deployer.py +++ b/boa_zksync/deployer.py @@ -1,5 +1,6 @@ from functools import cached_property from pathlib import Path +from typing import TYPE_CHECKING from boa import Env from boa.contracts.abi.abi_contract import ABIContractFactory, ABIFunction @@ -9,6 +10,9 @@ from boa_zksync.contract import ZksyncContract from boa_zksync.types import ZksyncCompilerData +if TYPE_CHECKING: + from boa_zksync.environment import ZksyncEnv + class ZksyncDeployer(ABIContractFactory): @@ -36,14 +40,7 @@ def from_abi_dict(cls, abi, name="", filename=None): raise NotImplementedError("ZksyncDeployer does not support loading from ABI") def deploy(self, *args, value=0, **kwargs) -> ZksyncContract: - env = Env.get_singleton() - from boa_zksync.environment import ZksyncEnv - - assert isinstance( - env, ZksyncEnv - ), "ZksyncDeployer can only be used in zkSync environments" - - address, _ = env.deploy_code( + address, _ = self.env.deploy_code( bytecode=self.compiler_data.bytecode, value=value, constructor_calldata=( @@ -59,7 +56,6 @@ def at(self, address: Address | str) -> ZksyncContract: Create an ABI contract object for a deployed contract at `address`. """ address = Address(address) - env = Env.get_singleton() contract = ZksyncContract( self.compiler_data, self._name, @@ -67,9 +63,9 @@ def at(self, address: Address | str) -> ZksyncContract: self.functions, address=address, filename=self.filename, - env=env, + env=self.env, ) - env.register_contract(address, contract) + self.env.register_contract(address, contract) return contract def deploy_as_blueprint(self, *args, **kwargs) -> ZksyncContract: @@ -87,3 +83,16 @@ def constructor(self) -> ABIFunction: """ ctor_abi = next(i for i in self.abi if i["type"] == "constructor") return ABIFunction(ctor_abi, contract_name=self._name) + + @property + def env(self) -> "ZksyncEnv": + """ + Get the environment for this deployer. Ensures that the environment is a ZksyncEnv. + :return: The ZksyncEnv singleton. + """ + env = Env.get_singleton() + from boa_zksync.environment import ZksyncEnv + assert isinstance( + env, ZksyncEnv + ), "ZksyncDeployer can only be used in zkSync environments" + return env diff --git a/boa_zksync/util.py b/boa_zksync/util.py index 65fb77c..f0b7cc4 100644 --- a/boa_zksync/util.py +++ b/boa_zksync/util.py @@ -39,8 +39,7 @@ def stop_subprocess(proc: Popen[bytes]): def install_zkvyper_compiler( - source="https://raw.githubusercontent.com/matter-labs/zkvyper-bin/" - "a0d3b90c93d8fba176233fdef074694add25a682/linux-amd64/zkvyper-linux-amd64-musl-v1.5.0", + source="https://raw.githubusercontent.com/matter-labs/zkvyper-bin/v1.5.2/linux-amd64/zkvyper-linux-amd64-musl-v1.5.2", # noqa: E501 destination="/usr/local/bin/zkvyper", ): """ @@ -59,8 +58,7 @@ def install_zkvyper_compiler( def install_era_test_node( - source="https://github.com/matter-labs/era-test-node/releases/download/" - "v0.1.0-alpha.23/era_test_node-v0.1.0-alpha.23-x86_64-unknown-linux-gnu.tar.gz", + source="https://github.com/matter-labs/era-test-node/releases/download/v0.1.0-alpha.25/era_test_node-v0.1.0-alpha.25-x86_64-unknown-linux-gnu.tar.gz", # noqa: E501 destination="/usr/local/bin/era_test_node", ): """