Skip to content

Commit

Permalink
Merge pull request #552 from crytic/dev
Browse files Browse the repository at this point in the history
sync master <> dev
  • Loading branch information
0xalpharush authored Mar 20, 2024
2 parents c0ad9f5 + de160c4 commit e910e5b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 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@v24
uses: cachix/install-nix-action@v25
- name: Set up cachix
if: matrix.type == 'dapp'
uses: cachix/cachix-action@v13
uses: cachix/cachix-action@v14
with:
name: dapp
- name: Install Foundry
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
path: dist/

- name: publish
uses: pypa/[email protected].11
uses: pypa/[email protected].14

- name: sign
uses: sigstore/[email protected]
Expand Down
8 changes: 6 additions & 2 deletions crytic_compile/crytic_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(self, target: Union[str, AbstractPlatform], **kwargs: str) -> None:
Args:
target (Union[str, AbstractPlatform]): Target
**kwargs: additional arguments
**kwargs: additional arguments. Used: "cwd"
"""

# dependencies is needed for platform conversion
Expand All @@ -145,7 +145,11 @@ def __init__(self, target: Union[str, AbstractPlatform], **kwargs: str) -> None:
# Note: line 1 is at index 0
self._cached_line_to_code: Dict[Filename, List[bytes]] = {}

self._working_dir = Path.cwd()
custom_cwd = kwargs.get("cwd")
if custom_cwd is not None:
self._working_dir = Path(custom_cwd)
else:
self._working_dir = Path.cwd()

# pylint: disable=too-many-nested-blocks
if isinstance(target, str):
Expand Down
22 changes: 22 additions & 0 deletions crytic_compile/platform/etherscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,28 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
via_ir=via_ir_enabled,
)

metadata_config = {
"solc_remaps": remappings if remappings else {},
"solc_solcs_select": compiler_version,
"solc_args": " ".join(
filter(
None,
[
"--via-ir" if via_ir_enabled else "",
"--optimize --optimize-runs " + str(optimize_runs) if optimize_runs else "",
"--evm-version " + evm_version if evm_version else "",
],
)
),
}

with open(
os.path.join(working_dir if working_dir else export_dir, "crytic_compile.config.json"),
"w",
encoding="utf-8",
) as f:
json.dump(metadata_config, f)

def clean(self, **_kwargs: str) -> None:
pass

Expand Down
31 changes: 31 additions & 0 deletions scripts/ci_test_etherscan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,34 @@ then
exit 255
fi
echo "::endgroup::"

# From crytic/crytic-compile#544
echo "::group::Etherscan #8"
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --etherscan-apikey "$GITHUB_ETHERSCAN"

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

dir_name=$(find crytic-export/etherscan-contracts/ -type d -name "*0x9AB6b21cDF116f611110b048987E58894786C244*" -print -quit)
cd "$dir_name" || { echo "Failed to change directory"; exit 255; }

if [ ! -f crytic_compile.config.json ]; then
echo "crytic_compile.config.json does not exist"
exit 255
fi

# TODO: Globbing at crytic_compile.py:720 to run with '.'
crytic-compile 'contracts/InterestRates/InterestRatePositionManager.f.sol' --config-file crytic_compile.config.json

if [ $? -ne 0 ]
then
echo "crytic-compile command failed"
exit 255
fi

cd ../../../

echo "::endgroup::"

0 comments on commit e910e5b

Please sign in to comment.