diff --git a/contracts/pegged-bridge/tokens/freezable/MintSwapCanonicalTokenFreezable.sol b/contracts/pegged-bridge/tokens/freezable/MintSwapCanonicalTokenFreezable.sol new file mode 100644 index 000000000..c61e8f634 --- /dev/null +++ b/contracts/pegged-bridge/tokens/freezable/MintSwapCanonicalTokenFreezable.sol @@ -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); + } +} diff --git a/deploy/pegged-bridge/tokens/freezable/001_mint_swap_canonical_token_freezable.ts b/deploy/pegged-bridge/tokens/freezable/001_mint_swap_canonical_token_freezable.ts new file mode 100644 index 000000000..603a31095 --- /dev/null +++ b/deploy/pegged-bridge/tokens/freezable/001_mint_swap_canonical_token_freezable.ts @@ -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;