mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-27 03:36:32 +00:00
Fix .gitignore: stop tracking ignored files
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
|
||||
|
||||
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 token owner or 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 token owner or approved"
|
||||
);
|
||||
|
||||
_burnBatch(account, ids, values);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.8.2) (token/ERC1155/extensions/ERC1155Pausable.sol)
|
||||
|
||||
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.
|
||||
*
|
||||
* IMPORTANT: This contract does not include public pause and unpause functions. In
|
||||
* addition to inheriting this contract, you must define both functions, invoking the
|
||||
* {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate
|
||||
* access control, e.g. using {AccessControl} or {Ownable}. Not doing so will
|
||||
* make the contract unpausable.
|
||||
*
|
||||
* _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");
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC1155.sol";
|
||||
|
||||
/**
|
||||
* @dev Extension of ERC1155 that adds tracking of total supply per id.
|
||||
*
|
||||
* Useful for scenarios where Fungible and Non-fungible tokens have to be
|
||||
* clearly identified. Note: While a totalSupply of 1 might mean the
|
||||
* corresponding is an NFT, there is no guarantees that no other token with the
|
||||
* same id are not going to be minted.
|
||||
*/
|
||||
abstract contract ERC1155Supply is ERC1155 {
|
||||
mapping(uint256 => uint256) private _totalSupply;
|
||||
|
||||
/**
|
||||
* @dev Total amount of tokens in with a given id.
|
||||
*/
|
||||
function totalSupply(uint256 id) public view virtual returns (uint256) {
|
||||
return _totalSupply[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Indicates whether any token exist with a given id, or not.
|
||||
*/
|
||||
function exists(uint256 id) public view virtual returns (bool) {
|
||||
return ERC1155Supply.totalSupply(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {ERC1155-_beforeTokenTransfer}.
|
||||
*/
|
||||
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);
|
||||
|
||||
if (from == address(0)) {
|
||||
for (uint256 i = 0; i < ids.length; ++i) {
|
||||
_totalSupply[ids[i]] += amounts[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (to == address(0)) {
|
||||
for (uint256 i = 0; i < ids.length; ++i) {
|
||||
uint256 id = ids[i];
|
||||
uint256 amount = amounts[i];
|
||||
uint256 supply = _totalSupply[id];
|
||||
require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
|
||||
unchecked {
|
||||
_totalSupply[id] = supply - amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155URIStorage.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../../../utils/Strings.sol";
|
||||
import "../ERC1155.sol";
|
||||
|
||||
/**
|
||||
* @dev ERC1155 token with storage based token URI management.
|
||||
* Inspired by the ERC721URIStorage extension
|
||||
*
|
||||
* _Available since v4.6._
|
||||
*/
|
||||
abstract contract ERC1155URIStorage is ERC1155 {
|
||||
using Strings for uint256;
|
||||
|
||||
// Optional base URI
|
||||
string private _baseURI = "";
|
||||
|
||||
// Optional mapping for token URIs
|
||||
mapping(uint256 => string) private _tokenURIs;
|
||||
|
||||
/**
|
||||
* @dev See {IERC1155MetadataURI-uri}.
|
||||
*
|
||||
* This implementation returns the concatenation of the `_baseURI`
|
||||
* and the token-specific uri if the latter is set
|
||||
*
|
||||
* This enables the following behaviors:
|
||||
*
|
||||
* - if `_tokenURIs[tokenId]` is set, then the result is the concatenation
|
||||
* of `_baseURI` and `_tokenURIs[tokenId]` (keep in mind that `_baseURI`
|
||||
* is empty per default);
|
||||
*
|
||||
* - if `_tokenURIs[tokenId]` is NOT set then we fallback to `super.uri()`
|
||||
* which in most cases will contain `ERC1155._uri`;
|
||||
*
|
||||
* - if `_tokenURIs[tokenId]` is NOT set, and if the parents do not have a
|
||||
* uri value set, then the result is empty.
|
||||
*/
|
||||
function uri(uint256 tokenId) public view virtual override returns (string memory) {
|
||||
string memory tokenURI = _tokenURIs[tokenId];
|
||||
|
||||
// If token URI is set, concatenate base URI and tokenURI (via abi.encodePacked).
|
||||
return bytes(tokenURI).length > 0 ? string(abi.encodePacked(_baseURI, tokenURI)) : super.uri(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets `tokenURI` as the tokenURI of `tokenId`.
|
||||
*/
|
||||
function _setURI(uint256 tokenId, string memory tokenURI) internal virtual {
|
||||
_tokenURIs[tokenId] = tokenURI;
|
||||
emit URI(uri(tokenId), tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets `baseURI` as the `_baseURI` for all tokens
|
||||
*/
|
||||
function _setBaseURI(string memory baseURI) internal virtual {
|
||||
_baseURI = baseURI;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
|
||||
|
||||
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