From 55df959a65ea13984e5793f8cd4dae33945ced4a Mon Sep 17 00:00:00 2001 From: tringuyenskymavis Date: Thu, 13 Jun 2024 14:30:35 +0700 Subject: [PATCH] chore: rename contract --- .../token/RoninMockERC1155Deploy.s.sol | 19 +++++++ src/mocks/token/RoninMockERC1155.sol | 57 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 script/contracts/token/RoninMockERC1155Deploy.s.sol create mode 100644 src/mocks/token/RoninMockERC1155.sol diff --git a/script/contracts/token/RoninMockERC1155Deploy.s.sol b/script/contracts/token/RoninMockERC1155Deploy.s.sol new file mode 100644 index 00000000..3e778584 --- /dev/null +++ b/script/contracts/token/RoninMockERC1155Deploy.s.sol @@ -0,0 +1,19 @@ +pragma solidity ^0.8.19; + +import { RoninMockERC1155 } from "@ronin/contracts/mocks/token/RoninMockERC1155.sol"; + +import { Contract } from "../../utils/Contract.sol"; +import { ISharedArgument } from "../../interfaces/ISharedArgument.sol"; +import { Migration } from "../../Migration.s.sol"; + +contract RoninMockERC1155Deploy is Migration { + function _defaultArguments() internal virtual override returns (bytes memory args) { + ISharedArgument.RoninMockERC1155Param memory param = config.sharedArguments().mockErc1155; + + args = abi.encode(param.defaultAdmin, param.uri, param.name, param.symbol); + } + + function run() public virtual returns (RoninMockERC1155) { + return RoninMockERC1155(_deployImmutable(Contract.RoninMockERC1155.key())); + } +} diff --git a/src/mocks/token/RoninMockERC1155.sol b/src/mocks/token/RoninMockERC1155.sol new file mode 100644 index 00000000..1d0525c0 --- /dev/null +++ b/src/mocks/token/RoninMockERC1155.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract RoninMockERC1155 is ERC1155Burnable, AccessControl { + // Token name + string internal _name; + // Token symbol + string internal _symbol; + + bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); + bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); + + constructor(address defaultAdmin, string memory uri, string memory name, string memory symbol) ERC1155(uri) { + _name = name; + _symbol = symbol; + _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin); + } + + function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyRole(MINTER_ROLE) { + _mint(account, id, amount, data); + } + + function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) + public + onlyRole(MINTER_ROLE) + { + _mintBatch(to, ids, amounts, data); + } + + function burn(address from, uint256 id, uint256 value) public override onlyRole(BURNER_ROLE) { + _burn(from, id, value); + } + + function burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) + public + override + onlyRole(BURNER_ROLE) + { + _burnBatch(from, ids, amounts); + } + + function name() public view returns (string memory) { + return _name; + } + + function symbol() public view returns (string memory) { + return _symbol; + } + + function supportsInterface(bytes4 interfaceId) public view override(ERC1155, AccessControl) returns (bool) { + return ERC1155.supportsInterface(interfaceId) || AccessControl.supportsInterface(interfaceId); + } +}