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
cff2509c
Commit
cff2509c
authored
Jan 22, 2019
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix all tests for 2.1.2
parent
dd433c41
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
59 deletions
+42
-59
StandardToken.sol
contracts/examples/StandardToken.sol
+5
-5
StandaloneERC20.sol
contracts/token/ERC20/StandaloneERC20.sol
+10
-10
StandaloneERC721.sol
contracts/token/ERC721/StandaloneERC721.sol
+5
-5
SimpleToken.test.js
test/examples/SimpleToken.test.js
+1
-1
StandardToken.test.js
test/examples/StandardToken.test.js
+8
-13
StandaloneERC20.test.js
test/token/ERC20/StandaloneERC20.test.js
+9
-16
StandaloneERC721.test.js
test/token/ERC721/StandaloneERC721.test.js
+4
-9
No files found.
contracts/examples/StandardToken.sol
View file @
cff2509c
...
@@ -13,7 +13,7 @@ import "../token/ERC20/ERC20Pausable.sol";
...
@@ -13,7 +13,7 @@ import "../token/ERC20/ERC20Pausable.sol";
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
function initialize(
function initialize(
string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
address[] memory minters, address[] memory pausers
address[] memory minters, address[] memory pausers
, address sender
) public initializer {
) public initializer {
ERC20Detailed.initialize(name, symbol, decimals);
ERC20Detailed.initialize(name, symbol, decimals);
...
@@ -23,11 +23,11 @@ contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Paus
...
@@ -23,11 +23,11 @@ contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Paus
}
}
// Initialize the minter and pauser roles, and renounce them
// Initialize the minter and pauser roles, and renounce them
ERC20Mintable.initialize(
msg.
sender);
ERC20Mintable.initialize(sender);
renounceMinter(
);
_removeMinter(sender
);
ERC20Pausable.initialize(
msg.
sender);
ERC20Pausable.initialize(sender);
renouncePauser(
);
_removePauser(sender
);
// Add the requested minters and pausers (this can be done after renouncing since
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
// these are the internal calls)
...
...
contracts/token/ERC20/StandaloneERC20.sol
View file @
cff2509c
...
@@ -13,7 +13,7 @@ import "./ERC20Pausable.sol";
...
@@ -13,7 +13,7 @@ import "./ERC20Pausable.sol";
contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
function initialize(
function initialize(
string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
address[] memory minters, address[] memory pausers
address[] memory minters, address[] memory pausers
, address sender
) public initializer {
) public initializer {
ERC20Detailed.initialize(name, symbol, decimals);
ERC20Detailed.initialize(name, symbol, decimals);
...
@@ -21,11 +21,11 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
...
@@ -21,11 +21,11 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
_mint(initialHolder, initialSupply);
_mint(initialHolder, initialSupply);
// Initialize the minter and pauser roles, and renounce them
// Initialize the minter and pauser roles, and renounce them
ERC20Mintable.initialize(
msg.
sender);
ERC20Mintable.initialize(sender);
renounceMinter(
);
_removeMinter(sender
);
ERC20Pausable.initialize(
msg.
sender);
ERC20Pausable.initialize(sender);
renouncePauser(
);
_removePauser(sender
);
// Add the requested minters and pausers (this can be done after renouncing since
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
// these are the internal calls)
...
@@ -39,16 +39,16 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
...
@@ -39,16 +39,16 @@ contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pa
}
}
function initialize(
function initialize(
string memory name, string memory symbol, uint8 decimals, address[] memory minters, address[] memory pausers
string memory name, string memory symbol, uint8 decimals, address[] memory minters, address[] memory pausers
, address sender
) public initializer {
) 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
ERC20Mintable.initialize(
msg.
sender);
ERC20Mintable.initialize(sender);
renounceMinter(
);
_removeMinter(sender
);
ERC20Pausable.initialize(
msg.
sender);
ERC20Pausable.initialize(sender);
renouncePauser(
);
_removePauser(sender
);
// Add the requested minters and pausers (this can be done after renouncing since
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
// these are the internal calls)
...
...
contracts/token/ERC721/StandaloneERC721.sol
View file @
cff2509c
...
@@ -15,17 +15,17 @@ import "./ERC721Pausable.sol";
...
@@ -15,17 +15,17 @@ import "./ERC721Pausable.sol";
contract StandaloneERC721
contract StandaloneERC721
is Initializable, ERC721, ERC721Enumerable, ERC721Metadata, ERC721MetadataMintable, ERC721Pausable
is Initializable, ERC721, ERC721Enumerable, ERC721Metadata, ERC721MetadataMintable, ERC721Pausable
{
{
function initialize(string memory name, string memory symbol, address[] memory minters, address[] memory pausers) public initializer {
function initialize(string memory name, string memory symbol, address[] memory minters, address[] memory pausers
, address sender
) public initializer {
ERC721.initialize();
ERC721.initialize();
ERC721Enumerable.initialize();
ERC721Enumerable.initialize();
ERC721Metadata.initialize(name, symbol);
ERC721Metadata.initialize(name, symbol);
// Initialize the minter and pauser roles, and renounce them
// Initialize the minter and pauser roles, and renounce them
ERC721MetadataMintable.initialize(
msg.
sender);
ERC721MetadataMintable.initialize(sender);
renounceMinter(
);
_removeMinter(sender
);
ERC721Pausable.initialize(
msg.
sender);
ERC721Pausable.initialize(sender);
renouncePauser(
);
_removePauser(sender
);
// Add the requested minters and pausers (this can be done after renouncing since
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
// these are the internal calls)
...
...
test/examples/SimpleToken.test.js
View file @
cff2509c
const
{
constants
,
expectEvent
}
=
require
(
'openzeppelin-test-helpers'
);
const
{
constants
,
expectEvent
}
=
require
(
'openzeppelin-test-helpers'
);
const
{
ZERO_ADDRESS
}
=
constants
;
const
{
ZERO_ADDRESS
}
=
constants
;
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken
Mock
'
);
contract
(
'SimpleToken'
,
function
([
_
,
creator
])
{
contract
(
'SimpleToken'
,
function
([
_
,
creator
])
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
...
...
test/examples/StandardToken.test.js
View file @
cff2509c
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
BigNumber
=
web3
.
BigNumber
;
const
{
BN
}
=
require
(
'openzeppelin-test-helpers'
);
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
const
StandardToken
=
artifacts
.
require
(
'StandardToken'
);
const
StandardToken
=
artifacts
.
require
(
'StandardToken'
);
...
@@ -14,9 +10,9 @@ contract('StandardToken', function ([
...
@@ -14,9 +10,9 @@ contract('StandardToken', function ([
])
{
])
{
const
name
=
'StdToken'
;
const
name
=
'StdToken'
;
const
symbol
=
'STDT'
;
const
symbol
=
'STDT'
;
const
decimals
=
18
;
const
decimals
=
new
BN
(
'18'
)
;
const
initialSupply
=
300
;
const
initialSupply
=
new
BN
(
'300'
)
;
const
minters
=
[
minterA
,
minterB
];
const
minters
=
[
minterA
,
minterB
];
const
pausers
=
[
pauserA
,
pauserB
];
const
pausers
=
[
pauserA
,
pauserB
];
...
@@ -28,10 +24,9 @@ contract('StandardToken', function ([
...
@@ -28,10 +24,9 @@ contract('StandardToken', function ([
});
});
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'
,
const
signature
=
'initialize(string,string,uint8,uint256,address,address[],address[],address)'
;
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
const
arguments
=
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
];
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
await
token
.
methods
[
signature
](...
arguments
,
{
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
context
(
'with all arguments'
,
function
()
{
context
(
'with all arguments'
,
function
()
{
...
@@ -77,8 +72,8 @@ contract('StandardToken', function ([
...
@@ -77,8 +72,8 @@ contract('StandardToken', function ([
});
});
it
(
'can be created with zero initial balance'
,
async
function
()
{
it
(
'can be created with zero initial balance'
,
async
function
()
{
await
initialize
(
this
.
token
,
name
,
symbol
,
decimals
,
0
,
ZERO_ADDRESS
,
minters
,
pausers
,
deployer
);
await
initialize
(
this
.
token
,
name
,
symbol
,
decimals
,
new
BN
(
0
)
,
ZERO_ADDRESS
,
minters
,
pausers
,
deployer
);
(
await
this
.
token
.
balanceOf
(
initialHolder
)).
should
.
be
.
bignumber
.
equal
(
0
);
(
await
this
.
token
.
balanceOf
(
initialHolder
)).
should
.
be
.
bignumber
.
equal
(
'0'
);
});
});
it
(
'can be created with no minters'
,
async
function
()
{
it
(
'can be created with no minters'
,
async
function
()
{
...
...
test/token/ERC20/StandaloneERC20.test.js
View file @
cff2509c
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
{
shouldBehaveLikeERC20Mintable
}
=
require
(
'./behaviors/ERC20Mintable.behavior'
);
const
{
shouldBehaveLikeERC20Mintable
}
=
require
(
'./behaviors/ERC20Mintable.behavior'
);
const
shouldFail
=
require
(
'../../helpers/shouldFail'
);
const
BigNumber
=
web3
.
BigNumber
;
const
{
shouldFail
,
BN
}
=
require
(
'openzeppelin-test-helpers'
);
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
const
StandaloneERC20
=
artifacts
.
require
(
'StandaloneERC20'
);
const
StandaloneERC20
=
artifacts
.
require
(
'StandaloneERC20'
);
...
@@ -15,9 +10,9 @@ contract('StandaloneERC20', function ([
...
@@ -15,9 +10,9 @@ contract('StandaloneERC20', function ([
])
{
])
{
const
name
=
'StandaloneERC20'
;
const
name
=
'StandaloneERC20'
;
const
symbol
=
'SAERC20'
;
const
symbol
=
'SAERC20'
;
const
decimals
=
18
;
const
decimals
=
new
BN
(
18
)
;
const
initialSupply
=
300
;
const
initialSupply
=
new
BN
(
300
)
;
const
minters
=
[
minterA
,
minterB
];
const
minters
=
[
minterA
,
minterB
];
const
pausers
=
[
pauserA
,
pauserB
];
const
pausers
=
[
pauserA
,
pauserB
];
...
@@ -29,17 +24,15 @@ contract('StandaloneERC20', function ([
...
@@ -29,17 +24,15 @@ contract('StandaloneERC20', function ([
});
});
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'
,
const
signature
=
'initialize(string,string,uint8,uint256,address,address[],address[],address)'
;
[
'string'
,
'string'
,
'uint8'
,
'uint256'
,
'address'
,
'address[]'
,
'address[]'
],
const
arguments
=
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
,
from
];
[
name
,
symbol
,
decimals
,
initialSupply
,
initialHolder
,
minters
,
pausers
]);
await
token
.
methods
[
signature
](...
arguments
,
{
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'
,
const
signature
=
'initialize(string,string,uint8,address[],address[],address)'
;
[
'string'
,
'string'
,
'uint8'
,
'address[]'
,
'address[]'
],
const
arguments
=
[
name
,
symbol
,
decimals
,
minters
,
pausers
,
from
];
[
name
,
symbol
,
decimals
,
minters
,
pausers
]);
await
token
.
methods
[
signature
](...
arguments
,
{
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
describe
(
'with all arguments'
,
function
()
{
describe
(
'with all arguments'
,
function
()
{
...
...
test/token/ERC721/StandaloneERC721.test.js
View file @
cff2509c
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
encodeCall
=
require
(
'zos-lib/lib/helpers/encodeCall'
).
default
;
const
BigNumber
=
web3
.
BigNumber
;
require
(
'openzeppelin-test-helpers'
);
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
const
StandaloneERC721
=
artifacts
.
require
(
'StandaloneERC721'
);
const
StandaloneERC721
=
artifacts
.
require
(
'StandaloneERC721'
);
...
@@ -20,10 +16,9 @@ contract('StandaloneERC721', function ([_, deployer, minterA, minterB, pauserA,
...
@@ -20,10 +16,9 @@ contract('StandaloneERC721', function ([_, deployer, minterA, minterB, pauserA,
});
});
async
function
initialize
(
token
,
name
,
symbol
,
minters
,
pausers
,
from
)
{
async
function
initialize
(
token
,
name
,
symbol
,
minters
,
pausers
,
from
)
{
const
callData
=
encodeCall
(
'initialize'
,
const
signature
=
'initialize(string,string,address[],address[],address)'
;
[
'string'
,
'string'
,
'address[]'
,
'address[]'
],
const
arguments
=
[
name
,
symbol
,
minters
,
pausers
,
from
];
[
name
,
symbol
,
minters
,
pausers
]);
await
token
.
methods
[
signature
](...
arguments
,
{
from
});
await
token
.
sendTransaction
({
data
:
callData
,
from
});
}
}
it
(
'can be created with no minters'
,
async
function
()
{
it
(
'can be created with no minters'
,
async
function
()
{
...
...
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