|
|
|
@ -11,7 +11,6 @@ chaos ensues until 1000 survivors - the game stops
|
|
|
|
|
********/
|
|
|
|
|
|
|
|
|
|
import {ERC721} from "solmate/tokens/ERC721.sol";
|
|
|
|
|
import {Owned} from "solmate/auth/Owned.sol";
|
|
|
|
|
import {LibString} from "solmate/utils/LibString.sol";
|
|
|
|
|
|
|
|
|
|
error NotOwnerOfToken();
|
|
|
|
@ -21,32 +20,39 @@ error NoContract();
|
|
|
|
|
error WrongEtherAmount();
|
|
|
|
|
error MaxAmountReached();
|
|
|
|
|
error NoAdmins();
|
|
|
|
|
error NotAdmin();
|
|
|
|
|
error NoRemoveSelf();
|
|
|
|
|
error NoRemoveDeployer();
|
|
|
|
|
|
|
|
|
|
contract Unaboomer is Owned, ERC721 {
|
|
|
|
|
contract Unaboomer is ERC721 {
|
|
|
|
|
using LibString for uint256;
|
|
|
|
|
|
|
|
|
|
enum TokenState {
|
|
|
|
|
LIVING,
|
|
|
|
|
DEAD
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapping(uint256 => TokenState) public tokenState;
|
|
|
|
|
mapping(uint256 => bool) public tokenDead;
|
|
|
|
|
mapping(address => bool) public adminWallets;
|
|
|
|
|
|
|
|
|
|
uint256 public constant MAX_SUPPLY = 10000;
|
|
|
|
|
uint256 public minted;
|
|
|
|
|
string public livingURI;
|
|
|
|
|
string public deadURI;
|
|
|
|
|
address public deployer;
|
|
|
|
|
address[] public payoutWallets;
|
|
|
|
|
|
|
|
|
|
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
|
|
|
|
|
constructor() ERC721("Unaboomer", "BOOMR") {
|
|
|
|
|
deployer = msg.sender;
|
|
|
|
|
adminWallets[msg.sender] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
// Admin
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
modifier onlyAdmin {
|
|
|
|
|
if (adminWallets[msg.sender] == false) revert NotAdmin();
|
|
|
|
|
_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///@dev Specify team wallets for payouts and contract administration
|
|
|
|
|
function updateAdmins(address[] calldata _admins) external onlyOwner {
|
|
|
|
|
function updateAdmins(address[] calldata _admins) external onlyAdmin {
|
|
|
|
|
payoutWallets = _admins;
|
|
|
|
|
for (uint256 i; i < _admins.length; i++) {
|
|
|
|
|
adminWallets[_admins[i]] = true;
|
|
|
|
@ -54,19 +60,31 @@ contract Unaboomer is Owned, ERC721 {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///@dev Remove admins if needed
|
|
|
|
|
function removeAdmin(address _admin) external onlyOwner {
|
|
|
|
|
function removeAdmin(address _admin) external onlyAdmin {
|
|
|
|
|
if (msg.sender == _admin) revert NoRemoveSelf();
|
|
|
|
|
if (_admin == deployer) revert NoRemoveDeployer();
|
|
|
|
|
adminWallets[_admin] = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///@dev Split payments to team
|
|
|
|
|
function withdraw() external onlyOwner {
|
|
|
|
|
function withdraw() external onlyAdmin {
|
|
|
|
|
if (payoutWallets.length == 0) revert NoAdmins();
|
|
|
|
|
uint256 balance = address(this).balance;
|
|
|
|
|
for (uint256 i; i < payoutWallets.length; i++) {
|
|
|
|
|
payable(payoutWallets[i]).transfer(balance / payoutWallets.length);
|
|
|
|
|
// payable(payoutWallets[i]).transfer(balance / payoutWallets.length);
|
|
|
|
|
(bool success, ) = payable(payoutWallets[i]).call{value: balance / payoutWallets.length}("");
|
|
|
|
|
require(success, "failed to withdraw");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setLivingURI(string calldata _baseURI) external onlyAdmin {
|
|
|
|
|
livingURI = _baseURI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setDeadURI(string calldata _baseURI) external onlyAdmin {
|
|
|
|
|
deadURI = _baseURI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
// Tokens
|
|
|
|
|
// =========================================================================
|
|
|
|
@ -87,12 +105,8 @@ contract Unaboomer is Owned, ERC721 {
|
|
|
|
|
return minted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setBaseURI(string calldata _baseURI) external onlyOwner {
|
|
|
|
|
livingURI = _baseURI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
|
|
|
|
|
if (tokenState[_tokenId] == TokenState.LIVING) {
|
|
|
|
|
if (tokenDead[_tokenId] == false) {
|
|
|
|
|
return string(abi.encodePacked(livingURI, _tokenId.toString(), ".json"));
|
|
|
|
|
} else {
|
|
|
|
|
return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json"));
|
|
|
|
|