-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
4 changed files
with
111 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,37 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; | ||
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
import {ERC20CappedUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20CappedUpgradeable.sol"; | ||
|
||
contract ZkLinkToken is | ||
OwnableUpgradeable, | ||
UUPSUpgradeable, | ||
ERC20Upgradeable, | ||
ERC20PermitUpgradeable, | ||
ERC20CappedUpgradeable | ||
{ | ||
function initialize() external initializer { | ||
__Ownable_init(); | ||
__UUPSUpgradeable_init(); | ||
__ERC20_init("ZKLink", "ZKL"); | ||
__ERC20Permit_init("ZKLink"); | ||
__ERC20Capped_init(1000000000000000000000000000); | ||
} | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner { | ||
// can only called by owner | ||
} | ||
|
||
function mint(address account, uint256 amount) external onlyOwner { | ||
_mint(account, amount); | ||
} | ||
|
||
function _mint(address account, uint256 amount) internal override(ERC20CappedUpgradeable, ERC20Upgradeable) { | ||
ERC20CappedUpgradeable._mint(account, amount); | ||
} | ||
} |
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
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,61 @@ | ||
const fs = require('fs'); | ||
const { getImplementationAddress } = require('@openzeppelin/upgrades-core'); | ||
const { verifyContractCode, createOrGetDeployLog, ChainContractDeployer, getDeployTx } = require('./utils'); | ||
const logName = require('./deploy_log_name'); | ||
const { task, types } = require('hardhat/config'); | ||
|
||
task('deployZkLinkToken', 'Deploy zkLink token') | ||
.addOptionalParam('skipVerify', 'Skip verify', false, types.boolean) | ||
.setAction(async (taskArgs, hardhat) => { | ||
let skipVerify = taskArgs.skipVerify; | ||
console.log('skip verify contracts?', skipVerify); | ||
|
||
const contractDeployer = new ChainContractDeployer(hardhat); | ||
await contractDeployer.init(); | ||
const deployerWallet = contractDeployer.deployerWallet; | ||
|
||
const { deployLogPath, deployLog } = createOrGetDeployLog(logName.DEPLOY_ZKLINK_TOKEN_LOG_PREFIX); | ||
deployLog[logName.DEPLOY_LOG_GOVERNOR] = deployerWallet.address; | ||
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2)); | ||
|
||
// deploy zkLink token | ||
let zkLinkTokenAddr; | ||
if (!(logName.DEPLOY_LOG_ZKLINK_TOKEN_PROXY in deployLog)) { | ||
console.log('deploy zkLink token...'); | ||
const contract = await contractDeployer.deployProxy('ZkLinkToken', [], []); | ||
const transaction = await getDeployTx(contract); | ||
zkLinkTokenAddr = await contract.getAddress(); | ||
deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_PROXY] = zkLinkTokenAddr; | ||
deployLog[logName.DEPLOY_LOG_DEPLOY_TX_HASH] = transaction.hash; | ||
deployLog[logName.DEPLOY_LOG_DEPLOY_BLOCK_NUMBER] = transaction.blockNumber; | ||
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2)); | ||
} else { | ||
zkLinkTokenAddr = deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_PROXY]; | ||
} | ||
console.log('zkLinkToken', zkLinkTokenAddr); | ||
|
||
let zkLinkTokenTargetAddr; | ||
if (!(logName.DEPLOY_LOG_ZKLINK_TOKEN_TARGET in deployLog)) { | ||
console.log('get zkLink token target...'); | ||
zkLinkTokenTargetAddr = await getImplementationAddress(hardhat.ethers.provider, zkLinkTokenAddr); | ||
deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_TARGET] = zkLinkTokenTargetAddr; | ||
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2)); | ||
} else { | ||
zkLinkTokenTargetAddr = deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_TARGET]; | ||
} | ||
console.log('zkLink token target', zkLinkTokenTargetAddr); | ||
|
||
// verify target contract | ||
if (!(logName.DEPLOY_LOG_ZKLINK_TOKEN_TARGET_VERIFIED in deployLog) && !skipVerify) { | ||
await verifyContractCode(hardhat, zkLinkTokenTargetAddr, []); | ||
deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_TARGET_VERIFIED] = true; | ||
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2)); | ||
} | ||
|
||
// verify proxy contract | ||
if (!(logName.DEPLOY_LOG_ZKLINK_TOKEN_PROXY_VERIFIED in deployLog) && !skipVerify) { | ||
await verifyContractCode(hardhat, zkLinkTokenAddr, []); | ||
deployLog[logName.DEPLOY_LOG_ZKLINK_TOKEN_PROXY_VERIFIED] = true; | ||
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2)); | ||
} | ||
}); |