Skip to content

Commit

Permalink
Merge pull request #4 from gryphnft/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
cblanquera authored Mar 11, 2022
2 parents 432f5af + ee2b37f commit b6bf215
Show file tree
Hide file tree
Showing 13 changed files with 411 additions and 214 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ yarn-error.log*
#Hardhat files
cache
artifacts
.openzeppelin
68 changes: 24 additions & 44 deletions contracts/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol";

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";

error BalanceQueryZeroAddress();
error ExistentToken();
Expand All @@ -24,16 +24,17 @@ error InvalidAmount();
error ERC721ReceiverNotReceived();
error TransferFromNotOwner();

abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
abstract contract ERC721 is
ContextUpgradeable,
ERC165Upgradeable,
IERC721Upgradeable,
IERC721MetadataUpgradeable
{
using AddressUpgradeable for address;
using StringsUpgradeable for uint256;

// ============ Storage ============

// Token name
string private _name;
// Token symbol
string private _symbol;
// Total supply
uint256 private _totalSupply;

Expand Down Expand Up @@ -61,17 +62,6 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
_;
}

// ============ Deploy ============

/**
* @dev Initializes the contract by setting a `name` and a `symbol`
* to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}

// ============ Read Methods ============

/**
Expand All @@ -84,13 +74,6 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
return _balances[owner];
}

/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns(string memory) {
return _name;
}

/**
* @dev See {IERC721-ownerOf}.
*/
Expand All @@ -104,20 +87,17 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public view virtual override(ERC165, IERC165) returns(bool)
public
view
virtual
override(ERC165Upgradeable, IERC165Upgradeable)
returns(bool)
{
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721Upgradeable).interfaceId ||
super.supportsInterface(interfaceId);
}

/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns(string memory) {
return _symbol;
}

/**
* @dev Shows the overall amount of tokens generated in the contract
Expand Down Expand Up @@ -287,10 +267,10 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721Receiver(to).onERC721Received(
try IERC721ReceiverUpgradeable(to).onERC721Received(
_msgSender(), from, tokenId, _data
) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert NotERC721Receiver();
Expand Down
36 changes: 0 additions & 36 deletions contracts/ERC721/ERC721Base.sol

This file was deleted.

36 changes: 36 additions & 0 deletions contracts/ERC721/ERC721Upgradable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./extensions/ERC721Pausable.sol";
import "./extensions/ERC721URIContract.sol";

abstract contract ERC721Upgradable is
OwnableUpgradeable,
ReentrancyGuardUpgradeable,
ERC721Pausable,
ERC721URIContract
{
// ============ Overrides ============

/**
* @dev Describes linear override for `_beforeTokenTransfer` used in
* both `ERC721` and `ERC721Pausable`
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
}
3 changes: 1 addition & 2 deletions contracts/ERC721/extensions/ERC721Burnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
pragma solidity ^0.8.0;

import "../ERC721.sol";
import "@openzeppelin/contracts/utils/Context.sol";

/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be irreversibly burned (destroyed).
*/
abstract contract ERC721Burnable is Context, ERC721 {
abstract contract ERC721Burnable is ContextUpgradeable, ERC721 {
/**
* @dev Burns `tokenId`. See {ERC721B-_burn}.
*
Expand Down
4 changes: 2 additions & 2 deletions contracts/ERC721/extensions/ERC721Pausable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.0;

import "../ERC721.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

error TransferWhilePaused();

Expand All @@ -14,7 +14,7 @@ error TransferWhilePaused();
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*/
abstract contract ERC721Pausable is Pausable, ERC721 {
abstract contract ERC721Pausable is PausableUpgradeable, ERC721 {
/**
* @dev See {ERC721B-_beforeTokenTransfer}.
*
Expand Down
Loading

0 comments on commit b6bf215

Please sign in to comment.