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
666ba11c
Commit
666ba11c
authored
Sep 18, 2020
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transform contracts to initializers
parent
df890e97
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
12 deletions
+33
-12
ERC1155BurnableMock.sol
contracts/mocks/ERC1155BurnableMock.sol
+3
-1
ERC1155Mock.sol
contracts/mocks/ERC1155Mock.sol
+2
-2
ERC1155.sol
contracts/token/ERC1155/ERC1155.sol
+6
-2
ERC1155Burnable.sol
contracts/token/ERC1155/ERC1155Burnable.sol
+3
-1
ERC1155Holder.sol
contracts/token/ERC1155/ERC1155Holder.sol
+3
-1
ERC1155Receiver.sol
contracts/token/ERC1155/ERC1155Receiver.sol
+6
-2
IERC1155.sol
contracts/token/ERC1155/IERC1155.sol
+3
-1
IERC1155MetadataURI.sol
contracts/token/ERC1155/IERC1155MetadataURI.sol
+3
-1
IERC1155Receiver.sol
contracts/token/ERC1155/IERC1155Receiver.sol
+3
-1
ERC1155Holder.test.js
test/token/ERC1155/ERC1155Holder.test.js
+1
-0
No files found.
contracts/mocks/ERC1155BurnableMock.sol
View file @
666ba11c
...
@@ -5,7 +5,9 @@ pragma solidity ^0.5.0;
...
@@ -5,7 +5,9 @@ pragma solidity ^0.5.0;
import "../token/ERC1155/ERC1155Burnable.sol";
import "../token/ERC1155/ERC1155Burnable.sol";
contract ERC1155BurnableMock is ERC1155Burnable {
contract ERC1155BurnableMock is ERC1155Burnable {
constructor(string memory uri) public ERC1155(uri) { }
constructor (string memory uri) public {
ERC1155.initialize(uri);
}
function mint(address to, uint256 id, uint256 value, bytes memory data) public {
function mint(address to, uint256 id, uint256 value, bytes memory data) public {
_mint(to, id, value, data);
_mint(to, id, value, data);
...
...
contracts/mocks/ERC1155Mock.sol
View file @
666ba11c
...
@@ -9,8 +9,8 @@ import "../token/ERC1155/ERC1155.sol";
...
@@ -9,8 +9,8 @@ import "../token/ERC1155/ERC1155.sol";
* This mock just publicizes internal functions for testing purposes
* This mock just publicizes internal functions for testing purposes
*/
*/
contract ERC1155Mock is ERC1155 {
contract ERC1155Mock is ERC1155 {
constructor (string memory uri) public
ERC1155(uri)
{
constructor (string memory uri) public {
// solhint-disable-previous-line no-empty-blocks
ERC1155.initialize(uri);
}
}
function setURI(string memory newuri) public {
function setURI(string memory newuri) public {
...
...
contracts/token/ERC1155/ERC1155.sol
View file @
666ba11c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./IERC1155.sol";
import "./IERC1155.sol";
import "./IERC1155MetadataURI.sol";
import "./IERC1155MetadataURI.sol";
import "./IERC1155Receiver.sol";
import "./IERC1155Receiver.sol";
...
@@ -18,7 +20,7 @@ import "../../utils/Address.sol";
...
@@ -18,7 +20,7 @@ import "../../utils/Address.sol";
*
*
* _Available since v3.1._
* _Available since v3.1._
*/
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
contract ERC1155 is
Initializable,
Context, ERC165, IERC1155, IERC1155MetadataURI {
using SafeMath for uint256;
using SafeMath for uint256;
using Address for address;
using Address for address;
...
@@ -52,7 +54,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
...
@@ -52,7 +54,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
/**
/**
* @dev See {_setURI}.
* @dev See {_setURI}.
*/
*/
constructor (string memory uri) public {
function initialize(string memory uri) public initializer {
ERC165.initialize();
_setURI(uri);
_setURI(uri);
// register the supported interfaces to conform to ERC1155 via ERC165
// register the supported interfaces to conform to ERC1155 via ERC165
...
...
contracts/token/ERC1155/ERC1155Burnable.sol
View file @
666ba11c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./ERC1155.sol";
import "./ERC1155.sol";
/**
/**
...
@@ -10,7 +12,7 @@ import "./ERC1155.sol";
...
@@ -10,7 +12,7 @@ import "./ERC1155.sol";
*
*
* _Available since v3.1._
* _Available since v3.1._
*/
*/
contract ERC1155Burnable is ERC1155 {
contract ERC1155Burnable is
Initializable,
ERC1155 {
function burn(address account, uint256 id, uint256 value) public {
function burn(address account, uint256 id, uint256 value) public {
require(
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
account == _msgSender() || isApprovedForAll(account, _msgSender()),
...
...
contracts/token/ERC1155/ERC1155Holder.sol
View file @
666ba11c
...
@@ -2,12 +2,14 @@
...
@@ -2,12 +2,14 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./ERC1155Receiver.sol";
import "./ERC1155Receiver.sol";
/**
/**
* @dev _Available since v3.1._
* @dev _Available since v3.1._
*/
*/
contract ERC1155Holder is ERC1155Receiver {
contract ERC1155Holder is
Initializable,
ERC1155Receiver {
function onERC1155Received(address, address, uint256, uint256, bytes memory) public returns (bytes4) {
function onERC1155Received(address, address, uint256, uint256, bytes memory) public returns (bytes4) {
return this.onERC1155Received.selector;
return this.onERC1155Received.selector;
}
}
...
...
contracts/token/ERC1155/ERC1155Receiver.sol
View file @
666ba11c
...
@@ -2,14 +2,18 @@
...
@@ -2,14 +2,18 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./IERC1155Receiver.sol";
import "./IERC1155Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../introspection/ERC165.sol";
/**
/**
* @dev _Available since v3.1._
* @dev _Available since v3.1._
*/
*/
contract ERC1155Receiver is ERC165, IERC1155Receiver {
contract ERC1155Receiver is Initializable, ERC165, IERC1155Receiver {
constructor() public {
function initialize() public initializer {
ERC165.initialize();
_registerInterface(
_registerInterface(
ERC1155Receiver(0).onERC1155Received.selector ^
ERC1155Receiver(0).onERC1155Received.selector ^
ERC1155Receiver(0).onERC1155BatchReceived.selector
ERC1155Receiver(0).onERC1155BatchReceived.selector
...
...
contracts/token/ERC1155/IERC1155.sol
View file @
666ba11c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../introspection/IERC165.sol";
import "../../introspection/IERC165.sol";
/**
/**
...
@@ -10,7 +12,7 @@ import "../../introspection/IERC165.sol";
...
@@ -10,7 +12,7 @@ import "../../introspection/IERC165.sol";
*
*
* _Available since v3.1._
* _Available since v3.1._
*/
*/
contract IERC1155 is IERC165 {
contract IERC1155 is I
nitializable, I
ERC165 {
/**
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
*/
...
...
contracts/token/ERC1155/IERC1155MetadataURI.sol
View file @
666ba11c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./IERC1155.sol";
import "./IERC1155.sol";
/**
/**
...
@@ -10,7 +12,7 @@ import "./IERC1155.sol";
...
@@ -10,7 +12,7 @@ import "./IERC1155.sol";
*
*
* _Available since v3.1._
* _Available since v3.1._
*/
*/
contract IERC1155MetadataURI is IERC1155 {
contract IERC1155MetadataURI is I
nitializable, I
ERC1155 {
/**
/**
* @dev Returns the URI for token type `id`.
* @dev Returns the URI for token type `id`.
*
*
...
...
contracts/token/ERC1155/IERC1155Receiver.sol
View file @
666ba11c
...
@@ -2,12 +2,14 @@
...
@@ -2,12 +2,14 @@
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../introspection/IERC165.sol";
import "../../introspection/IERC165.sol";
/**
/**
* _Available since v3.1._
* _Available since v3.1._
*/
*/
contract IERC1155Receiver is IERC165 {
contract IERC1155Receiver is I
nitializable, I
ERC165 {
/**
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
@dev Handles the receipt of a single ERC1155 token type. This function is
...
...
test/token/ERC1155/ERC1155Holder.test.js
View file @
666ba11c
...
@@ -18,6 +18,7 @@ describe('ERC1155Holder', function () {
...
@@ -18,6 +18,7 @@ describe('ERC1155Holder', function () {
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
multiToken
=
await
ERC1155Mock
.
new
(
uri
,
{
from
:
creator
});
this
.
multiToken
=
await
ERC1155Mock
.
new
(
uri
,
{
from
:
creator
});
this
.
holder
=
await
ERC1155Holder
.
new
();
this
.
holder
=
await
ERC1155Holder
.
new
();
await
this
.
holder
.
initialize
();
await
this
.
multiToken
.
mintBatch
(
creator
,
multiTokenIds
,
multiTokenAmounts
,
'0x'
,
{
from
:
creator
});
await
this
.
multiToken
.
mintBatch
(
creator
,
multiTokenIds
,
multiTokenAmounts
,
'0x'
,
{
from
:
creator
});
});
});
...
...
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