Skip to content
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
6 changes: 6 additions & 0 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

```
Expand Down
10 changes: 5 additions & 5 deletions contracts/mocks/ERC721ReceiverMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ contract ERC721ReceiverMock is IERC721Receiver {
bool reverts_;

event Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data,
uint256 _gas
address operator,
address from,
uint256 tokenId,
bytes data,
uint256 gas
);

constructor(bytes4 _retval, bool _reverts) public {
Expand Down
18 changes: 9 additions & 9 deletions contracts/token/ERC721/IERC721Basic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ contract IERC721Basic is IERC165 {
*/

event Transfer(
address indexed _from,
address indexed _to,
uint256 indexed _tokenId
address indexed from,
address indexed to,
uint256 indexed tokenId
);
event Approval(
address indexed _owner,
address indexed _approved,
uint256 indexed _tokenId
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
event ApprovalForAll(
address indexed _owner,
address indexed _operator,
bool _approved
address indexed owner,
address indexed operator,
bool approved
);

function balanceOf(address _owner) public view returns (uint256 _balance);
Expand Down
58 changes: 29 additions & 29 deletions test/token/ERC721/ERC721Basic.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emit only a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('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[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);
});
} else {
it('emits only a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('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[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);
});
}

Expand Down Expand Up @@ -167,9 +167,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emits only a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('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[0].args.from.should.be.equal(owner);
logs[0].args.to.should.be.equal(owner);
logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
});

it('keeps the owner balance', async function () {
Expand Down Expand Up @@ -247,21 +247,21 @@ function shouldBehaveLikeERC721Basic (accounts) {
result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.equal('Received');
log.args._operator.should.be.equal(owner);
log.args._from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId);
log.args._data.should.be.equal(data);
log.args.operator.should.be.equal(owner);
log.args.from.should.be.equal(owner);
log.args.tokenId.toNumber().should.be.equal(tokenId);
log.args.data.should.be.equal(data);
});

it('should call onERC721Received from approved', async function () {
const result = await transferFun.call(this, owner, this.to, tokenId, { from: approved });
result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.equal('Received');
log.args._operator.should.be.equal(approved);
log.args._from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId);
log.args._data.should.be.equal(data);
log.args.operator.should.be.equal(approved);
log.args.from.should.be.equal(owner);
log.args.tokenId.toNumber().should.be.equal(tokenId);
log.args.data.should.be.equal(data);
});

describe('with an invalid token id', function () {
Expand Down Expand Up @@ -334,9 +334,9 @@ function shouldBehaveLikeERC721Basic (accounts) {
it('emits an approval event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Approval');
logs[0].args._owner.should.be.equal(sender);
logs[0].args._approved.should.be.equal(address);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
logs[0].args.owner.should.be.equal(sender);
logs[0].args.approved.should.be.equal(address);
logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
});
};

Expand Down Expand Up @@ -447,9 +447,9 @@ function shouldBehaveLikeERC721Basic (accounts) {

logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true);
logs[0].args.owner.should.be.equal(sender);
logs[0].args.operator.should.be.equal(operator);
logs[0].args.approved.should.equal(true);
});
});

Expand All @@ -469,9 +469,9 @@ function shouldBehaveLikeERC721Basic (accounts) {

logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true);
logs[0].args.owner.should.be.equal(sender);
logs[0].args.operator.should.be.equal(operator);
logs[0].args.approved.should.equal(true);
});

it('can unset the operator approval', async function () {
Expand All @@ -497,9 +497,9 @@ function shouldBehaveLikeERC721Basic (accounts) {

logs.length.should.be.equal(1);
logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.equal(true);
logs[0].args.owner.should.be.equal(sender);
logs[0].args.operator.should.be.equal(operator);
logs[0].args.approved.should.equal(true);
});
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/token/ERC721/ERC721MintBurn.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) {
it('emits a transfer event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(ZERO_ADDRESS);
logs[0].args._to.should.be.equal(to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
logs[0].args.from.should.be.equal(ZERO_ADDRESS);
logs[0].args.to.should.be.equal(to);
logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
});
});

Expand Down Expand Up @@ -78,9 +78,9 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) {
it('emits a burn event', async function () {
logs.length.should.be.equal(1);
logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(sender);
logs[0].args._to.should.be.equal(ZERO_ADDRESS);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
logs[0].args.from.should.be.equal(sender);
logs[0].args.to.should.be.equal(ZERO_ADDRESS);
logs[0].args.tokenId.should.be.bignumber.equal(tokenId);
});
});

Expand Down