Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/nile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ def run(path, network):
@click.argument("artifact", nargs=1)
@click.argument("arguments", nargs=-1)
@click.option("--alias")
@click.option("--overriding_path")
@click.option("--abi")
@network_option
@mainnet_token_option
@watch_option
def deploy(artifact, arguments, network, alias, watch_mode, abi, token):
def deploy(artifact, arguments, network, alias, watch_mode, overriding_path=None, abi=None, token=None):
"""Deploy StarkNet smart contract."""
deploy_command(
contract_name=artifact,
arguments=arguments,
network=network,
alias=alias,
overriding_path=overriding_path,
abi=abi,
mainnet_token=token,
watch_mode=watch_mode,
Expand Down Expand Up @@ -231,10 +233,11 @@ def test(contracts):
@click.argument("contracts", nargs=-1)
@click.option("--directory")
@click.option("--cairo_path")
@click.option("--output")
@click.option("--account_contract", is_flag="True")
@click.option("--disable-hint-validation", is_flag=True)
def compile(
contracts, directory, cairo_path, account_contract, disable_hint_validation
contracts, directory, cairo_path, output, account_contract, disable_hint_validation
):
"""
Compile cairo contracts.
Expand All @@ -249,7 +252,7 @@ def compile(
Compiles foo.cairo and bar.cairo
"""
compile_command(
contracts, directory, cairo_path, account_contract, disable_hint_validation
contracts, directory, cairo_path, output, account_contract, disable_hint_validation
)


Expand Down
16 changes: 11 additions & 5 deletions src/nile/core/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ def compile(
contracts,
directory=None,
cairo_path=None,
output=None,
account_contract=False,
disable_hint_validation=False,
):
"""Compile cairo contracts to default output directory."""
# to do: automatically support subdirectories

contracts_directory = directory if directory else CONTRACTS_DIRECTORY
abis_directory = f"{output}/abis" if output else ABIS_DIRECTORY

if not os.path.exists(ABIS_DIRECTORY):
logging.info(f"📁 Creating {ABIS_DIRECTORY} to store compilation artifacts")
os.makedirs(ABIS_DIRECTORY, exist_ok=True)
if not os.path.exists(abis_directory):
logging.info(f"📁 Creating {abis_directory} to store compilation artifacts")
os.makedirs(abis_directory, exist_ok=True)

all_contracts = contracts

Expand All @@ -40,6 +42,7 @@ def compile(
contract,
contracts_directory,
cairo_path,
output,
account_contract,
disable_hint_validation,
)
Expand All @@ -63,6 +66,7 @@ def _compile_contract(
path,
directory=None,
cairo_path=None,
output=None,
account_contract=False,
disable_hint_validation=False,
):
Expand All @@ -71,12 +75,14 @@ def _compile_contract(
logging.info(f"🔨 Compiling {path}")
contracts_directory = directory if directory else CONTRACTS_DIRECTORY
cairo_path = cairo_path if cairo_path else contracts_directory
build_directory = output if output else BUILD_DIRECTORY
abis_directory = f"{output}/abis" if output else ABIS_DIRECTORY

cmd = f"""
starknet-compile {path} \
--cairo_path={cairo_path}
--output {BUILD_DIRECTORY}/{filename}.json \
--abi {ABIS_DIRECTORY}/{filename}.json
--output {build_directory}/{filename}.json \
--abi {abis_directory}/{filename}.json
"""

if account_contract or filename.endswith("Account"):
Expand Down