Skip to content

Don't emit Approval event when approval is cleared on transfer (#1038) #1039

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

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion contracts/token/ERC721/ERC721BasicToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
require(ownerOf(_tokenId) == _owner);
if (tokenApprovals[_tokenId] != address(0)) {
tokenApprovals[_tokenId] = address(0);
emit Approval(_owner, address(0), _tokenId);
}
}

Expand Down
34 changes: 12 additions & 22 deletions test/token/ERC721/ERC721BasicToken.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,12 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {
});

if (approved) {
it('emits an approval and transfer events', async function () {
logs.length.should.be.equal(2);
logs[0].event.should.be.eq('Approval');
logs[0].args._owner.should.be.equal(owner);
logs[0].args._approved.should.be.equal(ZERO_ADDRESS);
it('emit only a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer');
logs[0].args._from.should.be.equal(owner);
logs[0].args._to.should.be.equal(this.to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);

logs[1].event.should.be.eq('Transfer');
logs[1].args._from.should.be.equal(owner);
logs[1].args._to.should.be.equal(this.to);
logs[1].args._tokenId.should.be.bignumber.equal(tokenId);
});
} else {
it('emits only a transfer event', async function () {
Expand Down Expand Up @@ -201,17 +196,12 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {
approvedAccount.should.be.equal(ZERO_ADDRESS);
});

it('emits an approval and transfer events', async function () {
logs.length.should.be.equal(2);
logs[0].event.should.be.eq('Approval');
logs[0].args._owner.should.be.equal(owner);
logs[0].args._approved.should.be.equal(ZERO_ADDRESS);
it('emits only a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer');
logs[0].args._from.should.be.equal(owner);
logs[0].args._to.should.be.equal(owner);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);

logs[1].event.should.be.eq('Transfer');
logs[1].args._from.should.be.equal(owner);
logs[1].args._to.should.be.equal(owner);
logs[1].args._tokenId.should.be.bignumber.equal(tokenId);
});

it('keeps the owner balance', async function () {
Expand Down Expand Up @@ -287,8 +277,8 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {

it('should call onERC721Received', async function () {
const result = await transferFun.call(this, owner, this.to, tokenId, { from: owner });
result.receipt.logs.length.should.be.equal(3);
const [log] = decodeLogs([result.receipt.logs[2]], ERC721Receiver, this.receiver.address);
result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.eq('Received');
log.args._address.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId);
Expand Down
11 changes: 0 additions & 11 deletions test/token/ERC721/ERC721MintBurn.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ export default function shouldMintAndBurnERC721Token (accounts) {
const approvedAccount = await this.token.getApproved(tokenId);
approvedAccount.should.be.equal(ZERO_ADDRESS);
});

it('emits an approval event', async function () {
logs.length.should.be.equal(2);

logs[0].event.should.be.eq('Approval');
logs[0].args._owner.should.be.equal(sender);
logs[0].args._approved.should.be.equal(ZERO_ADDRESS);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);

logs[1].event.should.be.eq('Transfer');
});
});

describe('when the given token ID was not tracked by this contract', function () {
Expand Down