diff --git a/packages/manifold/test/physicalclaim/PhysicalClaim.t.sol b/packages/manifold/test/physicalclaim/PhysicalClaim.t.sol index 343fc907..b3de0f18 100644 --- a/packages/manifold/test/physicalclaim/PhysicalClaim.t.sol +++ b/packages/manifold/test/physicalclaim/PhysicalClaim.t.sol @@ -341,4 +341,96 @@ contract PhysicalClaimTest is Test { vm.stopPrank(); } + function testTwoForOneBurn() public { + vm.startPrank(owner); + + // Mint 2 tokens to other + creatorCore721.mintBase(other, ""); + creatorCore721.mintBase(other, ""); + + IPhysicalClaimCore.BurnItem[] memory burnItems = new IPhysicalClaimCore.BurnItem[](2); + burnItems[0] = IPhysicalClaimCore.BurnItem({ + validationType: IPhysicalClaimCore.ValidationType.CONTRACT, + contractAddress: address(creatorCore721), + tokenSpec: IPhysicalClaimCore.TokenSpec.ERC721, + burnSpec: IPhysicalClaimCore.BurnSpec.MANIFOLD, + amount: 1, + minTokenId: 1, + maxTokenId: 1, + merkleRoot: "" + }); + burnItems[1] = IPhysicalClaimCore.BurnItem({ + validationType: IPhysicalClaimCore.ValidationType.CONTRACT, + contractAddress: address(creatorCore721), + tokenSpec: IPhysicalClaimCore.TokenSpec.ERC721, + burnSpec: IPhysicalClaimCore.BurnSpec.MANIFOLD, + amount: 1, + minTokenId: 2, + maxTokenId: 2, + merkleRoot: "" + }); + + IPhysicalClaimCore.BurnGroup[] memory burnSet = new IPhysicalClaimCore.BurnGroup[](1); + burnSet[0] = IPhysicalClaimCore.BurnGroup({ + requiredCount: 2, + items: burnItems + }); + + IPhysicalClaimCore.Variation[] memory variations = new IPhysicalClaimCore.Variation[](1); + variations[0] = IPhysicalClaimCore.Variation({ + id: 1, + max: 1 + }); + + // Create claim initialization parameters. Total supply is 1 so they will use the whole supply + IPhysicalClaimCore.PhysicalClaimParameters memory claimPs = IPhysicalClaimCore.PhysicalClaimParameters({ + paymentReceiver: payable(owner), + totalSupply: 1, + startDate: 0, + endDate: 0, + cost: 0, + burnSet: burnSet, + variations: variations, + signer: signerForCost + }); + + // Initialize the physical claim + example.initializePhysicalClaim(instanceId, claimPs); + + vm.stopPrank(); + vm.startPrank(other); + + // Approve token for burning + creatorCore721.approve(address(example), 1); + creatorCore721.approve(address(example), 2); + + IPhysicalClaimCore.BurnToken[] memory burnTokens = new IPhysicalClaimCore.BurnToken[](2); + burnTokens[0] = IPhysicalClaimCore.BurnToken({ + groupIndex: 0, + itemIndex: 0, + contractAddress: address(creatorCore721), + id: 1, + merkleProof: new bytes32[](0) + }); + burnTokens[1] = IPhysicalClaimCore.BurnToken({ + groupIndex: 0, + itemIndex: 1, + contractAddress: address(creatorCore721), + id: 2, + merkleProof: new bytes32[](0) + }); + + IPhysicalClaimCore.PhysicalClaimSubmission[] memory submissions = new IPhysicalClaimCore.PhysicalClaimSubmission[](1); + submissions[0].instanceId = instanceId; + submissions[0].physicalClaimCount = 1; + submissions[0].currentClaimCount = 0; + submissions[0].burnTokens = burnTokens; + submissions[0].variation = 0; + submissions[0].data = ""; + + example.burnRedeem(submissions); + + vm.stopPrank(); + } + }