Commit bd8345a1 by Francisco Giordano Committed by Nicolás Venturo

Separate ERC721Mintable (#1365)

* separate part of ERC721Mintable into ERC721MetadataMintable

* remove mint and burn from 721 tests

* Fixed linter error.

* fix ERC721 mint tests

* Minor fixes.

(cherry picked from commit 744f567f)
parent 76169cda
......@@ -2,15 +2,18 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721MetadataMintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
/**
* @title ERC721Mock
* @title ERC721FullMock
* This mock just provides a public mint and burn functions for testing purposes,
* and a public setter for metadata URI
*/
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721Burnable {
contract ERC721FullMock
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor(string name, string symbol) public
ERC721Mintable()
ERC721Full(name, symbol)
......
......@@ -2,6 +2,7 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721MetadataMintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
......@@ -9,7 +10,7 @@ import "../token/ERC721/ERC721Burnable.sol";
* @title ERC721MintableBurnableImpl
*/
contract ERC721MintableBurnableImpl
is ERC721Full, ERC721Mintable, ERC721Burnable {
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor()
ERC721Mintable()
......
pragma solidity ^0.4.24;
import "./ERC721Metadata.sol";
import "../../access/roles/MinterRole.sol";
/**
* @title ERC721MetadataMintable
* @dev ERC721 minting logic with metadata
*/
contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param tokenId The token id to mint.
* @param tokenURI The token URI of the minted token.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithTokenURI(
address to,
uint256 tokenId,
string tokenURI
)
public
onlyMinter
returns (bool)
{
_mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
}
pragma solidity ^0.4.24;
import "./ERC721Full.sol";
import "./ERC721.sol";
import "../../access/roles/MinterRole.sol";
......@@ -8,7 +8,7 @@ import "../../access/roles/MinterRole.sol";
* @title ERC721Mintable
* @dev ERC721 minting logic
*/
contract ERC721Mintable is ERC721Full, MinterRole {
contract ERC721Mintable is ERC721, MinterRole {
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
......@@ -26,18 +26,4 @@ contract ERC721Mintable is ERC721Full, MinterRole {
_mint(to, tokenId);
return true;
}
function mintWithTokenURI(
address to,
uint256 tokenId,
string tokenURI
)
public
onlyMinter
returns (bool)
{
mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
}
const { assertRevert } = require('../../helpers/assertRevert');
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
const { shouldBehaveLikeMintAndBurnERC721 } = require('./ERC721MintBurn.behavior');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const _ = require('lodash');
......@@ -217,7 +216,6 @@ contract('ERC721Full', function ([
});
shouldBehaveLikeERC721(creator, minter, accounts);
shouldBehaveLikeMintAndBurnERC721(creator, minter, accounts);
shouldSupportInterfaces([
'ERC165',
......
......@@ -52,13 +52,13 @@ function shouldBehaveLikeMintAndBurnERC721 (
describe('when the given owner address is the zero address', function () {
it('reverts', async function () {
await assertRevert(this.token.mint(ZERO_ADDRESS, thirdTokenId));
await assertRevert(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter }));
});
});
describe('when the given token ID was already tracked by this contract', function () {
it('reverts', async function () {
await assertRevert(this.token.mint(owner, firstTokenId));
await assertRevert(this.token.mint(owner, firstTokenId, { from: minter }));
});
});
});
......
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