Skip to content

Commit

Permalink
Merge pull request #465 from crytic/dev
Browse files Browse the repository at this point in the history
Sync master <> dev
  • Loading branch information
0xalpharush authored Jul 6, 2023
2 parents 52e00c5 + fda579d commit f28ae19
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
path: './html/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
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].6
uses: pypa/[email protected].7

- name: sign
uses: sigstore/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Crytic-compile
[![Build Status](https://img.shields.io/github/workflow/status/crytic/crytic-compile/CI/master)](https://github.com/crytic/crytic-compile/actions?query=workflow%3ACI)
[![Build Status](https://img.shields.io/github/actions/workflow/status/crytic/crytic-compile/ci.yml?branch=master)](https://github.com/crytic/crytic-compile/actions?query=workflow%3ACI)
[![Slack Status](https://slack.empirehacking.nyc/badge.svg)](https://slack.empirehacking.nyc)
[![PyPI version](https://badge.fury.io/py/crytic-compile.svg)](https://badge.fury.io/py/crytic-compile)

Expand Down
4 changes: 2 additions & 2 deletions crytic_compile/crytic_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@


def get_platforms() -> List[Type[AbstractPlatform]]:
"""Return the available platforms classes
"""Return the available platforms classes in order of preference
Returns:
List[Type[AbstractPlatform]]: Available platforms
"""
platforms = [getattr(all_platforms, name) for name in dir(all_platforms)]
platforms = [d for d in platforms if inspect.isclass(d) and issubclass(d, AbstractPlatform)]
return sorted(platforms, key=lambda platform: platform.TYPE)
return sorted(platforms, key=lambda platform: (platform.TYPE.priority(), platform.TYPE))


def is_supported(target: str) -> bool:
Expand Down
10 changes: 4 additions & 6 deletions crytic_compile/platform/hardhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,10 @@ def is_supported(target: str, **kwargs: str) -> bool:
if hardhat_ignore:
return False

# If there is both foundry and hardhat, foundry takes priority
if os.path.isfile(os.path.join(target, "foundry.toml")):
return False

return os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
os.path.join(target, "hardhat.config.ts")
return (
os.path.isfile(os.path.join(target, "hardhat.config.js"))
or os.path.isfile(os.path.join(target, "hardhat.config.ts"))
or os.path.isfile(os.path.join(target, "hardhat.config.cjs"))
)

def is_dependency(self, path: str) -> bool:
Expand Down
6 changes: 0 additions & 6 deletions crytic_compile/platform/truffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,6 @@ def is_supported(target: str, **kwargs: str) -> bool:
if truffle_ignore:
return False

# Avoid conflicts with hardhat
if os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
os.path.join(target, "hardhat.config.ts")
):
return False

return os.path.isfile(os.path.join(target, "truffle.js")) or os.path.isfile(
os.path.join(target, "truffle-config.js")
)
Expand Down
21 changes: 21 additions & 0 deletions crytic_compile/platform/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,24 @@ def __str__(self) -> str: # pylint: disable=too-many-branches
if self == Type.FOUNDRY:
return "Foundry"
raise ValueError

def priority(self) -> int:
"""Return the priority for a certain platform.
A lower priority means the platform is more preferable. This is used to
consistently select a platform when two or more are available.
Returns:
int: priority number
"""

if self == Type.FOUNDRY:
return 100

if self == Type.HARDHAT:
return 200

if self in [Type.TRUFFLE, Type.WAFFLE]:
return 300

return 1000
6 changes: 0 additions & 6 deletions crytic_compile/platform/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ def is_supported(target: str, **kwargs: str) -> bool:
if waffle_ignore:
return False

# Avoid conflicts with hardhat
if os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
os.path.join(target, "hardhat.config.ts")
):
return False

if os.path.isfile(os.path.join(target, "waffle.json")) or os.path.isfile(
os.path.join(target, ".waffle.json")
):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
license="AGPL-3.0",
long_description=long_description,
long_description_content_type="text/markdown",
package_data={"crytic_compile": ["py.typed"]},
entry_points={"console_scripts": ["crytic-compile = crytic_compile.__main__:main"]},
)

0 comments on commit f28ae19

Please sign in to comment.