编译器
0.8.10+commit.fc410830
文件 1 的 5:DropMetadataRenderer.sol
pragma solidity ^0.8.10;
import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import {IMetadataRenderer} from "../interfaces/IMetadataRenderer.sol";
import {MetadataRenderAdminCheck} from "./MetadataRenderAdminCheck.sol";
contract DropMetadataRenderer is IMetadataRenderer, MetadataRenderAdminCheck {
error MetadataFrozen();
event MetadataUpdated(
address indexed target,
string metadataBase,
string metadataExtension,
string contractURI,
uint256 freezeAt
);
event ProvenanceHashUpdated(address indexed target, bytes32 provenanceHash);
struct MetadataURIInfo {
string base;
string extension;
string contractURI;
uint256 freezeAt;
}
mapping(address => MetadataURIInfo) public metadataBaseByContract;
mapping(address => bytes32) public provenanceHashes;
function initializeWithData(bytes memory data) external {
(string memory initialBaseURI, string memory initialContractURI) = abi
.decode(data, (string, string));
_updateMetadataDetails(
msg.sender,
initialBaseURI,
"",
initialContractURI,
0
);
}
function updateProvenanceHash(address target, bytes32 provenanceHash)
external
requireSenderAdmin(target)
{
provenanceHashes[target] = provenanceHash;
emit ProvenanceHashUpdated(target, provenanceHash);
}
function updateMetadataBase(
address target,
string memory baseUri,
string memory newContractUri
) external requireSenderAdmin(target) {
_updateMetadataDetails(target, baseUri, "", newContractUri, 0);
}
function updateMetadataBaseWithDetails(
address target,
string memory metadataBase,
string memory metadataExtension,
string memory newContractURI,
uint256 freezeAt
) external requireSenderAdmin(target) {
_updateMetadataDetails(
target,
metadataBase,
metadataExtension,
newContractURI,
freezeAt
);
}
function _updateMetadataDetails(
address target,
string memory metadataBase,
string memory metadataExtension,
string memory newContractURI,
uint256 freezeAt
) internal {
if (freezeAt != 0 && freezeAt > block.timestamp) {
revert MetadataFrozen();
}
metadataBaseByContract[target] = MetadataURIInfo({
base: metadataBase,
extension: metadataExtension,
contractURI: newContractURI,
freezeAt: freezeAt
});
emit MetadataUpdated({
target: target,
metadataBase: metadataBase,
metadataExtension: metadataExtension,
contractURI: newContractURI,
freezeAt: freezeAt
});
}
function contractURI() external view override returns (string memory) {
string memory uri = metadataBaseByContract[msg.sender].contractURI;
if (bytes(uri).length == 0) revert();
return uri;
}
function tokenURI(uint256 tokenId)
external
view
override
returns (string memory)
{
MetadataURIInfo memory info = metadataBaseByContract[msg.sender];
if (bytes(info.base).length == 0) revert();
return
string(
abi.encodePacked(
info.base,
StringsUpgradeable.toString(tokenId),
info.extension
)
);
}
}
文件 2 的 5:IERC721Drop.sol
pragma solidity ^0.8.10;
import {IMetadataRenderer} from "../interfaces/IMetadataRenderer.sol";
interface IERC721Drop {
error Access_OnlyAdmin();
error Access_MissingRoleOrAdmin(bytes32 role);
error Access_WithdrawNotAllowed();
error Withdraw_FundsSendFailure();
error Sale_Inactive();
error Presale_Inactive();
error Presale_MerkleNotApproved();
error Purchase_WrongPrice(uint256 correctPrice);
error Mint_SoldOut();
error Purchase_TooManyForAddress();
error Presale_TooManyForAddress();
error Setup_RoyaltyPercentageTooHigh(uint16 maxRoyaltyBPS);
error Admin_InvalidUpgradeAddress(address proposedAddress);
error Admin_UnableToFinalizeNotOpenEdition();
event Sale(
address indexed to,
uint256 indexed quantity,
uint256 indexed pricePerToken,
uint256 firstPurchasedTokenId
);
struct Configuration {
IMetadataRenderer metadataRenderer;
uint64 editionSize;
uint16 royaltyBPS;
address payable fundsRecipient;
}
struct SalesConfiguration {
uint104 publicSalePrice;
uint32 maxSalePurchasePerAddress;
uint64 publicSaleStart;
uint64 publicSaleEnd;
uint64 presaleStart;
uint64 presaleEnd;
bytes32 presaleMerkleRoot;
}
struct SaleDetails {
bool publicSaleActive;
bool presaleActive;
uint256 publicSalePrice;
uint64 publicSaleStart;
uint64 publicSaleEnd;
uint64 presaleStart;
uint64 presaleEnd;
bytes32 presaleMerkleRoot;
uint256 maxSalePurchasePerAddress;
uint256 totalMinted;
uint256 maxSupply;
}
struct AddressMintDetails {
uint256 totalMints;
uint256 presaleMints;
uint256 publicMints;
}
function purchase(uint256 quantity) external payable returns (uint256);
function purchasePresale(
uint256 quantity,
uint256 maxQuantity,
uint256 pricePerToken,
bytes32[] memory merkleProof
) external payable returns (uint256);
function saleDetails() external view returns (SaleDetails memory);
function mintedPerAddress(address minter)
external
view
returns (AddressMintDetails memory);
function owner() external view returns (address);
function adminMint(address to, uint256 quantity) external returns (uint256);
function adminMintAirdrop(address[] memory to) external returns (uint256);
function isAdmin(address user) external view returns (bool);
}
文件 3 的 5:IMetadataRenderer.sol
pragma solidity ^0.8.10;
interface IMetadataRenderer {
function tokenURI(uint256) external view returns (string memory);
function contractURI() external view returns (string memory);
function initializeWithData(bytes memory initData) external;
}
文件 4 的 5:MetadataRenderAdminCheck.sol
pragma solidity ^0.8.10;
import {IERC721Drop} from "../interfaces/IERC721Drop.sol";
contract MetadataRenderAdminCheck {
error Access_OnlyAdmin();
modifier requireSenderAdmin(address target) {
if (target != msg.sender && !IERC721Drop(target).isAdmin(msg.sender)) {
revert Access_OnlyAdmin();
}
_;
}
}
文件 5 的 5:StringsUpgradeable.sol
pragma solidity ^0.8.0;
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
{
"compilationTarget": {
"src/metadata/DropMetadataRenderer.sol": "DropMetadataRenderer"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 5000
},
"remappings": [
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
":base64/=lib/base64/",
":ds-test/=lib/ds-test/src/",
":erc721a-upgradeable/=lib/ERC721A-Upgradeable/contracts/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":src/=src/"
]
}
[{"inputs":[],"name":"Access_OnlyAdmin","type":"error"},{"inputs":[],"name":"MetadataFrozen","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"string","name":"metadataBase","type":"string"},{"indexed":false,"internalType":"string","name":"metadataExtension","type":"string"},{"indexed":false,"internalType":"string","name":"contractURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"freezeAt","type":"uint256"}],"name":"MetadataUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes32","name":"provenanceHash","type":"bytes32"}],"name":"ProvenanceHashUpdated","type":"event"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initializeWithData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"metadataBaseByContract","outputs":[{"internalType":"string","name":"base","type":"string"},{"internalType":"string","name":"extension","type":"string"},{"internalType":"string","name":"contractURI","type":"string"},{"internalType":"uint256","name":"freezeAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"provenanceHashes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"string","name":"baseUri","type":"string"},{"internalType":"string","name":"newContractUri","type":"string"}],"name":"updateMetadataBase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"string","name":"metadataBase","type":"string"},{"internalType":"string","name":"metadataExtension","type":"string"},{"internalType":"string","name":"newContractURI","type":"string"},{"internalType":"uint256","name":"freezeAt","type":"uint256"}],"name":"updateMetadataBaseWithDetails","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes32","name":"provenanceHash","type":"bytes32"}],"name":"updateProvenanceHash","outputs":[],"stateMutability":"nonpayable","type":"function"}]