-
Notifications
You must be signed in to change notification settings - Fork 973
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
Generate interface code in new slither.utils.code_generation
#1730
Conversation
pylint is complaining about the following line in returns = ["address" if isinstance(ret.type, UserDefinedType) and isinstance(ret.type.type, Contract)
else str(ret.type) for ret in self.returns] It says |
in `Function.interface_signature_str`
I think this should not be on the core object and should instead be a utility like |
That sounds reasonable enough. Do you think I should start a new util in |
@webthethird That sounds like a good idea |
Rather than on the core objects.
Looks like the failing CI checks related to linting are unrelated to this PR: |
slither.utils.code_generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add tests? (cc @0xalpharush )
Would we just test this by having an input .sol file and an expected output .sol file, and doing a diff between the expected and actual output? |
Adds
Function.interface_signature_str
,Structure.interface_def_str()
andContract.generate_interface()
.The new Contract method uses the other two to generate Solidity code for an interface to the contract.
Still isn't quite as clean as the code @glarregay-tob wrote outside of Slither, which I think handles struct return types better.