forked from ConstellationCrypto/bridging-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Manta-Network/feature/MantaMintableERC20Wi…
…thBridgeFlag Feature/manta mintable erc20 with bridge flag
- Loading branch information
Showing
4 changed files
with
101 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
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
48 changes: 48 additions & 0 deletions
48
standard-bridge-custom-token/contracts/MantaMintableERC20WithBridgeFlag.sol
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,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.15; | ||
|
||
import {OptimismMintableERC20} from "@eth-optimism/contracts-bedrock/src/universal/OptimismMintableERC20.sol"; | ||
|
||
contract MantaMintableERC20WithBridgeFlag is OptimismMintableERC20 { | ||
address public admin; | ||
bool public bridgePaused; | ||
|
||
modifier onlyAdmin() { | ||
require(admin == msg.sender, "MantaMintableERC20WithBridgeFlag: Only Admin"); | ||
_; | ||
} | ||
|
||
constructor( | ||
address _bridge, | ||
address _remoteToken, | ||
string memory _name, | ||
string memory _symbol, | ||
uint8 _decimals | ||
) OptimismMintableERC20(_bridge, _remoteToken, _name, _symbol, _decimals) { | ||
admin = msg.sender; | ||
bridgePaused=true; | ||
} | ||
|
||
function setAdmin(address _newAdmin) external onlyAdmin { | ||
require( | ||
_newAdmin != address(0), | ||
"MantaMintableERC20WithBridgeFlag: invalid new admin" | ||
); | ||
admin = _newAdmin; | ||
} | ||
|
||
function pause() external onlyAdmin { | ||
bridgePaused = true; | ||
} | ||
|
||
function unPause() external onlyAdmin { | ||
bridgePaused = false; | ||
} | ||
|
||
function burn(address _from, uint256 _amount) external override onlyBridge { | ||
require(!bridgePaused, "MantaMintableERC20WithBridgeFlag: bridge paused"); | ||
|
||
_burn(_from, _amount); | ||
emit Burn(_from, _amount); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
standard-bridge-custom-token/scripts/deployBridgeFlagToken.js
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,42 @@ | ||
require("dotenv").config(); | ||
|
||
const { ethers, run } = require("hardhat"); | ||
const { TOKENS } = require("../config"); | ||
|
||
async function main(token) { | ||
const l2CustomERC20Factory = await ethers.getContractFactory( | ||
"MantaMintableERC20WithBridgeFlag" | ||
); | ||
const args = [ | ||
"0x4200000000000000000000000000000000000010", | ||
token.l1TokenAddress, | ||
token.name, | ||
token.symbol, | ||
token.decimals, | ||
]; | ||
const l2CustomERC20 = await l2CustomERC20Factory.deploy(...args); | ||
console.log(`${token.symbol} L2 Address: ${l2CustomERC20.address}`); | ||
|
||
await l2CustomERC20.deployTransaction.wait(); | ||
|
||
await run("verify:verify", { | ||
address: l2CustomERC20.address, | ||
constructorArguments: args, | ||
contract: "contracts/MantaMintableERC20WithBridgeFlag.sol:MantaMintableERC20WithBridgeFlag" | ||
}); | ||
} | ||
|
||
const tokenInfo = TOKENS[process.env.DEPLOY_TOKEN_NAME]; | ||
if (!tokenInfo) { | ||
console.error('Invalid Token: "process.env.DEPLOY_TOKEN_NAME"'); | ||
return; | ||
} | ||
if (tokenInfo.l2TokenAddress) { | ||
console.error(`Already Deployed: ${tokenInfo.l2TokenAddress}`); | ||
return; | ||
} | ||
|
||
main(tokenInfo).catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |