-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example configure and deploy script
- Loading branch information
Showing
11 changed files
with
134 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import {ItemType} from "seaport-types/src/lib/ConsiderationEnums.sol"; | ||
import {OfferItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; | ||
import {RedeemableContractOffererV0} from "../src/RedeemableContractOffererV0.sol"; | ||
import {CampaignParamsV0} from "../src/lib/RedeemableStructs.sol"; | ||
import {ERC721RedemptionMintable} from "../src/lib/ERC721RedemptionMintable.sol"; | ||
import {TestERC721} from "../test/utils/mocks/TestERC721.sol"; | ||
|
||
contract DeployAndConfigureExampleCampaign is Script { | ||
// Addresses: Seaport | ||
address seaport = 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC; | ||
address conduit = 0x1E0049783F008A0085193E00003D00cd54003c71; | ||
|
||
address constant _BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; | ||
|
||
function run() external { | ||
vm.startBroadcast(); | ||
|
||
RedeemableContractOffererV0 offerer = new RedeemableContractOffererV0(seaport); | ||
TestERC721 redeemableToken = new TestERC721(); | ||
ERC721RedemptionMintable redemptionToken = new ERC721RedemptionMintable(address(offerer)); | ||
|
||
// Configure the campaign. | ||
OfferItem[] memory offer = new OfferItem[](1); | ||
offer[0] = OfferItem({ | ||
itemType: ItemType.ERC721, | ||
token: address(redemptionToken), | ||
identifierOrCriteria: 0, | ||
startAmount: 1, | ||
endAmount: 1 | ||
}); | ||
|
||
ConsiderationItem[] memory consideration = new ConsiderationItem[](1); | ||
consideration[0] = ConsiderationItem({ | ||
itemType: ItemType.ERC721, | ||
token: address(redeemableToken), | ||
identifierOrCriteria: 0, | ||
startAmount: 1, | ||
endAmount: 1, | ||
recipient: payable(_BURN_ADDRESS) | ||
}); | ||
|
||
CampaignParamsV0 memory params = CampaignParamsV0({ | ||
offer: offer, | ||
consideration: consideration, | ||
signer: address(0), | ||
startTime: uint32(block.timestamp), | ||
endTime: uint32(block.timestamp + 1_000_000), | ||
maxTotalRedemptions: 1_000, | ||
manager: address(this) | ||
}); | ||
offerer.updateCampaign(0, params, ""); | ||
|
||
// Mint tokens 1 and 5 to redeem for tokens 1 and 5. | ||
redeemableToken.mint(msg.sender, 1); | ||
redeemableToken.mint(msg.sender, 5); | ||
|
||
// Let's redeem them! | ||
uint256 campaignId = 1; | ||
bytes32 redemptionHash = bytes32(0); | ||
bytes memory data = abi.encode(campaignId, redemptionHash); | ||
redeemableToken.safeTransferFrom(msg.sender, address(offerer), 1, data); | ||
redeemableToken.safeTransferFrom(msg.sender, address(offerer), 5, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IERC1155} from "forge-std/interfaces/IERC1155.sol"; | ||
import {RedemptionContextV0} from "../lib/RedeemableStructs.sol"; | ||
|
||
interface IERC1155RedemptionMintable is IERC1155 { | ||
function mintWithRedemptionContext( | ||
address to, | ||
uint256[] calldata ids, | ||
uint256[] calldata amounts, | ||
RedemptionContextV0 calldata context | ||
) external; | ||
interface IERC1155RedemptionMintable { | ||
function mintWithRedemptionContext(address to, RedemptionContextV0 calldata context) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IERC721} from "forge-std/interfaces/IERC721.sol"; | ||
import {RedemptionContextV0} from "../lib/RedeemableStructs.sol"; | ||
|
||
interface IERC721RedemptionMintable is IERC721 { | ||
function mintWithRedemptionContext(address to, uint256 quantity, RedemptionContextV0 calldata context) external; | ||
interface IERC721RedemptionMintable { | ||
function mintWithRedemptionContext(address to, RedemptionContextV0 calldata context) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {ERC721} from "solady/src/tokens/ERC721.sol"; | ||
import {IERC721RedemptionMintable} from "../interfaces/IERC721RedemptionMintable.sol"; | ||
import {RedemptionContextV0} from "../lib/RedeemableStructs.sol"; | ||
|
||
contract ERC721RedemptionMintable is ERC721, IERC721RedemptionMintable { | ||
address private _redeemableContractOfferer; | ||
|
||
/// @dev Revert with an error if the redeemable contract offerer is not the sender of mintWithRedemptionContext. | ||
error InvalidSender(); | ||
|
||
constructor(address redeemableContractOfferer) { | ||
_redeemableContractOfferer = redeemableContractOfferer; | ||
} | ||
|
||
function mintWithRedemptionContext(address to, RedemptionContextV0 calldata context) external { | ||
if (msg.sender != _redeemableContractOfferer) revert InvalidSender(); | ||
|
||
// Mint the same token IDs redeemed. | ||
for (uint256 i = 0; i < context.spent.length;) { | ||
_mint(to, context.spent[i].identifier); | ||
|
||
unchecked { | ||
++i; | ||
} | ||
} | ||
} | ||
|
||
function name() public pure override returns (string memory) { | ||
return "ERC721RedemptionMintable"; | ||
} | ||
|
||
function symbol() public pure override returns (string memory) { | ||
return "721RM"; | ||
} | ||
|
||
function tokenURI(uint256 tokenId) public pure override returns (string memory) { | ||
return string(abi.encodePacked("https://example.com/", tokenId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters