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
0ae92d78
Commit
0ae92d78
authored
Oct 18, 2018
by
Santiago Palladino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linter issues
parent
5e69036b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
27 deletions
+51
-27
StandaloneERC20.sol
contracts/examples/StandaloneERC20.sol
+7
-2
StandaloneERC721.sol
contracts/examples/StandaloneERC721.sol
+3
-1
StandardToken.sol
contracts/examples/StandardToken.sol
+4
-1
StandaloneERC20.test.js
test/examples/StandaloneERC20.test.js
+20
-10
StandaloneERC721.test.js
test/examples/StandaloneERC721.test.js
+7
-6
StandardToken.test.js
test/examples/StandardToken.test.js
+10
-7
No files found.
contracts/examples/StandaloneERC20.sol
View file @
0ae92d78
...
@@ -11,7 +11,10 @@ import "../token/ERC20/ERC20Pausable.sol";
...
@@ -11,7 +11,10 @@ import "../token/ERC20/ERC20Pausable.sol";
*
*
*/
*/
contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
function initialize(string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder, address[] minters, address[] pausers) public initializer {
function initialize(
string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
address[] minters, address[] pausers
) public initializer {
require(initialSupply > 0);
require(initialSupply > 0);
ERC20Detailed.initialize(name, symbol, decimals);
ERC20Detailed.initialize(name, symbol, decimals);
...
@@ -37,7 +40,9 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
...
@@ -37,7 +40,9 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
}
}
}
}
function initialize(string name, string symbol, uint8 decimals, address[] minters, address[] pausers) public initializer {
function initialize(
string name, string symbol, uint8 decimals, address[] minters, address[] pausers
) public initializer {
ERC20Detailed.initialize(name, symbol, decimals);
ERC20Detailed.initialize(name, symbol, decimals);
// Initialize the minter and pauser roles, and renounce them
// Initialize the minter and pauser roles, and renounce them
...
...
contracts/examples/StandaloneERC721.sol
View file @
0ae92d78
...
@@ -12,7 +12,9 @@ import "../token/ERC721/ERC721Pausable.sol";
...
@@ -12,7 +12,9 @@ import "../token/ERC721/ERC721Pausable.sol";
* @title Standard ERC721 token, with minting and pause functionality.
* @title Standard ERC721 token, with minting and pause functionality.
*
*
*/
*/
contract StandaloneERC721 is Initializable, ERC721, ERC721Enumerable, ERC721Metadata, ERC721MetadataMintable, ERC721Pausable {
contract StandaloneERC721
is Initializable, ERC721, ERC721Enumerable, ERC721Metadata, ERC721MetadataMintable, ERC721Pausable
{
function initialize(string name, string symbol, address[] minters, address[] pausers) public initializer {
function initialize(string name, string symbol, address[] minters, address[] pausers) public initializer {
ERC721.initialize();
ERC721.initialize();
ERC721Enumerable.initialize();
ERC721Enumerable.initialize();
...
...
contracts/examples/StandardToken.sol
View file @
0ae92d78
...
@@ -11,7 +11,10 @@ import "../token/ERC20/ERC20Pausable.sol";
...
@@ -11,7 +11,10 @@ import "../token/ERC20/ERC20Pausable.sol";
*
*
*/
*/
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
function initialize(string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder, address[] minters, address[] pausers) public initializer {
function initialize(
string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
address[] minters, address[] pausers
) public initializer {
ERC20Detailed.initialize(name, symbol, decimals);
ERC20Detailed.initialize(name, symbol, decimals);
// Mint the initial supply
// Mint the initial supply
...
...
test/examples/StandaloneERC20.test.js
View file @
0ae92d78
...
@@ -4,15 +4,17 @@ const { assertRevert } = require('../helpers/assertRevert');
...
@@ -4,15 +4,17 @@ const { assertRevert } = require('../helpers/assertRevert');
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
const
should
=
require
(
'chai'
)
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
.
should
();
const
StandaloneERC20
=
artifacts
.
require
(
'StandaloneERC20'
);
const
StandaloneERC20
=
artifacts
.
require
(
'StandaloneERC20'
);
contract
(
'StandaloneERC20'
,
function
([
_
,
deployer
,
initialHolder
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
])
{
contract
(
'StandaloneERC20'
,
function
([
const
name
=
"StandaloneERC20"
;
_
,
deployer
,
initialHolder
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
const
symbol
=
"SAERC20"
;
])
{
const
name
=
'StandaloneERC20'
;
const
symbol
=
'SAERC20'
;
const
decimals
=
18
;
const
decimals
=
18
;
const
initialSupply
=
300
;
const
initialSupply
=
300
;
...
@@ -26,19 +28,25 @@ contract('StandaloneERC20', function ([_, deployer, initialHolder, minterA, mint
...
@@ -26,19 +28,25 @@ contract('StandaloneERC20', function ([_, deployer, initialHolder, minterA, mint
this
.
token
=
await
StandaloneERC20
.
new
({
from
:
deployer
});
this
.
token
=
await
StandaloneERC20
.
new
({
from
:
deployer
});
});
});
async
function
initializeFull
(
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
)
{
async
function
initializeFull
(
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
)
{
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
await
token
.
sendTransaction
({
data
:
callData
,
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
async
function
initializePartial
(
token
,
name
,
symbol
,
decimals
,
minters
,
pausers
,
from
)
{
async
function
initializePartial
(
token
,
name
,
symbol
,
decimals
,
minters
,
pausers
,
from
)
{
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
minters
,
pausers
]);
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
minters
,
pausers
]);
await
token
.
sendTransaction
({
data
:
callData
,
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
describe
(
'with all arguments'
,
function
()
{
describe
(
'with all arguments'
,
function
()
{
it
(
'reverts if initial balance is zero'
,
async
function
()
{
it
(
'reverts if initial balance is zero'
,
async
function
()
{
await
assertRevert
(
initializeFull
(
this
.
token
,
name
,
symbol
,
decimals
,
0
,
ZERO_ADDRESS
,
minters
,
pausers
,
deployer
));
await
assertRevert
(
initializeFull
(
this
.
token
,
name
,
symbol
,
decimals
,
0
,
ZERO_ADDRESS
,
minters
,
pausers
,
deployer
)
);
});
});
it
(
'can be created with no minters'
,
async
function
()
{
it
(
'can be created with no minters'
,
async
function
()
{
...
@@ -59,7 +67,9 @@ contract('StandaloneERC20', function ([_, deployer, initialHolder, minterA, mint
...
@@ -59,7 +67,9 @@ contract('StandaloneERC20', function ([_, deployer, initialHolder, minterA, mint
context
(
'with token'
,
async
function
()
{
context
(
'with token'
,
async
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
initializeFull
(
this
.
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
deployer
);
await
initializeFull
(
this
.
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
deployer
);
});
});
it
(
'initializes metadata'
,
async
function
()
{
it
(
'initializes metadata'
,
async
function
()
{
...
...
test/examples/StandaloneERC721.test.js
View file @
0ae92d78
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
{
assertRevert
}
=
require
(
'../helpers/assertRevert'
);
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
const
should
=
require
(
'chai'
)
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
.
should
();
const
StandaloneERC721
=
artifacts
.
require
(
'StandaloneERC721'
);
const
StandaloneERC721
=
artifacts
.
require
(
'StandaloneERC721'
);
contract
(
'StandaloneERC721'
,
function
([
_
,
deployer
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
])
{
contract
(
'StandaloneERC721'
,
function
([
_
,
deployer
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
])
{
const
name
=
"StandaloneERC721"
;
const
name
=
'StandaloneERC721'
;
const
symbol
=
"SAERC721"
;
const
symbol
=
'SAERC721'
;
const
minters
=
[
minterA
,
minterB
];
const
minters
=
[
minterA
,
minterB
];
const
pausers
=
[
pauserA
,
pauserB
];
const
pausers
=
[
pauserA
,
pauserB
];
...
@@ -20,8 +19,10 @@ contract('StandaloneERC721', function ([_, deployer, minterA, minterB, pauserA,
...
@@ -20,8 +19,10 @@ contract('StandaloneERC721', function ([_, deployer, minterA, minterB, pauserA,
this
.
token
=
await
StandaloneERC721
.
new
({
from
:
deployer
});
this
.
token
=
await
StandaloneERC721
.
new
({
from
:
deployer
});
});
});
async
function
initialize
(
token
,
name
,
symbol
,
minters
,
pausers
,
from
)
{
async
function
initialize
(
token
,
name
,
symbol
,
minters
,
pausers
,
from
)
{
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
minters
,
pausers
]);
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
minters
,
pausers
]);
await
token
.
sendTransaction
({
data
:
callData
,
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
...
...
test/examples/StandardToken.test.js
View file @
0ae92d78
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
{
shouldBehaveLikeERC20Mintable
}
=
require
(
'../token/ERC20/behaviors/ERC20Mintable.behavior'
);
const
{
shouldBehaveLikeERC20Mintable
}
=
require
(
'../token/ERC20/behaviors/ERC20Mintable.behavior'
);
const
{
shouldBehaveLikePublicRole
}
=
require
(
'../access/roles/PublicRole.behavior'
);
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
const
should
=
require
(
'chai'
)
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
.
should
();
const
StandardToken
=
artifacts
.
require
(
'StandardToken'
);
const
StandardToken
=
artifacts
.
require
(
'StandardToken'
);
contract
(
'StandardToken'
,
function
([
_
,
deployer
,
initialHolder
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
])
{
contract
(
'StandardToken'
,
function
([
const
name
=
"StdToken"
;
_
,
deployer
,
initialHolder
,
minterA
,
minterB
,
pauserA
,
pauserB
,
anyone
,
...
otherAccounts
const
symbol
=
"STDT"
;
])
{
const
name
=
'StdToken'
;
const
symbol
=
'STDT'
;
const
decimals
=
18
;
const
decimals
=
18
;
const
initialSupply
=
300
;
const
initialSupply
=
300
;
...
@@ -26,8 +27,10 @@ contract('StandardToken', function ([_, deployer, initialHolder, minterA, minter
...
@@ -26,8 +27,10 @@ contract('StandardToken', function ([_, deployer, initialHolder, minterA, minter
this
.
token
=
await
StandardToken
.
new
({
from
:
deployer
});
this
.
token
=
await
StandardToken
.
new
({
from
:
deployer
});
});
});
async
function
initialize
(
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
)
{
async
function
initialize
(
token
,
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
)
{
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
const
callData
=
encodeCall
(
'initialize'
,
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
await
token
.
sendTransaction
({
data
:
callData
,
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
...
...
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