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

Synchronise master with dev #343

Merged
merged 103 commits into from
Jan 11, 2023
Merged
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e1966fa
contracts file path must be first for transform
japerk Apr 25, 2022
81ad88c
auto-clean: first draft implementation
elopez Nov 27, 2022
30c8e55
Split CompilationUnit into CompilationUnit + SourceUnit
montyly Dec 5, 2022
b2b264c
Merge branch 'dev-38' into dev-source-unit
montyly Dec 5, 2022
256f04d
Fix darglint
montyly Dec 5, 2022
7e47170
Merge branch 'dev' into dev-source-unit
montyly Dec 6, 2022
ab436a3
hardhat: revert changes
elopez Dec 13, 2022
02cc1df
auto-clean: clean up dapp and hardhat implementations with a helper
elopez Dec 13, 2022
9e786ac
Merge remote-tracking branch 'upstream/dev' into dev-auto-clean
elopez Dec 13, 2022
1dc0cbf
ci: update actions to the latest versions
elopez Dec 13, 2022
70752e3
Actions: enable dependabot version updates
elopez Nov 23, 2022
cf3bfd0
auto-clean: fix typing errors and lint warnings
elopez Dec 13, 2022
7f7047b
lint scripts
Dec 15, 2022
be1fdb9
add test for monorepops
Dec 15, 2022
04d6733
add some test artifacts to gitignore
Dec 15, 2022
ed9a6f8
implement hacky fix for monorepo issue
Dec 15, 2022
82dce8a
cryticparser: add missing brownie and foundry arguments
elopez Dec 16, 2022
69cf42c
cryticparser: rename misleading variables
elopez Dec 16, 2022
cb067dd
cryticparser: start names with caps
elopez Dec 16, 2022
d920853
implement correct fix for node_modules resolution
Dec 16, 2022
9dc45fd
bump version
Dec 16, 2022
32c03dd
Revert "lint scripts"
Dec 16, 2022
b05bb0a
use python 3.8 in CI
Dec 16, 2022
570176a
Merge branch 'dev' into node-module-resolution
Dec 16, 2022
f995aec
Merge branch 'dev' into node-module-resolution
Dec 16, 2022
5afa62c
check cwd node_modules
Dec 16, 2022
3ca1c8c
harden monorepo tests
Dec 16, 2022
98db0cb
refactor fix to use fewer statements
Dec 16, 2022
8172da5
Merge pull request #322 from crytic/dev-misc-actions
montyly Dec 20, 2022
28ce1e7
Merge pull request #323 from crytic/dev-fix-foundry-options
montyly Dec 20, 2022
6c13bcc
add metadata parsing + removal from bytecode
Oct 28, 2022
f3994a1
rerun black
Oct 31, 2022
661539e
fix pylint error
Nov 2, 2022
cf148ea
fix comments
Nov 4, 2022
ff92c5a
add ci test for metadata parsing
Dec 21, 2022
36d73e9
fix
Dec 21, 2022
f16340e
use separate python file
Dec 21, 2022
8612a25
fix
Dec 21, 2022
b002639
try fix
Dec 21, 2022
80276e5
test
Dec 21, 2022
a468802
Merge branch 'dev' into node-module-resolution
Dec 21, 2022
d14f59f
rm unnecessary elif
Dec 21, 2022
cdadc24
disable too-many-statements pylint rule
Dec 21, 2022
bc7c024
Fix pylint
montyly Dec 22, 2022
1a3c98d
Merge branch 'dev' into dev-source-unit
montyly Dec 22, 2022
9d52a5f
Merge pull request #316 from crytic/dev-source-unit
montyly Dec 22, 2022
3e55744
Merge branch 'dev' into fix-metadata-issue
montyly Dec 22, 2022
bebe2e9
Use pytest + minor improvements
montyly Dec 22, 2022
56fd5f5
Minor
montyly Dec 22, 2022
567ffb0
Merge pull request #324 from crytic/node-module-resolution
montyly Dec 22, 2022
99c0288
Merge pull request #304 from crytic/fix-metadata-issue
montyly Dec 22, 2022
e726dd0
support multiple compilation units for foundry
0xalpharush Jan 2, 2023
6708c58
pylint
0xalpharush Jan 2, 2023
4b7e6fa
Refactor filenames/filenames_lookup
montyly Jan 3, 2023
80b2848
Merge pull request #336 from crytic/dev-filenames-lookup
montyly Jan 3, 2023
1bde2bf
Actions: replace deprecated set-output
elopez Jan 3, 2023
bbaf905
Actions: update setup-node, setup-python, checkout
elopez Jan 3, 2023
69e6f18
Fix linting warnings and errors
elopez Jan 3, 2023
7e830e0
Fix incorrect import of 0.0.2 format
montyly Jan 3, 2023
74c0c8d
Add test
montyly Jan 4, 2023
d60119c
Minor
montyly Jan 4, 2023
43d9f41
Minor
montyly Jan 4, 2023
4ee6d3b
Refactor copy/paste logic
montyly Jan 4, 2023
d890670
pylint
montyly Jan 4, 2023
ba44500
Merge pull request #337 from crytic/dev-actions-dep-warning-cleanup
montyly Jan 5, 2023
2cd29fc
Fix darglint
montyly Jan 5, 2023
7a7c56b
ci: etherscan: sleep briefly when the API key is not available
elopez Jan 5, 2023
30333e5
ci: pass GITHUB_TOKEN to tests
elopez Jan 5, 2023
94a80d6
Merge pull request #340 from crytic/dev-fix-import-0.0.2
montyly Jan 5, 2023
9c52b54
Merge branch 'dev' into dev-auto-clean
Jan 5, 2023
3ea6558
ci: etherscan: de-randomize sleep
elopez Jan 5, 2023
fd9cdc6
set check=true on subprocess cmd runner
Jan 5, 2023
08f1f79
auto-clean: improve subprocess handling
elopez Dec 14, 2022
ee3cbeb
auto-clean: expose skip_clean config
elopez Dec 14, 2022
0b03f41
Merge branch 'master' into dev
montyly Jan 6, 2023
1b08cef
Merge remote-tracking branch 'upstream/dev' into dev-auto-clean
elopez Jan 6, 2023
441cabd
Merge pull request #342 from elopez/dev-fix-etherscan-brownie
montyly Jan 6, 2023
23f5694
Merge branch 'dev' into creyzies_fix
Jan 6, 2023
bc07da5
rm trailing whitespace
Jan 6, 2023
6a18ffb
Fixed solc
joevanloon Jan 2, 2023
4b4de6d
Update solc.py
joevanloon Jan 3, 2023
ca1296e
Fixed linter issues
joevanloon Jan 4, 2023
cd52336
reformat via black
Jan 6, 2023
aebea8d
Merge pull request #345 from bohendo/creyzies_fix
montyly Jan 9, 2023
5af9cbb
Merge pull request #346 from bohendo/master
montyly Jan 9, 2023
8b12dce
Update doc
montyly Jan 9, 2023
25c1245
Try to help mypy
montyly Jan 9, 2023
6e2f404
Merge branch 'dev' into foundry-multiple-compilation-units-mypy
montyly Jan 9, 2023
fe7aadf
Merge pull request #312 from crytic/dev-auto-clean
montyly Jan 9, 2023
570baea
:Merge branch 'dev' into foundry-multiple-compilation-units-mypy
montyly Jan 9, 2023
7a15010
Improve support for new standard format
montyly Jan 9, 2023
f464090
Fix pylint
montyly Jan 9, 2023
6041a51
Minor
montyly Jan 9, 2023
b94bdac
Minor
montyly Jan 9, 2023
5466633
Change priority hardhat <> foundry
montyly Jan 9, 2023
719ffe3
Decode debugging and error output with backslashreplace
elopez Jan 9, 2023
a2662cb
Merge pull request #351 from crytic/dev-fix-error-decode
montyly Jan 10, 2023
2e5b7ca
surface stderr/ errors from solc-select
0xalpharush Jan 10, 2023
82320e1
remove print
0xalpharush Jan 10, 2023
fe27372
Merge pull request #348 from crytic/foundry-multiple-compilation-unit…
montyly Jan 10, 2023
bcc4293
Merge pull request #353 from crytic/output-solc-stderr
montyly Jan 10, 2023
29b6c9d
Merge pull request #350 from crytic/hardhat-foundry
montyly Jan 11, 2023
aad5d41
Merge pull request #349 from crytic/dev-standard-fix
montyly Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
auto-clean: clean up dapp and hardhat implementations with a helper
elopez committed Dec 13, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 02cc1df4e801c1b4be723268f55da7ecc82a66b7
12 changes: 2 additions & 10 deletions crytic_compile/platform/dapp.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
from crytic_compile.platform.abstract_platform import AbstractPlatform
from crytic_compile.platform.types import Type
from crytic_compile.utils.naming import convert_filename, extract_name
from crytic_compile.utils.subprocess import run

# Handle cycle
from crytic_compile.utils.natspec import Natspec
@@ -129,16 +130,7 @@ def clean(self, **kwargs: str) -> None:
if dapp_ignore_compile:
return

cmd = ["dapp", "clean"]
LOGGER.info(
"'%s' running",
" ".join(cmd),
)
subprocess.run(
cmd,
cwd=self._target,
executable=shutil.which(cmd[0]),
)
run(["dapp", "clean"], cwd=self._target)

@staticmethod
def is_supported(target: str, **kwargs: str) -> bool:
35 changes: 17 additions & 18 deletions crytic_compile/platform/hardhat.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
from crytic_compile.platform.types import Type
from crytic_compile.utils.naming import convert_filename, extract_name
from crytic_compile.utils.natspec import Natspec
from crytic_compile.utils.subprocess import run
from .abstract_platform import AbstractPlatform

# Handle cycle
@@ -35,6 +36,17 @@ class Hardhat(AbstractPlatform):
PROJECT_URL = "https://github.com/nomiclabs/hardhat"
TYPE = Type.HARDHAT

def _settings(self, args):
hardhat_ignore_compile = args.get("hardhat_ignore_compile", False) or args.get(
"ignore_compile", False
)

base_cmd = ["hardhat"]
if not args.get("npx_disable", False):
base_cmd = ["npx"] + base_cmd

return hardhat_ignore_compile, base_cmd

# pylint: disable=too-many-locals,too-many-statements
def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
"""Run the compilation
@@ -48,13 +60,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
InvalidCompilation: If hardhat failed to run
"""

hardhat_ignore_compile = kwargs.get("hardhat_ignore_compile", False) or kwargs.get(
"ignore_compile", False
)

base_cmd = ["hardhat"]
if not kwargs.get("npx_disable", False):
base_cmd = ["npx"] + base_cmd
hardhat_ignore_compile, base_cmd = self._settings(kwargs)

detected_paths = self._get_hardhat_paths(base_cmd, kwargs)

@@ -187,20 +193,13 @@ def clean(self, **kwargs: str) -> None:
**kwargs: optional arguments.
"""

if self._ignore_compile:
hardhat_ignore_compile, base_cmd = self._settings(kwargs)

if hardhat_ignore_compile:
return

for clean_cmd in [["clean"], ["clean", "--global"]]:
cmd = self._base_cmd + clean_cmd
LOGGER.info(
"'%s' running",
" ".join(cmd),
)
subprocess.run(
cmd,
cwd=self._target,
executable=shutil.which(cmd[0]),
)
run(base_cmd + clean_cmd, cwd=self._target)

@staticmethod
def is_supported(target: str, **kwargs: str) -> bool:
53 changes: 53 additions & 0 deletions crytic_compile/utils/subprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import logging
import os
from pathlib import Path
import shutil
import subprocess
from typing import Dict, List

LOGGER = logging.getLogger("CryticCompile")


def run(
cmd: List[str],
cwd: os.PathLike | None = None,
extra_env: Dict[str, str] | None = None,
**kwargs,
) -> subprocess.CompletedProcess | None:
"""
Execute a command in a cross-platform compatible way.
Args:
cmd (List[str]): Command to run
cwd (PathLike): Working directory to run the command in
extra_env (Dict[str, str]): extra environment variables to define for the execution
**kwargs: optional arguments passed to `subprocess.run`
Returns:
CompletedProcess: If the execution succeeded
None: if there was a problem executing
"""
subprocess_cwd = Path(os.getcwd() if cwd is None else cwd).resolve()
subprocess_env = None if extra_env is None else dict(os.environ, extra_env)
subprocess_exe = shutil.which(cmd[0])

if subprocess_exe is None:
LOGGER.error("Cannot execute `%s`, is it installed and in PATH?", cmd[0])
return None

LOGGER.info(
"'%s' running (wd: %s)",
" ".join(cmd),
subprocess_cwd,
)

try:
return subprocess.run(
cmd, cwd=subprocess_cwd, executable=subprocess_exe, env=subprocess_env, **kwargs
)
except FileNotFoundError:
LOGGER.error("Could not execute `%s`, is it installed and in PATH?", cmd[0])
except OSError:
LOGGER.error("OS error executing:", exc_info=1)

return None