Commit 666ba11c by Francisco Giordano

transform contracts to initializers

parent df890e97
...@@ -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);
......
...@@ -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 {
......
...@@ -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
......
...@@ -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()),
......
...@@ -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;
} }
......
...@@ -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
......
...@@ -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 Initializable, IERC165 {
/** /**
* @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`.
*/ */
......
...@@ -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 Initializable, IERC1155 {
/** /**
* @dev Returns the URI for token type `id`. * @dev Returns the URI for token type `id`.
* *
......
...@@ -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 Initializable, IERC165 {
/** /**
@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
......
...@@ -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 });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment