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

Fetch @notice comments from contract to add them as explanation of the functions #111

Open
Pabl0cks opened this issue Jun 17, 2024 · 2 comments

Comments

@Pabl0cks
Copy link
Member

Just realized Etherscan had this feature and I think it would be nice to have it too. Maybe is only possible for verified contracts?

The only thing that scares me is it could be exploitable by bad actors, giving a secure feeling to the user, and doing different malicious stuff in the code.

Example:

etherscan-comments-1

etherscan-comments-2

@Pabl0cks Pabl0cks changed the title Fetch @notice comments from contract and add them as explanation of the functions. Fetch @notice comments from contract to add them as explanation of the functions. Jun 17, 2024
@Pabl0cks Pabl0cks changed the title Fetch @notice comments from contract to add them as explanation of the functions. Fetch @notice comments from contract to add them as explanation of the functions Jun 17, 2024
@lukaw3d
Copy link
Contributor

lukaw3d commented Jun 17, 2024

anyabi.xyz doesn't return enough data for this - Sourcify API would return userdoc and devdoc fields. For sourcify you might be able to use some code from @ethereum-sourcify/contract-call-decoder for it (tho it might get deprecated ethereum/sourcify#1388 (comment))

https://github.com/ethereum/sourcify/blob/d31d9f54d638785dedd708a2d1d9340fd1324c7e/packages/contract-call-decoder/src/lib/ContractCallDecoder.ts#L171

@Pabl0cks
Copy link
Member Author

anyabi.xyz doesn't return enough data for this - Sourcify API would return userdoc and devdoc fields. For sourcify you might be able to use some code from @ethereum-sourcify/contract-call-decoder for it (tho it might get deprecated ethereum/sourcify#1388 (comment))

https://github.com/ethereum/sourcify/blob/d31d9f54d638785dedd708a2d1d9340fd1324c7e/packages/contract-call-decoder/src/lib/ContractCallDecoder.ts#L171

Thanks a lot for the deep insights! 🙌

I think we could get source code from Etherscan API changing action parameter to getsourcecode instead of getabi, but then we'd need to always do the Etherscan API call, and change the parsing logic.

I feel downsides might be greater than the UX benefits 😥

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

No branches or pull requests

2 participants