parent
cb0ba36841
commit
272a195149
@ -0,0 +1,29 @@ |
||||
// SPDX-License-Identifier: Apache-2.0 |
||||
pragma solidity >=0.8.0; |
||||
|
||||
import {HypERC721Collateral} from "../HypERC721Collateral.sol"; |
||||
|
||||
import {IERC721MetadataUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; |
||||
|
||||
/** |
||||
* @title Hyperlane ERC721 Token Collateral that wraps an existing ERC721 with remote transfer and URI relay functionality. |
||||
* @author Abacus Works |
||||
*/ |
||||
contract HypERC721URICollateral is HypERC721Collateral { |
||||
constructor(address erc721) HypERC721Collateral(erc721) {} |
||||
|
||||
/** |
||||
* @dev Transfers `_tokenId` of `wrappedToken` from `msg.sender` to this contract. |
||||
* @return The URI of `_tokenId` on `wrappedToken`. |
||||
* @inheritdoc HypERC721Collateral |
||||
*/ |
||||
function _transferFromSender(uint256 _tokenId) |
||||
internal |
||||
override |
||||
returns (bytes memory) |
||||
{ |
||||
HypERC721Collateral._transferFromSender(_tokenId); |
||||
return |
||||
bytes(IERC721MetadataUpgradeable(wrappedToken).tokenURI(_tokenId)); |
||||
} |
||||
} |
@ -0,0 +1,73 @@ |
||||
// SPDX-License-Identifier: Apache-2.0 |
||||
pragma solidity >=0.8.0; |
||||
|
||||
import {HypERC721} from "../HypERC721.sol"; |
||||
|
||||
import {ERC721URIStorageUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; |
||||
import {ERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; |
||||
import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; |
||||
|
||||
/** |
||||
* @title Hyperlane ERC721 Token that extends ERC721URIStorage with remote transfer and URI relay functionality. |
||||
* @author Abacus Works |
||||
*/ |
||||
contract HypERC721URIStorage is HypERC721, ERC721URIStorageUpgradeable { |
||||
/** |
||||
* @return _tokenURI The URI of `_tokenId`. |
||||
* @inheritdoc HypERC721 |
||||
*/ |
||||
function _transferFromSender(uint256 _tokenId) |
||||
internal |
||||
override |
||||
returns (bytes memory _tokenURI) |
||||
{ |
||||
_tokenURI = bytes(tokenURI(_tokenId)); // requires minted |
||||
HypERC721._transferFromSender(_tokenId); |
||||
} |
||||
|
||||
/** |
||||
* @dev Sets the URI for `_tokenId` to `_tokenURI`. |
||||
* @inheritdoc HypERC721 |
||||
*/ |
||||
function _transferTo( |
||||
address _recipient, |
||||
uint256 _tokenId, |
||||
bytes calldata _tokenURI |
||||
) internal override { |
||||
HypERC721._transferTo(_recipient, _tokenId, _tokenURI); |
||||
_setTokenURI(_tokenId, string(_tokenURI)); // requires minted |
||||
} |
||||
|
||||
function tokenURI(uint256 tokenId) |
||||
public |
||||
view |
||||
override(ERC721Upgradeable, ERC721URIStorageUpgradeable) |
||||
returns (string memory) |
||||
{ |
||||
return ERC721URIStorageUpgradeable.tokenURI(tokenId); |
||||
} |
||||
|
||||
function _beforeTokenTransfer( |
||||
address from, |
||||
address to, |
||||
uint256 tokenId |
||||
) internal override(ERC721EnumerableUpgradeable, ERC721Upgradeable) { |
||||
ERC721EnumerableUpgradeable._beforeTokenTransfer(from, to, tokenId); |
||||
} |
||||
|
||||
function supportsInterface(bytes4 interfaceId) |
||||
public |
||||
view |
||||
override(ERC721EnumerableUpgradeable, ERC721Upgradeable) |
||||
returns (bool) |
||||
{ |
||||
return ERC721EnumerableUpgradeable.supportsInterface(interfaceId); |
||||
} |
||||
|
||||
function _burn(uint256 tokenId) |
||||
internal |
||||
override(ERC721URIStorageUpgradeable, ERC721Upgradeable) |
||||
{ |
||||
ERC721URIStorageUpgradeable._burn(tokenId); |
||||
} |
||||
} |
Loading…
Reference in new issue