Reorganize the repo structure (#2503)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
31
contracts/token/ERC1155/extensions/ERC1155Burnable.sol
Normal file
31
contracts/token/ERC1155/extensions/ERC1155Burnable.sol
Normal file
@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC1155.sol";
|
||||
|
||||
/**
|
||||
* @dev Extension of {ERC1155} that allows token holders to destroy both their
|
||||
* own tokens and those that they have been approved to use.
|
||||
*
|
||||
* _Available since v3.1._
|
||||
*/
|
||||
abstract contract ERC1155Burnable is ERC1155 {
|
||||
function burn(address account, uint256 id, uint256 value) public virtual {
|
||||
require(
|
||||
account == _msgSender() || isApprovedForAll(account, _msgSender()),
|
||||
"ERC1155: caller is not owner nor approved"
|
||||
);
|
||||
|
||||
_burn(account, id, value);
|
||||
}
|
||||
|
||||
function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual {
|
||||
require(
|
||||
account == _msgSender() || isApprovedForAll(account, _msgSender()),
|
||||
"ERC1155: caller is not owner nor approved"
|
||||
);
|
||||
|
||||
_burnBatch(account, ids, values);
|
||||
}
|
||||
}
|
||||
41
contracts/token/ERC1155/extensions/ERC1155Pausable.sol
Normal file
41
contracts/token/ERC1155/extensions/ERC1155Pausable.sol
Normal file
@ -0,0 +1,41 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC1155.sol";
|
||||
import "../../../security/Pausable.sol";
|
||||
|
||||
/**
|
||||
* @dev ERC1155 token with pausable token transfers, minting and burning.
|
||||
*
|
||||
* Useful for scenarios such as preventing trades until the end of an evaluation
|
||||
* period, or having an emergency switch for freezing all token transfers in the
|
||||
* event of a large bug.
|
||||
*
|
||||
* _Available since v3.1._
|
||||
*/
|
||||
abstract contract ERC1155Pausable is ERC1155, Pausable {
|
||||
/**
|
||||
* @dev See {ERC1155-_beforeTokenTransfer}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the contract must not be paused.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address operator,
|
||||
address from,
|
||||
address to,
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts,
|
||||
bytes memory data
|
||||
)
|
||||
internal
|
||||
virtual
|
||||
override
|
||||
{
|
||||
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
|
||||
|
||||
require(!paused(), "ERC1155Pausable: token transfer while paused");
|
||||
}
|
||||
}
|
||||
21
contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
Normal file
21
contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
Normal file
@ -0,0 +1,21 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../IERC1155.sol";
|
||||
|
||||
/**
|
||||
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
|
||||
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
|
||||
*
|
||||
* _Available since v3.1._
|
||||
*/
|
||||
interface IERC1155MetadataURI is IERC1155 {
|
||||
/**
|
||||
* @dev Returns the URI for token type `id`.
|
||||
*
|
||||
* If the `\{id\}` substring is present in the URI, it must be replaced by
|
||||
* clients with the actual token type ID.
|
||||
*/
|
||||
function uri(uint256 id) external view returns (string memory);
|
||||
}
|
||||
Reference in New Issue
Block a user