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

add tool slither-interface #1898

Merged
merged 5 commits into from
May 16, 2023
Merged

Conversation

0xGusMcCrae
Copy link
Contributor

As per issue #1893

This tool outputs an interface file for a given contract input. The input can be a local source file or a deployment address if the contract is verified on etherscan.

Usage:
slither-interface <ContractName> <Source File or Address>

For example:
slither-interface WETH9 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
will output the interface file IWETH9.sol in crytic-export/interfaces.

There are optional flags for unrolling structs or excluding structs/enums/errors/events.

Tests can be found in scripts/ci_test_interface.sh

I believe I did testing/linting correctly, let me know if I need to fix anything.

@0xalpharush
Copy link
Contributor

We need to add "interface" to this list so the test is run in CI

"upgradability"]

@0xGusMcCrae 0xGusMcCrae requested a review from elopez as a code owner May 9, 2023 13:26
@0xGusMcCrae
Copy link
Contributor Author

I'm not sure why the tests are failing on Windows but not Ubuntu. Any ideas?

Is there a different directory structure that's causing it to be unable to find the test contract?

if [ "$DIFF" != "" ]
then
echo "slither-interface test 1 failed"
cat test_1.sol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be crytic-export/interfaces/IWETH9.sol? ditto for the other occurrences below.

@elopez
Copy link
Member

elopez commented May 11, 2023

As for the test failures on Windows, it might be caused by diff picking up on the different line endings. The test_N.sol files commited in the repo have \n endings, and autocrlf is disabled for solidity code in tests/. The files created by slither-interface will have \r\n line endings on Windows -- files are created with open(....'w') i.e. in text mode, which adjusts line endings to the platform specific variant.

You can pass --strip-trailing-cr to diff, which should make it skip the \r when comparing lines and hopefully fix the issue 👍

@montyly
Copy link
Member

montyly commented May 16, 2023

This is great work, thanks @0xGusMcCrae

@montyly montyly merged commit 9185f54 into crytic:dev May 16, 2023
@0xGusMcCrae
Copy link
Contributor Author

Thanks, glad I could help out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants