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.
This commit is contained in:
committed by
Nicolás Venturo
parent
b41b125c15
commit
744f567f40
@ -2,14 +2,17 @@ pragma solidity ^0.4.24;
|
|||||||
|
|
||||||
import "../token/ERC721/ERC721Full.sol";
|
import "../token/ERC721/ERC721Full.sol";
|
||||||
import "../token/ERC721/ERC721Mintable.sol";
|
import "../token/ERC721/ERC721Mintable.sol";
|
||||||
|
import "../token/ERC721/ERC721MetadataMintable.sol";
|
||||||
import "../token/ERC721/ERC721Burnable.sol";
|
import "../token/ERC721/ERC721Burnable.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ERC721Mock
|
* @title ERC721FullMock
|
||||||
* This mock just provides a public mint and burn functions for testing purposes,
|
* This mock just provides a public mint and burn functions for testing purposes,
|
||||||
* and a public setter for metadata URI
|
* 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
|
constructor(string name, string symbol) public
|
||||||
ERC721Mintable()
|
ERC721Mintable()
|
||||||
ERC721Full(name, symbol)
|
ERC721Full(name, symbol)
|
||||||
|
|||||||
@ -2,13 +2,14 @@ pragma solidity ^0.4.24;
|
|||||||
|
|
||||||
import "../token/ERC721/ERC721Full.sol";
|
import "../token/ERC721/ERC721Full.sol";
|
||||||
import "../token/ERC721/ERC721Mintable.sol";
|
import "../token/ERC721/ERC721Mintable.sol";
|
||||||
|
import "../token/ERC721/ERC721MetadataMintable.sol";
|
||||||
import "../token/ERC721/ERC721Burnable.sol";
|
import "../token/ERC721/ERC721Burnable.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ERC721MintableBurnableImpl
|
* @title ERC721MintableBurnableImpl
|
||||||
*/
|
*/
|
||||||
contract ERC721MintableBurnableImpl
|
contract ERC721MintableBurnableImpl
|
||||||
is ERC721Full, ERC721Mintable, ERC721Burnable {
|
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
ERC721Mintable()
|
ERC721Mintable()
|
||||||
|
|||||||
32
contracts/token/ERC721/ERC721MetadataMintable.sol
Normal file
32
contracts/token/ERC721/ERC721MetadataMintable.sol
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,13 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
import "./ERC721Full.sol";
|
import "./ERC721.sol";
|
||||||
import "../../access/roles/MinterRole.sol";
|
import "../../access/roles/MinterRole.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ERC721Mintable
|
* @title ERC721Mintable
|
||||||
* @dev ERC721 minting logic
|
* @dev ERC721 minting logic
|
||||||
*/
|
*/
|
||||||
contract ERC721Mintable is ERC721Full, MinterRole {
|
contract ERC721Mintable is ERC721, MinterRole {
|
||||||
/**
|
/**
|
||||||
* @dev Function to mint tokens
|
* @dev Function to mint tokens
|
||||||
* @param to The address that will receive the minted tokens.
|
* @param to The address that will receive the minted tokens.
|
||||||
@ -25,18 +25,4 @@ contract ERC721Mintable is ERC721Full, MinterRole {
|
|||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mintWithTokenURI(
|
|
||||||
address to,
|
|
||||||
uint256 tokenId,
|
|
||||||
string tokenURI
|
|
||||||
)
|
|
||||||
public
|
|
||||||
onlyMinter
|
|
||||||
returns (bool)
|
|
||||||
{
|
|
||||||
mint(to, tokenId);
|
|
||||||
_setTokenURI(tokenId, tokenURI);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
const { assertRevert } = require('../../helpers/assertRevert');
|
const { assertRevert } = require('../../helpers/assertRevert');
|
||||||
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
|
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
|
||||||
const { shouldBehaveLikeMintAndBurnERC721 } = require('./ERC721MintBurn.behavior');
|
|
||||||
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
|
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber;
|
const BigNumber = web3.BigNumber;
|
||||||
@ -221,7 +220,6 @@ contract('ERC721Full', function ([
|
|||||||
});
|
});
|
||||||
|
|
||||||
shouldBehaveLikeERC721(creator, minter, accounts);
|
shouldBehaveLikeERC721(creator, minter, accounts);
|
||||||
shouldBehaveLikeMintAndBurnERC721(creator, minter, accounts);
|
|
||||||
|
|
||||||
shouldSupportInterfaces([
|
shouldSupportInterfaces([
|
||||||
'ERC165',
|
'ERC165',
|
||||||
|
|||||||
@ -52,13 +52,13 @@ function shouldBehaveLikeMintAndBurnERC721 (
|
|||||||
|
|
||||||
describe('when the given owner address is the zero address', function () {
|
describe('when the given owner address is the zero address', function () {
|
||||||
it('reverts', async 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 () {
|
describe('when the given token ID was already tracked by this contract', function () {
|
||||||
it('reverts', async function () {
|
it('reverts', async function () {
|
||||||
await assertRevert(this.token.mint(owner, firstTokenId));
|
await assertRevert(this.token.mint(owner, firstTokenId, { from: minter }));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user