Skip to content

Style: Improve readability on ERC 721 parameter naming in approval functions #67

@farismln

Description

@farismln

Compose aim for onchain readability, with that in mind I want to propose some change on the current ERC 721 parameter naming in approval function.

The parameter name _approved is used in both approve and setApprovalForAll but it is represent two different data types (address and boolean):

    function approve(address _approved, uint256 _tokenId) external {
...
@>      s.approved[_tokenId] = _approved;
        emit Approval(owner, _approved, _tokenId);
    }

    function setApprovalForAll(address _operator, bool _approved) external {
        if (_operator == address(0)) {
            revert ERC721InvalidOperator(_operator);
        }
@>      getStorage().isApprovedForAll[msg.sender][_operator] = _approved;
        emit ApprovalForAll(msg.sender, _operator, _approved);
    }

Recommendation:

  1. _approved used for boolean parameter. (no change in current implementation of setApprovalForAll)
  2. _operator or _to is used for address parameter. this is the only change. affect only the approve function

Note: this deviate from EIP-721 interface examples, but it does not necessarily became non-compliant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions