ERC1155SupplyHarness.sol 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import "../../munged/token/ERC1155/extensions/ERC1155Supply.sol";
  2. contract ERC1155SupplyHarness is ERC1155Supply {
  3. address public owner;
  4. constructor(string memory uri_) ERC1155(uri_) {
  5. owner = msg.sender;
  6. }
  7. // workaround for problem caused by `exists` being a CVL keyword
  8. function exists_wrapper(uint256 id) public view virtual returns (bool) {
  9. return exists(id);
  10. }
  11. // These rules were not implemented in the base but there are changes in supply
  12. // that are affected by the internal contracts so we implemented them. We assume
  13. // only the owner can call any of these functions to be able to test them but also
  14. // limit false positives.
  15. modifier onlyOwner {
  16. require(msg.sender == owner);
  17. _;
  18. }
  19. function burn( address from, uint256 id, uint256 amount) public virtual onlyOwner {
  20. _burn(from, id, amount);
  21. }
  22. function burnBatch(
  23. address from,
  24. uint256[] memory ids,
  25. uint256[] memory amounts
  26. ) public virtual onlyOwner {
  27. _burnBatch(from, ids, amounts);
  28. }
  29. function mint(
  30. address to,
  31. uint256 id,
  32. uint256 amount,
  33. bytes memory data
  34. ) public virtual onlyOwner {
  35. _mint(to, id, amount, data);
  36. }
  37. function mintBatch(
  38. address to,
  39. uint256[] memory ids,
  40. uint256[] memory amounts,
  41. bytes memory data
  42. ) public virtual onlyOwner {
  43. _mintBatch(to, ids, amounts, data);
  44. }
  45. // In order to check the invariant that zero address never holds any tokens, we need to remove the require
  46. // from this function.
  47. function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
  48. // require(account != address(0), "ERC1155: address zero is not a valid owner");
  49. return _balances[id][account];
  50. }
  51. }