Skip to content

Commit

Permalink
MintSwapCanonicalTokenFreezable (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
hezhihua81 authored Sep 19, 2023
1 parent 4d742f6 commit 5c4642f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity 0.8.17;

import "./Freezable.sol";
import "../MintSwapCanonicalToken.sol";

/**
* @title Canonical token that supports multi-bridge minter and multi-token swap. Support freezable erc20 transfer
*/
contract MintSwapCanonicalTokenFreezable is MintSwapCanonicalToken, Freezable {
string private _name;
string private _symbol;

constructor(
string memory name_,
string memory symbol_,
uint8 decimals_
) MintSwapCanonicalToken(name_, symbol_, decimals_) {}

// freezable related
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!isFrozen(from), "ERC20Freezable: from account is frozen");
require(!isFrozen(to), "ERC20Freezable: to account is frozen");
}

function freeze(address _account) public onlyOwner {
freezes[_account] = true;
emit Frozen(_account);
}

function unfreeze(address _account) public onlyOwner {
freezes[_account] = false;
emit Unfrozen(_account);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as dotenv from 'dotenv';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

dotenv.config();

const deployFunc: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

await deploy('MintSwapCanonicalTokenFreezable', {
from: deployer,
log: true,
args: [
process.env.MINT_SWAP_CANONICAL_TOKEN_NAME,
process.env.MINT_SWAP_CANONICAL_TOKEN_SYMBOL,
process.env.MINT_SWAP_CANONICAL_TOKEN_DECIMALS
]
});
};

deployFunc.tags = ['MintSwapCanonicalTokenFreezable'];
deployFunc.dependencies = [];
export default deployFunc;

0 comments on commit 5c4642f

Please sign in to comment.