Skip to content

Commit

Permalink
Add extra assert for at, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jul 5, 2024
1 parent 126b53f commit 753246c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
31 changes: 20 additions & 11 deletions boa_zksync/deployer.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):

Expand Down Expand Up @@ -36,14 +40,7 @@ def from_abi_dict(cls, abi, name="<anonymous contract>", 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=(
Expand All @@ -59,17 +56,16 @@ 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,
self.abi,
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:
Expand All @@ -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
6 changes: 2 additions & 4 deletions boa_zksync/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
):
"""
Expand All @@ -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",
):
"""
Expand Down

0 comments on commit 753246c

Please sign in to comment.