-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add interfaces * Use interfaces in main contracts * change structure similar to OZ * move errors in interfaces class level * run prettier
- Loading branch information
Showing
10 changed files
with
175 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; | ||
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; | ||
|
||
/** | ||
* @dev Interface of an ERC721A compliant contract. | ||
*/ | ||
interface IERC721A is IERC721, IERC721Metadata { | ||
error ApprovalCallerNotOwnerNorApproved(); | ||
error ApprovalQueryForNonexistentToken(); | ||
error ApproveToCaller(); | ||
error ApprovalToCurrentOwner(); | ||
error BalanceQueryForZeroAddress(); | ||
error MintToZeroAddress(); | ||
error MintZeroQuantity(); | ||
error OwnerQueryForNonexistentToken(); | ||
error TransferCallerNotOwnerNorApproved(); | ||
error TransferFromIncorrectOwner(); | ||
error TransferToNonERC721ReceiverImplementer(); | ||
error TransferToZeroAddress(); | ||
error URIQueryForNonexistentToken(); | ||
|
||
// Compiler will pack this into a single 256bit word. | ||
struct TokenOwnership { | ||
// The address of the owner. | ||
address addr; | ||
// Keeps track of the start time of ownership with minimal overhead for tokenomics. | ||
uint64 startTimestamp; | ||
// Whether the token has been burned. | ||
bool burned; | ||
} | ||
|
||
// Compiler will pack this into a single 256bit word. | ||
struct AddressData { | ||
// Realistically, 2**64-1 is more than enough. | ||
uint64 balance; | ||
// Keeps track of mint count with minimal overhead for tokenomics. | ||
uint64 numberMinted; | ||
// Keeps track of burn count with minimal overhead for tokenomics. | ||
uint64 numberBurned; | ||
// For miscellaneous variable(s) pertaining to the address | ||
// (e.g. number of whitelist mint slots used). | ||
// If there are multiple variables, please pack them into a uint64. | ||
uint64 aux; | ||
} | ||
|
||
/** | ||
* @dev Returns the total amount of tokens stored by the contract. | ||
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. | ||
*/ | ||
function totalSupply() external view returns (uint256); | ||
} |
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,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '../IERC721A.sol'; | ||
|
||
/** | ||
* @dev Interface of an ERC721ABurnable compliant contract. | ||
*/ | ||
interface IERC721ABurnable is IERC721A { | ||
/** | ||
* @dev Burns `tokenId`. See {ERC721A-_burn}. | ||
* | ||
* Requirements: | ||
* | ||
* - The caller must own `tokenId` or be an approved operator. | ||
*/ | ||
function burn(uint256 tokenId) external; | ||
} |
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,69 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '../IERC721A.sol'; | ||
|
||
/** | ||
* @dev Interface of an ERC721AQueryable compliant contract. | ||
*/ | ||
interface IERC721AQueryable is IERC721A { | ||
error InvalidQueryRange(); | ||
|
||
/** | ||
* @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. | ||
* | ||
* If the `tokenId` is out of bounds: | ||
* - `addr` = `address(0)` | ||
* - `startTimestamp` = `0` | ||
* - `burned` = `false` | ||
* | ||
* If the `tokenId` is burned: | ||
* - `addr` = `<Address of owner before token was burned>` | ||
* - `startTimestamp` = `<Timestamp when token was burned>` | ||
* - `burned = `true` | ||
* | ||
* Otherwise: | ||
* - `addr` = `<Address of owner>` | ||
* - `startTimestamp` = `<Timestamp of start of ownership>` | ||
* - `burned = `false` | ||
*/ | ||
function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory); | ||
|
||
/** | ||
* @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order. | ||
* See {ERC721AQueryable-explicitOwnershipOf} | ||
*/ | ||
function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory); | ||
|
||
/** | ||
* @dev Returns an array of token IDs owned by `owner`, | ||
* in the range [`start`, `stop`) | ||
* (i.e. `start <= tokenId < stop`). | ||
* | ||
* This function allows for tokens to be queried if the collection | ||
* grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. | ||
* | ||
* Requirements: | ||
* | ||
* - `start` < `stop` | ||
*/ | ||
function tokensOfOwnerIn( | ||
address owner, | ||
uint256 start, | ||
uint256 stop | ||
) external view returns (uint256[] memory); | ||
|
||
/** | ||
* @dev Returns an array of token IDs owned by `owner`. | ||
* | ||
* This function scans the ownership mapping and is O(totalSupply) in complexity. | ||
* It is meant to be called off-chain. | ||
* | ||
* See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into | ||
* multiple smaller scans if the collection is large enough to cause | ||
* an out-of-gas error (10K pfp collections should be fine). | ||
*/ | ||
function tokensOfOwner(address owner) external view returns (uint256[] memory); | ||
} |
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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '../IERC721A.sol'; |
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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '../extensions/IERC721ABurnable.sol'; |
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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Creator: Chiru Labs | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import '../extensions/IERC721AQueryable.sol'; |
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