setting up ownership stuff and admin funcs

master
lza_menace 2 years ago
parent a98c468e6d
commit f27dbb1080

@ -844,8 +844,8 @@
} }
}, },
"src/Unaboomer.sol": { "src/Unaboomer.sol": {
"lastModificationDate": 1671786550029, "lastModificationDate": 1671788224237,
"contentHash": "dc7a3b2d64abcb2ce07b08d48f6be0e0", "contentHash": "0b13a03c3451af69b934c9c135fa1ea2",
"sourceName": "src/Unaboomer.sol", "sourceName": "src/Unaboomer.sol",
"solcConfig": { "solcConfig": {
"settings": { "settings": {
@ -888,8 +888,8 @@
} }
}, },
"test/Unaboomer.t.sol": { "test/Unaboomer.t.sol": {
"lastModificationDate": 1671786295883, "lastModificationDate": 1671788116305,
"contentHash": "e7d519d9b20eaf140b82bbd014382633", "contentHash": "16626fed72f7b7cf459778574cb060a1",
"sourceName": "test/Unaboomer.t.sol", "sourceName": "test/Unaboomer.t.sol",
"solcConfig": { "solcConfig": {
"settings": { "settings": {

@ -20,6 +20,7 @@ error TooMany();
error NoContract(); error NoContract();
error WrongEtherAmount(); error WrongEtherAmount();
error MaxAmountReached(); error MaxAmountReached();
error NoAdmins();
contract Unaboomer is Owned, ERC721 { contract Unaboomer is Owned, ERC721 {
using LibString for uint256; using LibString for uint256;
@ -30,26 +31,52 @@ contract Unaboomer is Owned, ERC721 {
} }
mapping(uint256 => TokenState) public tokenState; mapping(uint256 => TokenState) public tokenState;
mapping(address => bool) public adminWallets;
uint256 public constant MAX_SUPPLY = 10000; uint256 public constant MAX_SUPPLY = 10000;
uint256 public minted; uint256 public minted;
string public livingURI; string public livingURI;
string public deadURI; string public deadURI;
address[] public payoutWallets;
constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {} constructor() ERC721("Unaboomer", "BOOMR") Owned(msg.sender) {}
function mint(uint256 amount) external payable { // =========================================================================
if (msg.sender == tx.origin) { // Admin
revert NoContract(); // =========================================================================
}
if (amount > 20) { ///@dev Specify team wallets for payouts and contract administration
revert TooMany(); 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 { unchecked {
for (uint256 i; i < amount; i++) { for (uint256 i; i < _amount; i++) {
_mint(msg.sender, minted + 1); _mint(msg.sender, minted + 1);
minted++; minted++;
} }

@ -13,6 +13,16 @@ contract UnaboomerTest is Test {
boomr = new Unaboomer(); 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 { function testMint() public {
vm.startPrank(alice); vm.startPrank(alice);
boomr.mint(5); boomr.mint(5);

Loading…
Cancel
Save