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

Fix import 0.0.2 #340

Merged
merged 4 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-2022"]
type: ["brownie", "buidler", "dapp", "embark", "etherlime", "hardhat", "solc", "truffle", "waffle", "foundry"]
type: ["brownie", "buidler", "dapp", "embark", "etherlime", "hardhat", "solc", "truffle", "waffle", "foundry", "standard"]
exclude:
# Currently broken, tries to pull git:// which is blocked by GH
- type: embark
Expand Down
5 changes: 3 additions & 2 deletions crytic_compile/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from crytic_compile.crytic_compile import compile_all, get_platforms
from crytic_compile.cryticparser import DEFAULTS_FLAG_IN_CONFIG, cryticparser
from crytic_compile.platform import InvalidCompilation
from crytic_compile.platform.all_export import PLATFORMS_EXPORT
from crytic_compile.utils.zip import ZIP_TYPES_ACCEPTED, save_to_zip

if TYPE_CHECKING:
Expand Down Expand Up @@ -50,8 +51,8 @@ def parse_args() -> argparse.Namespace:

parser.add_argument(
"--export-format",
help="""Export json with non crytic-compile format
(default None. Accepted: standard, solc, truffle)""",
help=f"""Export json with non crytic-compile format
(default None. Accepted: ({", ".join(list(PLATFORMS_EXPORT))})""",
action="store",
dest="export_format",
default=None,
Expand Down
29 changes: 11 additions & 18 deletions crytic_compile/platform/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from crytic_compile.compiler.compiler import CompilerVersion
from crytic_compile.platform import Type as PlatformType
from crytic_compile.platform.abstract_platform import AbstractPlatform
from crytic_compile.utils.naming import Filename, convert_filename
from crytic_compile.utils.naming import Filename

# Cycle dependency
from crytic_compile.utils.natspec import Natspec
Expand Down Expand Up @@ -435,15 +435,16 @@ def _load_from_compile_current(crytic_compile: "CryticCompile", loaded_json: Dic
version=compilation_unit_json["compiler"]["version"],
optimized=compilation_unit_json["compiler"]["optimized"],
)
for contracts_data in compilation_unit_json["contracts"].values():
for contract_name, contract in contracts_data.items():

filename = Filename(
absolute=contract["filenames"]["absolute"],
relative=contract["filenames"]["relative"],
short=contract["filenames"]["short"],
used=contract["filenames"]["used"],
)
compilation_unit.filenames = {
_convert_dict_to_filename(filename) for filename in compilation_unit_json["filenames"]
}

for filename_str, source_unit_data in compilation_unit_json["source_units"].items():
filename = compilation_unit.filename_lookup(filename_str)
source_unit = compilation_unit.create_source_unit(filename)

for contract_name, contract in source_unit_data["contracts"].items():
compilation_unit.filename_to_contracts[filename].add(contract_name)

source_unit = compilation_unit.create_source_unit(filename)
Expand All @@ -465,15 +466,7 @@ def _load_from_compile_current(crytic_compile: "CryticCompile", loaded_json: Dic
crytic_compile.dependencies.add(filename.short)
crytic_compile.dependencies.add(filename.used)

compilation_unit.filenames = {
_convert_dict_to_filename(filename) for filename in compilation_unit_json["filenames"]
}

for path, ast in compilation_unit_json["asts"].items:
# The following might create lookup issue?
filename = convert_filename(path, lambda x: x, crytic_compile)
source_unit = compilation_unit.create_source_unit(filename)
source_unit.ast = ast
source_unit.ast = source_unit_data["ast"]


def load_from_compile(crytic_compile: "CryticCompile", loaded_json: Dict) -> Tuple[int, List[str]]:
Expand Down
39 changes: 39 additions & 0 deletions scripts/ci_test_standard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

DIR=$(mktemp -d)

cp tests/contract.sol "$DIR"
cd "$DIR" || exit 255

crytic-compile contract.sol --export-format archive

if [ $? -ne 0 ]
then
echo "Standard test failed"
exit 255
fi

crytic-compile crytic-export/contract.sol_export_archive.json

if [ $? -ne 0 ]
then
echo "Standard test failed"
exit 255
fi


crytic-compile contract.sol --export-zip test.zip

if [ $? -ne 0 ]
then
echo "Standard test failed"
exit 255
fi

crytic-compile test.zip

if [ $? -ne 0 ]
then
echo "Standard test failed"
exit 255
fi