-
Notifications
You must be signed in to change notification settings - Fork 166
Feat/59 add natspec descriptions #549
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
base: master
Are you sure you want to change the base?
Feat/59 add natspec descriptions #549
Conversation
… improved documentation and clarity
…es for cleaner code.
…y by removing redundant comments.
…ents for improved code clarity.
All contributors have signed the CLA ✍️ ✅ |
I confirm that I have read and hereby agree to the OpenZeppelin Contributor License Agreement |
Hey @mrscottyrose thanks for your MR ✨ Some considerations, when adding NatSpec we qwould probably want to align both content and formatting with what is found on the contract library here is an example Let's wait for @OpenZeppelin/contracts input for defining the content of the comments. |
@@ -0,0 +1,2 @@ | |||
--- |
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.
Missing detailed change-set description
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.
I like the idea at first. But I would prefer NatSpec documentation to be well thought and to provide useful information that's not available already in the documentation of the internal functions.
Since Wizard is a tool for developers, most of the information they'd need shows up on IDEs

Concretely, I'd avoid using @param
and @return
tags since they bloat the result with things like
/// @dev Executes a call to target with value
/// @param target The target that is going to be called
/// @param value The value to be sent
/// @param data The data to call with
function execute(address target, uint256 value, bytes data)
Instead, I think developers would benefit if we have more insightful descriptions in strategic functions (those not obvious). For example
/// @dev Performs a `call` to the `target` address. Consider override this function
/// to check if the target has code (_execute allows calling EOAs)
function execute(address target, uint256 value, bytes data) {
_execute(target, value, data);
}
c.setFunctionComments( | ||
[ | ||
`// IMPORTANT: Make sure Signer${opts.signer} is most derived than AccountERC7579`, | ||
`// in the inheritance chain (i.e. contract ... is AccountERC7579, ..., Signer${opts.signer})`, | ||
'// to ensure the correct order of function resolution.', | ||
'// AccountERC7579 returns false for `_rawSignatureValidation`', | ||
], | ||
signerFunctions._rawSignatureValidation, | ||
); |
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.
Any reason to remove this? It's an important consideration for anyone copy pastes the code
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.
Sorry for that. I have reverted it back
I've tried to resolve it according to the requirement could you please check and tell me if there's anything i could add or change? |
], | ||
}, | ||
initializeMultisig: { | ||
kind: 'public' as const, | ||
args: [ | ||
{ name: 'signers', type: 'bytes[] memory' }, | ||
{ name: 'threshold', type: 'uint256' }, |
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.
threshold
got removed, but should probably not
packages/core/solidity/src/signer.ts
Outdated
], | ||
}, | ||
initializeMultisigWeighted: { | ||
kind: 'public' as const, | ||
args: [ | ||
{ name: 'signers', type: 'bytes[] memory' }, | ||
{ name: 'signers', type: 'address[] memory' }, |
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.
Let's revert all type changes has it they are out of scope for this MR
Thanks for making changes, please revert any type / number of arguments changes from the MR. |
@CoveMB what about now? I couldn't understand why the netlify checks failed. |
packages/core/solidity/src/signer.ts
Outdated
}, | ||
_rawSignatureValidation: { | ||
kind: 'internal' as const, | ||
args: [ | ||
{ name: 'hash', type: 'bytes32' }, | ||
{ name: 'signature', type: 'bytes calldata' }, | ||
{ name: 'signature', type: 'calldata' }, |
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.
Arguments change are out of scope of this MR
packages/core/solidity/src/erc721.ts
Outdated
}, | ||
|
||
_baseURI: { | ||
kind: 'internal' as const, | ||
args: [], | ||
returns: ['string memory'], | ||
mutability: 'pure' as const, | ||
mutability: 'view' as const, |
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.
Should this mutability be changed? Probably out of scope
@CoveMB are these two changes are enough to merge the mr?? Or I have to change other things also? |
@CoveMB is there anything I need to change? |
@@ -464,8 +498,9 @@ const functions = defineFunctions({ | |||
{ name: 'descriptionHash', type: 'bytes32' }, | |||
], | |||
kind: 'internal', | |||
returns: ['uint48'], |
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.
👆?
packages/core/solidity/src/erc721.ts
Outdated
}, | ||
|
||
tokenURI: { | ||
kind: 'public' as const, | ||
args: [{ name: 'tokenId', type: 'uint256' }], | ||
returns: ['string memory'], | ||
mutability: 'view' as const, | ||
mutability: 'pure' as const, |
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.
👆?
packages/core/solidity/src/erc20.ts
Outdated
], | ||
}, | ||
|
||
mint: { |
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.
Wondering why moving the functions orders here "mint"
packages/core/solidity/src/erc20.ts
Outdated
], | ||
}, | ||
|
||
_spendAllowance: { |
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.
Wondering why adding this function?
packages/core/solidity/src/erc20.ts
Outdated
], | ||
}, | ||
|
||
_burn: { |
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.
Wondering why adding this function?
@ernestognw could you validate/correct the comment's content? |
… add return type for governor function
…n ERC20 contract, updating arguments and comments for clarity
@@ -400,16 +400,6 @@ function addSuperchainERC20(c: ContractBuilder) { | |||
functions._checkTokenBridge, | |||
'pure', | |||
); | |||
c.setFunctionComments( |
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.
This comment text is still relevant for this scenario. It would be fine for it to overwrite the generic function comment for _checkTokenBridge
…n ERC20 contract, updating arguments and comments for clarity
Co-authored-by: Eric Lau <ericglau@outlook.com>
…mrscottyrose/contracts-wizard into fix/59-add-natspec-descriptions
@ericglau sorry I was messing everything again and again. Could you please review the new commit? If there are any changes let me know thanks |
@CoveMB can you review it again? |
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.
Hi @mrscottyrose it seems some comments got added in multiple places for some function (like _rawSignatureValidation
, CLOCL_MODE
..), could you review those and consolidate the comments, in it's current state @openzeppelin/wizard
does not build, to make sure it build you can run yarn prepare
and it should build without errors
…mrscottyrose/contracts-wizard into fix/59-add-natspec-descriptions
…tion in ERC20 contract
@CoveMB can you check now? if everything is alright or not? |
It seem that this comment has not been addressed? (seem like the specialised comment is deleted instead of overriding the general comment) |
Thanks for making the code changes 🦾 you will also need to update the tests as the contract got modified (with the added natspecs) |
@CoveMB I ran the test and some of the tests fails cuz I'm in windows. What should I do? Will I commit the generated test files? |
Adds NatSpec descriptions to generated functions in the Contracts Wizard. This improves code documentation and maintainability by providing clear documentation for all generated functions.
Closes #59