-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MintSwapCanonicalTokenFreezable (#268)
- Loading branch information
1 parent
4d742f6
commit 5c4642f
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
contracts/pegged-bridge/tokens/freezable/MintSwapCanonicalTokenFreezable.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,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); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
deploy/pegged-bridge/tokens/freezable/001_mint_swap_canonical_token_freezable.ts
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,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; |