文件 1 的 5:BidProxy.sol
pragma solidity ^0.8.0;
import "./Pausable.sol";
import "./IKittyCore.sol";
import "./ISaleClockAuction.sol";
contract BidProxy is Pausable {
IKittyCore private immutable kitties;
ISaleClockAuction private immutable saleAuction;
address private constant WALLET1 = 0x37932f3ECA864632156CcbA7E2814b51A374caEc;
address private constant WALLET2 = 0x989A2ad9aCaa8C4e50B2fC6B650d6e1809b9195b;
constructor(address _kitties, address _saleAuction) {
kitties = IKittyCore(_kitties);
saleAuction = ISaleClockAuction(_saleAuction);
}
function _warmUpDapperWallet(address wallet) private view {
assembly {
extcodecopy(wallet, 0, 0, 0)
}
}
receive() external payable whenNotPaused {
if (msg.value > 0) {
require(msg.sender == address(saleAuction));
}
}
function _bid(uint256 _kittyId) private {
uint256 balanceBefore = address(this).balance - msg.value;
saleAuction.bid{value: msg.value}(_kittyId);
kitties.transfer(msg.sender, _kittyId);
require(kitties.ownerOf(_kittyId) == msg.sender);
uint256 balanceAfter = address(this).balance;
uint256 change = balanceAfter - balanceBefore;
if (change > 0) {
payable(msg.sender).transfer(change);
}
}
function bid(uint256 _kittyId) external payable whenNotPaused {
_warmUpDapperWallet(WALLET1);
_warmUpDapperWallet(WALLET2);
_bid(_kittyId);
}
function bidWithSpecificWarmups(uint256 _kittyId, address[] calldata _accountsToWarmUp) external payable whenNotPaused {
uint256 len = _accountsToWarmUp.length;
for (uint256 i = 0; i < len; i += 1) {
_warmUpDapperWallet(_accountsToWarmUp[i]);
}
_bid(_kittyId);
}
function rescueLostKitty(uint256 _kittyId, address _recipient) external onlyOwner whenNotPaused {
kitties.transfer(_recipient, _kittyId);
}
function call(address payable _to, uint256 _value, bytes calldata _data) external onlyOwner whenNotPaused payable returns (bytes memory) {
require(_to != address(0));
(bool _success, bytes memory _result) = _to.call{value: _value}(_data);
require(_success);
return _result;
}
}
文件 2 的 5:IKittyCore.sol
pragma solidity ^0.8.0;
interface IKittyCore {
function ownerOf(uint256 _tokenId) external view returns (address owner);
function transfer(address _to, uint256 _tokenId) external;
}
文件 3 的 5:ISaleClockAuction.sol
pragma solidity ^0.8.0;
interface ISaleClockAuction {
function bid(uint256 _tokenId) external payable;
function getAuction(uint256 _tokenId) external view returns (address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt);
function getCurrentPrice(uint256 _tokenId) external view returns (uint256);
}
文件 4 的 5:Ownable.sol
pragma solidity ^0.8.0;
contract Ownable {
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
文件 5 的 5:Pausable.sol
pragma solidity ^0.8.0;
import "./Ownable.sol";
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() external onlyOwner whenNotPaused returns (bool) {
paused = true;
emit Pause();
return true;
}
function unpause() external onlyOwner whenPaused returns (bool) {
paused = false;
emit Unpause();
return true;
}
}
{
"compilationTarget": {
"BidProxy.sol": "BidProxy"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_kitties","type":"address"},{"internalType":"address","name":"_saleAuction","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"inputs":[{"internalType":"uint256","name":"_kittyId","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kittyId","type":"uint256"},{"internalType":"address[]","name":"_accountsToWarmUp","type":"address[]"}],"name":"bidWithSpecificWarmups","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"call","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kittyId","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"rescueLostKitty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]