文件 1 的 8:ERC721Structs.sol
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
struct CreateParams {
string name;
string symbol;
string uri;
string tokensURI;
uint24 maxSupply;
bool isZeroIndexed;
uint24 royaltyAmount;
uint256 endTime;
}
struct MintParams {
address collection;
uint24 quantity;
bytes32[] merkleProof;
uint8 phaseId;
}
struct OmnichainMintParams {
address collection;
uint24 quantity;
uint256 paid;
uint8 phaseId;
address minter;
}
struct Phase {
uint256 from;
uint256 to;
uint24 maxPerAddress;
uint256 price;
bytes32 merkleRoot;
}
struct BasicCollectionParams {
string name;
string symbol;
string uri;
string tokensURI;
uint24 maxSupply;
address owner;
}
文件 2 的 8:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 3 的 8:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 4 的 8:IOmniseaDropsFactory.sol
pragma solidity ^0.8.7;
import {CreateParams} from "../structs/erc721/ERC721Structs.sol";
interface IOmniseaDropsFactory {
function create(CreateParams calldata params) external;
function drops(address) external returns (bool);
}
文件 5 的 8:IOmniseaERC721Psi.sol
pragma solidity >=0.5.0;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { CreateParams } from "../structs/erc721/ERC721Structs.sol";
interface IOmniseaERC721Psi is IERC165 {
function initialize(CreateParams memory params, address _owner, address _dropsManagerAddress, address _scheduler, address _universalONFT) external;
function mint(address _minter, uint24 _quantity, bytes32[] memory _merkleProof, uint8 _phaseId) external;
function mintPrice(uint8 _phaseId) external view returns (uint256);
function exists(uint256 tokenId) external view returns (bool);
function owner() external view returns (address);
function dropsManager() external view returns (address);
}
文件 6 的 8:OmniseaDropsFactory.sol
pragma solidity ^0.8.7;
import "../interfaces/IOmniseaERC721Psi.sol";
import "./OmniseaERC721PsiProxy.sol";
import "../interfaces/IOmniseaDropsFactory.sol";
import { CreateParams } from "../structs/erc721/ERC721Structs.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract OmniseaDropsFactory is IOmniseaDropsFactory, ReentrancyGuard {
address internal _manager;
address public owner;
address public scheduler;
address public universalONFT;
address public omniseaERC721Psi;
mapping(address => bool) public drops;
event Created(address indexed collection);
constructor(address _scheduler, address _universalONFT, address _omniseaERC721Psi) {
owner = msg.sender;
scheduler = _scheduler;
universalONFT = _universalONFT;
omniseaERC721Psi = _omniseaERC721Psi;
}
function create(CreateParams calldata _params) external override nonReentrant {
OmniseaERC721PsiProxy proxy = new OmniseaERC721PsiProxy(omniseaERC721Psi);
address proxyAddress = address(proxy);
IOmniseaERC721Psi(proxyAddress).initialize(_params, msg.sender, _manager, scheduler, universalONFT);
drops[proxyAddress] = true;
emit Created(proxyAddress);
}
function setManager(address manager_) external {
require(msg.sender == owner);
_manager = manager_;
}
}
文件 7 的 8:OmniseaERC721PsiProxy.sol
pragma solidity ^0.8.0;
contract OmniseaERC721PsiProxy {
address private _proxy;
constructor(address proxy_) {
_proxy = proxy_;
}
fallback() external payable {
_delegate(_proxy);
}
receive() external payable {
_delegate(_proxy);
}
function _delegate(address _proxyTo) internal {
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let result := delegatecall(gas(), _proxyTo, ptr, calldatasize(), 0, 0)
let size := returndatasize()
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
}
文件 8 的 8:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
{
"compilationTarget": {
"src/contracts/v3/OmniseaDropsFactory.sol": "OmniseaDropsFactory"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_scheduler","type":"address"},{"internalType":"address","name":"_universalONFT","type":"address"},{"internalType":"address","name":"_omniseaERC721Psi","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"}],"name":"Created","type":"event"},{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"string","name":"tokensURI","type":"string"},{"internalType":"uint24","name":"maxSupply","type":"uint24"},{"internalType":"bool","name":"isZeroIndexed","type":"bool"},{"internalType":"uint24","name":"royaltyAmount","type":"uint24"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"internalType":"struct CreateParams","name":"_params","type":"tuple"}],"name":"create","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"drops","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"omniseaERC721Psi","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scheduler","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"manager_","type":"address"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"universalONFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]