编译器
0.8.17+commit.8df45f5f
文件 1 的 11:Enjoy.sol
pragma solidity 0.8.17;
interface Enjoy {
}
文件 2 的 11:IContractMetadata.sol
pragma solidity 0.8.17;
interface IHasContractName {
function contractName() external returns (string memory);
}
interface IContractMetadata is IHasContractName {
function contractURI() external returns (string memory);
}
文件 3 的 11:ICreatorCommands.sol
pragma solidity 0.8.17;
interface ICreatorCommands {
enum CreatorActions {
NO_OP,
SEND_ETH,
MINT
}
struct Command {
CreatorActions method;
bytes args;
}
struct CommandSet {
Command[] commands;
uint256 at;
}
}
文件 4 的 11:IERC165Upgradeable.sol
pragma solidity ^0.8.0;
interface IERC165Upgradeable {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 5 的 11:ILimitedMintPerAddress.sol
pragma solidity 0.8.17;
import {IERC165Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC165Upgradeable.sol";
interface ILimitedMintPerAddress is IERC165Upgradeable {
error UserExceedsMintLimit(address user, uint256 limit, uint256 requestedAmount);
function getMintedPerWallet(address token, uint256 tokenId, address wallet) external view returns (uint256);
}
文件 6 的 11:IMinter1155.sol
pragma solidity 0.8.17;
import {IERC165Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC165Upgradeable.sol";
import {ICreatorCommands} from "./ICreatorCommands.sol";
interface IMinter1155 is IERC165Upgradeable {
function requestMint(
address sender,
uint256 tokenId,
uint256 quantity,
uint256 ethValueSent,
bytes calldata minterArguments
) external returns (ICreatorCommands.CommandSet memory commands);
}
文件 7 的 11:IVersionedContract.sol
pragma solidity 0.8.17;
interface IVersionedContract {
function contractVersion() external returns (string memory);
}
文件 8 的 11:LimitedMintPerAddress.sol
pragma solidity 0.8.17;
import {ILimitedMintPerAddress} from "../../interfaces/ILimitedMintPerAddress.sol";
contract LimitedMintPerAddress is ILimitedMintPerAddress {
mapping(address => mapping(uint256 => mapping(address => uint256))) internal mintedPerAddress;
function getMintedPerWallet(address tokenContract, uint256 tokenId, address wallet) external view returns (uint256) {
return mintedPerAddress[tokenContract][tokenId][wallet];
}
function _requireMintNotOverLimitAndUpdate(uint256 limit, uint256 numRequestedMint, address tokenContract, uint256 tokenId, address wallet) internal {
mintedPerAddress[tokenContract][tokenId][wallet] += numRequestedMint;
if (mintedPerAddress[tokenContract][tokenId][wallet] > limit) {
revert UserExceedsMintLimit(wallet, limit, mintedPerAddress[tokenContract][tokenId][wallet]);
}
}
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
return interfaceId == type(ILimitedMintPerAddress).interfaceId;
}
}
文件 9 的 11:SaleCommandHelper.sol
pragma solidity 0.8.17;
import {ICreatorCommands} from "../../interfaces/ICreatorCommands.sol";
library SaleCommandHelper {
function setSize(ICreatorCommands.CommandSet memory commandSet, uint256 size) internal pure {
commandSet.commands = new ICreatorCommands.Command[](size);
}
function mint(ICreatorCommands.CommandSet memory commandSet, address to, uint256 tokenId, uint256 quantity) internal pure {
unchecked {
commandSet.commands[commandSet.at++] = ICreatorCommands.Command({
method: ICreatorCommands.CreatorActions.MINT,
args: abi.encode(to, tokenId, quantity)
});
}
}
function transfer(ICreatorCommands.CommandSet memory commandSet, address to, uint256 amount) internal pure {
unchecked {
commandSet.commands[commandSet.at++] = ICreatorCommands.Command({method: ICreatorCommands.CreatorActions.SEND_ETH, args: abi.encode(to, amount)});
}
}
}
文件 10 的 11:SaleStrategy.sol
pragma solidity 0.8.17;
import {IERC165Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC165Upgradeable.sol";
import {IMinter1155} from "../interfaces/IMinter1155.sol";
import {IContractMetadata} from "../interfaces/IContractMetadata.sol";
import {IVersionedContract} from "../interfaces/IVersionedContract.sol";
abstract contract SaleStrategy is IMinter1155, IVersionedContract, IContractMetadata {
function resetSale(uint256 tokenId) external virtual;
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return interfaceId == type(IMinter1155).interfaceId || interfaceId == type(IERC165Upgradeable).interfaceId;
}
}
文件 11 的 11:ZoraCreatorFixedPriceSaleStrategy.sol
pragma solidity 0.8.17;
import {Enjoy} from "_imagine/mint/Enjoy.sol";
import {IMinter1155} from "../../interfaces/IMinter1155.sol";
import {ICreatorCommands} from "../../interfaces/ICreatorCommands.sol";
import {SaleStrategy} from "../SaleStrategy.sol";
import {SaleCommandHelper} from "../utils/SaleCommandHelper.sol";
import {LimitedMintPerAddress} from "../utils/LimitedMintPerAddress.sol";
contract ZoraCreatorFixedPriceSaleStrategy is Enjoy, SaleStrategy, LimitedMintPerAddress {
struct SalesConfig {
uint64 saleStart;
uint64 saleEnd;
uint64 maxTokensPerAddress;
uint96 pricePerToken;
address fundsRecipient;
}
mapping(address => mapping(uint256 => SalesConfig)) internal salesConfigs;
using SaleCommandHelper for ICreatorCommands.CommandSet;
function contractURI() external pure override returns (string memory) {
return "https://github.com/ourzora/zora-1155-contracts/";
}
function contractName() external pure override returns (string memory) {
return "Fixed Price Sale Strategy";
}
function contractVersion() external pure override returns (string memory) {
return "1.1.0";
}
error WrongValueSent();
error SaleEnded();
error SaleHasNotStarted();
event SaleSet(address indexed mediaContract, uint256 indexed tokenId, SalesConfig salesConfig);
event MintComment(address indexed sender, address indexed tokenContract, uint256 indexed tokenId, uint256 quantity, string comment);
function requestMint(
address,
uint256 tokenId,
uint256 quantity,
uint256 ethValueSent,
bytes calldata minterArguments
) external returns (ICreatorCommands.CommandSet memory commands) {
address mintTo;
string memory comment = "";
if (minterArguments.length == 32) {
mintTo = abi.decode(minterArguments, (address));
} else {
(mintTo, comment) = abi.decode(minterArguments, (address, string));
}
SalesConfig storage config = salesConfigs[msg.sender][tokenId];
if (block.timestamp > config.saleEnd) {
revert SaleEnded();
}
if (block.timestamp < config.saleStart) {
revert SaleHasNotStarted();
}
if (config.pricePerToken * quantity != ethValueSent) {
revert WrongValueSent();
}
if (config.maxTokensPerAddress > 0) {
_requireMintNotOverLimitAndUpdate(config.maxTokensPerAddress, quantity, msg.sender, tokenId, mintTo);
}
bool shouldTransferFunds = config.fundsRecipient != address(0);
commands.setSize(shouldTransferFunds ? 2 : 1);
commands.mint(mintTo, tokenId, quantity);
if (bytes(comment).length > 0) {
emit MintComment(mintTo, msg.sender, tokenId, quantity, comment);
}
if (shouldTransferFunds) {
commands.transfer(config.fundsRecipient, ethValueSent);
}
}
function setSale(uint256 tokenId, SalesConfig memory salesConfig) external {
salesConfigs[msg.sender][tokenId] = salesConfig;
emit SaleSet(msg.sender, tokenId, salesConfig);
}
function resetSale(uint256 tokenId) external override {
delete salesConfigs[msg.sender][tokenId];
emit SaleSet(msg.sender, tokenId, salesConfigs[msg.sender][tokenId]);
}
function sale(address tokenContract, uint256 tokenId) external view returns (SalesConfig memory) {
return salesConfigs[tokenContract][tokenId];
}
function supportsInterface(bytes4 interfaceId) public pure virtual override(LimitedMintPerAddress, SaleStrategy) returns (bool) {
return super.supportsInterface(interfaceId) || LimitedMintPerAddress.supportsInterface(interfaceId) || SaleStrategy.supportsInterface(interfaceId);
}
}
{
"compilationTarget": {
"src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol": "ZoraCreatorFixedPriceSaleStrategy"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 50
},
"remappings": [
":@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
":@zoralabs/openzeppelin-contracts-upgradeable/=node_modules/@zoralabs/openzeppelin-contracts-upgradeable/",
":@zoralabs/protocol-rewards/src/=node_modules/@zoralabs/protocol-rewards/src/",
":_imagine/=_imagine/",
":ds-test/=node_modules/ds-test/src/",
":forge-std/=node_modules/forge-std/src/",
":mint/=_imagine/mint/",
":solady/=node_modules/solady/src/",
":solemate/=/node_modules/solemate/src/",
":solmate/=node_modules/solmate/"
],
"viaIR": true
}
[{"inputs":[],"name":"SaleEnded","type":"error"},{"inputs":[],"name":"SaleHasNotStarted","type":"error"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"name":"UserExceedsMintLimit","type":"error"},{"inputs":[],"name":"WrongValueSent","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"tokenContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"string","name":"comment","type":"string"}],"name":"MintComment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"mediaContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint64","name":"saleStart","type":"uint64"},{"internalType":"uint64","name":"saleEnd","type":"uint64"},{"internalType":"uint64","name":"maxTokensPerAddress","type":"uint64"},{"internalType":"uint96","name":"pricePerToken","type":"uint96"},{"internalType":"address","name":"fundsRecipient","type":"address"}],"indexed":false,"internalType":"struct ZoraCreatorFixedPriceSaleStrategy.SalesConfig","name":"salesConfig","type":"tuple"}],"name":"SaleSet","type":"event"},{"inputs":[],"name":"contractName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"wallet","type":"address"}],"name":"getMintedPerWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"ethValueSent","type":"uint256"},{"internalType":"bytes","name":"minterArguments","type":"bytes"}],"name":"requestMint","outputs":[{"components":[{"components":[{"internalType":"enum ICreatorCommands.CreatorActions","name":"method","type":"uint8"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct ICreatorCommands.Command[]","name":"commands","type":"tuple[]"},{"internalType":"uint256","name":"at","type":"uint256"}],"internalType":"struct ICreatorCommands.CommandSet","name":"commands","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"resetSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"sale","outputs":[{"components":[{"internalType":"uint64","name":"saleStart","type":"uint64"},{"internalType":"uint64","name":"saleEnd","type":"uint64"},{"internalType":"uint64","name":"maxTokensPerAddress","type":"uint64"},{"internalType":"uint96","name":"pricePerToken","type":"uint96"},{"internalType":"address","name":"fundsRecipient","type":"address"}],"internalType":"struct ZoraCreatorFixedPriceSaleStrategy.SalesConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint64","name":"saleStart","type":"uint64"},{"internalType":"uint64","name":"saleEnd","type":"uint64"},{"internalType":"uint64","name":"maxTokensPerAddress","type":"uint64"},{"internalType":"uint96","name":"pricePerToken","type":"uint96"},{"internalType":"address","name":"fundsRecipient","type":"address"}],"internalType":"struct ZoraCreatorFixedPriceSaleStrategy.SalesConfig","name":"salesConfig","type":"tuple"}],"name":"setSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]