ERC1155PausableUpgradeable.sol 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol)
  3. pragma solidity ^0.8.0;
  4. import "../ERC1155Upgradeable.sol";
  5. import "../../../security/PausableUpgradeable.sol";
  6. import "../../../proxy/utils/Initializable.sol";
  7. /**
  8. * @dev ERC1155 token with pausable token transfers, minting and burning.
  9. *
  10. * Useful for scenarios such as preventing trades until the end of an evaluation
  11. * period, or having an emergency switch for freezing all token transfers in the
  12. * event of a large bug.
  13. *
  14. * _Available since v3.1._
  15. */
  16. abstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable {
  17. function __ERC1155Pausable_init() internal onlyInitializing {
  18. __Pausable_init_unchained();
  19. }
  20. function __ERC1155Pausable_init_unchained() internal onlyInitializing {
  21. }
  22. /**
  23. * @dev See {ERC1155-_beforeTokenTransfer}.
  24. *
  25. * Requirements:
  26. *
  27. * - the contract must not be paused.
  28. */
  29. function _beforeTokenTransfer(
  30. address operator,
  31. address from,
  32. address to,
  33. uint256[] memory ids,
  34. uint256[] memory amounts,
  35. bytes memory data
  36. ) internal virtual override {
  37. super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
  38. require(!paused(), "ERC1155Pausable: token transfer while paused");
  39. }
  40. /**
  41. * This empty reserved space is put in place to allow future versions to add new
  42. * variables without shifting down storage in the inheritance chain.
  43. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  44. */
  45. uint256[50] private __gap;
  46. }