Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
1c053245
Unverified
Commit
1c053245
authored
Aug 28, 2018
by
Leo Arias
Committed by
GitHub
Aug 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename events to past-tense (#1181)
parent
132994d2
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
38 additions
and
25 deletions
+38
-25
CODE_STYLE.md
CODE_STYLE.md
+17
-4
Crowdsale.sol
contracts/crowdsale/Crowdsale.sol
+2
-2
FinalizableCrowdsale.sol
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
+2
-2
Pausable.sol
contracts/lifecycle/Pausable.sol
+4
-4
BurnableToken.sol
contracts/token/ERC20/BurnableToken.sol
+2
-2
AllowanceCrowdsale.test.js
test/crowdsale/AllowanceCrowdsale.test.js
+1
-1
Crowdsale.test.js
test/crowdsale/Crowdsale.test.js
+2
-2
FinalizableCrowdsale.test.js
test/crowdsale/FinalizableCrowdsale.test.js
+1
-1
MintedCrowdsale.behavior.js
test/crowdsale/MintedCrowdsale.behavior.js
+1
-1
Pausable.test.js
test/lifecycle/Pausable.test.js
+2
-2
BurnableToken.behavior.js
test/token/ERC20/BurnableToken.behavior.js
+2
-2
PausableToken.test.js
test/token/ERC20/PausableToken.test.js
+2
-2
No files found.
CODE_STYLE.md
View file @
1c053245
...
@@ -18,8 +18,21 @@ Any exception or additions specific to our project are documented below.
...
@@ -18,8 +18,21 @@ Any exception or additions specific to our project are documented below.
*
Parameters must be prefixed with an underscore.
*
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.
contracts/crowdsale/Crowdsale.sol
View file @
1c053245
...
@@ -43,7 +43,7 @@ contract Crowdsale {
...
@@ -43,7 +43,7 @@ contract Crowdsale {
* @param value weis paid for purchase
* @param value weis paid for purchase
* @param amount amount of tokens purchased
* @param amount amount of tokens purchased
*/
*/
event Token
Purchase
(
event Token
sPurchased
(
address indexed purchaser,
address indexed purchaser,
address indexed beneficiary,
address indexed beneficiary,
uint256 value,
uint256 value,
...
@@ -92,7 +92,7 @@ contract Crowdsale {
...
@@ -92,7 +92,7 @@ contract Crowdsale {
weiRaised = weiRaised.add(weiAmount);
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
_processPurchase(_beneficiary, tokens);
emit Token
Purchase
(
emit Token
sPurchased
(
msg.sender,
msg.sender,
_beneficiary,
_beneficiary,
weiAmount,
weiAmount,
...
...
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
View file @
1c053245
...
@@ -15,7 +15,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
...
@@ -15,7 +15,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
bool public isFinalized = false;
bool public isFinalized = false;
event Finalized();
event
Crowdsale
Finalized();
/**
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* @dev Must be called after crowdsale ends, to do some extra finalization
...
@@ -26,7 +26,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
...
@@ -26,7 +26,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
require(hasClosed());
require(hasClosed());
finalization();
finalization();
emit Finalized();
emit
Crowdsale
Finalized();
isFinalized = true;
isFinalized = true;
}
}
...
...
contracts/lifecycle/Pausable.sol
View file @
1c053245
...
@@ -9,8 +9,8 @@ import "../ownership/Ownable.sol";
...
@@ -9,8 +9,8 @@ import "../ownership/Ownable.sol";
* @dev Base contract which allows children to implement an emergency stop mechanism.
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
*/
contract Pausable is Ownable {
contract Pausable is Ownable {
event Pause();
event Pause
d
();
event Unpause();
event Unpause
d
();
bool public paused = false;
bool public paused = false;
...
@@ -36,7 +36,7 @@ contract Pausable is Ownable {
...
@@ -36,7 +36,7 @@ contract Pausable is Ownable {
*/
*/
function pause() public onlyOwner whenNotPaused {
function pause() public onlyOwner whenNotPaused {
paused = true;
paused = true;
emit Pause();
emit Pause
d
();
}
}
/**
/**
...
@@ -44,6 +44,6 @@ contract Pausable is Ownable {
...
@@ -44,6 +44,6 @@ contract Pausable is Ownable {
*/
*/
function unpause() public onlyOwner whenPaused {
function unpause() public onlyOwner whenPaused {
paused = false;
paused = false;
emit Unpause();
emit Unpause
d
();
}
}
}
}
contracts/token/ERC20/BurnableToken.sol
View file @
1c053245
...
@@ -9,7 +9,7 @@ import "./StandardToken.sol";
...
@@ -9,7 +9,7 @@ import "./StandardToken.sol";
*/
*/
contract BurnableToken is StandardToken {
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.
* @dev Burns a specific amount of tokens.
...
@@ -34,6 +34,6 @@ contract BurnableToken is StandardToken {
...
@@ -34,6 +34,6 @@ contract BurnableToken is StandardToken {
*/
*/
function _burn(address _who, uint256 _value) internal {
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
super._burn(_who, _value);
emit
Burn
(_who, _value);
emit
TokensBurned
(_who, _value);
}
}
}
}
test/crowdsale/AllowanceCrowdsale.test.js
View file @
1c053245
...
@@ -37,7 +37,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
...
@@ -37,7 +37,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe
(
'high-level purchase'
,
function
()
{
describe
(
'high-level purchase'
,
function
()
{
it
(
'should log purchase'
,
async
function
()
{
it
(
'should log purchase'
,
async
function
()
{
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
Purchase
'
);
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
sPurchased
'
);
should
.
exist
(
event
);
should
.
exist
(
event
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
...
...
test/crowdsale/Crowdsale.test.js
View file @
1c053245
...
@@ -82,7 +82,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -82,7 +82,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
describe
(
'high-level purchase'
,
function
()
{
describe
(
'high-level purchase'
,
function
()
{
it
(
'should log purchase'
,
async
function
()
{
it
(
'should log purchase'
,
async
function
()
{
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
Purchase
'
);
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
sPurchased
'
);
should
.
exist
(
event
);
should
.
exist
(
event
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
...
@@ -106,7 +106,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -106,7 +106,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
describe
(
'low-level purchase'
,
function
()
{
describe
(
'low-level purchase'
,
function
()
{
it
(
'should log purchase'
,
async
function
()
{
it
(
'should log purchase'
,
async
function
()
{
const
{
logs
}
=
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
});
const
{
logs
}
=
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
});
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
Purchase
'
);
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
sPurchased
'
);
should
.
exist
(
event
);
should
.
exist
(
event
);
event
.
args
.
purchaser
.
should
.
equal
(
purchaser
);
event
.
args
.
purchaser
.
should
.
equal
(
purchaser
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
...
...
test/crowdsale/FinalizableCrowdsale.test.js
View file @
1c053245
...
@@ -56,7 +56,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
...
@@ -56,7 +56,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
it
(
'logs finalized'
,
async
function
()
{
it
(
'logs finalized'
,
async
function
()
{
await
increaseTimeTo
(
this
.
afterClosingTime
);
await
increaseTimeTo
(
this
.
afterClosingTime
);
const
{
logs
}
=
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
const
{
logs
}
=
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Finalized'
);
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'
Crowdsale
Finalized'
);
should
.
exist
(
event
);
should
.
exist
(
event
);
});
});
});
});
test/crowdsale/MintedCrowdsale.behavior.js
View file @
1c053245
...
@@ -20,7 +20,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
...
@@ -20,7 +20,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
describe
(
'high-level purchase'
,
function
()
{
describe
(
'high-level purchase'
,
function
()
{
it
(
'should log purchase'
,
async
function
()
{
it
(
'should log purchase'
,
async
function
()
{
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
{
logs
}
=
await
this
.
crowdsale
.
sendTransaction
({
value
:
value
,
from
:
investor
});
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
Purchase
'
);
const
event
=
logs
.
find
(
e
=>
e
.
event
===
'Token
sPurchased
'
);
should
.
exist
(
event
);
should
.
exist
(
event
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
purchaser
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
event
.
args
.
beneficiary
.
should
.
equal
(
investor
);
...
...
test/lifecycle/Pausable.test.js
View file @
1c053245
...
@@ -57,9 +57,9 @@ contract('Pausable', function () {
...
@@ -57,9 +57,9 @@ contract('Pausable', function () {
it
(
'should log Pause and Unpause events appropriately'
,
async
function
()
{
it
(
'should log Pause and Unpause events appropriately'
,
async
function
()
{
const
setPauseLogs
=
(
await
this
.
Pausable
.
pause
()).
logs
;
const
setPauseLogs
=
(
await
this
.
Pausable
.
pause
()).
logs
;
expectEvent
.
inLogs
(
setPauseLogs
,
'Pause'
);
expectEvent
.
inLogs
(
setPauseLogs
,
'Pause
d
'
);
const
setUnPauseLogs
=
(
await
this
.
Pausable
.
unpause
()).
logs
;
const
setUnPauseLogs
=
(
await
this
.
Pausable
.
unpause
()).
logs
;
expectEvent
.
inLogs
(
setUnPauseLogs
,
'Unpause'
);
expectEvent
.
inLogs
(
setUnPauseLogs
,
'Unpause
d
'
);
});
});
});
});
test/token/ERC20/BurnableToken.behavior.js
View file @
1c053245
...
@@ -29,7 +29,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
...
@@ -29,7 +29,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
});
});
it
(
'emits a burn event'
,
async
function
()
{
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
.
burner
.
should
.
equal
(
owner
);
event
.
args
.
value
.
should
.
be
.
bignumber
.
equal
(
amount
);
event
.
args
.
value
.
should
.
be
.
bignumber
.
equal
(
amount
);
});
});
...
@@ -80,7 +80,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
...
@@ -80,7 +80,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
});
});
it
(
'emits a burn event'
,
async
function
()
{
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
.
burner
.
should
.
equal
(
owner
);
event
.
args
.
value
.
should
.
be
.
bignumber
.
equal
(
amount
);
event
.
args
.
value
.
should
.
be
.
bignumber
.
equal
(
amount
);
});
});
...
...
test/token/ERC20/PausableToken.test.js
View file @
1c053245
...
@@ -20,7 +20,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
...
@@ -20,7 +20,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
const
{
logs
}
=
await
this
.
token
.
pause
({
from
});
const
{
logs
}
=
await
this
.
token
.
pause
({
from
});
logs
.
length
.
should
.
equal
(
1
);
logs
.
length
.
should
.
equal
(
1
);
logs
[
0
].
event
.
should
.
equal
(
'Pause'
);
logs
[
0
].
event
.
should
.
equal
(
'Pause
d
'
);
});
});
});
});
...
@@ -62,7 +62,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
...
@@ -62,7 +62,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
const
{
logs
}
=
await
this
.
token
.
unpause
({
from
});
const
{
logs
}
=
await
this
.
token
.
unpause
({
from
});
logs
.
length
.
should
.
equal
(
1
);
logs
.
length
.
should
.
equal
(
1
);
logs
[
0
].
event
.
should
.
equal
(
'Unpause'
);
logs
[
0
].
event
.
should
.
equal
(
'Unpause
d
'
);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment