ERC721ConsecutiveMock.sol 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {ERC721} from "../../token/ERC721/ERC721.sol";
  4. import {ERC721Consecutive} from "../../token/ERC721/extensions/ERC721Consecutive.sol";
  5. import {ERC721Pausable} from "../../token/ERC721/extensions/ERC721Pausable.sol";
  6. import {ERC721Votes} from "../../token/ERC721/extensions/ERC721Votes.sol";
  7. import {EIP712} from "../../utils/cryptography/EIP712.sol";
  8. /**
  9. * @title ERC721ConsecutiveMock
  10. */
  11. contract ERC721ConsecutiveMock is ERC721Consecutive, ERC721Pausable, ERC721Votes {
  12. uint96 private immutable _offset;
  13. constructor(
  14. string memory name,
  15. string memory symbol,
  16. uint96 offset,
  17. address[] memory delegates,
  18. address[] memory receivers,
  19. uint96[] memory amounts
  20. ) ERC721(name, symbol) EIP712(name, "1") {
  21. _offset = offset;
  22. for (uint256 i = 0; i < delegates.length; ++i) {
  23. _delegate(delegates[i], delegates[i]);
  24. }
  25. for (uint256 i = 0; i < receivers.length; ++i) {
  26. _mintConsecutive(receivers[i], amounts[i]);
  27. }
  28. }
  29. function _firstConsecutiveId() internal view virtual override returns (uint96) {
  30. return _offset;
  31. }
  32. function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address) {
  33. return super._ownerOf(tokenId);
  34. }
  35. function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Consecutive) {
  36. super._mint(to, tokenId);
  37. }
  38. function _beforeTokenTransfer(
  39. address from,
  40. address to,
  41. uint256 firstTokenId,
  42. uint256 batchSize
  43. ) internal virtual override(ERC721, ERC721Pausable) {
  44. super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
  45. }
  46. function _afterTokenTransfer(
  47. address from,
  48. address to,
  49. uint256 firstTokenId,
  50. uint256 batchSize
  51. ) internal virtual override(ERC721, ERC721Votes, ERC721Consecutive) {
  52. super._afterTokenTransfer(from, to, firstTokenId, batchSize);
  53. }
  54. }
  55. contract ERC721ConsecutiveNoConstructorMintMock is ERC721Consecutive {
  56. constructor(string memory name, string memory symbol) ERC721(name, symbol) {
  57. _mint(msg.sender, 0);
  58. }
  59. }