Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MintSwapCanonicalTokenFreezable #268

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
@@ -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;
Loading