Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IMintableBurnable } from "@layerzerolabs/oft-evm/contracts/interfaces/I
* IF the 'innerToken' applies something like a transfer fee, the default will NOT work...
* a pre/post balance check will need to be done to calculate the amountSentLD/amountReceivedLD.
*/
contract MyMintBurnOFTAdapter is MintBurnOFTAdapter {
contract BOMBAdapter is MintBurnOFTAdapter {
constructor(
address _token,
IMintableBurnable _minterBurner,
Expand Down
24 changes: 24 additions & 0 deletions examples/mint-burn-oft-adapter/contracts/BOMBMinterBurner.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

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

contract BOMBMinterBurner is IMintableBurnable {
BOMBToken public immutable bombToken;

constructor(address _bombToken) {
bombToken = BOMBToken(_bombToken);
}

function burn(address _from, uint256 _amount) external override returns (bool success) {
bombToken.transferFrom(_from, address(this), _amount);
bombToken.burn(_amount);
return true;
}

function mint(address _to, uint256 _amount) external override returns (bool success) {
bombToken.mint(_to, _amount);
return true;
}
}
27 changes: 27 additions & 0 deletions examples/mint-burn-oft-adapter/contracts/BOMBToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.8.16;

import "@openzeppelin-v4/contracts/access/AccessControlDefaultAdminRules.sol";
import "@openzeppelin-v4/contracts/token/ERC20/extensions/ERC20Votes.sol";

string constant NAME = "Bombie";
string constant SYMBOL = "BOMB";

contract BOMBToken is ERC20Votes, AccessControlDefaultAdminRules {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

constructor() ERC20Permit(NAME) ERC20(NAME, SYMBOL) AccessControlDefaultAdminRules(3 days, msg.sender) {}

function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}

function burn(uint256 amount) public onlyRole(BURNER_ROLE) {
_burn(msg.sender, amount);
}

function _maxSupply() internal view virtual override returns (uint224) {
return 10_000_000_000 * 1e18;
}
}
14 changes: 0 additions & 14 deletions examples/mint-burn-oft-adapter/contracts/MyOFT.sol

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions examples/mint-burn-oft-adapter/contracts/mocks/MyOFTMock.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

const contractName = 'MyMintBurnOFTAdapter'
const contractName = 'BOMBAdapter'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre
Expand Down Expand Up @@ -32,7 +32,6 @@ const deploy: DeployFunction = async (hre) => {
// }
// }
const endpointV2Deployment = await hre.deployments.get('EndpointV2')
const minterBurnerAddress = ''

// The token address must be defined in hardhat.config.ts
// If the token address is not defined, the deployment will log a warning and skip the deployment
Expand All @@ -42,11 +41,14 @@ const deploy: DeployFunction = async (hre) => {
return
}

// Get the BombMinterBurner deployment
const bombMinterBurnerDeployment = await hre.deployments.get('BOMBMinterBurner')

const { address } = await deploy(contractName, {
from: deployer,
args: [
hre.network.config.oftAdapter.tokenAddress, // token address
minterBurnerAddress, // token address implementing IMintableBurnable
bombMinterBurnerDeployment.address, // BombMinterBurner address implementing IMintableBurnable
endpointV2Deployment.address, // LayerZero's EndpointV2 address
deployer, // owner
],
Expand All @@ -58,5 +60,6 @@ const deploy: DeployFunction = async (hre) => {
}

deploy.tags = [contractName]
deploy.dependencies = ['BOMBMinterBurner']

export default deploy
34 changes: 34 additions & 0 deletions examples/mint-burn-oft-adapter/deploy/BOMBToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

const contractName = 'BOMBToken'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre

const { deploy } = deployments
const { deployer } = await getNamedAccounts()

assert(deployer, 'Missing named deployer account')

console.log(`Network: ${hre.network.name}`)
console.log(`Deployer: ${deployer}`)

// Deploy the BOMBToken contract
// Constructor: ERC20Permit(NAME), ERC20(NAME, SYMBOL), AccessControlDefaultAdminRules(3 days, msg.sender)
// NAME and SYMBOL are constants in the contract, so no args needed for those
// Only argument needed is the admin address (msg.sender)
const { address } = await deploy(contractName, {
from: deployer,
args: [], // No constructor args needed, msg.sender is set automatically
log: true,
skipIfAlreadyDeployed: false,
})

console.log(`Deployed contract: ${contractName}, network: ${hre.network.name}, address: ${address}`)
}

deploy.tags = [contractName]

export default deploy
37 changes: 37 additions & 0 deletions examples/mint-burn-oft-adapter/deploy/BombMinterBurner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

const contractName = 'BOMBMinterBurner'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre

const { deploy } = deployments
const { deployer } = await getNamedAccounts()

assert(deployer, 'Missing named deployer account')

console.log(`Network: ${hre.network.name}`)
console.log(`Deployer: ${deployer}`)

if (hre.network.config.oftAdapter == null) {
console.warn(`oftAdapter not configured on network config, skipping ${contractName} deployment`)
return
}

const { address } = await deploy(contractName, {
from: deployer,
args: [
hre.network.config.oftAdapter.tokenAddress, // BombToken address
],
log: true,
skipIfAlreadyDeployed: false,
})

console.log(`Deployed contract: ${contractName}, network: ${hre.network.name}, address: ${address}`)
}

deploy.tags = [contractName]

export default deploy
60 changes: 0 additions & 60 deletions examples/mint-burn-oft-adapter/deploy/MyOFT.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43113
Loading
Loading