Change-Id: Ie6265e1fcc8d91294dc416ad6bac18327f582c1e
This commit is contained in:
valentin 2021-09-13 12:08:01 +02:00
parent 3714624fb0
commit 75ac0c9153
2 changed files with 12 additions and 32 deletions

View File

@ -5,7 +5,6 @@ pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../libraries/external/BytesLib.sol";
@ -40,7 +39,6 @@ contract NFTBridge is NFTBridgeGovernance {
string memory nameString;
string memory uriString;
{
// decimals, symbol & token are not part of the core ERC20 token standard, so we need to support contracts that dont implement them
(,bytes memory queriedSymbol) = token.staticcall(abi.encodeWithSignature("symbol()"));
(,bytes memory queriedName) = token.staticcall(abi.encodeWithSignature("name()"));
(,bytes memory queriedURI) = token.staticcall(abi.encodeWithSignature("tokenURI(uint256)", tokenID));
@ -58,15 +56,13 @@ contract NFTBridge is NFTBridgeGovernance {
name := mload(add(nameString, 32))
}
if (tokenChain == chainId()) {
IERC721(token).safeTransferFrom(msg.sender, address(this), tokenID);
} else {
NFTImplementation(token).burn(tokenID);
}
sequence = logTransfer(NFTBridgeStructs.Transfer(
{
sequence = logTransfer(NFTBridgeStructs.Transfer({
tokenAddress : tokenAddress,
tokenChain : tokenChain,
name : name,
@ -75,8 +71,7 @@ contract NFTBridge is NFTBridgeGovernance {
uri : uriString,
to : recipient,
toChain : recipientChain
}
), msg.value, nonce);
}), msg.value, nonce);
}
function logTransfer(NFTBridgeStructs.Transfer memory transfer, uint256 callValue, uint32 nonce) internal returns (uint64 sequence) {
@ -248,7 +243,4 @@ contract NFTBridge is NFTBridgeGovernance {
}
return string(array);
}
// we need to accept ETH sends to unwrap WETH
receive() external payable {}
}

View File

@ -14,7 +14,7 @@ import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
// Based on the OpenZepplin ERC20 implementation, licensed under MIT
// Based on the OpenZepplin ERC721 implementation, licensed under MIT
contract NFTImplementation is NFTState, Context, IERC721, IERC721Metadata, ERC165 {
using Address for address;
using Strings for uint256;
@ -167,8 +167,6 @@ contract NFTImplementation is NFTState, Context, IERC721, IERC721Metadata, ERC16
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_state.balances[to] += 1;
_state.owners[tokenId] = to;
_state.tokenURIs[tokenId] = uri;
@ -183,8 +181,6 @@ contract NFTImplementation is NFTState, Context, IERC721, IERC721Metadata, ERC16
function _burn(uint256 tokenId) internal {
address owner_ = NFTImplementation.ownerOf(tokenId);
_beforeTokenTransfer(owner_, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
@ -202,8 +198,6 @@ contract NFTImplementation is NFTState, Context, IERC721, IERC721Metadata, ERC16
require(NFTImplementation.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
@ -242,12 +236,6 @@ contract NFTImplementation is NFTState, Context, IERC721, IERC721Metadata, ERC16
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal {}
modifier onlyOwner() {
require(owner() == _msgSender(), "caller is not the owner");
_;