Skip to content

Commit

Permalink
Implicitly clear ERC721 approval on burn (#3538)
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanOK committed Jul 9, 2022
1 parent 3a1c020 commit 96163c8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@
* `GovernorCompatibilityBravo`: remove unused `using` statements ([#3506](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3506))
* `ERC20`: optimize `_transfer`, `_mint` and `_burn` by using `unchecked` arithmetic when possible. ([#3513](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3513))
* `ERC721`: optimize transfers by making approval clearing implicit instead of emitting an event. ([#3481](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3481))
* `ERC721`: optimize burn by making approval clearing implicit instead of emitting an event. ([#3538](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3538))

### Compatibility Note

Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/ERC721.sol
Expand Up @@ -306,7 +306,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
_beforeTokenTransfer(owner, address(0), tokenId);

// Clear approvals
_approve(address(0), tokenId);
delete _tokenApprovals[tokenId];

_balances[owner] -= 1;
delete _owners[tokenId];
Expand Down
4 changes: 0 additions & 4 deletions test/token/ERC721/ERC721.behavior.js
Expand Up @@ -693,10 +693,6 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
expectEvent(this.receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId: firstTokenId });
});

it('emits an Approval event', function () {
expectEvent(this.receipt, 'Approval', { owner, approved: ZERO_ADDRESS, tokenId: firstTokenId });
});

it('deletes the token', async function () {
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('1');
await expectRevert(
Expand Down

0 comments on commit 96163c8

Please sign in to comment.