Skip to content

Commit

Permalink
refactor: minimum updates
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleygtrillion committed Sep 5, 2024
1 parent 64a883c commit 3cfe305
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 421 deletions.
20 changes: 1 addition & 19 deletions src/v2/FiatTokenV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,14 @@ pragma solidity 0.8.20;

import "../v1/FiatTokenV1.sol";

error InvalidReInitialization(address addr);

/// @custom:security-contact [email protected]
contract FiatTokenV2 is FiatTokenV1 {
uint8 internal _initializedVersion;
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

function initializeV2(address burner) external {
if (_initializedVersion > 0) {
revert InvalidReInitialization(msg.sender);
}

_grantRole(BURNER_ROLE, burner);

_initializedVersion = 1;
}

function burnBurner(uint256 value) public onlyRole(BURNER_ROLE) {
function burnByBurner(uint256 value) public onlyRole(BURNER_ROLE) {
_burn(_msgSender(), value);
}

function burnFromBurner(address account, uint256 value) public onlyRole(BURNER_ROLE) {
_spendAllowance(account, _msgSender(), value);
_burn(account, value);
}

function version() public pure virtual override(FiatTokenV1) returns (string memory) {
return "2";
}
Expand Down
1 change: 0 additions & 1 deletion test/v1/FiatTokenV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {Upgrades, Options} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CallerBlacklisted} from "../../src/v1/BlacklistableV1.sol";
import {Ramen} from "../../src/mocks/Ramen.sol";
// import {FiatTokenV99} from "../../src/mocks/FiatTokenV99.sol";

// mock contract to test upgrades
contract FiatTokenV99 is FiatTokenV1 {
Expand Down
Loading

0 comments on commit 3cfe305

Please sign in to comment.