Skip to content

Commit f28ae19

Browse files
authored
Merge pull request #465 from crytic/dev
Sync master <> dev
2 parents 52e00c5 + fda579d commit f28ae19

File tree

9 files changed

+31
-23
lines changed

9 files changed

+31
-23
lines changed

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
path: './html/'
4444
- name: Deploy to GitHub Pages
4545
id: deployment
46-
uses: actions/deploy-pages@v1
46+
uses: actions/deploy-pages@v2

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
path: dist/
4646

4747
- name: publish
48-
uses: pypa/[email protected].6
48+
uses: pypa/[email protected].7
4949

5050
- name: sign
5151
uses: sigstore/[email protected]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Crytic-compile
2-
[![Build Status](https://img.shields.io/github/workflow/status/crytic/crytic-compile/CI/master)](https://github.com/crytic/crytic-compile/actions?query=workflow%3ACI)
2+
[![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)
33
[![Slack Status](https://slack.empirehacking.nyc/badge.svg)](https://slack.empirehacking.nyc)
44
[![PyPI version](https://badge.fury.io/py/crytic-compile.svg)](https://badge.fury.io/py/crytic-compile)
55

crytic_compile/crytic_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636

3737

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

4848

4949
def is_supported(target: str) -> bool:

crytic_compile/platform/hardhat.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,10 @@ def is_supported(target: str, **kwargs: str) -> bool:
212212
if hardhat_ignore:
213213
return False
214214

215-
# If there is both foundry and hardhat, foundry takes priority
216-
if os.path.isfile(os.path.join(target, "foundry.toml")):
217-
return False
218-
219-
return os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
220-
os.path.join(target, "hardhat.config.ts")
215+
return (
216+
os.path.isfile(os.path.join(target, "hardhat.config.js"))
217+
or os.path.isfile(os.path.join(target, "hardhat.config.ts"))
218+
or os.path.isfile(os.path.join(target, "hardhat.config.cjs"))
221219
)
222220

223221
def is_dependency(self, path: str) -> bool:

crytic_compile/platform/truffle.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,6 @@ def is_supported(target: str, **kwargs: str) -> bool:
305305
if truffle_ignore:
306306
return False
307307

308-
# Avoid conflicts with hardhat
309-
if os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
310-
os.path.join(target, "hardhat.config.ts")
311-
):
312-
return False
313-
314308
return os.path.isfile(os.path.join(target, "truffle.js")) or os.path.isfile(
315309
os.path.join(target, "truffle-config.js")
316310
)

crytic_compile/platform/types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,24 @@ def __str__(self) -> str: # pylint: disable=too-many-branches
6666
if self == Type.FOUNDRY:
6767
return "Foundry"
6868
raise ValueError
69+
70+
def priority(self) -> int:
71+
"""Return the priority for a certain platform.
72+
73+
A lower priority means the platform is more preferable. This is used to
74+
consistently select a platform when two or more are available.
75+
76+
Returns:
77+
int: priority number
78+
"""
79+
80+
if self == Type.FOUNDRY:
81+
return 100
82+
83+
if self == Type.HARDHAT:
84+
return 200
85+
86+
if self in [Type.TRUFFLE, Type.WAFFLE]:
87+
return 300
88+
89+
return 1000

crytic_compile/platform/waffle.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,6 @@ def is_supported(target: str, **kwargs: str) -> bool:
245245
if waffle_ignore:
246246
return False
247247

248-
# Avoid conflicts with hardhat
249-
if os.path.isfile(os.path.join(target, "hardhat.config.js")) | os.path.isfile(
250-
os.path.join(target, "hardhat.config.ts")
251-
):
252-
return False
253-
254248
if os.path.isfile(os.path.join(target, "waffle.json")) or os.path.isfile(
255249
os.path.join(target, ".waffle.json")
256250
):

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
license="AGPL-3.0",
3737
long_description=long_description,
38+
long_description_content_type="text/markdown",
3839
package_data={"crytic_compile": ["py.typed"]},
3940
entry_points={"console_scripts": ["crytic-compile = crytic_compile.__main__:main"]},
4041
)

0 commit comments

Comments
 (0)