编译器
0.8.21+commit.d9974bed
文件 1 的 8:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 2 的 8:IDragonDistributor.sol
pragma solidity ^0.8.13;
interface IDragonDistributor {
event Initialize(address indexed dragonOG, uint256 startTimeA, uint256 endTimeA,
uint256 startTimeB, uint256 endTimeB, uint256 startTimePublic, uint256 endTimePublic);
event UpdateBaseURI(string baseURI);
event WhiteListAAdded(address indexed user, uint256 count);
event WhiteListARemoved(address indexed user);
event WhiteListBAdded(address indexed user, uint256 count);
event WhiteListBRemoved(address indexed user);
event MintA(address indexed user, uint256 indexed id);
event MintB(address indexed user, uint256 indexed id);
event PublicMint(address indexed user, uint256 indexed id);
function mintA(address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function mintB(address receiver, uint256 price, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function publicMint(address receiver, uint256 price, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function transferDragonOwner(address newOwner) external;
function mintableDragons(address user) external view returns(uint256, uint256, uint256);
function timeWindows() external view returns(uint256, uint256, uint256, uint256, uint256, uint256);
error ZeroWETHAddress(address thrower);
error NotInWhiteListA(address thrower, address user);
error NotInWhiteListB(address thrower, address user);
error AlreadyMinted(address thrower, address user, uint256 count);
error AlreadyEnded(address thrower, uint256 endTime);
error NotEnoughETH(address thrower, uint256 amount);
}
文件 3 的 8:IERC20.sol
pragma solidity ^0.8.20;
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 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 4 的 8:IWETH.sol
pragma solidity ^0.8.11;
interface IWETH {
function deposit() external payable;
function withdraw(uint256) external;
function approve(address guy, uint256 wad) external returns (bool);
function balanceOf(address user) external returns (uint256);
function transferFrom(
address src,
address dst,
uint256 wad
) external returns (bool);
}
文件 5 的 8:IWETHGateway.sol
pragma solidity ^0.8.11;
interface IWETHGateway {
function mintB(address distributor, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable;
function publicMint(address distributor, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable;
}
文件 6 的 8:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 7 的 8:Ownable2Step.sol
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
文件 8 的 8:WETHGateway.sol
pragma solidity ^0.8.11;
pragma experimental ABIEncoderV2;
import {IWETH} from './interfaces/IWETH.sol';
import {IWETHGateway} from './interfaces/IWETHGateway.sol';
import {IDragonDistributor} from './interfaces/IDragonDistributor.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {Ownable, Ownable2Step} from '@openzeppelin/contracts/access/Ownable2Step.sol';
contract WETHGateway is IWETHGateway, Ownable2Step {
IWETH internal immutable WETH;
mapping(address => uint256) public balanceOf;
constructor(address weth) Ownable(msg.sender) {
WETH = IWETH(weth);
}
function authorizeDistributor(address distributor) external onlyOwner {
WETH.approve(distributor, type(uint256).max);
}
function mintB(address distributor, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable override {
WETH.deposit{value: msg.value}();
IDragonDistributor(distributor).mintB(receiver, msg.value, deadline, v, r, s);
}
function publicMint(address distributor, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable override {
WETH.deposit{value: msg.value}();
IDragonDistributor(distributor).publicMint(receiver, msg.value, deadline, v, r, s);
}
function _safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'ETH_TRANSFER_FAILED');
}
function emergencyTokenTransfer(
address token,
address to,
uint256 amount
) external onlyOwner {
IERC20(token).transfer(to, amount);
}
function emergencyEtherTransfer(address to, uint256 amount) external onlyOwner {
_safeTransferETH(to, amount);
}
function getWETHAddress() external view returns (address) {
return address(WETH);
}
receive() external payable {
require(msg.sender == address(WETH), 'Receive not allowed');
}
fallback() external payable {
revert('Fallback not allowed');
}
}
{
"compilationTarget": {
"src/WETHGateway.sol": "WETHGateway"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"distributor","type":"address"}],"name":"authorizeDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyEtherTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getWETHAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"distributor","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"mintB","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"distributor","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"publicMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]