diff --git a/contracts/mocks/ERC721FullMock.sol b/contracts/mocks/ERC721FullMock.sol index e3f79b08f..49f4e31b7 100644 --- a/contracts/mocks/ERC721FullMock.sol +++ b/contracts/mocks/ERC721FullMock.sol @@ -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) diff --git a/contracts/mocks/ERC721MintableBurnableImpl.sol b/contracts/mocks/ERC721MintableBurnableImpl.sol index 4d3c962d8..eb328afa2 100644 --- a/contracts/mocks/ERC721MintableBurnableImpl.sol +++ b/contracts/mocks/ERC721MintableBurnableImpl.sol @@ -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() diff --git a/contracts/token/ERC721/ERC721MetadataMintable.sol b/contracts/token/ERC721/ERC721MetadataMintable.sol new file mode 100644 index 000000000..95a9f2124 --- /dev/null +++ b/contracts/token/ERC721/ERC721MetadataMintable.sol @@ -0,0 +1,32 @@ +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; + } +} diff --git a/contracts/token/ERC721/ERC721Mintable.sol b/contracts/token/ERC721/ERC721Mintable.sol index 3d17c0bc2..b7928a903 100644 --- a/contracts/token/ERC721/ERC721Mintable.sol +++ b/contracts/token/ERC721/ERC721Mintable.sol @@ -1,6 +1,6 @@ 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; - } } diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index ce8e915fa..ef3f67bc8 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -1,6 +1,5 @@ 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', diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index 31db1d176..ab54a6ae6 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -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 })); }); }); });