Giter VIP home page Giter VIP logo

nile's Introduction

Disclaimer: this project is deprecated and no longer maintained. Check out scarb instead.

OpenZeppelin | Nile ⛵

Docs Tests and linter

Navigate your StarkNet projects written in Cairo.

Overview

Nile is a CLI tool to develop or interact with StarkNet projects written in Cairo. It consists of different components for developing, compiling, testing, and deploying your smart contracts and dApps, providing a CLI for executing tasks, and a Runtime Environment (NRE) for scripting. The package is designed to be extensible and very customizable by using plugins.

Documentation

On our documentation site you can find:

And more.

Installation

Current supported Python versions are >=3.9 and <3.10.

  1. Install gmp on your machine (Cairo requirement).

    sudo apt install -y libgmp3-dev # linux
    or
    brew install gmp # mac
    

    If you have any trouble installing it on your Apple M1 computer, here’s a list of potential solutions.

  2. Create a folder for your project and cd into it:

    mkdir myproject && cd myproject
    
  3. Create a virtualenv and activate it:

    python3 -m venv env && source env/bin/activate
    
  4. Install Nile:

    pip install cairo-nile
    

Quickstart

Use nile init to quickly set up your development environment:

nile init
🗄 Creating project directory tree
⛵️ Nile project ready! Try running:

nile compile

Contribute

OpenZeppelin Nile exists thanks to its contributors. There are many ways you can participate and help build high quality software. Check out the contribution guide!

License

Nile is released under the MIT License.

nile's People

Contributors

andrew-fleming avatar ca11ab1e avatar ericglau avatar ericnordelo avatar exp-table avatar fracek avatar franalgaba avatar franciscod avatar ftupas avatar julissadantes avatar kevinhalliday avatar kootszhin avatar lucaslvy avatar marcellobardus avatar martriay avatar milancermak avatar omahs avatar perama-v avatar rootulp avatar sambarnes avatar timnooren avatar trevis-dev avatar tserg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nile's Issues

Report compile errors better

Hey,

I'd like to propose a change, but this might be a nitpick so feel free to ignore.

What do you think about improving the UX by showing a different failure emoji rather than the green thick mark when nile compile is done but the contract compilation fails?

So instead of this:

nile compile contracts/contract.cairo
🔨 Compiling contracts/contract.cairo
contracts/contract.cairo:19:5: Expected exactly 0 expressions, got 1.
    return (0)
    ^********^
✅ Done

we could have

nile compile contracts/contract.cairo
🔨 Compiling contracts/contract.cairo
contracts/contract.cairo:19:5: Expected exactly 0 expressions, got 1.
    return (0)
    ^********^
🛑 Compilation failed with 1 error

It's easier to spot that something actually failed (red vs. green). Would be also useful for a project with a lot of contracts, where the compilation failure might scroll off screen.

I also think if the compilation fails, nile compile should exit with a non zero value so that it can be used in scripting or CI workflows or in similar context.

I'm happy to send a PR if you believe doing this is worthwhile.

Get accounts

Add functionality to manage/retrieve available accounts on Nile, to use them programmatically.

nile run not available in current deployment but documented

The documentation has nile run as an example, but I don't believe the current deployment (0.3.0) has that.

Directly doing pip install git+https://github.com/OpenZeppelin/nile worked for me however that has other issues,

e.g. file:

def run(nre):
    address, abi = nre.deploy("NFTBridge", alias="nftBridge")
    print(abi, address)

nile run scripts/deploy.py

Traceback (most recent call last):
  File "/Users/x/cairo_venv/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/nile/cli.py", line 45, in run
    run_command(path, network)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/nile/core/run.py", line 14, in run
    script.run(nre)
  File "scripts/deploy.py", line 2, in run
    address, abi = nre.deploy("NFTBridge", alias="nftBridge")
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/nile/nre.py", line 22, in deploy
    return deploy(contract, arguments, self.network, alias, overriding_path)
  File "/Users/x/cairo_venv/lib/python3.7/site-packages/nile/core/deploy.py", line 23, in deploy
    if len(arguments) > 0:
TypeError: object of type 'NoneType' has no len()

Am I missing something?

Thank you!

got an error wen run nile init,how to fix it

Using legacy 'setup.py install' for fastecdsa, since package 'wheel' is not installed.
Installing collected packages: fastecdsa
    Running setup.py install for fastecdsa ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/abc/cairo_venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-install-igzixnb_/fastecdsa_042b94408cd74823ae2c9bb74b8ba4a5/setup.py'"'"'; __file__='"'"'/private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-install-igzixnb_/fastecdsa_042b94408cd74823ae2c9bb74b8ba4a5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-record-clfa9rd5/install-record.txt --single-version-externally-managed --compile --install-headers /Users/abc/cairo_venv/include/site/python3.8/fastecdsa
         cwd: /private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-install-igzixnb_/fastecdsa_042b94408cd74823ae2c9bb74b8ba4a5/
    Complete output (50 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-arm64-3.8
    creating build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/benchmark.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/util.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/__init__.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/keys.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/curve.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/point.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    copying fastecdsa/ecdsa.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa
    creating build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_point.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_keygen.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_nonce_generation.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_key_recovery.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_key_export_import.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_whycheproof_vectors.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/__init__.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_prehashed.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_brainpool_ecdh.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_rfc6979_ecdsa.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_whitespace_parsing.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_prime_field_curve_math.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    copying fastecdsa/tests/test_p256_ecdsa.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests
    creating build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/pem.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/util.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/__init__.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/sec1.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/der.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    copying fastecdsa/encoding/asn1.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/encoding
    creating build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests/encoding
    copying fastecdsa/tests/encoding/test_sec1.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests/encoding
    copying fastecdsa/tests/encoding/__init__.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests/encoding
    copying fastecdsa/tests/encoding/test_der.py -> build/lib.macosx-10.14-arm64-3.8/fastecdsa/tests/encoding
    running build_ext
    building 'fastecdsa.curvemath' extension
    creating build/temp.macosx-10.14-arm64-3.8
    creating build/temp.macosx-10.14-arm64-3.8/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/local/include -L/usr/local/lib -Isrc/ -I/Users/abc/cairo_venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/curveMath.c -o build/temp.macosx-10.14-arm64-3.8/src/curveMath.o -O2
    clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
    In file included from src/curveMath.c:1:
    src/curveMath.h:6:10: fatal error: 'gmp.h' file not found
    #include <gmp.h>
             ^~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/abc/cairo_venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-install-igzixnb_/fastecdsa_042b94408cd74823ae2c9bb74b8ba4a5/setup.py'"'"'; __file__='"'"'/private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-install-igzixnb_/fastecdsa_042b94408cd74823ae2c9bb74b8ba4a5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/f5/8fy_5csx18lbvvmz90n43qd80000gp/T/pip-record-clfa9rd5/install-record.txt --single-version-externally-managed --compile --install-headers /Users/abc/cairo_venv/include/site/python3.8/fastecdsa Check the logs for full command output.

Importlib metadata differs between python 3.7 and 3.8

Environment: python 3.7.9

Issue: nile compile command fails with error: ModuleNotFoundError: No module named 'importlib.metadata'

Potential resolution: In src/nile/__init__.py, changing from importlib.metadata to importlib_metadata resolves this issue.

Note that with python 3.8.6 the command works with the original importlib.metadata, so It is unclear to me how to resolve this to support 3.7 and 3.8.

nile send failing with "TypeError: expected str, bytes or os.PathLike object, not int"

Hello!

Using MacOS with Python 3.8.5,
nile version 0.4.0

I have exported a environment variable TEST_PRIV to 123 and successfully run nile setup TEST_PRIV with the following output:

$ nile setup TEST_PRIV                     
🚀 Deploying Account
⏳ ️Deployment of Account successfully sent at 0x0636ab47cf615028c92a64e9aa9630d5bc93a335aa0ae174fbce2e3f22773cfc
🧾 Transaction hash: 0x40b2b24dd47c1d86079c9c8ecb1f30d556c6132e1247ef7063a82854f63a3fd
📦 Registering deployment as account-0 in localhost.deployments.txt
(base) 

now I wanted to interact with a deployed contract and hence running nile send

nile send TEST_PRIV token1 mint 0x0636ab47cf615028c92a64e9aa9630d5bc93a335aa0ae174fbce2e3f22773cfc 1000 

and I get the following error:

Traceback (most recent call last):
  File "/Users/redacted/opt/anaconda3/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/nile/cli.py", line 96, in send
    account.send(contract_name, method, params)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/nile/core/account.py", line 62, in send
    call_or_invoke(
  File "/Users/redacted/opt/anaconda3/lib/python3.8/site-packages/nile/core/call_or_invoke.py", line 40, in call_or_invoke
    subprocess.check_call(command)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/Users/redacted/opt/anaconda3/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Users/redacted/opt/anaconda3/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/redacted/opt/anaconda3/lib/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not int
(base) 

Could any one provide any pointers on how to fix this please? thank you!

Please also let me know if any other information would be helpful for debugging, happy to provide!

Error when launching nile node

After installing nile environment, I have error when trying to launch nile node.
The following error is displayed:
KeyError: 'WERKZEUG_SERVER_FD'

Add signers

Integrate OZ account contracts and signers. Add send command to send signed transactions.

Import error during Nile installation

After a fresh install of cairo-nile, attempts to nile init will return a ModuleNotFoundError: No module named 'starkware' error. Here's the traceback:

(env) andrewfleming@Andrews-MacBook-Pro nile % nile init
Traceback (most recent call last):
  File "/Users/andrewfleming/Documents/starknet/nile-delete-me/env/bin/nile", line 6, in <module>
    from nile.cli import cli
  File "/Users/andrewfleming/Documents/starknet/nile-delete-me/env/lib/python3.7/site-packages/nile/cli.py", line 7, in <module>
    from nile.core.account import Account
  File "/Users/andrewfleming/Documents/starknet/nile-delete-me/env/lib/python3.7/site-packages/nile/core/account.py", line 9, in <module>
    from nile.signer import Signer
  File "/Users/andrewfleming/Documents/starknet/nile-delete-me/env/lib/python3.7/site-packages/nile/signer.py", line 3, in <module>
    from starkware.cairo.common.hash_state import compute_hash_on_elements
ModuleNotFoundError: No module named 'starkware'

TL;DR:

  • nile imports from nile/cli
  • nile/cli imports from nile/core/account
  • nile/core/account imports from nile/signer
  • nile/signer imports from starkware (which is not installed until after initialization)

Wrapping nile/core/account's import of nile/signer with a try/except should rectify this issue.

Support for cairo path cmdline arg for nile compile

I'm running into this need quite often - I would like to pass additional --cairo_path directories to the nile compile command. I know I can use CAIRO_PATH env var, but there's benefits of having it as a cmdline arg as well.

Would it be of interest to anyone else? If so, I can submit a PR.

Error installing Cairo on M1 chip (gmp.h)

image

As you can see, when I try to compile the cairo file, it show with these error. I tried to search on Google but can't find with any ideas. I think it's out of my knowledge, anyone know how to solve this? Thank you.

Cannot run nile using poetry

Trying to use nile from poetry in the following way:

poetry new nile-test # init new repo
cd nile-test
poetry add --dev cairo-nile # install nile
poetry run nile version

Resulting error is:

    from nile import __version__ as nile_version
ImportError: cannot import name '__version__' from 'nile' (unknown location)

Any idea for a workaround here? I'm trying to use poetry and nile together like yarn and hardhat are commonly used together in L1 land.

Add `status` command

Add observe command (or some other name) that fetches the status of a transaction using an await/retry strategy. Ideally, this should be an optional flag for send, invoke, and deploy. See #90 for discussion and its implementation in nile debug.

Windows setup not working

I'm not sure if there are any plans to get this working on Windows, but I'm getting some errors.

  • Running in venv
  • nile init works just fine
  • nile compile throws an error:

File "C:\Users\LauriP\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Vanilla Cairo seems to work.

P.S. Available in Starknet Discord as LauriP

Can't invoke functions from deployed contracts

Hello,
I have deployed a group of contrats on testnet and would like to interact with them using
nile invoke
The issue I face is that the goerli.deployments.txt doesn't seem like it is parsed correctly when nile is looking for the ABI:

(cairo_venv) macbook-pro-de-henri:starknet-cairo-101 henrilieutaud$ nile invoke 0x001102cdbe07a9b776a30002c331f83f01b7a9154a534fcf1e44a6c213dc9c41 set_teacher_temp 1 1507638031522682312191916131341364110496142099655924630921045603037699363192 --network goerli
usage: starknet [-h] --address ADDRESS --abi ABI --function FUNCTION
                [--inputs [INPUTS [INPUTS ...]]]
                [--signature [SIGNATURE [SIGNATURE ...]]]
starknet: error: argument --abi: can't open 'artifacts/abis/TDERC20.json
': [Errno 2] No such file or directory: 'artifacts/abis/TDERC20.json\n'

I have observed this with nile call too
Steps to reproduce:

  • Deploy more than one contract
  • nile invoke <contract_address> <function_name> <inputs> --network goerli
    Steps to correct:
  • Remove all following lines in goerli.deployments.txt

abi argument of call command has extra new line character

Steps to reproduce the issue in a new project:

nile init
nile complie
nile deploy --network goerli contract
nile call --network goerli 0xADDRESS get_balance

The nile call will fail. Here's a trace of the above:

Ⓟ starkware ~/projects/tmp/nile-issue  ➭ nile init

// SNIP

✅ Dependencies successfully installed
🗄  Creating project directory tree
⛵️ Nile project ready! Try running:

nile compile

Ⓟ starkware ~/projects/tmp/nile-issue  ➭ nile compile
📁 Creating artifacts/abis to store compilation artifacts
🤖 Compiling all Cairo contracts in the contracts directory
🔨 Compiling contracts/contract.cairo
✅ Done
Ⓟ starkware ~/projects/tmp/nile-issue  ➭ nile deploy --network goerli contract
🚀 Deploying contract
⏳ ️Deployment of contract successfully sent at 0x07893a17fda27426550e59d0ee4235377cac92a4aa172775223f6b6321252dca
🧾 Transaction hash: 0x645d26bc92aa744ce8b1fe6e6f597d28195626f0d1a705210939c27e8506313
📦 Registering 0x07893a17fda27426550e59d0ee4235377cac92a4aa172775223f6b6321252dca in goerli.deployments.txt
Ⓟ starkware ~/projects/tmp/nile-issue  ➭ nile call --network goerli 0x07893a17fda27426550e59d0ee4235377cac92a4aa172775223f6b6321252dca get_balance
usage: starknet [-h] --address ADDRESS --abi ABI --function FUNCTION [--inputs [INPUTS ...]] [--nonce NONCE] [--signature [SIGNATURE ...]] [--block_hash BLOCK_HASH] [--block_number BLOCK_NUMBER]
starknet: error: argument --abi: can't open 'artifacts/abis/contract.json
': [Errno 2] No such file or directory: 'artifacts/abis/contract.json\n'
Traceback (most recent call last):
  File "/Users/m/.pyenv/versions/starkware/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/nile/main.py", line 94, in call
    call_or_invoke_command(contract_name, "call", method, params, network)
  File "/Users/m/.pyenv/versions/3.9.6/envs/starkware/lib/python3.9/site-packages/nile/commands/call.py", line 36, in call_or_invoke_command
    subprocess.check_call(command)
  File "/Users/m/.pyenv/versions/3.9.6/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['starknet', 'call', '--address', '0x07893a17fda27426550e59d0ee4235377cac92a4aa172775223f6b6321252dca', '--abi', 'artifacts/abis/contract.json\n', '--function', 'get_balance']' returned non-zero exit status 2.

Notice the extra \n in the input to the --abi arg.

Reproduced with nile 0.3.0

make `compile` recursive

today, nile compile doesn't automatically look in contracts/ subdirectories. this issue aims to support that behavior.

test account related commands

We (I) recently merged and released a version of Nile updating the Account artifact files but not the Signer module, breaking most of the account related functionality. This issue is to address the lack of account commands testing that made this failure possible.

Support scripting

Expose a programatic API to execute invoke, call and deploy commands on any pre-configured network (local or mainnet by default), leveraging with the deployments management and eventually also signers.

`init` command

initialize a new cairo/starknet project:

  • set up virtual env
  • install cairo/starknet
  • create dir structure (contracts/, test/, maybe artifacts/)
  • --sample to opt in to example contracts and tests (or --bare to opt out)

`update-account` branch issue

Hi, getting this error when running a simple ERC20 ownable transferOwnership on the update-account branch

The below is a snippet from my deploy.py

out = owner.send(erc20_contract_address, 'transferOwnership', [int(new_owner_address, 16)])  # due to int(, 10)

Using nile run --network 'goerli' scripts/deploy.py it spits out a tx hash but when I check its status below I get this bizarre error.

╰─ starknet get_transaction --network 'alpha-goerli' --hash 0x61e017ff4e30cb5151d86a0bf95b4da8eba6f9192302422b70e06c98ab34574                                        ─╯
Error: ValidationError: {'transaction': {'calldata': {0: ['Expected int string, got: "0x1".'], 1: ['Expected int string, got: "0x5816f092a90175976e5ddf92746f4245bf49196a064bcc8ee4389c9e1607201".'], 2: ['Expected int string, got: "0x14a390f291e2e1f29874769efdef47ddad94d76f77ff516fad206a385e8995f".'], 3: ['Expected int string, got: "0x0".'], 4: ['Expected int string, got: "0x1".'], 5: ['Expected int string, got: "0x1".'], 6: ['Expected int string, got: "0x1573f855755959b21b69a38805d406a45a64954a47df6ba226494684851697f".'], 7: ['Expected int string, got: "0x0".']}, 'max_fee': ['Unknown field.']}, 'transaction_failure_reason': {'tx_id': ['Missing data for required field.']}}

Any ideas?

First install calls for uninstalled module

Environment: New python 3.8.6 environment

Issue: Running nile install 0.4.1 fails with error No module named: starkware

Description: Upon first installation, the package invokes the test module, which calls the starkware package, which is not yet installed.

Temporary resolution: In src/nile/main.py, removing the line from nile.commands.test import test_command allows the installation to proceed.

However, this also kills nile test. Replacing the line after installation allows for the nile test command to work.

I wasn't sure exactly how to approach this for a permanent fix.

Big picture view

I've spent some more time thinking how to organize cairo projects and what I'd like to see. I think we should leverage the python ecosystem as much as possible:

  • nile init could use cookiecutter to create the project
  • pypi to distribute cairo packages
  • users should be able to configure nile (for example the contracts directory) from their setup.cfg file like other python tools

I think cairo projects should use the same folder structure as python projects, this has the added benefit that library developers can distribute the cairo files together with an sdk to interact with it (like @uniswap/core and @uniswap/sdk).

.
├── src
│  └── cairoswap
│     ├── __init__.py
│     ├── cairo
│     │  ├── __init__.py
│     │  ├── pool.cairo
│     │  └── router.cairo
│     ├── pool.py
│     └── router.py
├── tests
│  ├── pool.test.cairo
│  ├── test_pool.py
│  └── test_router.py
├── pyproject.toml
├── setup.cfg
└── tox.in

Developers can then create a tox task than runs python tests with pytest and cairo tests with nile test.

If users don't need/want to setup a full blown project they can revert to a minimal setup and use nile to build and test.

.
└── src
   ├── pool.cairo
   └── pool.test.cairo

nile init fails w/ Python 3.8 on OSX / Mac m1: 'ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly'

I'm attempting to run nile using python 3.8 on an m1 mac. I am successfully able to init/compile/build with 3.7.12 on the same machine.

Steps to repro:

python3 -m venv env
source env/bin/activate
git clone https://github.com/OpenZeppelin/nile.git
pip install ./nile

Error message:

ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly```

Stack trace:
```Traceback (most recent call last):
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/nile/main.py", line 30, in init
    init_command()
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/nile/commands/init.py", line 18, in init_command
    install_command()
  File "/Users/threepwave/code/tmp/starknet-boilerplate/env/lib/python3.8/site-packages/nile/commands/install.py", line 9, in install_command
    subprocess.check_call(
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/threepwave/code/tmp/starknet-boilerplate/env/bin/python3', '-m', 'pip', 'install', 'cairo-lang', 'starknet-devnet']' returned non-zero exit status 1.

Full log:

Requirement already satisfied: ecdsa in ./env/lib/python3.8/site-packages (0.17.0)
Requirement already satisfied: fastecdsa in ./env/lib/python3.8/site-packages (2.2.3)
Requirement already satisfied: sympy in ./env/lib/python3.8/site-packages (1.9)
Requirement already satisfied: six>=1.9.0 in ./env/lib/python3.8/site-packages (from ecdsa) (1.16.0)
Requirement already satisfied: mpmath>=0.19 in ./env/lib/python3.8/site-packages (from sympy) (1.2.1)
Collecting cairo-lang
  Using cached cairo-lang-0.7.0.zip (794 kB)
Collecting starknet-devnet
  Using cached starknet_devnet-0.1.12-py3-none-any.whl (14 kB)
Collecting aiohttp
  Using cached aiohttp-3.8.1.tar.gz (7.3 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting cachetools
  Using cached cachetools-5.0.0-py3-none-any.whl (9.1 kB)
Requirement already satisfied: ecdsa in ./env/lib/python3.8/site-packages (from cairo-lang) (0.17.0)
Collecting eth-hash[pycryptodome]==0.2.0
  Using cached eth_hash-0.2.0-py3-none-any.whl (7.2 kB)
Requirement already satisfied: fastecdsa in ./env/lib/python3.8/site-packages (from cairo-lang) (2.2.3)
Collecting frozendict==1.2
  Using cached frozendict-1.2.tar.gz (2.6 kB)
Collecting lark-parser
  Using cached lark_parser-0.12.0-py2.py3-none-any.whl (103 kB)
Collecting marshmallow-dataclass>=7.1.0
  Using cached marshmallow_dataclass-8.5.3-py3-none-any.whl (15 kB)
Collecting marshmallow-enum
  Using cached marshmallow_enum-1.5.1-py2.py3-none-any.whl (4.2 kB)
Collecting marshmallow-oneofschema
  Using cached marshmallow_oneofschema-3.0.1-py2.py3-none-any.whl (5.8 kB)
Collecting marshmallow>=3.2.1
  Using cached marshmallow-3.14.1-py3-none-any.whl (47 kB)
Requirement already satisfied: mpmath in ./env/lib/python3.8/site-packages (from cairo-lang) (1.2.1)
Collecting numpy
  Using cached numpy-1.22.1.zip (11.4 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting pipdeptree
  Using cached pipdeptree-2.2.1-py3-none-any.whl (21 kB)
Collecting prometheus-client
  Using cached prometheus_client-0.12.0-py2.py3-none-any.whl (57 kB)
Collecting pytest
  Using cached pytest-6.2.5-py3-none-any.whl (280 kB)
Collecting pytest-asyncio
  Using cached pytest_asyncio-0.17.2-py3-none-any.whl (16 kB)
Collecting PyYAML
  Using cached PyYAML-6.0.tar.gz (124 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Requirement already satisfied: sympy in ./env/lib/python3.8/site-packages (from cairo-lang) (1.9)
Collecting typeguard
  Using cached typeguard-2.13.3-py3-none-any.whl (17 kB)
Collecting Web3
  Using cached web3-5.26.0-py3-none-any.whl (486 kB)
Collecting flask-cors<4.0.0,>=3.0.10
  Using cached Flask_Cors-3.0.10-py2.py3-none-any.whl (14 kB)
Collecting Flask[async]<3.0.0,>=2.0.2
  Using cached Flask-2.0.2-py3-none-any.whl (95 kB)
Collecting charset-normalizer<3.0,>=2.0
  Using cached charset_normalizer-2.0.10-py3-none-any.whl (39 kB)
Collecting multidict<7.0,>=4.5
  Using cached multidict-5.2.0.tar.gz (49 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting aiosignal>=1.1.2
  Using cached aiosignal-1.2.0-py3-none-any.whl (8.2 kB)
Collecting yarl<2.0,>=1.0
  Using cached yarl-1.7.2.tar.gz (168 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting attrs>=17.3.0
  Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting frozenlist>=1.1.1
  Using cached frozenlist-1.3.0.tar.gz (65 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting async-timeout<5.0,>=4.0.0a3
  Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Requirement already satisfied: six>=1.9.0 in ./env/lib/python3.8/site-packages (from ecdsa->cairo-lang) (1.16.0)
Collecting pycryptodome<4,>=3.6.6; extra == "pycryptodome"
  Using cached pycryptodome-3.12.0.zip (3.7 MB)
Collecting typing-inspect>=0.7.1
  Using cached typing_inspect-0.7.1-py3-none-any.whl (8.4 kB)
Requirement already satisfied: pip>=6.0.0 in ./env/lib/python3.8/site-packages (from pipdeptree->cairo-lang) (20.2.3)
Collecting py>=1.8.2
  Using cached py-1.11.0-py2.py3-none-any.whl (98 kB)
Collecting packaging
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting pluggy<2.0,>=0.12
  Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting iniconfig
  Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting eth-account<0.6.0,>=0.5.6
  Using cached eth_account-0.5.6-py3-none-any.whl (101 kB)
Collecting ipfshttpclient==0.8.0a2
  Using cached ipfshttpclient-0.8.0a2-py3-none-any.whl (82 kB)
Collecting hexbytes<1.0.0,>=0.1.0
  Using cached hexbytes-0.2.2-py3-none-any.whl (6.1 kB)
Collecting websockets<10,>=9.1
  Using cached websockets-9.1.tar.gz (76 kB)
Collecting eth-typing<3.0.0,>=2.0.0
  Using cached eth_typing-2.2.2-py3-none-any.whl (6.2 kB)
Collecting jsonschema<4.0.0,>=3.2.0
  Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Collecting eth-abi<3.0.0,>=2.0.0b6
  Using cached eth_abi-2.1.1-py3-none-any.whl (27 kB)
Collecting eth-utils<2.0.0,>=1.9.5
  Using cached eth_utils-1.10.0-py3-none-any.whl (24 kB)
Collecting lru-dict<2.0.0,>=1.1.6
  Using cached lru-dict-1.1.7.tar.gz (10 kB)
Collecting protobuf<4,>=3.10.0
  Using cached protobuf-3.19.3-py2.py3-none-any.whl (162 kB)
Collecting requests<3.0.0,>=2.16.0
  Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting Werkzeug>=2.0
  Using cached Werkzeug-2.0.2-py3-none-any.whl (288 kB)
Collecting itsdangerous>=2.0
  Using cached itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Collecting Jinja2>=3.0
  Using cached Jinja2-3.0.3-py3-none-any.whl (133 kB)
Requirement already satisfied: click>=7.1.2 in ./env/lib/python3.8/site-packages (from Flask[async]<3.0.0,>=2.0.2->starknet-devnet) (8.0.3)
Collecting asgiref>=3.2; extra == "async"
  Using cached asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting idna>=2.0
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting typing-extensions>=3.7.4
  Using cached typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Collecting mypy-extensions>=0.3.0
  Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Using cached pyparsing-3.0.6-py3-none-any.whl (97 kB)
Collecting eth-keyfile<0.6.0,>=0.5.0
  Using cached eth_keyfile-0.5.1-py3-none-any.whl (8.3 kB)
Collecting eth-keys!=0.3.2,<0.4.0,>=0.2.1
  Using cached eth_keys-0.3.3-py3-none-any.whl (20 kB)
Collecting bitarray<1.3.0,>=1.2.1
  Using cached bitarray-1.2.2.tar.gz (48 kB)
Collecting eth-rlp<2,>=0.1.2
  Using cached eth_rlp-0.3.0-py3-none-any.whl (5.0 kB)
Collecting rlp<3,>=1.0.0
  Using cached rlp-2.0.1-py2.py3-none-any.whl (20 kB)
Collecting multiaddr>=0.0.7
  Using cached multiaddr-0.0.9-py2.py3-none-any.whl (16 kB)
Collecting pyrsistent>=0.14.0
  Using cached pyrsistent-0.18.1.tar.gz (100 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Requirement already satisfied: setuptools in ./env/lib/python3.8/site-packages (from jsonschema<4.0.0,>=3.2.0->Web3->cairo-lang) (49.2.1)
Collecting parsimonious<0.9.0,>=0.8.0
  Using cached parsimonious-0.8.1.tar.gz (45 kB)
Collecting cytoolz<1.0.0,>=0.10.1; implementation_name == "cpython"
  Using cached cytoolz-0.11.2.tar.gz (481 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting MarkupSafe>=2.0
  Using cached MarkupSafe-2.0.1.tar.gz (18 kB)
Collecting netaddr
  Using cached netaddr-0.8.0-py2.py3-none-any.whl (1.9 MB)
Collecting varint
  Using cached varint-1.0.2.tar.gz (1.9 kB)
Collecting base58
  Using cached base58-2.1.1-py3-none-any.whl (5.6 kB)
Collecting toolz>=0.8.0
  Using cached toolz-0.11.2-py3-none-any.whl (55 kB)
Using legacy 'setup.py install' for cairo-lang, since package 'wheel' is not installed.
Using legacy 'setup.py install' for frozendict, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pycryptodome, since package 'wheel' is not installed.
Using legacy 'setup.py install' for websockets, since package 'wheel' is not installed.
Using legacy 'setup.py install' for lru-dict, since package 'wheel' is not installed.
Using legacy 'setup.py install' for bitarray, since package 'wheel' is not installed.
Using legacy 'setup.py install' for parsimonious, since package 'wheel' is not installed.
Using legacy 'setup.py install' for cytoolz, since package 'wheel' is not installed.
Using legacy 'setup.py install' for MarkupSafe, since package 'wheel' is not installed.
Using legacy 'setup.py install' for varint, since package 'wheel' is not installed.
Building wheels for collected packages: aiohttp, numpy, PyYAML, multidict, yarl, frozenlist, pyrsistent
  Building wheel for aiohttp (PEP 517): started
  Building wheel for aiohttp (PEP 517): finished with status 'done'
  Created wheel for aiohttp: filename=aiohttp-3.8.1-cp38-cp38-macosx_10_14_arm64.whl size=727455 sha256=148743f4b38440c79ad2a8213575caaa2584f7df0b17f3b4fda80cc4446ee329
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/8a/d8/49/2de846206798bd5b6c7e6d3814ab20465f2252593afb47698f
  Building wheel for numpy (PEP 517): started
  Building wheel for numpy (PEP 517): finished with status 'error'
  Building wheel for PyYAML (PEP 517): started
  Building wheel for PyYAML (PEP 517): finished with status 'done'
  Created wheel for PyYAML: filename=PyYAML-6.0-cp38-cp38-macosx_10_14_arm64.whl size=45339 sha256=96eebcfdc68c3ed44a02ae80c42df7fb56b807d96047b22408910a7c1a497ead
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/52/84/66/50912fd7bf1639a31758e40bd4312602e104a8eca1e0da9645
  Building wheel for multidict (PEP 517): started
  Building wheel for multidict (PEP 517): finished with status 'done'
  Created wheel for multidict: filename=multidict-5.2.0-cp38-cp38-macosx_10_14_arm64.whl size=64392 sha256=3c9600a6c2199ceae2e5908756d112057f68e4c20bcd586095ca951c44758022
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/cb/1d/38/bdfe293de7fdfdd2a0bd91c93059ffd2eb3f747a63d6018629
  Building wheel for yarl (PEP 517): started
  Building wheel for yarl (PEP 517): finished with status 'done'
  Created wheel for yarl: filename=yarl-1.7.2-cp38-cp38-macosx_10_14_arm64.whl size=154795 sha256=81daf41b10713b47fe9af1e581783f23951031379de8935901cbc1769d452c10
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/96/b2/8f/3bd1c6c0f0a9aa97fe489a67ac64757f045789723e57f3ce0d
  Building wheel for frozenlist (PEP 517): started
  Building wheel for frozenlist (PEP 517): finished with status 'done'
  Created wheel for frozenlist: filename=frozenlist-1.3.0-cp38-cp38-macosx_10_14_arm64.whl size=61809 sha256=4ed2304a2e44875605f3897f8f804de8c35cec2b4335626b93be76c84b2bba02
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/c8/f8/8f/875551eeab5a326af603ee251230723c80a1ce83c3eddf8db1
  Building wheel for pyrsistent (PEP 517): started
  Building wheel for pyrsistent (PEP 517): finished with status 'done'
  Created wheel for pyrsistent: filename=pyrsistent-0.18.1-cp38-cp38-macosx_10_14_arm64.whl size=81445 sha256=c3ddabf3baa7a42084c3e43c5770fa67497342ef7c62f1482c56640115d4766a
  Stored in directory: /Users/threepwave/Library/Caches/pip/wheels/30/87/4f/6ac908945dc671cfe494bbb1b0374a5f81238e2d67936a397b
Successfully built aiohttp PyYAML multidict yarl frozenlist pyrsistent
Failed to build numpy

--directory option fails

Hello,

When trying to compile with --directory option, an error is displayed:

Usage: nile compile [OPTIONS] [CONTRACTS]...
Try 'nile compile --help' for help.

Error: No such option: --directory

Run "nile node" cmd got this error

(env) xxxxx@xxxxxMacBook-Pro testProject % nile node
Traceback (most recent call last):
  File "/Users/xxxxx/devData/starkNet/testProject/env/bin/starknet-devnet", line 5, in <module>
    from starknet_devnet.server import main
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/starknet_devnet/server.py", line 3, in <module>
    from starkware.starknet.services.api.gateway.transaction import Deploy, InvokeFunction, Transaction
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/starkware/starknet/services/api/gateway/transaction.py", line 13, in <module>
    from services.everest.api.gateway.transaction import (
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/services/everest/api/gateway/transaction.py", line 5, in <module>
    from starkware.starkware_utils.validated_dataclass import ValidatedMarshmallowDataclass
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/starkware/starkware_utils/validated_dataclass.py", line 13, in <module>
    from starkware.starkware_utils.validated_fields import Field
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/starkware/starkware_utils/validated_fields.py", line 12, in <module>
    from starkware.starkware_utils.marshmallow_dataclass_fields import (
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/starkware/starkware_utils/marshmallow_dataclass_fields.py", line 6, in <module>
    from frozendict import frozendict
  File "/Users/xxxxx/devData/starkNet/testProject/env/lib/python3.10/site-packages/frozendict/__init__.py", line 16, in <module>
    class frozendict(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nile/main.py", line 122, in node
    node_command()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nile/commands/node.py", line 8, in node_command
    subprocess.check_call("starknet-devnet")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'starknet-devnet' returned non-zero exit status 1.

Debug contracts with Nile

It would be nice to debug contracts. I wrote a Cairo debugger that uses the debugger adapter protocol to communicate with VS Code, Emacs, and Vim. The package doesn't work with recent versions of Cairo or StarkNet (that was before StarkNet was announced).

How should the debugger be started? I was thinking it makes sense to pass the contract, a method, and its arguments.

nile setup fails

Hello team.
I am trying to setup a private key alias as described in the README. but I get an error.

I am on a working installation of Nile on macOS (I followed the macOS specific installations) and I am able to compile and deploy. I created the venv, installed cairo-nile with pip, inited the project. I also create a .env file in the root directory with the YOLO=123 key.

> nile setup YOLO    

Traceback (most recent call last):
  File "/opt/homebrew/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/nile/cli.py", line 84, in setup
    Account(signer, network)
  File "/opt/homebrew/lib/python3.9/site-packages/nile/core/account.py", line 20, in __init__
    self.signer = Signer(int(os.environ[signer]))
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'YOLO'

I have no idea what is going wrong

Dependency (Frozendict) appears to be broken ?

When trying to run nile compile I'm getting the following error

Traceback (most recent call last):
  File "/home/amxx/Work/OZ/cairo-contracts/env/bin/starknet-compile", line 7, in <module>
    from starkware.starknet.compiler.compile import main  # noqa
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/starknet/compiler/compile.py", line 7, in <module>
    from starkware.cairo.lang.compiler.assembler import assemble
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/cairo/lang/compiler/assembler.py", line 3, in <module>
    from starkware.cairo.lang.compiler.debug_info import DebugInfo, HintLocation, InstructionLocation
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/cairo/lang/compiler/debug_info.py", line 11, in <module>
    from starkware.starkware_utils.validated_dataclass import ValidatedMarshmallowDataclass
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/starkware_utils/validated_dataclass.py", line 12, in <module>
    from starkware.starkware_utils.validated_fields import Field
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/starkware_utils/validated_fields.py", line 13, in <module>
    from starkware.starkware_utils.marshmallow_dataclass_fields import (
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/starkware/starkware_utils/marshmallow_dataclass_fields.py", line 8, in <module>
    from frozendict import frozendict
  File "/home/amxx/Work/OZ/cairo-contracts/env/lib/python3.10/site-packages/frozendict/__init__.py", line 16, in <module>
    class frozendict(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'

Just opening python and ruining import frozendict does the same. Indeed, on my machine, running python 3.10.2, import collections does not include Mapping. There is however a Mapping in collections.abc

Can't run nile node in macOS

Hi,

I'm on macOS Big Sur, and there is some system process running at port 5000. Cause of which, nile node fails to run.

Is there a way to specify the port in nile node ?

Automating the --account_flag during compilation

When running nile compile, there should be a standardized way to let the compiler know that a contract is an account and thus automatically insert the --account_contract flag. My initial strategy was to simply look for Account in the contract name, but after the discussion in #79, this appears to be too restrictive. A better approach might be to trigger the flag when Account is the suffix i.e. Account.cairo and <something>Account.cairo.

End to end tests

We discussed both on Discord and in #40 about adding end to end tests. These tests would work as follows (let me know if I missed any step):

  • Create a new virtual environment
  • Install nile
  • Install cairo using nile install
  • Initialize a new repository with nile init
  • Compile the project
  • Run tests
  • Setup an account for the user (note: requires a private key)
  • Deploy smart contract
  • Use the account to interact with the smart contract
  • Read value back from smart contract

This series of commands tests everything available in nile except nile node, which could be tested by running all steps that involve a network interaction twice (with local node and with test network).

Since StarkNet does not have transaction fees for now we can generate a new private key every time we run the tests and then let the account rot (we can't destroy it anyway).

Any thoughts?

Cannot get `send` to work

I am having issues while trying to send a transaction via send.

Steps

  1. export PK1=123456789987654321
  2. nile setup PK1 --network localhost
  3. nile send PK1 contract_alias test_function --network localhost

Error:

Traceback (most recent call last):
  File "/usr/local/bin/nile", line 11, in <module>
    load_entry_point('cairo-nile===None', 'console_scripts', 'nile')()
  File "/usr/local/lib/python3.8/dist-packages/click-8.0.4-py3.8.egg/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click-8.0.4-py3.8.egg/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click-8.0.4-py3.8.egg/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click-8.0.4-py3.8.egg/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click-8.0.4-py3.8.egg/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/cairo_nile-None-py3.8.egg/nile/cli.py", line 100, in send
    account.send(contract_name, method, params)
  File "/usr/local/lib/python3.8/dist-packages/cairo_nile-None-py3.8.egg/nile/core/account.py", line 52, in send
    target_address, _ = next(deployments.load(to, self.network)) or to
StopIteration

Thank you

No ability to pass constructor arguments

Currently, there is no way to pass constructor arguments in the deploy function.

This stops the ability to deploy contracts that require args in their constructors.

Could this please be added?

How to test?

How should a nile project be tested?

There's a native nile test command (currently undocumented, see #7), which if I understand correctly, expects tests to be written in Cairo. Then there's also the test command in the Makefile that's created on nile init which runs pytest tests/.

What's the idea behind the first approach? Is it used anywhere?

Is it possible to have just one approach? Or combine the nile test command to run both the .test.cairo tests and also the ones in tests/ dir via pytest? Or maybe the test command can be removed altogether?

Support `nilerc`

This is related to #72 and something I personally wish was included. I think it would be helpful to have a configuration file that nile can use to lookup information such as:

  • cairo path
  • contracts directory

For example, the OZ cairo-contracts repository contains the cairo contracts in the openzeppelin directory and so nile compile won't compile them.

I'm also using the OZ contracts in my project and at the moment I can't compile with nile because I can't add the git submodule to the cairo path.

test nile commands

it'd be nice to implement some basic testing, probably starting with compile and clean.
this would make reviews and releases much more easy.

nile invoke on goerli fails because of the fee

using nile invoke alias returns

"tx_failure_reason": {
        "code": "FEE_TRANSFER_FAILURE",

but using starknet invoke ... --max_fee 0 works well

what am i doing wrong?
where can I change the fact that nile is using 0.000003 ETH as max_fee by default?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.