Skip to content

Commit

Permalink
Remove mint fee manager completely.
Browse files Browse the repository at this point in the history
Fix all tests to now consider there's a fee automatically
  • Loading branch information
oveddan committed Aug 10, 2023
1 parent 8fa67c6 commit dd6497b
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 196 deletions.
39 changes: 0 additions & 39 deletions src/fee/MintFeeManager.sol

This file was deleted.

90 changes: 0 additions & 90 deletions test/fee/MintFeeManager.t.sol

This file was deleted.

30 changes: 18 additions & 12 deletions test/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
address payable internal admin = payable(address(0x999));
address internal zora;

uint256 constant TOTAL_REWARD_PER_MINT = 0.000777 ether;

event SaleSet(address indexed mediaContract, uint256 indexed tokenId, ZoraCreatorFixedPriceSaleStrategy.SalesConfig salesConfig);
event MintComment(address indexed sender, address indexed tokenContract, uint256 indexed tokenId, uint256 quantity, string comment);

Expand All @@ -31,6 +33,10 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
fixedPrice = new ZoraCreatorFixedPriceSaleStrategy();
}

function rewardsValue(uint256 quantity) private pure returns (uint256) {
return quantity * TOTAL_REWARD_PER_MINT;
}

function test_ContractName() external {
assertEq(fixedPrice.contractName(), "Fixed Price Sale Strategy");
}
Expand Down Expand Up @@ -76,7 +82,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
vm.deal(tokenRecipient, 20 ether);

vm.startPrank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));

assertEq(target.balanceOf(tokenRecipient, newTokenId), 10);
assertEq(address(target).balance, 10 ether);
Expand Down Expand Up @@ -121,7 +127,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
vm.deal(tokenRecipient, 20 ether);

vm.startPrank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient));

assertEq(target.balanceOf(tokenRecipient, newTokenId), 10);
assertEq(address(target).balance, 10 ether);
Expand Down Expand Up @@ -168,7 +174,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
vm.startPrank(tokenRecipient);
vm.expectEmit(true, true, true, true);
emit MintComment(tokenRecipient, address(target), newTokenId, 10, "test comment");
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, "test comment"));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, "test comment"));

assertEq(target.balanceOf(tokenRecipient, newTokenId), 10);
assertEq(address(target).balance, 10 ether);
Expand Down Expand Up @@ -202,7 +208,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {

vm.expectRevert(abi.encodeWithSignature("SaleHasNotStarted()"));
vm.prank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
}

function test_SaleEnd() external {
Expand Down Expand Up @@ -233,7 +239,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {

vm.expectRevert(abi.encodeWithSignature("SaleEnded()"));
vm.prank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
}

function test_MaxTokensPerAddress() external {
Expand Down Expand Up @@ -264,7 +270,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {

vm.prank(tokenRecipient);
vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddress.UserExceedsMintLimit.selector, tokenRecipient, 5, 6));
target.mint{value: 6 ether}(fixedPrice, newTokenId, 6, abi.encode(tokenRecipient, ""));
target.mint{value: 6 ether + rewardsValue(6)}(fixedPrice, newTokenId, 6, abi.encode(tokenRecipient, ""));
}

function testFail_setupMint() external {
Expand Down Expand Up @@ -292,7 +298,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
vm.deal(tokenRecipient, 20 ether);

vm.startPrank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient));

assertEq(target.balanceOf(tokenRecipient, newTokenId), 10);
assertEq(address(target).balance, 10 ether);
Expand Down Expand Up @@ -328,10 +334,10 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {

vm.startPrank(tokenRecipient);
vm.expectRevert(abi.encodeWithSignature("WrongValueSent()"));
target.mint{value: 0.9 ether}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
target.mint{value: 0.9 ether + rewardsValue(1)}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
vm.expectRevert(abi.encodeWithSignature("WrongValueSent()"));
target.mint{value: 1.1 ether}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
target.mint{value: 1 ether}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
target.mint{value: 1.1 ether + rewardsValue(1)}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
target.mint{value: 1 ether + rewardsValue(1)}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""));
vm.stopPrank();
}

Expand Down Expand Up @@ -359,7 +365,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
address tokenRecipient = address(322);
vm.deal(tokenRecipient, 20 ether);
vm.prank(tokenRecipient);
target.mint{value: 10 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
target.mint{value: 10 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));

assertEq(address(1).balance, 10 ether);
}
Expand Down Expand Up @@ -388,7 +394,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
address tokenRecipient = address(322);
vm.deal(tokenRecipient, 20 ether);
vm.prank(tokenRecipient);
target.mint{value: 0 ether}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));
target.mint{value: 0 ether + rewardsValue(10)}(fixedPrice, newTokenId, 10, abi.encode(tokenRecipient, ""));

assertEq(fixedPrice.getMintedPerWallet(address(target), newTokenId, tokenRecipient), 10);
}
Expand Down
26 changes: 16 additions & 10 deletions test/minters/merkle/ZoraCreatorMerkleMinterStrategy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
address payable internal admin = payable(address(0x999));
address internal zora;

uint256 constant TOTAL_REWARD_PER_MINT = 0.000777 ether;

event SaleSet(address indexed sender, uint256 indexed tokenId, ZoraCreatorMerkleMinterStrategy.MerkleSaleSettings merkleSaleSettings);

function setUp() external {
Expand All @@ -32,6 +34,10 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
merkleMinter = new ZoraCreatorMerkleMinterStrategy();
}

function rewardsValue(uint256 quantity) private pure returns (uint256) {
return quantity * TOTAL_REWARD_PER_MINT;
}

function test_ContractURI() external {
assertEq(merkleMinter.contractURI(), "https://github.com/ourzora/zora-1155-contracts/");
}
Expand Down Expand Up @@ -80,7 +86,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
merkleProof[0] = bytes32(0x71013e6ce1f439aaa91aa706ddd0769517fbaa4d72a936af4a7c75d29b1ca862);

vm.startPrank(mintTo);
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));

assertEq(target.balanceOf(mintTo, newTokenId), 10);
assertEq(address(target).balance, 10 ether);
Expand Down Expand Up @@ -119,7 +125,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {

vm.prank(mintTo);
vm.expectRevert(abi.encodeWithSignature("SaleHasNotStarted()"));
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
}

function test_PreSaleEnd() external {
Expand Down Expand Up @@ -154,7 +160,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {

vm.prank(mintTo);
vm.expectRevert(abi.encodeWithSignature("SaleEnded()"));
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
}

function test_FundsRecipient() external {
Expand Down Expand Up @@ -193,7 +199,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
merkleProof[0] = bytes32(0x71013e6ce1f439aaa91aa706ddd0769517fbaa4d72a936af4a7c75d29b1ca862);

vm.prank(mintTo);
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));

assertEq(address(1234).balance, 10 ether);
}
Expand Down Expand Up @@ -235,7 +241,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {

vm.prank(mintTo);
vm.expectRevert(abi.encodeWithSignature("InvalidMerkleProof(address,bytes32[],bytes32)", mintTo, merkleProof, root));
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
}

function test_MaxQuantity() external {
Expand Down Expand Up @@ -274,14 +280,14 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
merkleProof[0] = bytes32(0x71013e6ce1f439aaa91aa706ddd0769517fbaa4d72a936af4a7c75d29b1ca862);

vm.startPrank(mintTo);
target.mint{value: 10 ether}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 10 ether + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddress.UserExceedsMintLimit.selector, mintTo, 10, 11));
target.mint{value: 1 ether}(merkleMinter, newTokenId, 1, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: 1 ether + rewardsValue(1)}(merkleMinter, newTokenId, 1, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));

vm.stopPrank();
}

function test_PricePerToken(uint256 ethToSend) external {
function test_PricePerToken(uint128 ethToSend) external {
vm.assume(ethToSend != 10 ether);
vm.startPrank(admin);
uint256 newTokenId = target.setupNewToken("https://zora.co/testing/token.json", 10);
Expand Down Expand Up @@ -310,7 +316,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {
vm.stopPrank();

address mintTo = address(0x0000000000000000000000000000000000000001);
vm.deal(mintTo, ethToSend);
vm.deal(mintTo, ethToSend + rewardsValue(10));

uint256 maxQuantity = 10;
uint256 pricePerToken = 1000000000000000000;
Expand All @@ -319,7 +325,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {

vm.startPrank(mintTo);
vm.expectRevert(abi.encodeWithSignature("WrongValueSent()"));
target.mint{value: ethToSend}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
target.mint{value: ethToSend + rewardsValue(10)}(merkleMinter, newTokenId, 10, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));
}

function test_ResetSale() external {
Expand Down
Loading

0 comments on commit dd6497b

Please sign in to comment.