|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 | pragma solidity ^0.8.22; |
4 | 4 |
|
5 | | -import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; |
6 | | -import {OFT} from "@layerzerolabs/oft-evm/contracts/OFT.sol"; |
| 5 | +import {OFTUpgradeable} from "@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTUpgradeable.sol"; |
| 6 | +import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; |
| 7 | +import {AccessControlDefaultAdminRulesUpgradeable} from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol"; |
7 | 8 | import {ITokenSpender} from "src/ITokenSpender.sol"; |
8 | 9 |
|
9 | 10 | /// @notice OFT is an ERC-20 token that extends the OFTCore contract. |
10 | | -contract RLCOFT is Ownable, OFT { |
11 | | - constructor(string memory _name, string memory _symbol, address _lzEndpoint, address _delegate) |
12 | | - Ownable(_delegate) |
13 | | - OFT(_name, _symbol, _lzEndpoint, _delegate) |
14 | | - {} |
| 11 | +contract RLCOFT is OFTUpgradeable, UUPSUpgradeable, AccessControlDefaultAdminRulesUpgradeable { |
| 12 | + // Upgrader Role RLCAdapter contracts. |
| 13 | + bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); |
| 14 | + // Bridge Minter Role required for minting RLC Token |
| 15 | + bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); |
| 16 | + |
| 17 | + /// @custom:oz-upgrades-unsafe-allow constructor |
| 18 | + constructor(address _lzEndpoint) OFTUpgradeable(_lzEndpoint) { |
| 19 | + _disableInitializers(); |
| 20 | + } |
| 21 | + |
| 22 | + /// @notice Initializes the contract |
| 23 | + /// @param _name Name of the token |
| 24 | + /// @param _symbol Symbol of the token |
| 25 | + /// @param _delegate Address of the contract owner |
| 26 | + function initialize(string memory _name, string memory _symbol, address _delegate) public initializer { |
| 27 | + __OFT_init(_name, _symbol, _delegate); |
| 28 | + __Ownable_init(_delegate); |
| 29 | + __UUPSUpgradeable_init(); |
| 30 | + __AccessControlDefaultAdminRules_init(0, _delegate); |
| 31 | + _grantRole(UPGRADER_ROLE, _delegate); |
| 32 | + } |
| 33 | + |
| 34 | + /// @notice Authorizes an upgrade to a new implementation |
| 35 | + /// @dev Can only be called by the owner |
| 36 | + /// @param newImplementation Address of the new implementation |
| 37 | + function _authorizeUpgrade( |
| 38 | + address newImplementation |
| 39 | + ) internal override onlyRole(UPGRADER_ROLE) {} |
15 | 40 |
|
16 | 41 | /** |
17 | 42 | * @dev Override the decimals function to return 9 instead of the default 18 |
|
0 commit comments