master
lza_menace 2 years ago
parent 0dff11698c
commit 7e83d0eab6

@ -13,20 +13,7 @@ chaos ensues until 1000 survivors - the game stops
import {ERC721} from "solmate/tokens/ERC721.sol"; import {ERC721} from "solmate/tokens/ERC721.sol";
import {Owned} from "solmate/auth/Owned.sol"; import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol"; import {LibString} from "solmate/utils/LibString.sol";
import {Unaboomer} from "./Unaboomer.sol"; import {UnaboomerCommon} from "./UnaboomerCommon.sol";
error NotEnoughEther();
error NotOwnerOfToken();
error MaxSupplyReached();
error TooMany();
error NoContract();
error WrongEtherAmount();
error MaxAmountReached();
error NoAdmins();
error NotAdmin();
error NoRemoveSelf();
error NoRemoveDeployer();
error NotEnoughBombs();
contract Mailbomb is ERC721, Owned { contract Mailbomb is ERC721, Owned {
using LibString for uint256; using LibString for uint256;
@ -67,11 +54,17 @@ contract Mailbomb is ERC721, Owned {
unchecked { unchecked {
for (uint256 i; i < _amount; i++) { for (uint256 i; i < _amount; i++) {
minted++; minted++;
_mint(to, minted); _mint(_to, minted);
} }
} }
} }
/// Burn spent tokens from main contract
function burn(uint256 tokenId) external {
require(msg.sender == address(main), "invalid minter");
super._burn(tokenId);
}
function totalSupply() public view returns (uint256 supply) { function totalSupply() public view returns (uint256 supply) {
return minted; return minted;
} }

@ -64,7 +64,7 @@ contract Unaboomer is ERC721, Owned {
unchecked { unchecked {
for (uint256 i; i < _amount; i++) { for (uint256 i; i < _amount; i++) {
minted++; minted++;
_mint(to, minted); _mint(_to, minted);
} }
} }
} }

@ -52,8 +52,8 @@ contract UnaboomerCommon is Owned {
} }
/// Set contract address for Mailbomb tokens /// Set contract address for Mailbomb tokens
function setUnaboomerContract(address _address) external onlyOwner { function setMailbombContract(address _address) external onlyOwner {
mailbomb = Unaboomer(_address); mailbomb = Mailbomb(_address);
} }
// ========================================================================= // =========================================================================
@ -94,14 +94,10 @@ contract UnaboomerCommon is Owned {
for (uint256 i; i < tokenIds.length; i++) { for (uint256 i; i < tokenIds.length; i++) {
require(mailbomb.ownerOf(tokenIds[i]) == msg.sender, "token not owned"); require(mailbomb.ownerOf(tokenIds[i]) == msg.sender, "token not owned");
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(tokenIds[i], block.timestamp, msg.sender))) % boomerSupply; uint256 randomBoomer = uint256(keccak256(abi.encodePacked(tokenIds[i], block.timestamp, msg.sender))) % boomerSupply;
mailbomb._burn(tokenIds[i]); mailbomb.burn(tokenIds[i]);
bool _res = killBoomer(randomBoomer); bool _res = killBoomer(randomBoomer);
res[i] = _res; res[i] = _res;
} }
return res; return res;
} }
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
} }

@ -2,28 +2,34 @@
pragma solidity ^0.8.13; pragma solidity ^0.8.13;
import "forge-std/Test.sol"; import "forge-std/Test.sol";
import {UnaboomerCommon} from "../src/UnaboomerCommon.sol";
import {Unaboomer} from "../src/Unaboomer.sol"; import {Unaboomer} from "../src/Unaboomer.sol";
import {Mailbomb} from "../src/Mailbomb.sol"; import {Mailbomb} from "../src/Mailbomb.sol";
contract UnaboomerTest is Test { contract UnaboomerTest is Test {
UnaboomerCommon public main;
Unaboomer public boomr; Unaboomer public boomr;
Mailbomb public bomb; Mailbomb public bomb;
function setUp() public { function setUp() public {
main = new UnaboomerCommon();
boomr = new Unaboomer(); boomr = new Unaboomer();
bomb = new Mailbomb(); bomb = new Mailbomb();
bomb.setUnaboomerContract(address(boomr)); boomr.setMainContract(address(main));
bomb.setMainContract(address(main));
main.setUnaboomerContract(address(boomr));
main.setMailbombContract(address(bomb));
} }
function testWithdraws() public { function testWithdraws() public {
vm.deal(address(boomr), 11 ether); vm.deal(address(main), 10 ether);
vm.prank(address(boomr.owner())); vm.prank(address(main.owner()));
boomr.withdraw(); main.withdraw();
} }
function testMint() public { function testMint() public {
hoax(address(1)); hoax(address(1));
boomr.mint{value: 0.05 ether}(5); main.radicalizeBoomer{value: 0.05 ether}(5);
assertEq(boomr.totalSupply(), 5); assertEq(boomr.totalSupply(), 5);
assertEq(boomr.tokenDead(1), false); assertEq(boomr.tokenDead(1), false);
} }

Loading…
Cancel
Save