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

Emit Approval events from burnFrom and transferFrom (Closes #74) #81

Merged
merged 2 commits into from
Jan 29, 2019
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
2 changes: 2 additions & 0 deletions contracts/token/ERC20/ExternalERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ contract ExternalERC20 is IERC20 {
_externalERC20Storage.allowed(from, originSender).sub(value)
);
_transfer(from, to, value);
emit Approval(from, originSender, _externalERC20Storage.allowed(from, originSender));
}

/**
Expand Down Expand Up @@ -283,5 +284,6 @@ contract ExternalERC20 is IERC20 {
_externalERC20Storage.allowed(account, burner).sub(value)
);
_burn(account, value);
emit Approval(account, burner, _externalERC20Storage.allowed(account, burner));
}
}
27 changes: 21 additions & 6 deletions test/token/ERC20/behaviors/ERC20.public.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,28 @@ function shouldBehaveLikeERC20PublicAPI (owner, recipient, anotherAccount) {
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(0);
});

it('emits a transfer event', async function () {
const { logs } = await this.token.transferFrom(owner, to, amount, { from: spender });
describe('emits', function () {
let events;

expectEvent.inLogs(logs, 'Transfer', {
from: owner,
to: to,
value: amount
beforeEach(async function () {
const { logs } = await this.token.transferFrom(owner, to, amount, { from: spender });
events = logs;
});

it('a transfer event', async function () {
expectEvent.inLogs(events, 'Transfer', {
from: owner,
to: to,
value: amount
});
});

it('an approval event', async function () {
expectEvent.inLogs(events, 'Approval', {
owner: owner,
spender: spender,
value: 0
});
});
});
});
Expand Down
8 changes: 8 additions & 0 deletions test/token/ERC20/behaviors/ERC20Burnable.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
value: amount
});
});

it('emits an approval event', async function () {
expectEvent.inLogs(this.logs, 'Approval', {
owner: owner,
spender: burner,
value: originalAllowance - amount
});
});
}
});

Expand Down