Skip to content

Commit

Permalink
Physicals General Availability Contract (#75)
Browse files Browse the repository at this point in the history
* physicals ga

* add nonce for physical claim submissions (needed to map back completed transactions to orders). add tests

* add tests

* add tests, fix formatting

* add multi-submission test

* fix bug with multi-submission where fees were not consumed properly, and excess fees for sold out items were not returned

* update test

* update test

* add totalLimit support

* add more tests

* fix verify comment

* add tests for erc721 direct transfer

* add 1155 transfer tests

* add batch transfer tests

* remove signing prefix which saves gas

---------

Co-authored-by: Johnny Shankman <[email protected]>
  • Loading branch information
wwhchung and johnnyshankman authored May 28, 2024
1 parent 28be13d commit e987266
Show file tree
Hide file tree
Showing 14 changed files with 3,820 additions and 4,119 deletions.
118 changes: 108 additions & 10 deletions packages/manifold/contracts/physicalclaim/IPhysicalClaim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,118 @@ pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "./IPhysicalClaimCore.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
* Burn Redeem Core interface
*/
interface IPhysicalClaim is IERC165, IERC721Receiver, IERC1155Receiver {
error InvalidToken(address, uint256);
error InvalidTokenSpec();
error InvalidBurnSpec();
error InvalidBurnAmount();
error InvalidInput();
error InvalidData();
error InvalidPaymentAmount();
error TransferFailure();
error SoldOut();

error InvalidSignature(); // 0x8baa579f
error ExpiredSignature();
error InvalidNonce();

enum TokenSpec { INVALID, ERC721, ERC1155, ERC721_NO_BURN }

enum BurnSpec { INVALID, NONE, MANIFOLD, OPENZEPPELIN }

struct BurnSubmission {
bytes signature;
bytes32 message;
uint256 instanceId;
BurnToken[] burnTokens;
uint8 variation;
uint64 variationLimit;
uint64 totalLimit;
address erc20;
uint256 price;
address payable fundsRecipient;
uint160 expiration;
bytes32 nonce;
}

event Redeem(uint256 instanceId, address indexed redeemer, uint8 variationSelection, bytes32 nonce);

/**
* @notice a `BurnItem` indicates which tokens are eligible to be burned
* @param contractAddress the contract address of the token to burn
* @param tokenId the token to burn
* @param tokenSpec the burn item token type
* @param burnSpec whether the contract for a token has a `burn` function and, if so,
* what interface
* @param amount (only for ERC1155 tokens) the amount (value) required to burn
*/
struct BurnToken {
address contractAddress;
uint256 tokenId;
TokenSpec tokenSpec;
BurnSpec burnSpec;
uint72 amount;
}

/**
* @notice burn tokens and physical claims multiple times in a single transaction
* @param submissions the burn submission entries
*/
function burnRedeem(BurnSubmission[] calldata submissions) external payable;

/**
* @notice burn tokens and physical claim
* @param submission the burn submission entries
*/
function burnRedeem(BurnSubmission calldata submission) external payable;

/**
* @notice withdraw Manifold fee proceeds from the contract
* @param recipient recepient of the funds
* @param amount amount to withdraw in Wei
*/
function withdraw(address payable recipient, uint256 amount) external;

/**
* @notice set the Manifold Membership contract address
* @param addr the address of the Manifold Membership contract
*/
function setMembershipAddress(address addr) external;

/**
* @notice update the authorized signer
* @param signingAddress the authorized signer
*/
function updateSigner(address signingAddress) external;

/**
* @notice recover a token that was sent to the contract without safeTransferFrom
* @param tokenAddress the address of the token contract
* @param tokenId the id of the token
* @param destination the address to send the token to
*/
function recover(address tokenAddress, uint256 tokenId, address destination) external;

interface IPhysicalClaim is IPhysicalClaimCore {
/**
* @notice initialize a new physical claim, emit initialize event
* @param instanceId the instanceId of the physicalClaim for the physical claim
* @param physicalClaimParameters the parameters which will affect the redemption behavior of the physical claim
* @notice get the number of variations redeemed
* @param instanceId the instance id
* @param variations the variations
* @return the number of variations redeemed
*/
function initializePhysicalClaim(uint256 instanceId, PhysicalClaimParameters calldata physicalClaimParameters) external;
function getVariationCounts(uint256 instanceId, uint8[] calldata variations) external view returns (uint64[] memory);

/**
* @notice update an existing physical claim
* @param instanceId the instanceId of the physicalClaim for the physical claim
* @param physicalClaimParameters the parameters which will affect the redemption behavior of the physical claim
* @notice get the number of redemptions for a given instance
* @param instanceId the instance id
* @return the number of redemptions
*/
function updatePhysicalClaim(uint256 instanceId, PhysicalClaimParameters calldata physicalClaimParameters) external;
function getTotalCount(uint256 instanceId) external view returns (uint64);

}
258 changes: 0 additions & 258 deletions packages/manifold/contracts/physicalclaim/IPhysicalClaimCore.sol

This file was deleted.

Loading

0 comments on commit e987266

Please sign in to comment.