Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/BridgedToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";

import {IMintableBurnable} from "@layerzerolabs/oft-evm/contracts/interfaces/IMintableBurnable.sol";

contract BridgedToken is
ERC20Upgradeable,
AccessControlUpgradeable,
IMintableBurnable
{
/*************
* Constants *
*************/

/// @notice The role required to mint tokens
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

/// @notice The role required to burn tokens
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

/***************
* Constructor *
***************/

constructor() {
_disableInitializers();
}

/// @notice Initializes the contract
/// @param admin The address of the admin
/// @param name The name of the token
/// @param symbol The symbol of the token
function initialize(
address admin,
string memory name,
string memory symbol
) external initializer {
__ERC20_init(name, symbol);
__AccessControl_init();

_grantRole(DEFAULT_ADMIN_ROLE, admin);
}

/*****************************
* Public Mutating Functions *
*****************************/

/// @inheritdoc IMintableBurnable
function burn(
address _from,
uint256 _amount
) external onlyRole(BURNER_ROLE) returns (bool success) {
_burn(_from, _amount);

return true;
}

/// @inheritdoc IMintableBurnable
function mint(
address _to,
uint256 _amount
) external onlyRole(MINTER_ROLE) returns (bool success) {
_mint(_to, _amount);

return true;
}
}
19 changes: 19 additions & 0 deletions src/oft/BridgedTokenOFTAdapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.30;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {MintBurnOFTAdapter} from "@layerzerolabs/oft-evm/contracts/MintBurnOFTAdapter.sol";
import {IMintableBurnable} from "@layerzerolabs/oft-evm/contracts/interfaces/IMintableBurnable.sol";

contract BridgedTokenOFTAdapter is MintBurnOFTAdapter {
constructor(
address _token,
IMintableBurnable _minterBurner,
address _lzEndpoint,
address _delegate
)
MintBurnOFTAdapter(_token, _minterBurner, _lzEndpoint, _delegate)
Ownable(_delegate)
{}
}
Loading