Skip to content

Commit

Permalink
Add burner role for burn functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleygtrillion committed Sep 3, 2024
1 parent c620158 commit 3fddf1a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@trillion-x/trillion-contracts",
"name": "trillion-contracts",
"version": "1.0.0",
"license": "MIT",
"repository": "[email protected]:royal-markets/royal-contracts.git",
"repository": "[email protected]:trillion-network/trillion-contracts.git",
"files": [
"out",
"ts-types"
Expand Down
2 changes: 1 addition & 1 deletion script/UpgradeFiatToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Script} from "forge-std/Script.sol";
import {Upgrades, Options} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {FiatTokenV1} from "../src/v1/FiatTokenV1.sol";

contract DeployFiatToken is Script {
contract UpgradeFiatToken is Script {
function run() public {
vm.startBroadcast();
address fiatTokenProxyAddress = vm.envAddress("FIAT_TOKEN_PROXY_ADDRESS");
Expand Down
5 changes: 3 additions & 2 deletions src/v1/FiatTokenV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract FiatTokenV1 is
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
bytes32 public constant RESCUER_ROLE = keccak256("RESCUER_ROLE");
bytes32 public constant BLACKLISTER_ROLE = keccak256("BLACKLISTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

/// @dev reserve storage slots so that future upgrades do not affect storage layout of child contracts
/// when extra variables are added, reduce the appropriate slots from the storage gap
Expand Down Expand Up @@ -93,11 +94,11 @@ contract FiatTokenV1 is
_mint(to, amount);
}

function burn(uint256 value) public override(ERC20BurnableUpgradeable) onlyRole(MINTER_ROLE) {
function burn(uint256 value) public override(ERC20BurnableUpgradeable) onlyRole(BURNER_ROLE) {
super.burn(value);
}

function burnFrom(address account, uint256 value) public override(ERC20BurnableUpgradeable) onlyRole(MINTER_ROLE) {
function burnFrom(address account, uint256 value) public override(ERC20BurnableUpgradeable) onlyRole(BURNER_ROLE) {
super.burnFrom(account, value);
}

Expand Down
21 changes: 21 additions & 0 deletions src/v2/FiatTokenV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

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

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

function burn(uint256 value) public override(FiatTokenV1) onlyRole(BURNER_ROLE) {
super.burn(value);
}

function burnFrom(address account, uint256 value) public override(FiatTokenV1) onlyRole(BURNER_ROLE) {
super.burnFrom(account, value);
}

function version() public pure virtual override(FiatTokenV1) returns (string memory) {
return "2";
}
}

0 comments on commit 3fddf1a

Please sign in to comment.