-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ERC721 extension for efficient batch minting (#3311)
Co-authored-by: Francisco <frangio.1@gmail.com>
- Loading branch information
Showing
17 changed files
with
845 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev ERC-2309: ERC-721 Consecutive Transfer Extension. | ||
* | ||
* _Available since v4.8._ | ||
*/ | ||
interface IERC2309 { | ||
/** | ||
* @dev Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`. | ||
*/ | ||
event ConsecutiveTransfer( | ||
uint256 indexed fromTokenId, | ||
uint256 toTokenId, | ||
address indexed fromAddress, | ||
address indexed toAddress | ||
); | ||
} |
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,158 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../token/ERC721/extensions/ERC721Burnable.sol"; | ||
import "../token/ERC721/extensions/ERC721Consecutive.sol"; | ||
import "../token/ERC721/extensions/ERC721Enumerable.sol"; | ||
import "../token/ERC721/extensions/ERC721Pausable.sol"; | ||
import "../token/ERC721/extensions/draft-ERC721Votes.sol"; | ||
|
||
/** | ||
* @title ERC721ConsecutiveMock | ||
*/ | ||
contract ERC721ConsecutiveMock is ERC721Burnable, ERC721Consecutive, ERC721Pausable, ERC721Votes { | ||
constructor( | ||
string memory name, | ||
string memory symbol, | ||
address[] memory delegates, | ||
address[] memory receivers, | ||
uint96[] memory amounts | ||
) ERC721(name, symbol) EIP712(name, "1") { | ||
for (uint256 i = 0; i < delegates.length; ++i) { | ||
_delegate(delegates[i], delegates[i]); | ||
} | ||
|
||
for (uint256 i = 0; i < receivers.length; ++i) { | ||
_mintConsecutive(receivers[i], amounts[i]); | ||
} | ||
} | ||
|
||
function pause() external { | ||
_pause(); | ||
} | ||
|
||
function unpause() external { | ||
_unpause(); | ||
} | ||
|
||
function exists(uint256 tokenId) public view returns (bool) { | ||
return _exists(tokenId); | ||
} | ||
|
||
function mint(address to, uint256 tokenId) public { | ||
_mint(to, tokenId); | ||
} | ||
|
||
function mintConsecutive(address to, uint96 amount) public { | ||
_mintConsecutive(to, amount); | ||
} | ||
|
||
function safeMint(address to, uint256 tokenId) public { | ||
_safeMint(to, tokenId); | ||
} | ||
|
||
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address) { | ||
return super._ownerOf(tokenId); | ||
} | ||
|
||
function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Consecutive) { | ||
super._mint(to, tokenId); | ||
} | ||
|
||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override(ERC721, ERC721Pausable) { | ||
super._beforeTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
function _afterTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override(ERC721, ERC721Votes, ERC721Consecutive) { | ||
super._afterTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
function _beforeConsecutiveTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 first, | ||
uint96 size | ||
) internal virtual override(ERC721, ERC721Pausable) { | ||
super._beforeConsecutiveTokenTransfer(from, to, first, size); | ||
} | ||
|
||
function _afterConsecutiveTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 first, | ||
uint96 size | ||
) internal virtual override(ERC721, ERC721Votes) { | ||
super._afterConsecutiveTokenTransfer(from, to, first, size); | ||
} | ||
} | ||
|
||
contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable { | ||
constructor( | ||
string memory name, | ||
string memory symbol, | ||
address[] memory receivers, | ||
uint96[] memory amounts | ||
) ERC721(name, symbol) { | ||
for (uint256 i = 0; i < receivers.length; ++i) { | ||
_mintConsecutive(receivers[i], amounts[i]); | ||
} | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
virtual | ||
override(ERC721, ERC721Enumerable) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
|
||
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address) { | ||
return super._ownerOf(tokenId); | ||
} | ||
|
||
function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Consecutive) { | ||
super._mint(to, tokenId); | ||
} | ||
|
||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override(ERC721, ERC721Enumerable) { | ||
super._beforeTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
function _afterTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override(ERC721, ERC721Consecutive) { | ||
super._afterTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
function _beforeConsecutiveTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 first, | ||
uint96 size | ||
) internal virtual override(ERC721, ERC721Enumerable) { | ||
super._beforeConsecutiveTokenTransfer(from, to, first, size); | ||
} | ||
} | ||
|
||
contract ERC721ConsecutiveNoConstructorMintMock is ERC721Consecutive { | ||
constructor(string memory name, string memory symbol) ERC721(name, symbol) { | ||
_mint(msg.sender, 0); | ||
} | ||
} |
Oops, something went wrong.