diff --git a/src/Unaboomer.sol b/src/Unaboomer.sol index 172228d..a0da436 100644 --- a/src/Unaboomer.sol +++ b/src/Unaboomer.sol @@ -11,6 +11,7 @@ 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(); @@ -24,67 +25,44 @@ error NotAdmin(); error NoRemoveSelf(); error NoRemoveDeployer(); -contract Unaboomer is ERC721 { +contract Unaboomer is ERC721, Owned { using LibString for uint256; mapping(uint256 => bool) public tokenDead; - mapping(address => bool) public adminWallets; uint256 public constant MAX_SUPPLY = 10000; uint256 public minted; - string public livingURI; + string public aliveURI; string public deadURI; - address public deployer; - address[] public payoutWallets; + address public MailBombContract; - constructor() ERC721("Unaboomer", "BOOMR") { - deployer = msg.sender; - adminWallets[msg.sender] = true; - } + constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {} // ========================================================================= // 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 onlyAdmin { - payoutWallets = _admins; - for (uint256 i; i < _admins.length; i++) { - adminWallets[_admins[i]] = true; - } - } - - ///@dev Remove admins if needed - 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 onlyAdmin { - if (payoutWallets.length == 0) revert NoAdmins(); + /// Withdraw funds to contract owner + function withdraw() external onlyOwner { uint256 balance = address(this).balance; - for (uint256 i; i < payoutWallets.length; i++) { - // payable(payoutWallets[i]).transfer(balance / payoutWallets.length); - (bool success, ) = payable(payoutWallets[i]).call{value: balance / payoutWallets.length}(""); - require(success, "failed to withdraw"); - } + payable(msg.sender).transfer(balance); } - function setLivingURI(string calldata _baseURI) external onlyAdmin { - livingURI = _baseURI; + /// Set metadata URI for alive BOOMR + function setAliveURI(string calldata _baseURI) external onlyOwner { + aliveURI = _baseURI; } - function setDeadURI(string calldata _baseURI) external onlyAdmin { + /// Set metadata URI for dead BOOMR + function setDeadURI(string calldata _baseURI) external onlyOwner { deadURI = _baseURI; } + /// Set contract address for Mailbomb tokens + function setMailBombContract(address _address) external onlyOwner { + MailBombContract = _address; + } + // ========================================================================= // Tokens // ========================================================================= @@ -99,6 +77,7 @@ contract Unaboomer is ERC721 { minted++; } } + // also mint 2 BOMB to user } function totalSupply() view public returns (uint256 supply) { @@ -106,14 +85,14 @@ contract Unaboomer is ERC721 { } function tokenURI(uint256 _tokenId) public view override returns (string memory) { - if (tokenDead[_tokenId] == false) { - return string(abi.encodePacked(livingURI, _tokenId.toString(), ".json")); - } else { + if (tokenDead[_tokenId]) { return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json")); + } else { + return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json")); } } function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) { return super.supportsInterface(interfaceId); } -} +} \ No newline at end of file diff --git a/test/Unaboomer.t.sol b/test/Unaboomer.t.sol index 6f00207..898e584 100644 --- a/test/Unaboomer.t.sol +++ b/test/Unaboomer.t.sol @@ -6,42 +6,20 @@ import "../src/Unaboomer.sol"; contract UnaboomerTest is Test { Unaboomer public boomr; - address alice = address(1); - address bob = address(2); - address[] admins = new address[](2); function setUp() public { boomr = new Unaboomer(); - admins[0] = address(1); - admins[1] = address(2); - boomr.updateAdmins(admins); - } - - function testUpdatingAdmins() public { - // confirm admin on 1 and 2 - assertEq(boomr.adminWallets(boomr.deployer()), true); - assertEq(boomr.adminWallets(address(1)), true); - assertEq(boomr.adminWallets(address(2)), true); - assertEq(boomr.adminWallets(address(3)), false); - hoax(address(1)); - boomr.removeAdmin(address(2)); - assertEq(boomr.adminWallets(address(2)), false); - hoax(address(2)); - vm.expectRevert(); - boomr.withdraw(); } function testWithdraws() public { - // confirm payouts divvy equally - vm.deal(address(boomr), 11.5 ether); - vm.prank(address(1)); + vm.deal(address(boomr), 11 ether); + vm.prank(address(boomr.owner())); boomr.withdraw(); - assertEq(address(1).balance, 5.75 ether); - assertEq(address(2).balance, 5.75 ether); + assertEq(boomr.owner().balance > 10 ether, true); } function testMint() public { - vm.startPrank(alice); + vm.startPrank(address(1)); boomr.mint(5); assertEq(boomr.totalSupply(), 5); assertEq(boomr.tokenDead(1), false);