-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change ERC721Common to ERC721ACommon. (#31)
* Change ERC721Common to ERC721ACommon. Both ERC721CommonAutoIncrement and ERC721CommonEnumerable are removed. The former is the default behaviour of ERC721A and the latter is generally unnecessary (+ goes against the point of ERC721A). * Remove unnecessary import
- Loading branch information
1 parent
f020acc
commit 815e7d9
Showing
12 changed files
with
130 additions
and
400 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./ERC721APreApproval.sol"; | ||
import "../utils/OwnerPausable.sol"; | ||
|
||
/** | ||
@notice An ERC721A contract with common functionality: | ||
- OpenSea gas-free listings | ||
- Pausable with toggling functions exposed to Owner only | ||
*/ | ||
contract ERC721ACommon is ERC721APreApproval, OwnerPausable { | ||
constructor(string memory name, string memory symbol) | ||
ERC721A(name, symbol) | ||
{} // solhint-disable-line no-empty-blocks | ||
|
||
/// @notice Requires that the token exists. | ||
modifier tokenExists(uint256 tokenId) { | ||
require(ERC721A._exists(tokenId), "ERC721ACommon: Token doesn't exist"); | ||
_; | ||
} | ||
|
||
/// @notice Requires that msg.sender owns or is approved for the token. | ||
modifier onlyApprovedOrOwner(uint256 tokenId) { | ||
require( | ||
_ownershipOf(tokenId).addr == _msgSender() || | ||
getApproved(tokenId) == _msgSender(), | ||
"ERC721ACommon: Not approved nor owner" | ||
); | ||
_; | ||
} | ||
|
||
function _beforeTokenTransfers( | ||
address from, | ||
address to, | ||
uint256 startTokenId, | ||
uint256 quantity | ||
) internal virtual override { | ||
require(!paused(), "ERC721ACommon: paused"); | ||
super._beforeTokenTransfers(from, to, startTokenId, quantity); | ||
} | ||
|
||
/// @notice Overrides supportsInterface as required by inheritance. | ||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
virtual | ||
override(ERC721A) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "../../contracts/erc721/ERC721ACommon.sol"; | ||
import "../../contracts/erc721/BaseTokenURI.sol"; | ||
|
||
/// @notice Exposes a functions modified with the modifiers under test. | ||
contract TestableERC721ACommon is ERC721ACommon, BaseTokenURI { | ||
// solhint-disable-next-line no-empty-blocks | ||
constructor() ERC721ACommon("Token", "JRR") BaseTokenURI("") {} | ||
|
||
function mint() public { | ||
mintN(1); | ||
} | ||
|
||
function mintN(uint256 num) public { | ||
ERC721A._safeMint(msg.sender, num); | ||
} | ||
|
||
function burn(uint256 tokenId) public { | ||
ERC721A._burn(tokenId); | ||
} | ||
|
||
/// @dev For testing the tokenExists() modifier. | ||
// solhint-disable-next-line no-empty-blocks | ||
function mustExist(uint256 tokenId) public view tokenExists(tokenId) {} | ||
|
||
/// @dev For testing the onlyApprovedOrOwner() modifier. | ||
function mustBeApprovedOrOwner(uint256 tokenId) | ||
public | ||
onlyApprovedOrOwner(tokenId) | ||
{} // solhint-disable-line no-empty-blocks | ||
|
||
function _baseURI() | ||
internal | ||
view | ||
override(ERC721A, BaseTokenURI) | ||
returns (string memory) | ||
{ | ||
return BaseTokenURI._baseURI(); | ||
} | ||
} |
Oops, something went wrong.