Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile the contrat #5

Open
mohammedi-haroune opened this issue Oct 5, 2022 · 1 comment
Open

Cannot compile the contrat #5

mohammedi-haroune opened this issue Oct 5, 2022 · 1 comment

Comments

@mohammedi-haroune
Copy link

I followed the steps README to compile the contract but I'm getting errors

I'm using Python 3.9.14

Here's my pip freeze

aiohttp==3.8.3
aiosignal==1.2.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==22.1.0
base58==2.1.1
bitarray==2.6.0
cachetools==5.2.0
cairo-lang==0.10.0
cairo-nile @ git+https://github.com/OpenZeppelin/nile.git@4d1ebf4f70fc6f187a0994b596676744b1c443cc
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
cloudpickle==2.1.0
crypto-cpp-py==1.0.4
cytoolz==0.12.0
ecdsa==0.18.0
eth-abi==2.2.0
eth-account==0.5.9
eth-hash==0.5.0
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-typing==2.3.0
eth-utils==1.9.5
fastecdsa==2.2.3
Flask==2.0.3
Flask-Cors==3.0.10
frozendict==1.2
frozenlist==1.3.1
gunicorn==20.1.0
hexbytes==0.3.0
idna==3.4
importlib-metadata==5.0.0
iniconfig==1.1.1
ipfshttpclient==0.8.0a2
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.16.0
lark-parser==0.12.0
lru-dict==1.1.8
MarkupSafe==2.1.1
marshmallow==3.17.1
marshmallow-dataclass==8.5.9
marshmallow-enum==1.5.1
marshmallow-oneofschema==3.0.1
mpmath==1.2.1
multiaddr==0.0.9
multidict==6.0.2
mypy-extensions==0.4.3
netaddr==0.8.0
numpy==1.23.3
packaging==21.3
parsimonious==0.8.1
pipdeptree==2.3.1
pluggy==1.0.0
prometheus-client==0.14.1
protobuf==3.20.3
py==1.11.0
pycryptodome==3.15.0
pyparsing==3.0.9
pyrsistent==0.18.1
pytest==7.1.3
pytest-asyncio==0.19.0
python-dotenv==0.21.0
PyYAML==6.0
requests==2.28.1
rlp==2.0.1
six==1.16.0
starknet-devnet==0.3.2
sympy==1.11.1
tomli==2.0.1
toolz==0.12.0
typeguard==2.13.3
typing-inspect==0.8.0
typing_extensions==4.3.0
urllib3==1.26.12
varint==1.0.2
web3==5.31.0
websockets==9.1
Werkzeug==2.0.3
yarl==1.8.1
zipp==3.8.1

Errors:

❯ nile compile
🤖 Compiling all Cairo contracts in the contracts directory
🔨 Compiling contracts/briq_impl.cairo
contracts/briq_impl.cairo:13:1: Unexpected character "#".
## Semantics:
^
🔨 Compiling contracts/types.cairo
contracts/types.cairo:3:14: Unexpected token Token('COLON', ':'). Expected: "{".
struct FTSpec:
             ^
🔨 Compiling contracts/UInt256_felt_conv.cairo
contracts/UInt256_felt_conv.cairo:14:40: Unexpected token Token('COLON', ':'). Expected one of: "*", "{".
    } (value: Uint256) -> (value: felt):
                                       ^
🔨 Compiling contracts/set_impl.cairo
contracts/set_impl.cairo:19:24: Unexpected token Token('COLON', ':'). Expected: "{".
namespace IBriqContract:
                       ^
🔨 Compiling contracts/erc20_proxy.cairo
contracts/erc20_proxy.cairo:8:31: Unexpected token Token('COLON', ':'). Expected: "{".
namespace IBriqBackendContract:
                              ^
🔨 Compiling contracts/allowance.cairo
contracts/allowance.cairo:8:57: Unexpected token Token('COLON', ':'). Expected one of: "*", "{".
func _approval_single(token_id: felt) -> (address: felt):
                                                        ^
🔨 Compiling contracts/mint.cairo
contracts/mint.cairo:7:1: Unexpected character "#".
# Contract that limits minting for the alpha release
^
🔨 Compiling contracts/authorization.cairo
contracts/authorization.cairo:11:1: Unexpected character "#".
####################
^
🔨 Compiling contracts/proxy/library.cairo
contracts/proxy/library.cairo:6:1: Unexpected character "#".
#
^
🔨 Compiling contracts/proxy/_proxy.cairo
contracts/proxy/_proxy.cairo:18:25: Unexpected token Token('COLON', ':'). Expected: "{".
namespace Implementation:
                        ^
🔨 Compiling contracts/caistring/str.cairo
contracts/caistring/str.cairo:12:1: Unexpected character "#".
#
^
🔨 Compiling contracts/caistring/array.cairo
contracts/caistring/array.cairo:1:1: Unexpected character "#".
# https://github.com/marcellobardus/starknet-l2-storage-verifier/blob/master/contracts/starknet/lib/concat_arr.cairo
^
🛑 Failed to compile the following 12 contracts:
   contracts/briq_impl.cairo
   contracts/types.cairo
   contracts/UInt256_felt_conv.cairo
   contracts/set_impl.cairo
   contracts/erc20_proxy.cairo
   contracts/allowance.cairo
   contracts/mint.cairo
   contracts/authorization.cairo
   contracts/proxy/library.cairo
   contracts/proxy/_proxy.cairo
   contracts/caistring/str.cairo
   contracts/caistring/array.cairo

I tried to use cairo-lang 0.9.1 and go different errors:

❯ nile compile
🤖 Compiling all Cairo contracts in the contracts directory
🔨 Compiling contracts/briq_impl.cairo
/Users/mac/Workspace/OpenSource/dao/briq-protocol/contracts/authorization.cairo:5:63: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import call_contract, delegate_l1_handler, delegate_call
                                                              ^*****************^
🔨 Compiling contracts/types.cairo
🔨 Compiling contracts/UInt256_felt_conv.cairo
contracts/UInt256_felt_conv.cairo:4:63: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import call_contract, delegate_l1_handler, delegate_call
                                                              ^*****************^
🔨 Compiling contracts/set_impl.cairo
/Users/mac/Workspace/OpenSource/dao/briq-protocol/contracts/Uint256_felt_conv.cairo:4:63: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import call_contract, delegate_l1_handler, delegate_call
                                                              ^*****************^
🔨 Compiling contracts/erc20_proxy.cairo
🔨 Compiling contracts/allowance.cairo
contracts/allowance.cairo:5:63: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import call_contract, delegate_l1_handler, delegate_call
                                                              ^*****************^
🔨 Compiling contracts/mint.cairo
🔨 Compiling contracts/authorization.cairo
contracts/authorization.cairo:5:63: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import call_contract, delegate_l1_handler, delegate_call
                                                              ^*****************^
🔨 Compiling contracts/proxy/library.cairo
🔨 Compiling contracts/proxy/_proxy.cairo
contracts/proxy/_proxy.cairo:4:48: Cannot import 'delegate_l1_handler' from 'starkware.starknet.common.syscalls'.
from starkware.starknet.common.syscalls import delegate_l1_handler, delegate_call
                                               ^*****************^
🔨 Compiling contracts/caistring/str.cairo
contracts/caistring/str.cairo:270:17: While trying to retrieve the implicit argument 'syscall_ptr' in:
    let (res) = str_concat (str, str_literal)
                ^***************************^
contracts/caistring/str.cairo:42:18: Unknown identifier 'syscall_ptr'.
func str_concat {syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, bitwise_ptr: BitwiseBuiltin*, range_check_ptr} (
                 ^****************^
🔨 Compiling contracts/caistring/array.cairo
🛑 Failed to compile the following 7 contracts:
   contracts/briq_impl.cairo
   contracts/UInt256_felt_conv.cairo
   contracts/set_impl.cairo
   contracts/allowance.cairo
   contracts/authorization.cairo
   contracts/proxy/_proxy.cairo
   contracts/caistring/str.cairo
@Cevedale
Copy link

Cevedale commented Nov 7, 2023

The errors you are encountering during the compilation of your Cairo contracts seem to be related to syntax and import issues.
Cairo 0.4.0 is required i think.
Of course you should make sure that your contracts are written in the correct syntax according to Cairo 0.4.0, i suggest to review your contract files for any syntax errors or outdated constructs. Don't forget to update contract dependencies as well.
After making the necessary updates to your contract code and dependencies, try to recompile your contracts using the new Cairo version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants