Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage and misc updates #16

Merged
merged 6 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Compiler files
cache/
out/
coverage/
lcov.info

# Ignores broadcast logs
/broadcast
Expand Down
19 changes: 9 additions & 10 deletions script/DeployAndConfigure1155Receive.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {Script} from "forge-std/Script.sol";
import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {Campaign, CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {BURN_ADDRESS} from "../src/lib/RedeemablesConstants.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721OwnerMintable} from "../src/test/ERC721OwnerMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC1155ShipyardRedeemableMintable} from "../src/extensions/ERC1155ShipyardRedeemableMintable.sol";

contract DeployAndConfigure1155Receive is Script, Test {
Expand Down Expand Up @@ -60,18 +59,18 @@ contract DeployAndConfigure1155Receive is Script, Test {
requirements[0].consideration = consideration;

CampaignParams memory params = CampaignParams({
requirements: requirements,
signer: address(0),
startTime: 0,
endTime: 0,
maxCampaignRedemptions: 1_000,
manager: msg.sender
manager: msg.sender,
signer: address(0)
});
receiveToken.createCampaign(params, "ipfs://QmQjubc6guHReNW5Es5ZrgDtJRwXk2Aia7BkVoLJGaCRqP");
Campaign memory campaign = Campaign({params: params, requirements: requirements});
receiveToken.createCampaign(campaign, "ipfs://QmQjubc6guHReNW5Es5ZrgDtJRwXk2Aia7BkVoLJGaCRqP");

// To test updateCampaign, update to proper start/end times.
params.startTime = uint32(block.timestamp);
params.endTime = uint32(block.timestamp + 1_000_000);
receiveToken.updateCampaign(1, params, "");
campaign.params.startTime = uint32(block.timestamp);
campaign.params.endTime = uint32(block.timestamp + 1_000_000);
receiveToken.updateCampaign(1, campaign, "");
}
}
4 changes: 2 additions & 2 deletions script/DeployAndConfigureExampleCampaign.s.sol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationS
import {RedeemableContractOfferer} from "../src/RedeemableContractOfferer.sol";
import {CampaignParams} from "../src/lib/RedeemablesStructs.sol";
import {BURN_ADDRESS} from "../src/lib/RedeemablesConstants.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {TestERC721} from "../test/utils/mocks/TestERC721.sol";

contract DeployAndConfigureExampleCampaign is Script {
Expand All @@ -26,7 +26,7 @@ contract DeployAndConfigureExampleCampaign is Script {
seaport
);
TestERC721 redeemableToken = new TestERC721();
ERC721RedemptionMintable redemptionToken = new ERC721RedemptionMintable(
ERC721ShipyardRedeemableMintable redemptionToken = new ERC721ShipyardRedeemableMintable(
address(offerer),
address(redeemableToken)
);
Expand Down
35 changes: 21 additions & 14 deletions script/DeployAndRedeemTokens-CampaignOnReceiveToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {Script} from "forge-std/Script.sol";
import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {Campaign, CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {BURN_ADDRESS} from "../src/lib/RedeemablesConstants.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721OwnerMintable} from "../src/test/ERC721OwnerMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC721ShipyardRedeemableOwnerMintable} from "../src/test/ERC721ShipyardRedeemableOwnerMintable.sol";

contract DeployAndRedeemTokens_CampaignOnReceiveToken is Script, Test {
function run() external {
vm.startBroadcast();

ERC721OwnerMintable redeemToken = new ERC721OwnerMintable();
ERC721ShipyardRedeemableOwnerMintable redeemToken =
new ERC721ShipyardRedeemableOwnerMintable("TestRedeemablesRedeemToken", "TEST-RDM");
ERC721ShipyardRedeemableMintable receiveToken =
new ERC721ShipyardRedeemableMintable("TestRedeemablesReceiveToken", "TEST");
new ERC721ShipyardRedeemableMintable("TestRedeemablesReceiveToken", "TEST-RCV");

// Configure the campaign.
OfferItem[] memory offer = new OfferItem[](1);
Expand Down Expand Up @@ -46,25 +46,32 @@ contract DeployAndRedeemTokens_CampaignOnReceiveToken is Script, Test {
requirements[0].consideration = consideration;

CampaignParams memory params = CampaignParams({
requirements: requirements,
signer: address(0),
startTime: uint32(block.timestamp),
endTime: uint32(block.timestamp + 1_000_000),
maxCampaignRedemptions: 1_000,
manager: msg.sender
manager: msg.sender,
signer: address(0)
});
Campaign memory campaign = Campaign({params: params, requirements: requirements});
uint256 campaignId =
receiveToken.createCampaign(params, "ipfs://QmQKc93y2Ev5k9Kz54mCw48ZM487bwGDktZYPLtrjJ3r1d");
receiveToken.createCampaign(campaign, "ipfs://QmbFxYgQMoBSUNFyW7WRWGaAWwJiRPM6HbK86aFkSJSq5N");

// Mint token 1 to redeem for token 1.
redeemToken.mint(msg.sender, 1);
redeemToken.mint(msg.sender, 2);
redeemToken.mint(msg.sender, 3);
redeemToken.mint(msg.sender, 4);

// Let's redeem them!
uint256 requirementsIndex = 0;
bytes32 redemptionHash;
uint256 salt;
bytes memory signature;
bytes memory data = abi.encode(campaignId, requirementsIndex, redemptionHash, salt, signature);
uint256[] memory traitRedemptionTokenIds;
bytes memory data = abi.encode(
campaignId,
0, // requirementsIndex
bytes32(0), // redemptionHash
traitRedemptionTokenIds,
uint256(0), // salt
bytes("") // signature
);

uint256[] memory tokenIds = new uint256[](1);
tokenIds[0] = 1;
Expand Down
33 changes: 18 additions & 15 deletions script/DeployAndRedeemTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {Script} from "forge-std/Script.sol";
import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {Campaign, CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {BURN_ADDRESS} from "../src/lib/RedeemablesConstants.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC721ShipyardRedeemableOwnerMintable} from "../src/test/ERC721ShipyardRedeemableOwnerMintable.sol";

contract DeployAndRedeemTokens is Script, Test {
Expand All @@ -20,11 +20,11 @@ contract DeployAndRedeemTokens is Script, Test {
);
address[] memory redeemTokens = new address[](1);
redeemTokens[0] = address(redeemToken);
ERC721RedemptionMintable receiveToken = new ERC721RedemptionMintable(
ERC721ShipyardRedeemableMintable receiveToken = new ERC721ShipyardRedeemableMintable(
"TestRedeemablesRecieveToken",
"TEST",
redeemTokens
"TEST"
);
receiveToken.setRedeemablesContracts(redeemTokens);

// Configure the campaign.
OfferItem[] memory offer = new OfferItem[](1);
Expand Down Expand Up @@ -53,25 +53,28 @@ contract DeployAndRedeemTokens is Script, Test {
requirements[0].consideration = consideration;

CampaignParams memory params = CampaignParams({
requirements: requirements,
signer: address(0),
startTime: uint32(block.timestamp),
endTime: uint32(block.timestamp + 1_000_000),
maxCampaignRedemptions: 1_000,
manager: msg.sender
manager: msg.sender,
signer: address(0)
});
redeemToken.createCampaign(params, "");
Campaign memory campaign = Campaign({params: params, requirements: requirements});
redeemToken.createCampaign(campaign, "");

// Mint token 1 to redeem for token 1.
redeemToken.mint(msg.sender, 1);

// Let's redeem them!
uint256 campaignId = 1;
uint256 requirementsIndex = 0;
bytes32 redemptionHash;
uint256 salt;
bytes memory signature;
bytes memory data = abi.encode(campaignId, requirementsIndex, redemptionHash, salt, signature);
uint256[] memory traitRedemptionTokenIds;
bytes memory data = abi.encode(
1, // campaignId
0, // requirementsIndex
bytes32(0), // redemptionHash
traitRedemptionTokenIds,
uint256(0), // salt
bytes("") // signature
);

uint256[] memory tokenIds = new uint256[](1);
tokenIds[0] = 1;
Expand Down
24 changes: 11 additions & 13 deletions script/DeployAndRedeemTrait.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {IERC7496} from "shipyard-core/src/dynamic-traits/interfaces/IERC7496.sol";
import {CampaignParams, CampaignRequirements, TraitRedemption} from "../src/lib/RedeemablesStructs.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {Campaign, CampaignParams, CampaignRequirements, TraitRedemption} from "../src/lib/RedeemablesStructs.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC721ShipyardRedeemablePreapprovedTraitSetters} from
"../src/test/ERC721ShipyardRedeemablePreapprovedTraitSetters.sol";
import {ERC721ShipyardRedeemableTraitSetters} from "../src/test/ERC721ShipyardRedeemableTraitSetters.sol";

contract DeployAndRedeemTrait is Script, Test {
function run() external {
Expand All @@ -26,13 +24,13 @@ contract DeployAndRedeemTrait is Script, Test {
address[] memory allowedTraitSetters = new address[](1);
allowedTraitSetters[0] = address(receiveToken);

// deploy the redeem token with the receive token as an allowed trait setter
ERC721ShipyardRedeemablePreapprovedTraitSetters redeemToken =
new ERC721ShipyardRedeemablePreapprovedTraitSetters(
// deploy the redeem token
ERC721ShipyardRedeemableTraitSetters redeemToken = new ERC721ShipyardRedeemableTraitSetters(
"DynamicTraitsRedeemToken",
"TEST",
allowedTraitSetters
"TEST"
);
// set the receive token as an allowed trait setter
redeemToken.setAllowedTraitSetters(allowedTraitSetters);

// configure the campaign.
OfferItem[] memory offer = new OfferItem[](1);
Expand Down Expand Up @@ -76,14 +74,14 @@ contract DeployAndRedeemTrait is Script, Test {
requirements[0].traitRedemptions = traitRedemptions;

CampaignParams memory params = CampaignParams({
requirements: requirements,
signer: address(0),
startTime: uint32(block.timestamp),
endTime: uint32(block.timestamp + 1_000_000),
maxCampaignRedemptions: 1_000,
manager: msg.sender
manager: msg.sender,
signer: address(0)
});
receiveToken.createCampaign(params, "");
Campaign memory campaign = Campaign({params: params, requirements: requirements});
receiveToken.createCampaign(campaign, "");

// Mint token 1 to redeem for token 1.
redeemToken.mint(msg.sender, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import {Script} from "forge-std/Script.sol";
import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {Campaign, CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {BURN_ADDRESS} from "../src/lib/RedeemablesConstants.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721OwnerMintable} from "../src/test/ERC721OwnerMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC721ShipyardRedeemableOwnerMintable} from "../src/test/ERC721ShipyardRedeemableOwnerMintable.sol";

contract DeployERC721ReceiveTokenWithPredeployedSeaDropRedeemToken is Script, Test {
function run() external {
Expand Down Expand Up @@ -47,15 +46,15 @@ contract DeployERC721ReceiveTokenWithPredeployedSeaDropRedeemToken is Script, Te
requirements[0].consideration = consideration;

CampaignParams memory params = CampaignParams({
requirements: requirements,
signer: address(0),
startTime: uint32(block.timestamp),
endTime: uint32(block.timestamp + 1_000_000),
maxCampaignRedemptions: 1_000,
manager: msg.sender
manager: msg.sender,
signer: address(0)
});
Campaign memory campaign = Campaign({params: params, requirements: requirements});
uint256 campaignId =
receiveToken.createCampaign(params, "ipfs://QmQKc93y2Ev5k9Kz54mCw48ZM487bwGDktZYPLtrjJ3r1d");
receiveToken.createCampaign(campaign, "ipfs://QmQKc93y2Ev5k9Kz54mCw48ZM487bwGDktZYPLtrjJ3r1d");

// redeemToken.setBaseURI(
// "ipfs://QmYTSupCtriDLBHgPBBhZ98wYdp6N9S8jTL5sKSZwbASeT"
Expand Down
19 changes: 11 additions & 8 deletions script/RedeemTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {Test} from "forge-std/Test.sol";
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol";
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {CampaignParams, CampaignRequirements} from "../src/lib/RedeemablesStructs.sol";
import {ERC721RedemptionMintable} from "../src/extensions/ERC721RedemptionMintable.sol";
import {ERC721OwnerMintable} from "../src/test/ERC721OwnerMintable.sol";
import {ERC721ShipyardRedeemableMintable} from "../src/extensions/ERC721ShipyardRedeemableMintable.sol";
import {ERC721ShipyardRedeemableOwnerMintable} from "../src/test/ERC721ShipyardRedeemableOwnerMintable.sol";
import {ERC1155ShipyardRedeemableMintable} from "../src/extensions/ERC1155ShipyardRedeemableMintable.sol";

contract RedeemTokens is Script, Test {
Expand All @@ -19,12 +19,15 @@ contract RedeemTokens is Script, Test {
ERC1155ShipyardRedeemableMintable(0x3D0fa2a8D07dfe357905a4cB4ed51b0Aea8385B9);

// Let's redeem them!
uint256 campaignId = 1;
uint256 requirementsIndex = 0;
bytes32 redemptionHash;
uint256 salt;
bytes memory signature;
bytes memory data = abi.encode(campaignId, requirementsIndex, redemptionHash, salt, signature);
uint256[] memory traitRedemptionTokenIds;
bytes memory data = abi.encode(
1, // campaignId
0, // requirementsIndex
bytes32(0), // redemptionHash
traitRedemptionTokenIds,
uint256(0), // salt
bytes("") // signature
);

uint256[] memory redeemTokenIds = new uint256[](1);
redeemTokenIds[0] = 1;
Expand Down
16 changes: 3 additions & 13 deletions src/ERC1155SeaDropRedeemable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,26 @@ import {ERC1155SeaDropContractOfferer} from "seadrop/src/lib/ERC1155SeaDropContr
import {IERC7498} from "./interfaces/IERC7498.sol";
import {ERC7498NFTRedeemables} from "./lib/ERC7498NFTRedeemables.sol";
import {DynamicTraits} from "shipyard-core/src/dynamic-traits/DynamicTraits.sol";
import {CampaignParams} from "./lib/RedeemablesStructs.sol";
import {Campaign} from "./lib/RedeemablesStructs.sol";

contract ERC1155SeaDropRedeemable is ERC1155SeaDrop, ERC7498NFTRedeemables {
constructor(address allowedConfigurer, address allowedSeaport, string memory _name, string memory _symbol)
ERC1155SeaDrop(allowedConfigurer, allowedSeaport, _name, _symbol)
{}

function createCampaign(CampaignParams calldata params, string calldata uri)
function createCampaign(Campaign calldata campaign, string calldata metadataURI)
public
override
onlyOwner
returns (uint256 campaignId)
{
campaignId = ERC7498NFTRedeemables.createCampaign(params, uri);
campaignId = ERC7498NFTRedeemables.createCampaign(campaign, metadataURI);
}

function setTrait(uint256 tokenId, bytes32 traitKey, bytes32 value) public virtual override onlyOwner {
DynamicTraits.setTrait(tokenId, traitKey, value);
}

function getTraitValue(uint256 tokenId, bytes32 traitKey)
public
view
virtual
override
returns (bytes32 traitValue)
{
traitValue = DynamicTraits.getTraitValue(tokenId, traitKey);
}

function _useInternalBurn() internal pure virtual override returns (bool) {
return true;
}
Expand Down
16 changes: 3 additions & 13 deletions src/ERC1155ShipyardRedeemable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,24 @@ import {ERC1155ShipyardContractMetadata} from "./lib/ERC1155ShipyardContractMeta
import {Ownable} from "solady/src/auth/Ownable.sol";
import {ERC7498NFTRedeemables} from "./lib/ERC7498NFTRedeemables.sol";
import {DynamicTraits} from "shipyard-core/src/dynamic-traits/DynamicTraits.sol";
import {CampaignParams} from "./lib/RedeemablesStructs.sol";
import {Campaign} from "./lib/RedeemablesStructs.sol";

contract ERC1155ShipyardRedeemable is ERC1155ShipyardContractMetadata, ERC7498NFTRedeemables {
constructor(string memory name_, string memory symbol_) ERC1155ShipyardContractMetadata(name_, symbol_) {}

function createCampaign(CampaignParams calldata params, string calldata uri_)
function createCampaign(Campaign calldata campaign, string calldata metadataURI)
public
override
onlyOwner
returns (uint256 campaignId)
{
campaignId = ERC7498NFTRedeemables.createCampaign(params, uri_);
campaignId = ERC7498NFTRedeemables.createCampaign(campaign, metadataURI);
}

function setTrait(uint256 tokenId, bytes32 traitKey, bytes32 value) public virtual override onlyOwner {
DynamicTraits.setTrait(tokenId, traitKey, value);
}

function getTraitValue(uint256 tokenId, bytes32 traitKey)
public
view
virtual
override
returns (bytes32 traitValue)
{
traitValue = DynamicTraits.getTraitValue(tokenId, traitKey);
}

function _useInternalBurn() internal pure virtual override returns (bool) {
return true;
}
Expand Down
Loading