From f27dbb1080b5e811ae6ba8c6d6e1c067b53d9c39 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Fri, 23 Dec 2022 01:38:19 -0800 Subject: [PATCH] setting up ownership stuff and admin funcs --- cache/solidity-files-cache.json | 8 +++--- src/Unaboomer.sol | 45 ++++++++++++++++++++++++++------- test/Unaboomer.t.sol | 10 ++++++++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/cache/solidity-files-cache.json b/cache/solidity-files-cache.json index 09d0d43..7b435dd 100644 --- a/cache/solidity-files-cache.json +++ b/cache/solidity-files-cache.json @@ -844,8 +844,8 @@ } }, "src/Unaboomer.sol": { - "lastModificationDate": 1671786550029, - "contentHash": "dc7a3b2d64abcb2ce07b08d48f6be0e0", + "lastModificationDate": 1671788224237, + "contentHash": "0b13a03c3451af69b934c9c135fa1ea2", "sourceName": "src/Unaboomer.sol", "solcConfig": { "settings": { @@ -888,8 +888,8 @@ } }, "test/Unaboomer.t.sol": { - "lastModificationDate": 1671786295883, - "contentHash": "e7d519d9b20eaf140b82bbd014382633", + "lastModificationDate": 1671788116305, + "contentHash": "16626fed72f7b7cf459778574cb060a1", "sourceName": "test/Unaboomer.t.sol", "solcConfig": { "settings": { diff --git a/src/Unaboomer.sol b/src/Unaboomer.sol index 6ae279a..60e3e95 100644 --- a/src/Unaboomer.sol +++ b/src/Unaboomer.sol @@ -20,6 +20,7 @@ error TooMany(); error NoContract(); error WrongEtherAmount(); error MaxAmountReached(); +error NoAdmins(); contract Unaboomer is Owned, ERC721 { using LibString for uint256; @@ -30,26 +31,52 @@ contract Unaboomer is Owned, ERC721 { } mapping(uint256 => TokenState) public tokenState; + mapping(address => bool) public adminWallets; uint256 public constant MAX_SUPPLY = 10000; uint256 public minted; string public livingURI; string public deadURI; + address[] public payoutWallets; constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {} - function mint(uint256 amount) external payable { - if (msg.sender == tx.origin) { - revert NoContract(); - } - if (amount > 20) { - revert TooMany(); + // ========================================================================= + // Admin + // ========================================================================= + + ///@dev Specify team wallets for payouts and contract administration + function updateAdmins(address[] calldata _admins) external onlyOwner { + payoutWallets = _admins; + for (uint256 i; i < _admins.length; i++) { + adminWallets[_admins[i]] = true; } - if (minted + amount > MAX_SUPPLY) { - revert MaxSupplyReached(); + } + + ///@dev Remove admins if needed + function removeAdmin(address _admin) external onlyOwner { + adminWallets[_admin] = false; + } + + ///@dev Split payments to team + function withdraw() external onlyOwner { + 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); } + } + + // ========================================================================= + // Tokens + // ========================================================================= + + function mint(uint256 _amount) external payable { + if (msg.sender == tx.origin) revert NoContract(); + if (_amount > 20) revert TooMany(); + if (minted + _amount > MAX_SUPPLY) revert MaxSupplyReached(); unchecked { - for (uint256 i; i < amount; i++) { + for (uint256 i; i < _amount; i++) { _mint(msg.sender, minted + 1); minted++; } diff --git a/test/Unaboomer.t.sol b/test/Unaboomer.t.sol index b918d5e..8f1343d 100644 --- a/test/Unaboomer.t.sol +++ b/test/Unaboomer.t.sol @@ -13,6 +13,16 @@ contract UnaboomerTest is Test { boomr = new Unaboomer(); } + function testUpdatingAdmins() public { + address[] memory owners; + owners[0] = address(2); + owners[1] = address(3); + boomr.transferOwnership(address(1)); + startHoax(address(1)); + boomr.updateAdmins(owners); + assertEq(boomr.adminWallets(address(2)), true); + } + function testMint() public { vm.startPrank(alice); boomr.mint(5);