Skip to content

Commit

Permalink
Merge branch 'refactor/deploy_and_declare' into feature/call_and_invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
Radinyn committed Aug 5, 2022
2 parents 4ae9198 + 845186f commit 42b6337
Show file tree
Hide file tree
Showing 94 changed files with 2,155 additions and 2,904 deletions.

This file was deleted.

36 changes: 35 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,38 @@ jobs:
poetry run poe build
- name: E2E tests
run: |
poetry run poe test_e2e
poetry run poe test_e2e
# FIXME(arcticae): Fixable with self-hosted runner on gh-actions
# performance-tests:
# name: Performance tests
# runs-on: ubuntu-latest
# needs: setup
# steps:
# - uses: actions/checkout@v2
# with:
# submodules: recursive
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.8
# - name: Install poetry
# run: |
# python -m pip install --upgrade pip
# pip install poetry
# - name: Restore caches
# uses: actions/cache@v3
# with:
# path: |
# ~/.cache/pypoetry
# key: poetry-${{ hashFiles('poetry.lock') }}
#
# - name: Run performance tests
# run: |
# poetry run poe benchmark
# - uses: actions/upload-artifact@v3
# with:
# name: benchmark
# path: .benchmarks
# - name: Assess performance
# run: |
# poetry run poe statistical_test
1,345 changes: 125 additions & 1,220 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions protostar/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from protostar.commands.build import BuildCommand
from protostar.commands.declare import DeclareCommand
from protostar.commands.deploy import DeployCommand
from protostar.commands.init import InitCommand
from protostar.commands.install import InstallCommand
Expand Down
37 changes: 25 additions & 12 deletions protostar/commands/build/build_command.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
from logging import Logger
from typing import List, Optional

from protostar.cli.command import Command
from protostar.commands.build.project_compiler import ProjectCompiler
from protostar.cli import ActivityIndicator, Command
from protostar.compiler import ProjectCompiler, ProjectCompilerConfig
from protostar.utils import log_color_provider


class BuildCommand(Command):
def __init__(self, project_compiler: ProjectCompiler) -> None:
def __init__(self, project_compiler: ProjectCompiler, logger: Logger) -> None:
super().__init__()
self._project_compiler = project_compiler
self._logger = logger

@property
def example(self) -> Optional[str]:
return "$ protostar build"

@property
def name(self) -> str:
Expand All @@ -17,10 +24,6 @@ def name(self) -> str:
def description(self) -> str:
return "Compile contracts."

@property
def example(self) -> Optional[str]:
return "$ protostar build"

@property
def arguments(self) -> List[Command.Argument]:
return [
Expand All @@ -45,8 +48,18 @@ def arguments(self) -> List[Command.Argument]:
]

async def run(self, args):
self._project_compiler.compile(
output_dir=args.output,
relative_cairo_path=args.cairo_path,
disable_hint_validation=args.disable_hint_validation,
)
with ActivityIndicator(
log_color_provider.colorize("GRAY", "Building projects' contracts")
):
try:
self._project_compiler.compile_project(
output_dir=args.output,
config=ProjectCompilerConfig(
hint_validation_disabled=args.disable_hint_validation,
relative_cairo_path=args.cairo_path,
),
)
except BaseException as exc:
self._logger.error("Build failed")
raise exc
self._logger.info("Built the project successfully")
5 changes: 0 additions & 5 deletions protostar/commands/build/build_exceptions.py

This file was deleted.

141 changes: 0 additions & 141 deletions protostar/commands/build/project_compiler.py

This file was deleted.

35 changes: 23 additions & 12 deletions protostar/commands/declare/declare_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
class DeclareCommand(Command):
def __init__(
self,
gateway_facade: GatewayFacade,
gateway_facade_builder: GatewayFacade.Builder,
logger: Logger,
):
self._gateway_facade = gateway_facade
self._gateway_facade_builder = gateway_facade_builder
self._gateway_facade: Optional[GatewayFacade] = None
self._logger = logger

@property
Expand Down Expand Up @@ -46,30 +47,37 @@ def arguments(self) -> List[Command.Argument]:
Command.Argument(
name="signature",
description=("Signature information for the declaration."),
type="str",
type="int",
is_array=True,
),
Command.Argument(
name="token",
description="Used for declaring contracts in Alpha MainNet.",
type="str",
),
Command.Argument(
name="wait-for-acceptance",
description="Wait until 'Accepted on L2' status.",
type="bool",
default=False,
),
DeployCommand.gateway_url_arg,
DeployCommand.network_arg,
]

async def run(self, args) -> SuccessfulDeclareResponse:
assert isinstance(args.contract, Path)
assert args.network is None or isinstance(args.network, str)
assert args.gateway_url is None or isinstance(args.gateway_url, str)
assert args.network is None or isinstance(args.network, str)
assert args.token is None or isinstance(args.token, str)
assert isinstance(args.wait_for_acceptance, bool)
assert args.signature is None or isinstance(args.signature, list)

return await self.declare(
compiled_contract_path=args.contract,
network=args.network,
gateway_url=args.gateway_url,
network=args.network or args.gateway_url,
token=args.token,
wait_for_acceptance=args.wait_for_acceptance,
signature=args.signature,
)

Expand All @@ -78,21 +86,24 @@ async def declare(
self,
compiled_contract_path: Path,
network: Optional[str] = None,
gateway_url: Optional[str] = None,
token: Optional[str] = None,
signature: Optional[List[str]] = None,
wait_for_acceptance: bool = False,
signature: Optional[List[int]] = None,
) -> SuccessfulDeclareResponse:
if network is None and gateway_url is None:
if network is None:
raise ProtostarException(
f"Argument `{DeployCommand.gateway_url_arg.name}` or `{DeployCommand.network_arg.name}` is required"
f"Argument `{DeployCommand.network_arg.name}` is required"
)

network_config = NetworkConfig.build(network=network, gateway_url=gateway_url)
self._gateway_facade_builder.set_network(network)
self._gateway_facade = self._gateway_facade_builder.build()

network_config = NetworkConfig(network)

response = await self._gateway_facade.declare(
compiled_contract_path=compiled_contract_path,
gateway_url=network_config.gateway_url,
token=token,
wait_for_acceptance=wait_for_acceptance,
signature=signature,
)

Expand Down
Loading

0 comments on commit 42b6337

Please sign in to comment.