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
4bd1add2
Commit
4bd1add2
authored
Mar 16, 2021
by
github-actions
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transpile
2030235e
parent
e950855d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
14 deletions
+94
-14
ERC721MockUpgradeable.sol
contracts/mocks/ERC721MockUpgradeable.sol
+1
-11
README.adoc
contracts/token/ERC721/README.adoc
+1
-1
ERC721URIStorageUpgradeable.sol
...s/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol
+1
-1
TimelockController.test.js
test/governance/TimelockController.test.js
+37
-0
ProxyAdmin.test.js
test/proxy/transparent/ProxyAdmin.test.js
+8
-0
ReentrancyGuard.test.js
test/security/ReentrancyGuard.test.js
+6
-0
ERC1155PresetMinterPauser.test.js
test/token/ERC1155/presets/ERC1155PresetMinterPauser.test.js
+9
-0
ERC20PresetMinterPauser.test.js
test/token/ERC20/presets/ERC20PresetMinterPauser.test.js
+13
-1
ERC721URIStorage.test.js
test/token/ERC721/extensions/ERC721URIStorage.test.js
+9
-0
ERC721PresetMinterPauserAutoId.test.js
...ken/ERC721/presets/ERC721PresetMinterPauserAutoId.test.js
+9
-0
No files found.
contracts/mocks/ERC721MockUpgradeable.sol
View file @
4bd1add2
...
@@ -10,8 +10,6 @@ import "../proxy/utils/Initializable.sol";
...
@@ -10,8 +10,6 @@ import "../proxy/utils/Initializable.sol";
* This mock just provides a public safeMint, mint, and burn functions for testing purposes
* This mock just provides a public safeMint, mint, and burn functions for testing purposes
*/
*/
contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
string private _baseTokenURI;
function __ERC721Mock_init(string memory name, string memory symbol) internal initializer {
function __ERC721Mock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__Context_init_unchained();
__ERC165_init_unchained();
__ERC165_init_unchained();
...
@@ -21,14 +19,6 @@ contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
...
@@ -21,14 +19,6 @@ contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
function __ERC721Mock_init_unchained(string memory name, string memory symbol) internal initializer { }
function __ERC721Mock_init_unchained(string memory name, string memory symbol) internal initializer { }
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata newBaseTokenURI) public {
_baseTokenURI = newBaseTokenURI;
}
function baseURI() public view returns (string memory) {
function baseURI() public view returns (string memory) {
return _baseURI();
return _baseURI();
}
}
...
@@ -52,5 +42,5 @@ contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
...
@@ -52,5 +42,5 @@ contract ERC721MockUpgradeable is Initializable, ERC721Upgradeable {
function burn(uint256 tokenId) public {
function burn(uint256 tokenId) public {
_burn(tokenId);
_burn(tokenId);
}
}
uint256[
49
] private __gap;
uint256[
50
] private __gap;
}
}
contracts/token/ERC721/README.adoc
View file @
4bd1add2
...
@@ -39,7 +39,7 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel
...
@@ -39,7 +39,7 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel
{{ERC721Burnable}}
{{ERC721Burnable}}
{{ERC721
TokenUri
}}
{{ERC721
URIStorage
}}
== Presets
== Presets
...
...
contracts/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol
View file @
4bd1add2
...
@@ -6,7 +6,7 @@ import "../ERC721Upgradeable.sol";
...
@@ -6,7 +6,7 @@ import "../ERC721Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
/**
* @dev ERC721 token with storage based token
uri
management.
* @dev ERC721 token with storage based token
URI
management.
*/
*/
abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
function __ERC721URIStorage_init() internal initializer {
function __ERC721URIStorage_init() internal initializer {
...
...
test/governance/TimelockController.test.js
View file @
4bd1add2
...
@@ -368,6 +368,36 @@ contract('TimelockController', function (accounts) {
...
@@ -368,6 +368,36 @@ contract('TimelockController', function (accounts) {
);
);
});
});
it
(
'length of batch parameter must match #1'
,
async
function
()
{
await
expectRevert
(
this
.
timelock
.
scheduleBatch
(
this
.
operation
.
targets
,
[],
this
.
operation
.
datas
,
this
.
operation
.
predecessor
,
this
.
operation
.
salt
,
MINDELAY
,
{
from
:
proposer
},
),
'TimelockController: length mismatch'
,
);
});
it
(
'length of batch parameter must match #1'
,
async
function
()
{
await
expectRevert
(
this
.
timelock
.
scheduleBatch
(
this
.
operation
.
targets
,
this
.
operation
.
values
,
[],
this
.
operation
.
predecessor
,
this
.
operation
.
salt
,
MINDELAY
,
{
from
:
proposer
},
),
'TimelockController: length mismatch'
,
);
});
it
(
'prevent non-proposer from commiting'
,
async
function
()
{
it
(
'prevent non-proposer from commiting'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
timelock
.
scheduleBatch
(
this
.
timelock
.
scheduleBatch
(
...
@@ -623,6 +653,13 @@ contract('TimelockController', function (accounts) {
...
@@ -623,6 +653,13 @@ contract('TimelockController', function (accounts) {
expectEvent
(
receipt
,
'Cancelled'
,
{
id
:
this
.
operation
.
id
});
expectEvent
(
receipt
,
'Cancelled'
,
{
id
:
this
.
operation
.
id
});
});
});
it
(
'cannot cancel invalid operation'
,
async
function
()
{
await
expectRevert
(
this
.
timelock
.
cancel
(
constants
.
ZERO_BYTES32
,
{
from
:
proposer
}),
'TimelockController: operation cannot be cancelled'
,
);
});
it
(
'prevent non-proposer from canceling'
,
async
function
()
{
it
(
'prevent non-proposer from canceling'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
timelock
.
cancel
(
this
.
operation
.
id
,
{
from
:
other
}),
this
.
timelock
.
cancel
(
this
.
operation
.
id
,
{
from
:
other
}),
...
...
test/proxy/transparent/ProxyAdmin.test.js
View file @
4bd1add2
...
@@ -35,6 +35,10 @@ contract('ProxyAdmin', function (accounts) {
...
@@ -35,6 +35,10 @@ contract('ProxyAdmin', function (accounts) {
const
admin
=
await
this
.
proxyAdmin
.
getProxyAdmin
(
this
.
proxy
.
address
);
const
admin
=
await
this
.
proxyAdmin
.
getProxyAdmin
(
this
.
proxy
.
address
);
expect
(
admin
).
to
.
be
.
equal
(
this
.
proxyAdmin
.
address
);
expect
(
admin
).
to
.
be
.
equal
(
this
.
proxyAdmin
.
address
);
});
});
it
(
'call to invalid proxy'
,
async
function
()
{
await
expectRevert
.
unspecified
(
this
.
proxyAdmin
.
getProxyAdmin
(
this
.
implementationV1
.
address
));
});
});
});
describe
(
'#changeProxyAdmin'
,
function
()
{
describe
(
'#changeProxyAdmin'
,
function
()
{
...
@@ -56,6 +60,10 @@ contract('ProxyAdmin', function (accounts) {
...
@@ -56,6 +60,10 @@ contract('ProxyAdmin', function (accounts) {
const
implementationAddress
=
await
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
proxy
.
address
);
const
implementationAddress
=
await
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
proxy
.
address
);
expect
(
implementationAddress
).
to
.
be
.
equal
(
this
.
implementationV1
.
address
);
expect
(
implementationAddress
).
to
.
be
.
equal
(
this
.
implementationV1
.
address
);
});
});
it
(
'call to invalid proxy'
,
async
function
()
{
await
expectRevert
.
unspecified
(
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
implementationV1
.
address
));
});
});
});
describe
(
'#upgrade'
,
function
()
{
describe
(
'#upgrade'
,
function
()
{
...
...
test/security/ReentrancyGuard.test.js
View file @
4bd1add2
...
@@ -11,6 +11,12 @@ contract('ReentrancyGuard', function (accounts) {
...
@@ -11,6 +11,12 @@ contract('ReentrancyGuard', function (accounts) {
expect
(
await
this
.
reentrancyMock
.
counter
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
reentrancyMock
.
counter
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
});
});
it
(
'nonReentrant function can be called'
,
async
function
()
{
expect
(
await
this
.
reentrancyMock
.
counter
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
await
this
.
reentrancyMock
.
callback
();
expect
(
await
this
.
reentrancyMock
.
counter
()).
to
.
be
.
bignumber
.
equal
(
'1'
);
});
it
(
'does not allow remote callback'
,
async
function
()
{
it
(
'does not allow remote callback'
,
async
function
()
{
const
attacker
=
await
ReentrancyAttack
.
new
();
const
attacker
=
await
ReentrancyAttack
.
new
();
await
expectRevert
(
await
expectRevert
(
...
...
test/token/ERC1155/presets/ERC1155PresetMinterPauser.test.js
View file @
4bd1add2
...
@@ -120,6 +120,15 @@ contract('ERC1155PresetMinterPauser', function (accounts) {
...
@@ -120,6 +120,15 @@ contract('ERC1155PresetMinterPauser', function (accounts) {
'ERC1155PresetMinterPauser: must have pauser role to pause'
,
'ERC1155PresetMinterPauser: must have pauser role to pause'
,
);
);
});
});
it
(
'other accounts cannot unpause'
,
async
function
()
{
await
this
.
token
.
pause
({
from
:
deployer
});
await
expectRevert
(
this
.
token
.
unpause
({
from
:
other
}),
'ERC1155PresetMinterPauser: must have pauser role to unpause'
,
);
});
});
});
describe
(
'burning'
,
function
()
{
describe
(
'burning'
,
function
()
{
...
...
test/token/ERC20/presets/ERC20PresetMinterPauser.test.js
View file @
4bd1add2
...
@@ -84,7 +84,19 @@ contract('ERC20PresetMinterPauser', function (accounts) {
...
@@ -84,7 +84,19 @@ contract('ERC20PresetMinterPauser', function (accounts) {
});
});
it
(
'other accounts cannot pause'
,
async
function
()
{
it
(
'other accounts cannot pause'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
pause
({
from
:
other
}),
'ERC20PresetMinterPauser: must have pauser role to pause'
);
await
expectRevert
(
this
.
token
.
pause
({
from
:
other
}),
'ERC20PresetMinterPauser: must have pauser role to pause'
,
);
});
it
(
'other accounts cannot unpause'
,
async
function
()
{
await
this
.
token
.
pause
({
from
:
deployer
});
await
expectRevert
(
this
.
token
.
unpause
({
from
:
other
}),
'ERC20PresetMinterPauser: must have pauser role to unpause'
,
);
});
});
});
});
...
...
test/token/ERC721/extensions/ERC721URIStorage.test.js
View file @
4bd1add2
...
@@ -73,6 +73,15 @@ contract('ERC721URIStorage', function (accounts) {
...
@@ -73,6 +73,15 @@ contract('ERC721URIStorage', function (accounts) {
expect
(
await
this
.
token
.
tokenURI
(
firstTokenId
)).
to
.
be
.
equal
(
baseURI
+
firstTokenId
);
expect
(
await
this
.
token
.
tokenURI
(
firstTokenId
)).
to
.
be
.
equal
(
baseURI
+
firstTokenId
);
});
});
it
(
'tokens without URI can be burnt '
,
async
function
()
{
await
this
.
token
.
burn
(
firstTokenId
,
{
from
:
owner
});
expect
(
await
this
.
token
.
exists
(
firstTokenId
)).
to
.
equal
(
false
);
await
expectRevert
(
this
.
token
.
tokenURI
(
firstTokenId
),
'ERC721URIStorage: URI query for nonexistent token'
,
);
});
it
(
'tokens with URI can be burnt '
,
async
function
()
{
it
(
'tokens with URI can be burnt '
,
async
function
()
{
await
this
.
token
.
setTokenURI
(
firstTokenId
,
sampleUri
);
await
this
.
token
.
setTokenURI
(
firstTokenId
,
sampleUri
);
...
...
test/token/ERC721/presets/ERC721PresetMinterPauserAutoId.test.js
View file @
4bd1add2
...
@@ -97,6 +97,15 @@ contract('ERC721PresetMinterPauserAutoId', function (accounts) {
...
@@ -97,6 +97,15 @@ contract('ERC721PresetMinterPauserAutoId', function (accounts) {
'ERC721PresetMinterPauserAutoId: must have pauser role to pause'
,
'ERC721PresetMinterPauserAutoId: must have pauser role to pause'
,
);
);
});
});
it
(
'other accounts cannot unpause'
,
async
function
()
{
await
this
.
token
.
pause
({
from
:
deployer
});
await
expectRevert
(
this
.
token
.
unpause
({
from
:
other
}),
'ERC721PresetMinterPauserAutoId: must have pauser role to unpause'
,
);
});
});
});
describe
(
'burning'
,
function
()
{
describe
(
'burning'
,
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