ERC1155SupplyHarness.sol 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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(
  20. address from,
  21. uint256 id,
  22. uint256 amount
  23. ) public virtual onlyOwner {
  24. _burn(from, id, amount);
  25. }
  26. function burnBatch(
  27. address from,
  28. uint256[] memory ids,
  29. uint256[] memory amounts
  30. ) public virtual onlyOwner {
  31. _burnBatch(from, ids, amounts);
  32. }
  33. function mint(
  34. address to,
  35. uint256 id,
  36. uint256 amount,
  37. bytes memory data
  38. ) public virtual onlyOwner {
  39. _mint(to, id, amount, data);
  40. }
  41. function mintBatch(
  42. address to,
  43. uint256[] memory ids,
  44. uint256[] memory amounts,
  45. bytes memory data
  46. ) public virtual onlyOwner {
  47. _mintBatch(to, ids, amounts, data);
  48. }
  49. // In order to check the invariant that zero address never holds any tokens, we need to remove the require
  50. // from this function.
  51. function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
  52. // require(account != address(0), "ERC1155: address zero is not a valid owner");
  53. return _balances[id][account];
  54. }
  55. }