-
Notifications
You must be signed in to change notification settings - Fork 89
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
Improve NatSpec documentation #18
Conversation
src/MultiOwnable.sol
Outdated
/// NOTE: `uint256` rather than a smaller uint because it provides flexibility, | ||
/// in that we will practically never run out of indices. | ||
/// | ||
/// In the context of checking whether something was signed by an owner this |
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 is not true in the normal ethereum address case because ecrecover returns the address
src/MultiOwnable.sol
Outdated
mapping(bytes => bool) isOwner; | ||
/// @dev Mapping of indices to raw owner bytes, used to idenfitied owners by their | ||
/// uint256 id (to economize calldata). | ||
/// NOTE: `uint256` rather than a smaller uint because it provides flexibility, |
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 think it's important to explain the "flexibility at little to no cost"
src/MultiOwnable.sol
Outdated
function _addOwnerAtIndex(bytes memory owner, uint256 index) internal virtual { | ||
if (isOwnerBytes(owner)) revert AlreadyOwner(owner); | ||
|
||
_getMultiOwnableStorage().isOwner[owner] = true; | ||
_getMultiOwnableStorage().ownerAtIndex[index] = owner; | ||
|
||
emit AddOwner(index, owner); | ||
emit AddOwner({index: index, owner: owner}); |
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.
what's the thought here? We don't use type args elsewhere?
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.
No we don't but I think we should use them more. It helps for readability and increase confidence about writing sound contracts (avoid swapping params).
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 actually think they are more cluttering than helpful. We should lean on good variable names to avoid swapping params
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.
yeah I find it redundant here and we should be consistent with our events
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 understand your point and agree that it might be redundant, so I will remove them.
However, from my experience, using named parameters has the great benefit of ensuring, without any context about what the function does, nor about its parameter names and types, that the call is most likely correct. When conducting code reviews, I find it much easier to read, as I don't have to hop between the function definition and the function call to make sure the developer wrote what they really intended. You don't have to be a skilled auditor to notice that transfer({to: from, from: to, amount: amount})
is incorrect, which I believe is important if we want to provide secure and foolproof open-source 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.
Yes thanks @xenoliss, let's file these away for our style guide discussion, after which we can commit to using the same approach in all places
src/CoinbaseSmartWalletFactory.sol
Outdated
function initCodeHash() public view virtual returns (bytes32 result) { | ||
result = LibClone.initCodeHashERC1967(implementation); | ||
} | ||
|
||
/// @dev Returns the salt that will be used for deterministic address | ||
/// @notice Returns the salt that will be / was used to deploy the account (using create2). |
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 think this reads more clearly:
/// @notice Returns the salt that will be / was used to deploy the account (using create2). | |
/// @notice Returns the deterministic salt for a specific set of `owners` and `nonce` |
src/ERC1271.sol
Outdated
/// @notice Validate the `signature` against the given `message`. | ||
/// | ||
/// @dev MUST be defined by the implementation. | ||
/// @dev The `signature` content MIGHT NOT necessarily be the usual (r,s,v) values. It is the responsability |
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.
/// @dev The `signature` content MIGHT NOT necessarily be the usual (r,s,v) values. It is the responsability | |
/// @dev The `signature` content MIGHT NOT necessarily be the usual (r,s,v) values. It is the responsibility |
src/MultiOwnable.sol
Outdated
0x97e2c6aad4ce5d562ebfaa00db6b9e0fb66ea5d8162ed5b243f51a2e03086f00; | ||
|
||
/// @notice Reverted when the sender is not an owner and is trying to call a privileged function. |
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.
Picking up where the comments ended on the previous pr...
This reads weird to me still. The errors aren't reverting; they are being thrown when reverting. I won't die on this hill but i'm not a fan.
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.
Yeah I think "thrown when" might be better phrasing :)
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.
Alright going to update to "thrown when".
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.
Still thinking about this, given the call is revert error()
rather than throw error()
maybe @xenoliss had this right 🤔
Although the docs use thrown so let's stick with it
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'm used to Reverted when XXX
so I am defiitely biased but when re-reading the docs it is true that errors are not "reverted"; the state is.
src/MultiOwnable.sol
Outdated
function _addOwnerAtIndex(bytes memory owner, uint256 index) internal virtual { | ||
if (isOwnerBytes(owner)) revert AlreadyOwner(owner); | ||
|
||
_getMultiOwnableStorage().isOwner[owner] = true; | ||
_getMultiOwnableStorage().ownerAtIndex[index] = owner; | ||
|
||
emit AddOwner(index, owner); | ||
emit AddOwner({index: index, owner: owner}); |
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 actually think they are more cluttering than helpful. We should lean on good variable names to avoid swapping params
I removed the usage of named parameters in the last commit bd548a8. I think we're good to merge. |
This PR generally improves NatSpec doc on the contracts and replaces PR #17