-
Notifications
You must be signed in to change notification settings - Fork 12.4k
feat: implement ERC721Mintable and ERC721Burnable #1276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
frangio
merged 11 commits into
OpenZeppelin:rbac-migration
from
shrugs:feat/mintable-erc721
Sep 6, 2018
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3f0d557
feat: implement ERC721Mintable and ERC721Burnable
shrugs cc33969
fix: linting errors
shrugs ff4d8a5
fix: remove unused mintable mock for ERC721BasicMock
shrugs 047bc41
fix: add finishMinting tests
shrugs 4852489
fix: catch MintFinished typo
shrugs 2ed86d9
inline ERC721Full behavior
frangio 3948f46
undo pretty formatting
frangio 3e181f2
Merge branch 'rbac-migration' of github.com:OpenZeppelin/openzeppelinβ¦
frangio 0fb67e1
fix lint errors
frangio e49a1e4
rename canMint to onlyBeforeMintingFinished for consistency with ERC2β¦
frangio 8b44a79
Merge remote-tracking branch 'upstream/rbac-migration' into feat/mintβ¦
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| pragma solidity ^0.4.24; | ||
|
|
||
| import "../token/ERC721/ERC721.sol"; | ||
| import "../token/ERC721/ERC721Mintable.sol"; | ||
| import "../token/ERC721/ERC721Burnable.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title ERC721MintableBurnableImpl | ||
| */ | ||
| contract ERC721MintableBurnableImpl is ERC721, ERC721Mintable, ERC721Burnable { | ||
| constructor() | ||
| ERC721Mintable() | ||
| ERC721("Test", "TEST") | ||
| public | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| pragma solidity ^0.4.24; | ||
|
|
||
| import "./ERC721.sol"; | ||
|
|
||
|
|
||
| contract ERC721Burnable is ERC721 { | ||
| function burn(uint256 _tokenId) | ||
| public | ||
| { | ||
| require(_isApprovedOrOwner(msg.sender, _tokenId)); | ||
| _burn(ownerOf(_tokenId), _tokenId); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| pragma solidity ^0.4.24; | ||
|
|
||
| import "./ERC721.sol"; | ||
| import "../../access/roles/MinterRole.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title ERC721Mintable | ||
| * @dev ERC721 minting logic | ||
| */ | ||
| contract ERC721Mintable is ERC721, MinterRole { | ||
| event Minted(address indexed to, uint256 tokenId); | ||
| event MintingFinished(); | ||
|
|
||
| bool public mintingFinished = false; | ||
|
|
||
| modifier onlyBeforeMintingFinished() { | ||
| require(!mintingFinished); | ||
| _; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Function to mint tokens | ||
| * @param _to The address that will receive the minted tokens. | ||
| * @param _tokenId The token id to mint. | ||
| * @return A boolean that indicates if the operation was successful. | ||
| */ | ||
| function mint( | ||
| address _to, | ||
| uint256 _tokenId | ||
| ) | ||
| public | ||
| onlyMinter | ||
| onlyBeforeMintingFinished | ||
| returns (bool) | ||
| { | ||
| _mint(_to, _tokenId); | ||
| emit Minted(_to, _tokenId); | ||
| return true; | ||
| } | ||
|
|
||
| function mintWithTokenURI( | ||
| address _to, | ||
| uint256 _tokenId, | ||
| string _tokenURI | ||
| ) | ||
| public | ||
| onlyMinter | ||
| onlyBeforeMintingFinished | ||
| returns (bool) | ||
| { | ||
| mint(_to, _tokenId); | ||
| _setTokenURI(_tokenId, _tokenURI); | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Function to stop minting new tokens. | ||
| * @return True if the operation was successful. | ||
| */ | ||
| function finishMinting() | ||
| public | ||
| onlyMinter | ||
| onlyBeforeMintingFinished | ||
| returns (bool) | ||
| { | ||
| mintingFinished = true; | ||
| emit MintingFinished(); | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed, for constructor with no arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, but since it's a mock I'll leave it so we can merge sooner. π