This repository has been archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add HypERC721URIStorage * Add HypERC721URICollateral
- Loading branch information
Showing
14 changed files
with
499 additions
and
258 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
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,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); | ||
} | ||
} |
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
Oops, something went wrong.