Skip to content

Commit

Permalink
Merge branch 'dev' into fix-conflict-when-multiple-api-keys-provied
Browse files Browse the repository at this point in the history
  • Loading branch information
vovikhangcdv authored Jul 22, 2024
2 parents 8a2c69b + 4291072 commit c425ceb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ jobs:
solc-select use 0.5.7 --always-install
- name: Set up nix
if: matrix.type == 'dapp'
uses: cachix/install-nix-action@v25
uses: cachix/install-nix-action@V27
- name: Set up cachix
if: matrix.type == 'dapp'
uses: cachix/cachix-action@v14
uses: cachix/cachix-action@v15
with:
name: dapp
- name: Install Foundry
Expand Down
6 changes: 3 additions & 3 deletions crytic_compile/platform/solc.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def _run_solc(
solc_disable_warnings (bool): If True, disable solc warnings
solc_arguments (Optional[str]): Additional solc cli arguments
solc_remaps (Optional[Union[str, List[str]]], optional): Solc remaps. Can be a string where remap are separated with space, or list of str, or a list of. Defaults to None.
env (Optional[Dict]): Environement variable when solc is run. Defaults to None.
env (Optional[Dict]): Environment variable when solc is run. Defaults to None.
working_dir (Optional[Union[Path, str]]): Working directory when solc is run. Defaults to None.
force_legacy_json (bool): Force to use the legacy json format. Defaults to False.
Expand Down Expand Up @@ -607,7 +607,7 @@ def _run_solcs_path(
solc_disable_warnings (bool): If True, disable solc warnings
solc_arguments (str): Additional solc cli arguments
solc_remaps (Optional[Union[str, List[str]]], optional): Solc remaps. Can be a string where remap are separated with space, or list of str, or a list of. Defaults to None.
env (Optional[Dict]): Environement variable when solc is run. Defaults to None.
env (Optional[Dict]): Environment variable when solc is run. Defaults to None.
working_dir (Optional[Union[Path, str]], optional): Working directory when solc is run. Defaults to None.
force_legacy_json (bool): Force to use the legacy json format. Defaults to False.
Expand Down Expand Up @@ -697,7 +697,7 @@ def _run_solcs_env(
solc_disable_warnings (bool): If True, disable solc warnings
solc_arguments (str): Additional solc cli arguments
solc_remaps (Optional[Union[str, List[str]]], optional): Solc remaps. Can be a string where remap are separated with space, or list of str, or a list of. Defaults to None.
env (Optional[Dict], optional): Environement variable when solc is run. Defaults to None.
env (Optional[Dict], optional): Environment variable when solc is run. Defaults to None.
working_dir (Optional[Union[Path, str]], optional): Working directory when solc is run. Defaults to None.
solcs_env (Optional[List[str]]): List of solc env variable to try. Defaults to None.
force_legacy_json (bool): Force to use the legacy json format. Defaults to False.
Expand Down
23 changes: 15 additions & 8 deletions crytic_compile/platform/solc_standard_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import json
import logging
import os
from pathlib import Path
import shutil
import subprocess
from typing import TYPE_CHECKING, Dict, List, Optional, Union, Any
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from crytic_compile.compilation_unit import CompilationUnit
from crytic_compile.compiler.compiler import CompilerVersion
from crytic_compile.platform.exceptions import InvalidCompilation
from crytic_compile.platform.solc import Solc, get_version, is_optimized, relative_to_short
from crytic_compile.platform.solc import (
Solc,
get_version,
is_optimized,
relative_to_short,
)
from crytic_compile.platform.types import Type
from crytic_compile.utils.naming import convert_filename

Expand Down Expand Up @@ -166,7 +171,6 @@ def run_solc_standard_json(
" ".join(cmd),
)
try:

with subprocess.Popen(
cmd,
stdin=subprocess.PIPE,
Expand All @@ -176,7 +180,6 @@ def run_solc_standard_json(
executable=shutil.which(cmd[0]),
**additional_kwargs,
) as process:

stdout_b, stderr_b = process.communicate(json.dumps(solc_input).encode("utf-8"))
stdout, stderr = (
stdout_b.decode(),
Expand Down Expand Up @@ -457,7 +460,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: Any) -> None:
Args:
crytic_compile (CryticCompile): Associated CryticCompile object
**kwargs: optional arguments. Used: "solc", "solc_disable_warnings", "solc_args", "solc_working_dir",
"solc_remaps"
"solc_remaps", "solc_env"
"""

solc: str = kwargs.get("solc", "solc")
Expand All @@ -466,13 +469,16 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: Any) -> None:

solc_remaps: Optional[Union[str, List[str]]] = kwargs.get("solc_remaps", None)
solc_working_dir: Optional[str] = kwargs.get("solc_working_dir", None)
solc_env: Optional[Dict] = kwargs.get("solc_env", None)

compilation_unit = CompilationUnit(crytic_compile, "standard_json")

compilation_unit.compiler_version = CompilerVersion(
compiler="solc",
version=get_version(solc, None),
optimized=is_optimized(solc_arguments),
version=get_version(solc, solc_env),
optimized=is_optimized(solc_arguments)
or self.to_dict().get("settings", {}).get("optimizer", {}).get("enabled", False),
optimize_runs=self.to_dict().get("settings", {}).get("optimizer", {}).get("runs", None),
)

add_optimization(
Expand All @@ -493,6 +499,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: Any) -> None:
self.to_dict(),
compilation_unit.compiler_version,
solc_disable_warnings=solc_disable_warnings,
working_dir=solc_working_dir,
)

parse_standard_json_output(
Expand Down
2 changes: 1 addition & 1 deletion crytic_compile/platform/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def _load_config(config_file: str) -> Dict:


def _get_version(compiler: str, cwd: str, config: Optional[Dict] = None) -> str:
"""Return the solidity verison used
"""Return the solidity version used
Args:
compiler (str): compiler used
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_truffle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ then
echo "Truffle test failed"
exit 255
fi
# TODO: for some reason truffle output is not deterministc
# TODO: for some reason truffle output is not deterministic
# The assigned id changes
#cd -
#
Expand Down

0 comments on commit c425ceb

Please sign in to comment.