Advertisement
Guest User

Untitled

a guest
Oct 20th, 2021
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity 0.8.9;
  3.  
  4. import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
  5.  
  6. import "./MyERC721.sol";
  7. import "./interfaces/ICollectionManager.sol";
  8.  
  9. contract CollectionManager is ICollectionManager {
  10. // Collection[] public allCollections;
  11. mapping(address => address[]) public collectionsOf;
  12. mapping(address => Collection) public collection;
  13.  
  14. function createCollection(string memory name, string memory symbol) external {
  15. MyERC721 newCollection = new MyERC721(name, symbol, address(this));
  16.  
  17. address collectionAddress = address(newCollection);
  18. address sender = msg.sender;
  19.  
  20. collection[collectionAddress].status = Status.Inactive;
  21. collection[collectionAddress].owner = sender;
  22.  
  23. // allCollections.push(collection[collectionAddress])
  24. collectionsOf[sender].push(collectionAddress);
  25.  
  26. emit CollectionCreated(sender, collectionAddress, block.timestamp);
  27. }
  28.  
  29. function setCollectionActive(address collectionAddress) external {
  30. collection[collectionAddress].status = Status.Active;
  31.  
  32. emit CollectionActivated(collectionAddress, block.timestamp);
  33. }
  34.  
  35. function mint(address collectionAddress) external {
  36. uint256 tokenId = collection[collectionAddress].tokenIdCounter + 1;
  37.  
  38. collection[collectionAddress].tokenIdCounter = tokenId;
  39.  
  40. MyERC721(collectionAddress).safeMint(msg.sender, tokenId);
  41. }
  42.  
  43. function balanceOf(address collectionAddress) external view returns(uint256) {
  44. return MyERC721(collectionAddress).balanceOf(msg.sender);
  45. }
  46.  
  47. function totalSupply(address collectionAddress) external view returns(uint256) {
  48. return ERC721Enumerable(collectionAddress).totalSupply();
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement