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

feat(protocol): tokens can only mint once #13252

Merged
merged 3 commits into from
Mar 4, 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
11 changes: 10 additions & 1 deletion packages/protocol/contracts/test/erc20/FreeMintERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// An ERC20 Token with a mint function anyone can call, for free, to receive
// 5 tokens.
contract FreeMintERC20 is ERC20 {
error HasMinted();

mapping(address minter => bool hasMinted) public minters;

constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

function mint(address to) public {
_mint(to, 5 * (10 ** decimals()));
if (minters[msg.sender]) {
revert HasMinted();
}

minters[msg.sender] = true;
_mint(to, 50 * (10 ** decimals()));
}
}
11 changes: 10 additions & 1 deletion packages/protocol/contracts/test/erc20/MayFailFreeMintERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// This token has 50% of failure on transfers so we can
// test the bridge's error handling.
contract MayFailFreeMintERC20 is ERC20 {
error HasMinted();

mapping(address minter => bool hasMinted) public minters;

constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

function mint(address to) public {
_mint(to, 5 * (10 ** decimals()));
if (minters[msg.sender]) {
revert HasMinted();
}

minters[msg.sender] = true;
_mint(to, 50 * (10 ** decimals()));
}

function transfer(
Expand Down