-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16a4f36
commit 55df959
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |