-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Open
Milestone
Description
π§ Motivation
OpenZeppelin contracts generally optimise for readability, security, and auditability (at least from my perspective). Therefore, I think using Function Calls with Named Parameters provides a huge value-add to the codebase wrt readability and auditability.
π Details
Example (ERC20Burnable):
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance({owner: account, spender: _msgSender(), amount: amount});
_burn({account: account, amount: amount});
}There might be cases where currently the parameter names coincide (e.g. amount or account above), but I would still consider this a value-add wrt clear readability.
Edit: I also suggest using named parameters for events.
Example (ERC20):
event Transfer(address indexed from, address indexed to, uint256 value);
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer({from: address(0), to: account, value: amount});
_afterTokenTransfer(address(0), account, amount);
}PaulRBerg, ernestognw and CJ42PaulRBerg, ernestognw, nicolasgarcia214 and CJ42
Metadata
Metadata
Assignees
Labels
No labels