Skip to content

Commit

Permalink
fix update
Browse files Browse the repository at this point in the history
  • Loading branch information
iainnash committed Aug 15, 2023
1 parent 3048e30 commit 74c7948
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 126 deletions.
6 changes: 3 additions & 3 deletions src/ERC721Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/se
import {MerkleProofUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {MathUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import {IProtocolRewards} from "@zoralabs/protocol-rewards/dist/contracts/interfaces/IProtocolRewards.sol";
import {ERC721Rewards} from "@zoralabs/protocol-rewards/dist/contracts/abstract/ERC721/ERC721Rewards.sol";
import {ERC721RewardsStorageV1} from "@zoralabs/protocol-rewards/dist/contracts/abstract/ERC721/ERC721RewardsStorageV1.sol";
import {IProtocolRewards} from "@zoralabs/protocol-rewards/src/interfaces/IProtocolRewards.sol";
import {ERC721Rewards} from "@zoralabs/protocol-rewards/src/abstract/ERC721/ERC721Rewards.sol";
import {ERC721RewardsStorageV1} from "@zoralabs/protocol-rewards/src/abstract/ERC721/ERC721RewardsStorageV1.sol";

import {IMetadataRenderer} from "./interfaces/IMetadataRenderer.sol";
import {IOperatorFilterRegistry} from "./interfaces/IOperatorFilterRegistry.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/ERC721Drop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity ^0.8.10;
import {Test} from "forge-std/Test.sol";
import {IERC721AUpgradeable} from "erc721a-upgradeable/IERC721AUpgradeable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/dist/contracts/ProtocolRewards.sol";
import {RewardsSettings} from "@zoralabs/protocol-rewards/dist/contracts/abstract/RewardSplits.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.sol";
import {RewardsSettings} from "@zoralabs/protocol-rewards/src/abstract/RewardSplits.sol";

import {ERC721Drop} from "../src/ERC721Drop.sol";
import {DummyMetadataRenderer} from "./utils/DummyMetadataRenderer.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/ZoraNFTCreatorV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.10;

import {Test} from "forge-std/Test.sol";
import {IERC721AUpgradeable} from "erc721a-upgradeable/IERC721AUpgradeable.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/dist/contracts/ProtocolRewards.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.sol";

import {IMetadataRenderer} from "../src/interfaces/IMetadataRenderer.sol";
import "../src/ZoraNFTCreatorV1.sol";
Expand Down
147 changes: 27 additions & 120 deletions test/merkle/MerkleDrop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.10;

import {Test} from "forge-std/Test.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/dist/contracts/ProtocolRewards.sol";
import {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.sol";

import {IERC721Drop} from "../../src/interfaces/IERC721Drop.sol";
import {ERC721Drop} from "../../src/ERC721Drop.sol";
Expand All @@ -17,10 +17,8 @@ contract ZoraNFTBaseTest is Test {
DummyMetadataRenderer public dummyRenderer = new DummyMetadataRenderer();
MerkleData public merkleData;
address public constant DEFAULT_OWNER_ADDRESS = address(0x23499);
address payable public constant DEFAULT_FUNDS_RECIPIENT_ADDRESS =
payable(address(0x21303));
address payable public constant DEFAULT_ZORA_DAO_ADDRESS =
payable(address(0x999));
address payable public constant DEFAULT_FUNDS_RECIPIENT_ADDRESS = payable(address(0x21303));
address payable public constant DEFAULT_ZORA_DAO_ADDRESS = payable(address(0x999));
address public constant mediaContract = address(0x123456);
address payable public constant mintFeeRecipient = payable(address(0x1234));
uint256 public constant mintFee = 0.000777 ether;
Expand Down Expand Up @@ -48,19 +46,8 @@ contract ZoraNFTBaseTest is Test {
protocolRewards = new ProtocolRewards();

vm.prank(DEFAULT_ZORA_DAO_ADDRESS);
address impl = address(
new ERC721Drop(
address(1234),
FactoryUpgradeGate(address(0)),
address(0),
mintFee,
mintFeeRecipient,
address(protocolRewards)
)
);
address payable newDrop = payable(
address(new ERC721DropProxy(impl, ""))
);
address impl = address(new ERC721Drop(address(1234), FactoryUpgradeGate(address(0)), address(0), mintFee, mintFeeRecipient, address(protocolRewards)));
address payable newDrop = payable(address(new ERC721DropProxy(impl, "")));
zoraNFTBase = ERC721Drop(newDrop);
merkleData = new MerkleData();
}
Expand All @@ -74,9 +61,7 @@ contract ZoraNFTBaseTest is Test {
presaleEnd: type(uint64).max,
publicSalePrice: 0 ether,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: merkleData
.getTestSetByName("test-3-addresses")
.root
presaleMerkleRoot: merkleData.getTestSetByName("test-3-addresses").root
});
vm.stopPrank();

Expand All @@ -87,35 +72,19 @@ contract ZoraNFTBaseTest is Test {
vm.deal(address(item.user), 1 ether);
vm.startPrank(address(item.user));

zoraNFTBase.purchasePresale{value: item.mintPrice + fee}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: item.mintPrice + fee}(1, item.maxMint, item.mintPrice, item.proof);
assertEq(zoraNFTBase.saleDetails().maxSupply, 10);
assertEq(zoraNFTBase.saleDetails().totalMinted, 1);
require(
zoraNFTBase.ownerOf(1) == address(item.user),
"owner is wrong for new minted token"
);
require(zoraNFTBase.ownerOf(1) == address(item.user), "owner is wrong for new minted token");
vm.stopPrank();

item = merkleData.getTestSetByName("test-3-addresses").entries[1];
vm.deal(address(item.user), 1 ether);
vm.startPrank(address(item.user));
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 2}(
2,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 2}(2, item.maxMint, item.mintPrice, item.proof);
assertEq(zoraNFTBase.saleDetails().maxSupply, 10);
assertEq(zoraNFTBase.saleDetails().totalMinted, 3);
require(
zoraNFTBase.ownerOf(2) == address(item.user),
"owner is wrong for new minted token"
);
require(zoraNFTBase.ownerOf(2) == address(item.user), "owner is wrong for new minted token");
vm.stopPrank();
}

Expand All @@ -128,9 +97,7 @@ contract ZoraNFTBaseTest is Test {
presaleEnd: type(uint64).max,
publicSalePrice: 0 ether,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: merkleData
.getTestSetByName("test-3-addresses")
.root
presaleMerkleRoot: merkleData.getTestSetByName("test-3-addresses").root
});
vm.stopPrank();

Expand All @@ -141,18 +108,8 @@ contract ZoraNFTBaseTest is Test {
vm.deal(address(item.user), 1 ether);
vm.startPrank(address(item.user));

vm.expectRevert(
abi.encodeWithSelector(
IERC721Drop.Purchase_WrongPrice.selector,
item.mintPrice + fee
)
);
zoraNFTBase.purchasePresale{value: item.mintPrice - 1}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
vm.expectRevert(abi.encodeWithSelector(IERC721Drop.Purchase_WrongPrice.selector, item.mintPrice + fee));
zoraNFTBase.purchasePresale{value: item.mintPrice - 1}(1, item.maxMint, item.mintPrice, item.proof);
assertEq(zoraNFTBase.saleDetails().maxSupply, 10);
assertEq(zoraNFTBase.saleDetails().totalMinted, 0);
vm.stopPrank();
Expand All @@ -167,9 +124,7 @@ contract ZoraNFTBaseTest is Test {
presaleEnd: type(uint64).max,
publicSalePrice: 0 ether,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: merkleData
.getTestSetByName("test-3-addresses")
.root
presaleMerkleRoot: merkleData.getTestSetByName("test-3-addresses").root
});
vm.stopPrank();

Expand All @@ -181,21 +136,13 @@ contract ZoraNFTBaseTest is Test {

vm.expectRevert(IERC721Drop.Presale_MerkleNotApproved.selector);
item.proof[1] = item.proof[1] & bytes32(bytes4(0xcafecafe));
zoraNFTBase.purchasePresale{value: item.mintPrice - 1}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: item.mintPrice - 1}(1, item.maxMint, item.mintPrice, item.proof);
assertEq(zoraNFTBase.saleDetails().maxSupply, 10);
assertEq(zoraNFTBase.saleDetails().totalMinted, 0);
vm.stopPrank();
}

function test_MerklePurchaseAndPublicSalePurchaseLimits()
public
setupZoraNFTBase
{
function test_MerklePurchaseAndPublicSalePurchaseLimits() public setupZoraNFTBase {
vm.startPrank(DEFAULT_OWNER_ADDRESS);
zoraNFTBase.setSaleConfiguration({
publicSaleStart: 0,
Expand All @@ -217,44 +164,18 @@ contract ZoraNFTBaseTest is Test {
vm.startPrank(address(item.user));

vm.expectRevert(IERC721Drop.Presale_TooManyForAddress.selector);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 3}(
3,
item.maxMint,
item.mintPrice,
item.proof
);

zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 3}(3, item.maxMint, item.mintPrice, item.proof);

zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(1, item.maxMint, item.mintPrice, item.proof);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(1, item.maxMint, item.mintPrice, item.proof);
assertEq(zoraNFTBase.saleDetails().totalMinted, 2);
require(
zoraNFTBase.ownerOf(1) == address(item.user),
"owner is wrong for new minted token"
);
require(zoraNFTBase.ownerOf(1) == address(item.user), "owner is wrong for new minted token");

vm.expectRevert(IERC721Drop.Presale_TooManyForAddress.selector);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: (item.mintPrice + fee) * 1}(1, item.maxMint, item.mintPrice, item.proof);

zoraNFTBase.purchase{value: 0.1 ether + fee}(1);
require(
zoraNFTBase.ownerOf(3) == address(item.user),
"owner is wrong for new minted token"
);
require(zoraNFTBase.ownerOf(3) == address(item.user), "owner is wrong for new minted token");
vm.expectRevert(IERC721Drop.Purchase_TooManyForAddress.selector);
zoraNFTBase.purchase{value: 0.1 ether + fee}(1);
vm.stopPrank();
Expand Down Expand Up @@ -294,12 +215,7 @@ contract ZoraNFTBaseTest is Test {
vm.startPrank(address(item.user));

vm.expectRevert(IERC721Drop.Mint_SoldOut.selector);
zoraNFTBase.purchasePresale{value: item.mintPrice}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: item.mintPrice}(1, item.maxMint, item.mintPrice, item.proof);
vm.stopPrank();
}

Expand All @@ -314,23 +230,14 @@ contract ZoraNFTBaseTest is Test {
presaleEnd: 0,
publicSalePrice: 0 ether,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: merkleData
.getTestSetByName("test-3-addresses")
.root
presaleMerkleRoot: merkleData.getTestSetByName("test-3-addresses").root
});
vm.stopPrank();
vm.deal(address(0x10), 1 ether);

vm.startPrank(address(0x10));
MerkleData.MerkleEntry memory item = merkleData
.getTestSetByName("test-3-addresses")
.entries[0];
MerkleData.MerkleEntry memory item = merkleData.getTestSetByName("test-3-addresses").entries[0];
vm.expectRevert(IERC721Drop.Presale_Inactive.selector);
zoraNFTBase.purchasePresale{value: item.mintPrice}(
1,
item.maxMint,
item.mintPrice,
item.proof
);
zoraNFTBase.purchasePresale{value: item.mintPrice}(1, item.maxMint, item.mintPrice, item.proof);
}
}

0 comments on commit 74c7948

Please sign in to comment.