Commit 964bc404 by Leo Arias Committed by Francisco Giordano

Remove underscores from event parameters. (#1258)

* Remove underscores from event parameters.

Fixes #1175

* Add comment about ERC
parent 4385fd5a
...@@ -24,6 +24,12 @@ Any exception or additions specific to our project are documented below. ...@@ -24,6 +24,12 @@ Any exception or additions specific to our project are documented below.
} }
``` ```
The exception are the parameters of events. There is no chance of ambiguity
with these, so they should not have underscores. Not even if they are
specified on an ERC with underscores; removing them doesn't change the ABI,
so we should be consistent with the rest of the events in this repository
and remove them.
* Internal and private state variables should have an underscore suffix. * Internal and private state variables should have an underscore suffix.
``` ```
......
...@@ -8,11 +8,11 @@ contract ERC721ReceiverMock is IERC721Receiver { ...@@ -8,11 +8,11 @@ contract ERC721ReceiverMock is IERC721Receiver {
bool internal reverts_; bool internal reverts_;
event Received( event Received(
address _operator, address operator,
address _from, address from,
uint256 _tokenId, uint256 tokenId,
bytes _data, bytes data,
uint256 _gas uint256 gas
); );
constructor(bytes4 _retval, bool _reverts) public { constructor(bytes4 _retval, bool _reverts) public {
......
...@@ -40,19 +40,19 @@ contract IERC721Basic is IERC165 { ...@@ -40,19 +40,19 @@ contract IERC721Basic is IERC165 {
*/ */
event Transfer( event Transfer(
address indexed _from, address indexed from,
address indexed _to, address indexed to,
uint256 indexed _tokenId uint256 indexed tokenId
); );
event Approval( event Approval(
address indexed _owner, address indexed owner,
address indexed _approved, address indexed approved,
uint256 indexed _tokenId uint256 indexed tokenId
); );
event ApprovalForAll( event ApprovalForAll(
address indexed _owner, address indexed owner,
address indexed _operator, address indexed operator,
bool _approved bool approved
); );
function balanceOf(address _owner) public view returns (uint256 _balance); function balanceOf(address _owner) public view returns (uint256 _balance);
......
...@@ -92,17 +92,17 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -92,17 +92,17 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emit only a transfer event', async function () { it('emit only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args.from.should.be.equal(owner);
logs[0].args._to.should.be.equal(this.to); logs[0].args.to.should.be.equal(this.to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
} else { } else {
it('emits only a transfer event', async function () { it('emits only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args.from.should.be.equal(owner);
logs[0].args._to.should.be.equal(this.to); logs[0].args.to.should.be.equal(this.to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
} }
...@@ -167,9 +167,9 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -167,9 +167,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emits only a transfer event', async function () { it('emits only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args.from.should.be.equal(owner);
logs[0].args._to.should.be.equal(owner); logs[0].args.to.should.be.equal(owner);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
it('keeps the owner balance', async function () { it('keeps the owner balance', async function () {
...@@ -247,10 +247,10 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -247,10 +247,10 @@ function shouldBehaveLikeERC721Basic (accounts) {
result.receipt.logs.length.should.be.equal(2); result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address); const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.equal('Received'); log.event.should.be.equal('Received');
log.args._operator.should.be.equal(owner); log.args.operator.should.be.equal(owner);
log.args._from.should.be.equal(owner); log.args.from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId); log.args.tokenId.toNumber().should.be.equal(tokenId);
log.args._data.should.be.equal(data); log.args.data.should.be.equal(data);
}); });
it('should call onERC721Received from approved', async function () { it('should call onERC721Received from approved', async function () {
...@@ -258,10 +258,10 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -258,10 +258,10 @@ function shouldBehaveLikeERC721Basic (accounts) {
result.receipt.logs.length.should.be.equal(2); result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address); const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.equal('Received'); log.event.should.be.equal('Received');
log.args._operator.should.be.equal(approved); log.args.operator.should.be.equal(approved);
log.args._from.should.be.equal(owner); log.args.from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId); log.args.tokenId.toNumber().should.be.equal(tokenId);
log.args._data.should.be.equal(data); log.args.data.should.be.equal(data);
}); });
describe('with an invalid token id', function () { describe('with an invalid token id', function () {
...@@ -334,9 +334,9 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -334,9 +334,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emits an approval event', async function () { it('emits an approval event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Approval'); logs[0].event.should.be.equal('Approval');
logs[0].args._owner.should.be.equal(sender); logs[0].args.owner.should.be.equal(sender);
logs[0].args._approved.should.be.equal(address); logs[0].args.approved.should.be.equal(address);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
}; };
...@@ -447,9 +447,9 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -447,9 +447,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args.owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args.operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true); logs[0].args.approved.should.equal(true);
}); });
}); });
...@@ -469,9 +469,9 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -469,9 +469,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args.owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args.operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true); logs[0].args.approved.should.equal(true);
}); });
it('can unset the operator approval', async function () { it('can unset the operator approval', async function () {
...@@ -497,9 +497,9 @@ function shouldBehaveLikeERC721Basic (accounts) { ...@@ -497,9 +497,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args.owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args.operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true); logs[0].args.approved.should.equal(true);
}); });
}); });
}); });
......
...@@ -40,9 +40,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) { ...@@ -40,9 +40,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) {
it('emits a transfer event', async function () { it('emits a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(ZERO_ADDRESS); logs[0].args.from.should.be.equal(ZERO_ADDRESS);
logs[0].args._to.should.be.equal(to); logs[0].args.to.should.be.equal(to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
}); });
...@@ -78,9 +78,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) { ...@@ -78,9 +78,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) {
it('emits a burn event', async function () { it('emits a burn event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(sender); logs[0].args.from.should.be.equal(sender);
logs[0].args._to.should.be.equal(ZERO_ADDRESS); logs[0].args.to.should.be.equal(ZERO_ADDRESS);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment