From 9f6ab6de7daa492cc3830363e9330919f9bdd1a4 Mon Sep 17 00:00:00 2001 From: Krishang Nadgauda Date: Wed, 30 Mar 2022 13:11:13 -0400 Subject: [PATCH] Update multiwrap interface --- contracts/interfaces/IMultiwrap.sol | 77 +++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 21 deletions(-) diff --git a/contracts/interfaces/IMultiwrap.sol b/contracts/interfaces/IMultiwrap.sol index 7bb445339..d18ccdfea 100644 --- a/contracts/interfaces/IMultiwrap.sol +++ b/contracts/interfaces/IMultiwrap.sol @@ -4,50 +4,85 @@ pragma solidity ^0.8.11; import "./IThirdwebContract.sol"; import "./IThirdwebRoyalty.sol"; import "./IThirdwebOwnable.sol"; -import "../lib/MultiTokenTransferLib.sol"; + +/** + * Thirdweb's Multiwrap contract lets you wrap arbitrary ERC20, ERC721 and ERC1155 + * tokens you own into a single wrapped token / NFT. + * + * A wrapped NFT can be unwrapped i.e. burned in exchange for its underlying contents. + */ interface IMultiwrap is IThirdwebContract, IThirdwebOwnable, IThirdwebRoyalty { + + /// @notice The type of assets that can be wrapped. + enum TokenType { ERC20, ERC721, ERC1155 } + + /** + * @notice A generic interface to describe a token to wrap. + * + * @param assetContract The contract address of the asset to wrap. + * @param tokenType The token type (ERC20 / ERC721 / ERC1155) of the asset to wrap. + * @param tokenId The token Id of the asset to wrap, if the asset is an ERC721 / ERC1155 NFT. + * @param amount The amount of the asset to wrap, if the asset is an ERC20 / ERC1155 fungible token. + */ + struct Token { + address assetContract; + TokenType tokenType; + uint256 tokenId; + uint256 amount; + } + + /** + * @notice An internal data structure to track the wrapped contents of a wrapped NFT. + * + * @param count The total kinds of assets i.e. `Token` wrapped. + * @param token Mapping from a UID -> to the asset i.e. `Token` at that UID. + */ + struct WrappedContents { + uint256 count; + mapping(uint256 => Token) token; + } + /// @dev Emitted when tokens are wrapped. event TokensWrapped( address indexed wrapper, - uint256 indexed tokenIdOfShares, - MultiTokenTransferLib.MultiToken wrappedContents + address indexed recipientOfWrappedToken, + uint256 indexed tokenIdOfWrappedToken, + Token[] wrappedContents ); /// @dev Emitted when tokens are unwrapped. event TokensUnwrapped( - address indexed wrapper, - address sentTo, - uint256 indexed tokenIdOfShares, - uint256 sharesUnwrapped, - MultiTokenTransferLib.MultiToken wrappedContents + address indexed unwrapper, + address indexed recipientOfWrappedContents, + uint256 indexed tokenIdOfWrappedToken, + Token[] wrappedContents ); - /// @dev Emitted when a new Owner is set. + /// @dev Emitted when the contract owner is updated. event OwnerUpdated(address prevOwner, address newOwner); /** - * @notice Wrap multiple ERC1155, ERC721, ERC20 tokens into 'n' shares (i.e. variable supply of 1 ERC 1155 token) + * @notice Wrap multiple ERC1155, ERC721, ERC20 tokens into a single wrapped NFT. * - * @param wrappedContents The tokens to wrap. - * @param shares The number of shares to issue for the wrapped contents. - * @param uriForShares The URI for the shares i.e. wrapped token. + * @param wrappedContents The tokens to wrap. + * @param uriForWrappedToken The metadata URI for the wrapped NFT. + * @param recipient The recipient of the wrapped NFT. */ function wrap( - MultiTokenTransferLib.MultiToken calldata wrappedContents, - uint256 shares, - string calldata uriForShares + Token[] memory wrappedContents, + string calldata uriForWrappedToken, + address recipient ) external payable returns (uint256 tokenId); /** - * @notice Unwrap shares to retrieve underlying ERC1155, ERC721, ERC20 tokens. + * @notice Unwrap a wrapped NFT to retrieve underlying ERC1155, ERC721, ERC20 tokens. * - * @param tokenId The token Id of the tokens to unwrap. - * @param amountToRedeem The amount of shares to unwrap + * @param tokenId The token Id of the wrapped NFT to unwrap. + * @param recipient The recipient of the underlying ERC1155, ERC721, ERC20 tokens of the wrapped NFT. */ function unwrap( uint256 tokenId, - uint256 amountToRedeem, - address _sendTo + address recipient ) external; }