-
Notifications
You must be signed in to change notification settings - Fork 147
Mint-Burn gas token privileged contract #334
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3147f11
Mint-Burn gas token privileged contract
TucksonDev af5e5dd
Address feedback
TucksonDev 5b1e0f8
Format
TucksonDev 1482b01
Add interface
TucksonDev 01df41f
Address feedback
TucksonDev 3389c19
Remove admins from constructor and check for isChainOwner
TucksonDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,27 @@ | ||
// Copyright 2021-2022, Offchain Labs, Inc. | ||
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
interface IMinterBurnerForwarder { | ||
/** | ||
* @notice Mints some amount of the native gas token for this chain to the calling address. | ||
* @dev This function calls mintNativeToken in the ArbOwner precompile, so this contract must also be a chain owner. | ||
* No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs() | ||
* @param amount The amount of native gas token to mint | ||
*/ | ||
function mintNativeToken( | ||
uint256 amount | ||
) external; | ||
|
||
/** | ||
* @notice Burns some amount of the native gas token for this chain from the given address. | ||
* @dev This function calls burnNativeToken in the ArbOwner precompile, so this contract must also be a chain owner. | ||
* No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs() | ||
* @param amount The amount of native gas token to burn | ||
*/ | ||
function burnNativeToken( | ||
uint256 amount | ||
) external; | ||
} |
This file contains hidden or 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,55 @@ | ||||||||||||||||||||||||
// Copyright 2021-2022, Offchain Labs, Inc. | ||||||||||||||||||||||||
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE | ||||||||||||||||||||||||
// SPDX-License-Identifier: BUSL-1.1 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
pragma solidity ^0.8.0; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; | ||||||||||||||||||||||||
import "./IMinterBurnerForwarder.sol"; | ||||||||||||||||||||||||
import "../precompiles/ArbOwner.sol"; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
/** | ||||||||||||||||||||||||
* @title MinterBurnerForwarder | ||||||||||||||||||||||||
* @notice This contract allows the chain owner of a chain to give rights for minting and burning native gas tokens to third parties. | ||||||||||||||||||||||||
* Minting and burning will be done by using the ArbOwner functions mintNativeToken and burnNativeToken. | ||||||||||||||||||||||||
* This contract must be set as a chain owner of the chain to be able to call ArbOwner functions | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
contract MinterBurnerForwarder is IMinterBurnerForwarder, AccessControlEnumerable { | ||||||||||||||||||||||||
// Roles | ||||||||||||||||||||||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER"); | ||||||||||||||||||||||||
bytes32 public constant BURNER_ROLE = keccak256("BURNER"); | ||||||||||||||||||||||||
TucksonDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
// ArbOwner precompile | ||||||||||||||||||||||||
ArbOwner constant ARB_OWNER = ArbOwner(address(112)); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
constructor(address[] memory admins, address[] memory minters, address[] memory burners) { | ||||||||||||||||||||||||
// Grant ADMIN role to admins | ||||||||||||||||||||||||
for (uint256 i = 0; i < admins.length; i++) { | ||||||||||||||||||||||||
_grantRole(DEFAULT_ADMIN_ROLE, admins[i]); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// Grant MINTER role to minters | ||||||||||||||||||||||||
for (uint256 i = 0; i < minters.length; i++) { | ||||||||||||||||||||||||
_grantRole(MINTER_ROLE, minters[i]); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// Grant BURNER role to burners | ||||||||||||||||||||||||
for (uint256 i = 0; i < burners.length; i++) { | ||||||||||||||||||||||||
_grantRole(BURNER_ROLE, burners[i]); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
/// @inheritdoc IMinterBurnerForwarder | ||||||||||||||||||||||||
function mintNativeToken( | ||||||||||||||||||||||||
uint256 amount | ||||||||||||||||||||||||
) external onlyRole(MINTER_ROLE) { | ||||||||||||||||||||||||
ARB_OWNER.mintNativeToken(msg.sender, amount); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should do this to burn too
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
/// @inheritdoc IMinterBurnerForwarder | ||||||||||||||||||||||||
function burnNativeToken( | ||||||||||||||||||||||||
uint256 amount | ||||||||||||||||||||||||
) external onlyRole(BURNER_ROLE) { | ||||||||||||||||||||||||
ARB_OWNER.burnNativeToken(msg.sender, amount); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.