// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* __ _______ _ _ _____ _____ _________ __
* \ \ / /_ _| \ | |/ ____|_ _|__ __\ \ / /
* \ \ /\ / / | | | \| | | | | | | \ \_/ /
* \ \/ \/ / | | | . ` | | | | | | \ /
* \ /\ / _| |_| |\ | |____ _| |_ | | | |
* \/ \/ |_____|_| \_|\_____|_____| |_| |_|
*
* @author Wincity | Antoine Duez
* @title ITransferManagerNFT
* @notice Interface for ERC tokens manager
*/
interface ITransferManagerNFT {
function transferNFT(
address collection,
address from,
address to,
uint256 tokenId
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {ITransferManagerNFT} from "./interfaces/ITransferManagerNFT.sol";
/**
* __ _______ _ _ _____ _____ _________ __
* \ \ / /_ _| \ | |/ ____|_ _|__ __\ \ / /
* \ \ /\ / / | | | \| | | | | | | \ \_/ /
* \ \/ \/ / | | | . ` | | | | | | \ /
* \ /\ / _| |_| |\ | |____ _| |_ | | | |
* \/ \/ |_____|_| \_|\_____|_____| |_| |_|
*
* @author Wincity | Antoine Duez
* @title TransferManagerERC1155
* @notice Handles the transfer of ERC1155 tokens.
*/
contract TransferManagerERC1155 is ITransferManagerNFT {
address public immutable WINCITY_EXCHANGE;
/**
* @notice Constructor
* @param _wincityExchange address of the exchange
*/
constructor(address _wincityExchange) {
WINCITY_EXCHANGE = _wincityExchange;
}
/**
* @notice Transfer ERC1155 token
* @param collection address of the collection
* @param from address of the sender
* @param to address of the recipient
* @param tokenId ERC1155 token id
* @dev Wincity ERC1155 tokens (PGC) are to be considered as non fungible, so amount should always be 1
*/
function transferNFT(
address collection,
address from,
address to,
uint256 tokenId
) external override {
require(
msg.sender == WINCITY_EXCHANGE,
"Transfer: method reserved to WincityExchange"
);
IERC1155(collection).safeTransferFrom(from, to, tokenId, 1, "");
}
}
{
"compilationTarget": {
"contracts/marketplace/TransferManagerERC1155.sol": "TransferManagerERC1155"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_wincityExchange","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WINCITY_EXCHANGE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferNFT","outputs":[],"stateMutability":"nonpayable","type":"function"}]