apeworx / ape-solidity Goto Github PK
View Code? Open in Web Editor NEWSolidity compiler plugin for the Ape Framework
Home Page: https://www.apeworx.io/
License: Apache License 2.0
Solidity compiler plugin for the Ape Framework
Home Page: https://www.apeworx.io/
License: Apache License 2.0
Error: Source file requires different compiler version (current compiler is 0.8.12+commit.f00d7308.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> test/ERC20.sol:1:1:
|
1 | pragma solidity =0.5.16;
Looking at code, it seems like we only using in version in the compile call
Right now, if you compile something once, and then change a compiler setting in your ape-config.yaml
(such as optimize
), it does not detect that it needs to recompile.
It might be nice to do this somehow.
Related to this: ApeWorX/ape#149
This is the other side of getting github dependencies to work for simple projects
Desired Example Config Syntax
dependencies:
open_zeppelin: OpenZeppelin/[email protected]
solidity:
remapping:
- "@openzeppelin=open_zeppelin"
ape
and plugin versions:$ ape --version
0.4.3
$ ape plugins list
Installed Plugins:
solidity 0.4.0
Fail to compile a contract:
import "@openzeppelin/token/ERC20/IERC20.sol";
contract Test {}
with ape-config.yaml
:
name: test
plugins:
- name: solidity
dependencies:
- name: OpenZeppelin
github: OpenZeppelin/openzeppelin-contracts
version: 2.0.0
exclude:
- package.json # Ignore package.json files.
- mocks/**/* # Ignore all files in the 'mocks' directory
solidity:
import_remapping:
- "@openzeppelin=OpenZeppelin/2.0.0"
$ ape -v DEBUG compile
INFO: Compiling 'Test.sol'.
DEBUG: Compiling using Solidity compiler '0.4.26'
Traceback (most recent call last):
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/bin/ape", line 8, in <module>
sys.exit(cli())
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape/_cli.py", line 40, in invoke
return super().invoke(ctx)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape_compile/_cli.py", line 53, in cli
contract_types = cli_ctx.project_manager.load_contracts(
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape/managers/project/manager.py", line 473, in load_contracts
manifest = self._project.create_manifest(file_paths, use_cache=use_cache)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape/managers/project/types.py", line 158, in create_manifest
compiled_contract_types = self.compiler_manager.compile(list(needs_compiling))
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape/managers/compilers.py", line 98, in compile
compiled_contracts = self.registered_compilers[extension].compile(
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/ape_solidity/compiler.py", line 243, in compile
output = solcx.compile_files([f for f in files], **kwargs)
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/solcx/main.py", line 216, in compile_files
return _compile_combined_json(
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/solcx/main.py", line 291, in _compile_combined_json
stdoutdata, stderrdata, command, proc = wrapper.solc_wrapper(
File "/Users/folk/Library/Caches/pypoetry/virtualenvs/lido-withdrawals-ZlTFoF_3-py3.9/lib/python3.9/site-packages/solcx/wrapper.py", line 158, in solc_wrapper
raise SolcError(
solcx.exceptions.SolcError: An error occurred during execution
> command: `/Users/folk/.solcx/solc-v0.4.26 /Users/folk/Projects/lido/lido-withdrawals/contracts/.cache/OpenZeppelin/v2.0.0/token/ERC20/IERC20.sol /Users/folk/Projects/lido/lido-withdrawals/contracts/Test.sol @openzeppelin=.cache/OpenZeppelin/v2.0.0 --combined-json abi,bin,bin-runtime,devdoc,userdoc --optimize`
> return code: `1`
> stdout:
> stderr:
/Users/folk/Projects/lido/lido-withdrawals/contracts/Test.sol:5:1: Error: Source ".cache/OpenZeppelin/v2.0.0/token/ERC20/IERC20.sol" not found: File outside of allowed directories.
import "@openzeppelin/token/ERC20/IERC20.sol";
^--------------------------------------------^
Since solc versions before 0.6.9
does not support --base-path
, it can't figure out how to find a relative path like .cache/OpenZeppelin/v2.0.0/token/ERC20/IERC20.sol
. There is a two theoretically possible ways to fix it:
solc
from contracts
path, but it will require a modification in solcx
package and, according to documentation, can lead to Windows compatibility problemsLooks, like we can remove these lines to achieve this, but it can break something else
(brownie) sabotage@sabotage:~/ape$ brownie bake token
Brownie v1.15.1 - Python development framework for Ethereum
Downloading from https://github.com/brownie-mix/token-mix/archive/master.zip...
9.13kiB [00:00, 3.69MiB/s]
SUCCESS: Brownie mix 'token' has been initiated at /home/sabotage/ape/token
(brownie) sabotage@sabotage:~/ape$ pyenv deactivate
sabotage@sabotage:~/ape$ pyenv activate apeworx
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(apeworx) sabotage@sabotage:~/ape$ cd token/
(apeworx) sabotage@sabotage:~/ape/token$ ape compile
INFO: Compiling 'contracts/Token.sol'
INFO: Compiling 'contracts/SafeMath.sol'
Traceback (most recent call last):
File "/home/sabotage/.pyenv/versions/apeworx/bin/ape", line 8, in <module>
sys.exit(cli())
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/ape_compile/_cli.py", line 75, in cli
contract_types = project.load_contracts(use_cache)
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/ape/managers/project.py", line 117, in load_contracts
contract_types.update(self.compilers.compile(list(needs_compiling)))
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/ape/managers/compilers.py", line 49, in compile
for contract_type in self.registered_compilers[extension].compile(paths_to_compile):
File "/home/sabotage/ape/ape-solidity/ape_solidity/compiler.py", line 77, in compile
for result in solcx.compile_source(
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/solcx/main.py", line 112, in compile_source
return _compile_combined_json(
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/solcx/main.py", line 288, in _compile_combined_json
stdoutdata, stderrdata, command, proc = wrapper.solc_wrapper(
File "/home/sabotage/.pyenv/versions/3.8.10/envs/apeworx/lib/python3.8/site-packages/solcx/wrapper.py", line 158, in solc_wrapper
raise SolcError(
solcx.exceptions.SolcError: An error occurred during execution
> command: `/home/sabotage/.solcx/solc-v0.6.12 --combined-json abi,bin,bin-runtime,devdoc,userdoc -`
> return code: `1`
> stdout:
> stderr:
Error: Source "SafeMath.sol" not found: File not found.
--> <stdin>:5:1:
|
5 | import "./SafeMath.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^
ape
and plugin versions:$ ape --version
0.6.8
$ ape plugins list
Installed Plugins:
solidity 0.6.3
Running into the following issues running tests for our project that uses ape. The ape config file specifies solidity version 0.8.17. The test suite was previously passing but is now failing without code changes:
The failures manifest as:
With Invalid opcode 0x5f for a variety of tests
/home/runner/work/nucypher-contracts/nucypher-contracts/tests/test_subscription_manager.py:12: in proxy_admin
return accounts[0].deploy(dependency.ProxyAdmin)
E ape.exceptions.ContractLogicError: Invalid opcode 0x5f @ 31
You can view more error logs here - https://github.com/nucypher/nucypher-contracts/pull/80/checks
Please include information like:
what command you ran
$ ape test
the code that caused the failure (see this link for help with formatting code)
full output of the error you received
https://github.com/nucypher/nucypher-contracts/pull/80/checks
Fill this in if you have ideas on how the bug could be fixed.
Could be the incorrect version of solidity, 0.8.20 being used even though 0.8.17 is specified (?)
From ApeWorX Discord:
fubuloubu — Today at 2:02 PM
It's using 0.8.20 by accident. What is your config file saying? We might have a bug if you're pinning a specific version and it is not recognizing it
derek — Today at 2:02 PM
solidity:
version: 0.8.17
import_remapping:
- "@openzeppelin/contracts=openzeppelin/v4.8.1"
- "@openzeppelin-upgradeable/contracts=openzeppelin-upgradeable/v4.8.1"
fubuloubu — Today at 2:03 PM
Yup, that's a bug then, it should be pinning to the specific version you state. Can you open an issue in ape-solidity and we can get that fixed?
Currently py-solc-x will utilize the default installation path of ~/.solcx
(on *nix) when ape-solidity tests are running.
This means that the tests may run differently based on the running system's current solc installations, and that the user's installed solc versions will be different after the tests have been run.
To rectify this we can use an autouse
, session scoped test fixture to set the environment variable specified solcx.install.SOLCX_BINARY_PATH_VARIABLE
to a temporary directory. This way the tests will start with a clean slate, and will only install compilers in a temporary directory that won't interfere with the user's installation (or vice versa).
At the end of the test suite the temporary directory can be removed
Allow specifying the evmVersion
solidity:
evm_version: <fork-name>
get_compiler_settings()
under key evmVersion
call as kwarg
evm_version`Include links to any open issues that must be resolved before this feature can be implemented.
ape-config.yaml
:
plugins:
- name: solidity
dependencies:
- name: v3-core
github: Uniswap/v3-core
branch: main
error:
Error: Source file requires different compiler version (current compiler is 0.8.14+commit.80d49f37.Linux.g++) - note that nightly builds are considered to be strictly less than the released version
--> libraries/FullMath.sol:2:1:
|
2 | pragma solidity >=0.4.0 <0.8.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
reincorporate project template so that changelogs are automatically built in the future for releases
pin should be updateable now that test suite no longer supports python 3.6
currently we areskipping bytecode for contracts using linking.
lets properly support it!
https://docs.soliditylang.org/en/v0.8.18/using-the-compiler.html#library-linking
Output evm.gasEstimates
for potential integrations with configuring automatic gas values.
evm.gasEstimates
in output_values
list of compiler..ape/solidity/<contract_name>/gas_estimates.json
estimate_gas_cost(txn)
Include links to any open issues that must be resolved before this feature can be implemented.
Currently, there is no way to configure optimization runs in the plugin.
The runs are included in the published package manifest.
Right now they are always defaulted to 200.
ape-config.yaml
:
solidity:
optimize_runs: 200
Include links to any open issues that must be resolved before this feature can be implemented.
It is sometimes handy to map to contracts that exist outside of the contracts directory like in ./lib/*
or ./interfaces/*
Sometimes, it would be nice to have manual control of the compiler version(s) used.
Perhaps it can be a list to allow more than one version since the compiler is pretty good at multi-version now.
Otherwise, just specifying the version is a bit of an optimization for many projects.
Latest ape and plugin
It has been reported that it is challenging to run Slither on the .cache
directory from dependencies.
Not sure! We should experiment with Slither and consider integrating with the tool more officially.
Receiving the error UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte
while compiling solidity smart contracts.
The error occurs evidently from the ape-solidity
plugin.
(venv) mbp:truhuis-smart-contracts mac$ ape compile
WARNING: Unprocessed plugin config(s): scripts_folder, tests_folder. Plugins may not be installed yet or keys may be mis-spelled.
WARNING: Unprocessed plugin config(s): scripts_folder, tests_folder. Plugins may not be installed yet or keys may be mis-spelled.
WARNING: Unprocessed plugin config(s): scripts_folder, tests_folder. Plugins may not be installed yet or keys may be mis-spelled.
WARNING: Unprocessed plugin config(s): scripts_folder, tests_folder. Plugins may not be installed yet or keys may be mis-spelled.
INFO: Compiling 'BrownieContract.sol'.
Traceback (most recent call last):
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/bin/ape", line 8, in <module>
sys.exit(cli())
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/_cli.py", line 40, in invoke
return super().invoke(ctx)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_compile/_cli.py", line 53, in cli
contract_types = cli_ctx.project_manager.load_contracts(
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/project/manager.py", line 422, in load_contracts
manifest = self._project.create_manifest(file_paths, use_cache=use_cache)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/project/types.py", line 158, in create_manifest
compiled_contract_types = self.compiler_manager.compile(list(needs_compiling))
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/compilers.py", line 98, in compile
compiled_contracts = self.registered_compilers[extension].compile(
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 214, in compile
files_by_solc_version = self.get_version_map(contract_filepaths, base_path=contracts_path)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 369, in get_version_map
imports = self.get_imports(get_all_files_in_directory(contracts_path), contracts_path)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 334, in get_imports
source_lines = filepath.read_text().splitlines()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pathlib.py", line 1133, in read_text
return f.read()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte
(venv) mbp:truhuis-smart-contracts mac$ ls -al
In order to escape the error and compile I have to remove .DS_Store
file inside of contracts
folder each time and after that run ape compile
. It would be nice to avoid manually remove that file or to modify the plugin so that the error not occurs.
The ABIs are type dict but they should be type ABI
Resolve by using from_dict()
method on ABI.
Main branch
Seems like tests don't run out of the box on main. Lots of Missing sources:
errors and packages not installed.
Looks like what needs to happen is npm install
in the tests/
dir. Should clean up this devex a bit. At a minimum it should be documented in README. Alternatively, maybe a setuptools post-install command.
ape
and plugin versions:$ ape --version
0.3.5.dev1+gcf0ee464
$ ape plugins list
Installed Plugins:
template 0.3.0
solidity 0.3.1
alchemy 0.3.0
vyper 0.3.0
ape-config.yaml
(NOTE: do not post anything private like RPC urls or secrets!):$ cat ape-config.yaml
plugins:
- name: solidity
Running tests without any changes errors if the relevant solc versions are not installed for the contracts attempting to be compiled by the tests
Looks like it's a false-positive issue when checking if a version of solc is installed, compiler.py:411
likely
Fixes potential migration issue
The sourceId property is always the last path in the loop of file contract paths.
push0 rollout went bad, with many networks not supporting the latest evm version yet, possibly resulting in potentially broken deploys.
instead of latest (shanghai), it would be better to default to paris unless explicitly overriden by a user who knows what they are doing.
Currently there is no way to specify which fields in abi is needed. For example when AST added to output files our abi folder size grew 5 times comparing to old one. If we can select which fields do we want in output that would be great. (really mandatory ones can be protected like abi, runtimeBytecode, deploymentBytecode these are really the most important ones.)
.add_library
is great for pre-compile scripts but it'd be nice to have a way to list the libraries in the ape-config.yaml
file as well.
solidity:
libraries:
ethereum:
mainnet:
MyLibrary: 0x003123012312412541241241242 # pretend is address
And then (not sure about this next part): Have compile()
detect if we are connected to a provider and if the network matches anything we have listed in libraries:
and if it does, grab those addresses and add the libraries.
Include links to any open issues that must be resolved before this feature can be implemented.
When trying to install ape-solidity either with pip install -e .
, or via the setuptools, I get the following error:
ModuleNotFoundError: No module named '_ctypes'
Any idea on why this error reverted? I've tried to compile that solidity interface in another development framework and didn't receive that kind of issue.
(venv) mbp:truhuis-smart-contracts mac$ ape compile contracts/interfaces/ITruhuisAuction.sol
INFO: Compiling 'interfaces/ITruhuisAuction.sol'.
Traceback (most recent call last):
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/bin/ape", line 8, in <module>
sys.exit(cli())
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/_cli.py", line 40, in invoke
return super().invoke(ctx)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_compile/_cli.py", line 53, in cli
contract_types = cli_ctx.project_manager.load_contracts(
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/project/manager.py", line 422, in load_contracts
manifest = self._project.create_manifest(file_paths, use_cache=use_cache)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/project/types.py", line 158, in create_manifest
compiled_contract_types = self.compiler_manager.compile(list(needs_compiling))
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape/managers/compilers.py", line 98, in compile
compiled_contracts = self.registered_compilers[extension].compile(
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 214, in compile
files_by_solc_version = self.get_version_map(contract_filepaths, base_path=contracts_path)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 369, in get_version_map
imports = self.get_imports(get_all_files_in_directory(contracts_path), contracts_path)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 353, in get_imports
import_item = import_str_to_source_id(import_str=import_str, source_path=filepath)
File "/Users/mac/P_D_V/projects-current/truhuis/tmp/truhuis-smart-contracts/venv/lib/python3.10/site-packages/ape_solidity/compiler.py", line 301, in import_str_to_source_id
end_index = import_str.index(quote) + 1
ValueError: substring not found
I think this might already be the case, but need to make sure. It is critical for the work I am doing on dependencies.
ape
and plugin versions:$ ape --version
0.3.5.dev1+gcf0ee464
$ ape plugins list
Installed Plugins:
template 0.3.0
solidity 0.3.1
alchemy 0.3.0
vyper 0.3.0
ape-config.yaml
(NOTE: do not post anything private like RPC urls or secrets!):$ cat ape-config.yaml
plugins:
- name: solidity
This came about while I was playing around with setting up a template project.
My steps were basically this:
pragma solidity <version>
so the contract is not specifying a versionape-solidity
will actually skip the steps of auto-installing any compiler version. Once it gets to get_best_version()
it will fail due to the call to max()
with an empty listVersion is skipped early due to pragma_spec is None
ape-solidity/ape_solidity/compiler.py
Lines 404 to 421 in ffff92c
No pragma specs falls back on max installed version, but no versions were ever installed:
ape-solidity/ape_solidity/compiler.py
Lines 426 to 432 in ffff92c
The resulting error is a ValueError: max() arg is an empty sequence
which isn't super cryptic, but doesn't really describe the underlying issue:
INFO: Compiling 'Token.sol'.
Traceback (most recent call last):
File "../.venv/ape/bin/ape", line 33, in <module>
sys.exit(load_entry_point('eth-ape', 'console_scripts', 'ape')())
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "../Documents/Code/Python/ape/src/ape/_cli.py", line 40, in invoke
return super().invoke(ctx)
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "../.venv/ape/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "../.venv/ape/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "../Documents/Code/Python/ape/src/ape_compile/_cli.py", line 53, in cli
contract_types = cli_ctx.project_manager.load_contracts(
File "../Documents/Code/Python/ape/src/ape/managers/project/manager.py", line 422, in load_contracts
manifest = self._project.create_manifest(file_paths, use_cache=use_cache)
File "../Documents/Code/Python/ape/src/ape/managers/project/types.py", line 158, in create_manifest
compiled_contract_types = self.compiler_manager.compile(list(needs_compiling))
File "../Documents/Code/Python/ape/src/ape/managers/compilers.py", line 98, in compile
compiled_contracts = self.registered_compilers[extension].compile(
File "../.venv/ape/lib/python3.9/site-packages/ape_solidity/compiler.py", line 214, in compile
files_by_solc_version = self.get_version_map(contract_filepaths, base_path=contracts_path)
File "../.venv/ape/lib/python3.9/site-packages/ape_solidity/compiler.py", line 437, in get_version_map
solc_version = get_best_version(source_file_path)
File "../.venv/ape/lib/python3.9/site-packages/ape_solidity/compiler.py", line 431, in get_best_version
else max(self.installed_versions)
ValueError: max() arg is an empty sequence
During the resolution of the pragma specs / installation of Solidity versions, we will need to check if we have any contracts where a spec has not been defined. If there are any, then we need to ensure that we also install the latest version of Solidity, so that we can rely on it later in get_best_version()
ape
and plugin versions:CompilerError preventing from getting a flattened contract.
ape-solidity/ape_solidity/compiler.py
Lines 1038 to 1040 in f186f1e
Change to a warning.
Provide a simple overview of what you wish to see added. Please include:
As of v0.8.13, the solidity compiler allows code generation through the Yul IR via the --via-ir
flag. One noticeable benefit of using this flag is handling stack too deep errors.
Currently, the ape-solidity plugin doesn't have the ability to enable the --via-ir
flag, and it would be useful to have the option to do so.
A simple config file option via_ir
would be sufficient.
Would be nice to have a simple way to get the fully flattened contract including all dependencies that can be printed out or exported to a designated file.
Verification post deployment using the etherscan API, especially on non-ethereum chains can cause issues with the verification process when the locally compiled files dont't exactly match what Etherscans compiler expects.
One of the easiest ways to avoid this is to get the flattened source file and deploy through Remix since they use the exact same compiler as etherscan. Being able to easily get the full flattened source would make this process much simpilier.
A syntax similar to Brownies version or Foundrys command would be sufficient.
Brownie Ex:
Using the Brownie console you could use
ContractContainer.get_verification_info()[
ContractContainer._flattener.flattened_source
Foundry Ex:
from the command line you can enter
forge flatten --output src/Contract.flattened.sol src/Contract.sol
Any variation or something similar would work fine.
Would close out issue ApeWorX/ape#788
Reference to original Brownie issue eth-brownie/brownie#849
Reference to original Brownie implementation eth-brownie/brownie#914
(brownie) sabotage@sabotage:~/ape/token$ docker run --volume $HOME/.ape:/root/ape --volume $HOME/.vvm:/root/.vvm --volume $HOME/.solcx:/root/.solcx --volume $PWD:/root/project --workdir /root/project apeworx/ape ape compile
INFO: Compiling 'contracts/Token.sol'
INFO: Compiling 'contracts/SafeMath.sol'
Traceback (most recent call last):
File "/usr/local/bin/ape", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/ape_compile/_cli.py", line 75, in cli
contract_types = project.load_contracts(use_cache)
File "/usr/local/lib/python3.8/dist-packages/ape/managers/project.py", line 117, in load_contracts
contract_types.update(self.compilers.compile(list(needs_compiling)))
File "/usr/local/lib/python3.8/dist-packages/ape/managers/compilers.py", line 49, in compile
for contract_type in self.registered_compilers[extension].compile(paths_to_compile):
File "/usr/local/lib/python3.8/dist-packages/ape_solidity/compiler.py", line 77, in compile
for result in solcx.compile_source(
File "/usr/local/lib/python3.8/dist-packages/solcx/main.py", line 112, in compile_source
return _compile_combined_json(
File "/usr/local/lib/python3.8/dist-packages/solcx/main.py", line 288, in _compile_combined_json
stdoutdata, stderrdata, command, proc = wrapper.solc_wrapper(
File "/usr/local/lib/python3.8/dist-packages/solcx/wrapper.py", line 158, in solc_wrapper
raise SolcError(
solcx.exceptions.SolcError: An error occurred during execution
> command: `/root/.solcx/solc-v0.6.12 --combined-json abi,bin,bin-runtime,devdoc,userdoc -`
> return code: `1`
> stdout:
> stderr:
Error: Source "SafeMath.sol" not found: File not found.
--> <stdin>:5:1:
|
5 | import "./SafeMath.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^
Originally posted by @sabotagebeats in ApeWorX/ape#127 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.