Skip to content

Commit

Permalink
feat: track points
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec committed May 16, 2024
1 parent 4b47e53 commit 33277cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
31 changes: 29 additions & 2 deletions contracts/tokenWrappers/ProtToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import "../utils/Errors.sol";
/// @notice Base token contract that can only be minted
contract ProtToken is ERC20 {
mapping(address => bool) public minters;
mapping(address => bool) public whitelistedRecipients;
ICore public core;
uint8 public allowedTransfers;

constructor(string memory name_, string memory symbol_, address _minter, address _core) ERC20(name_, symbol_) {
if (_core == address(0) || _minter == address(0)) revert ZeroAddress();
Expand All @@ -37,11 +39,36 @@ contract ProtToken is ERC20 {
_mint(account, amount);
}

function burn(address account, uint256 amount) public onlyMinter {
function burn(address account, uint256 amount) external onlyMinter {
_burn(account, amount);
}

function toggleMinter(address minter) public onlyGovernorOrGuardian {
function mintBatch(address[] memory accounts, uint256[] memory amounts) external onlyMinter {
uint256 length = accounts.length;
for (uint256 i = 0; i < length; ++i) {
_mint(accounts[i], amounts[i]);
}
}

function toggleMinter(address minter) external onlyGovernorOrGuardian {
minters[minter] = !minters[minter];
}

function toggleAllowedTransfers() external onlyGovernorOrGuardian {
allowedTransfers = 1 - allowedTransfers;
}

function toggleWhitelistedRecipient(address recipient) external onlyGovernorOrGuardian {
whitelistedRecipients[recipient] = !whitelistedRecipients[recipient];
}

function _beforeTokenTransfer(address from, address to, uint256) internal view override {
if (
allowedTransfers == 0 &&
from != address(0) &&
to != address(0) &&
!whitelistedRecipients[from] &&
!whitelistedRecipients[to]
) revert NotAllowed();
}
}
1 change: 1 addition & 0 deletions contracts/utils/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ error InvalidUninitializedRoot();
error InvalidReward();
error InvalidSignature();
error NoDispute();
error NotAllowed();
error NotGovernor();
error NotGovernorOrGuardian();
error NotSigned();
Expand Down

0 comments on commit 33277cd

Please sign in to comment.