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

Refactor ERC721 operator approvals to an internal function #2870

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions contracts/token/ERC721/ERC721.sol
Expand Up @@ -135,8 +135,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");

_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
_setOperatorApproval(_msgSender(), operator, approved);
}

/**
Expand Down Expand Up @@ -356,6 +355,20 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}

/**
* @dev Approve or revoke approval from `operator` to operate on all tokens owned by `owner`
*
* Emits a {ApprovalForAll} event.
*/
function _setOperatorApproval(
address owner,
address operator,
bool approved
) internal virtual {
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}

/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
Expand Down