mysterybox1

This commit is contained in:
owen05
2021-04-14 19:08:11 +08:00
parent 388b294b58
commit be4c049e0a
7 changed files with 73 additions and 51 deletions

View File

@@ -4,6 +4,7 @@
pragma solidity 0.6.9;
import {IERC1155} from "../../intf/IERC1155.sol";
import {IERC165} from "../../intf/IERC165.sol";
import {IERC1155Receiver} from "../../intf/IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "../../intf/IERC1155MetadataURI.sol";
import {ERC165} from "../utils/ERC165.sol";
@@ -31,13 +32,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor (string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
@@ -399,4 +393,3 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
return array;
}
}

View File

@@ -4,6 +4,7 @@
pragma solidity 0.6.9;
import {IERC721} from "../../intf/IERC721.sol";
import {IERC165} from "../../intf/IERC165.sol";
import {IERC721Receiver} from "../../intf/IERC721Receiver.sol";
import {IERC721Metadata} from "../../intf/IERC721Metadata.sol";
import {ERC165} from "../utils/ERC165.sol";
@@ -21,10 +22,12 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Strings for uint256;
// Token name
string private _name;
string internal _name;
// Token symbol
string private _symbol;
string internal _symbol;
string internal _baseURI = "";
// Mapping from token ID to owner address
mapping (uint256 => address) private _owners;
@@ -84,20 +87,12 @@ 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 "";
}
/**
* @dev See {IERC721-approve}.
*/

View File

@@ -9,7 +9,7 @@ pragma solidity 0.6.9;
import {ERC721} from "./ERC721.sol";
contract InitializableERC1155 is ERC721 {
contract InitializableERC721 is ERC721 {
function init(
address creator,
string memory name,

View File

@@ -3,7 +3,7 @@
pragma solidity 0.6.9;
import "./IERC165.sol";
import "../../intf/IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.

View File

@@ -1,25 +0,0 @@
// This is a file copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.9;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}