Unverified Commit 1c053245 by Leo Arias Committed by GitHub

Rename events to past-tense (#1181)

parent 132994d2
......@@ -18,8 +18,21 @@ Any exception or additions specific to our project are documented below.
* Parameters must be prefixed with an underscore.
```
function test(uint256 _testParameter1, uint256 _testParameter2) {
```
function test(uint256 _testParameter1, uint256 _testParameter2) {
...
}
```
}
```
* Events should be emitted immediately after the state change that they
represent, and consequently they should be named in past tense.
```
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
emit TokensBurned(_who, _value);
}
```
Some standards (e.g. ERC20) use present tense, and in those cases the
standard specification prevails.
......@@ -43,7 +43,7 @@ contract Crowdsale {
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(
event TokensPurchased(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
......@@ -92,7 +92,7 @@ contract Crowdsale {
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
emit TokensPurchased(
msg.sender,
_beneficiary,
weiAmount,
......@@ -111,7 +111,7 @@ contract Crowdsale {
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
* super._preValidatePurchase(_beneficiary, _weiAmount);
* require(weiRaised.add(_weiAmount) <= cap);
* @param _beneficiary Address performing the token purchase
......
......@@ -15,7 +15,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
bool public isFinalized = false;
event Finalized();
event CrowdsaleFinalized();
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
......@@ -26,7 +26,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
require(hasClosed());
finalization();
emit Finalized();
emit CrowdsaleFinalized();
isFinalized = true;
}
......
......@@ -9,8 +9,8 @@ import "../ownership/Ownable.sol";
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
event Paused();
event Unpaused();
bool public paused = false;
......@@ -36,7 +36,7 @@ contract Pausable is Ownable {
*/
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
emit Paused();
}
/**
......@@ -44,6 +44,6 @@ contract Pausable is Ownable {
*/
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpause();
emit Unpaused();
}
}
......@@ -9,7 +9,7 @@ import "./StandardToken.sol";
*/
contract BurnableToken is StandardToken {
event Burn(address indexed burner, uint256 value);
event TokensBurned(address indexed burner, uint256 value);
/**
* @dev Burns a specific amount of tokens.
......@@ -34,6 +34,6 @@ contract BurnableToken is StandardToken {
*/
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
emit Burn(_who, _value);
emit TokensBurned(_who, _value);
}
}
......@@ -37,7 +37,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe('high-level purchase', function () {
it('should log purchase', async function () {
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase');
const event = logs.find(e => e.event === 'TokensPurchased');
should.exist(event);
event.args.purchaser.should.equal(investor);
event.args.beneficiary.should.equal(investor);
......
......@@ -82,7 +82,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
describe('high-level purchase', function () {
it('should log purchase', async function () {
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase');
const event = logs.find(e => e.event === 'TokensPurchased');
should.exist(event);
event.args.purchaser.should.equal(investor);
event.args.beneficiary.should.equal(investor);
......@@ -106,7 +106,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
describe('low-level purchase', function () {
it('should log purchase', async function () {
const { logs } = await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
const event = logs.find(e => e.event === 'TokenPurchase');
const event = logs.find(e => e.event === 'TokensPurchased');
should.exist(event);
event.args.purchaser.should.equal(purchaser);
event.args.beneficiary.should.equal(investor);
......
......@@ -56,7 +56,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
it('logs finalized', async function () {
await increaseTimeTo(this.afterClosingTime);
const { logs } = await this.crowdsale.finalize({ from: owner });
const event = logs.find(e => e.event === 'Finalized');
const event = logs.find(e => e.event === 'CrowdsaleFinalized');
should.exist(event);
});
});
......@@ -20,7 +20,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
describe('high-level purchase', function () {
it('should log purchase', async function () {
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase');
const event = logs.find(e => e.event === 'TokensPurchased');
should.exist(event);
event.args.purchaser.should.equal(investor);
event.args.beneficiary.should.equal(investor);
......
......@@ -57,9 +57,9 @@ contract('Pausable', function () {
it('should log Pause and Unpause events appropriately', async function () {
const setPauseLogs = (await this.Pausable.pause()).logs;
expectEvent.inLogs(setPauseLogs, 'Pause');
expectEvent.inLogs(setPauseLogs, 'Paused');
const setUnPauseLogs = (await this.Pausable.unpause()).logs;
expectEvent.inLogs(setUnPauseLogs, 'Unpause');
expectEvent.inLogs(setUnPauseLogs, 'Unpaused');
});
});
......@@ -29,7 +29,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
});
it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
const event = expectEvent.inLogs(this.logs, 'TokensBurned');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});
......@@ -80,7 +80,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
});
it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
const event = expectEvent.inLogs(this.logs, 'TokensBurned');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});
......
......@@ -20,7 +20,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
const { logs } = await this.token.pause({ from });
logs.length.should.equal(1);
logs[0].event.should.equal('Pause');
logs[0].event.should.equal('Paused');
});
});
......@@ -62,7 +62,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
const { logs } = await this.token.unpause({ from });
logs.length.should.equal(1);
logs[0].event.should.equal('Unpause');
logs[0].event.should.equal('Unpaused');
});
});
......
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