update mysteryboxV1
This commit is contained in:
12
contracts/external/ERC721/ERC721.sol
vendored
12
contracts/external/ERC721/ERC721.sol
vendored
@@ -27,7 +27,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
|
||||
// Token symbol
|
||||
string internal _symbol;
|
||||
|
||||
string internal _baseURI = "";
|
||||
string internal _baseUri = "";
|
||||
|
||||
// Mapping from token ID to owner address
|
||||
mapping (uint256 => address) private _owners;
|
||||
@@ -87,12 +87,20 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
|
||||
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
|
||||
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
|
||||
|
||||
string memory baseURI = _baseURI;
|
||||
string memory baseURI = _baseURI();
|
||||
return bytes(baseURI).length > 0
|
||||
? string(abi.encodePacked(baseURI, tokenId.toString()))
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Base URI for computing {tokenURI}. Empty by default, can be overriden
|
||||
* in child contracts.
|
||||
*/
|
||||
function _baseURI() internal view virtual returns (string memory) {
|
||||
return _baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC721-approve}.
|
||||
*/
|
||||
|
||||
67
contracts/external/ERC721/ERC721URIStorage.sol
vendored
Normal file
67
contracts/external/ERC721/ERC721URIStorage.sol
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// This is a file copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721URIStorage.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import "./ERC721.sol";
|
||||
|
||||
/**
|
||||
* @dev ERC721 token with storage based token URI management.
|
||||
*/
|
||||
abstract contract ERC721URIStorage is ERC721 {
|
||||
using Strings for uint256;
|
||||
|
||||
// Optional mapping for token URIs
|
||||
mapping (uint256 => string) private _tokenURIs;
|
||||
|
||||
/**
|
||||
* @dev See {IERC721Metadata-tokenURI}.
|
||||
*/
|
||||
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
|
||||
require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
|
||||
|
||||
string memory _tokenURI = _tokenURIs[tokenId];
|
||||
string memory base = _baseURI();
|
||||
|
||||
// If there is no base URI, return the token URI.
|
||||
if (bytes(base).length == 0) {
|
||||
return _tokenURI;
|
||||
}
|
||||
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
|
||||
if (bytes(_tokenURI).length > 0) {
|
||||
return string(abi.encodePacked(base, _tokenURI));
|
||||
}
|
||||
|
||||
return super.tokenURI(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `tokenId` must exist.
|
||||
*/
|
||||
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
|
||||
require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
|
||||
_tokenURIs[tokenId] = _tokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Destroys `tokenId`.
|
||||
* The approval is cleared when the token is burned.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `tokenId` must exist.
|
||||
*
|
||||
* Emits a {Transfer} event.
|
||||
*/
|
||||
function _burn(uint256 tokenId) internal virtual override {
|
||||
super._burn(tokenId);
|
||||
|
||||
if (bytes(_tokenURIs[tokenId]).length != 0) {
|
||||
delete _tokenURIs[tokenId];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ contract InitializableERC721 is ERC721 {
|
||||
address creator,
|
||||
string memory name,
|
||||
string memory symbol,
|
||||
string memory baseUrI
|
||||
string memory baseUri
|
||||
) public {
|
||||
_name = name;
|
||||
_symbol = symbol;
|
||||
_baseURI = baseUrI;
|
||||
_baseUri = baseUri;
|
||||
_mint(creator, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user