forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 9
contracts: Add FeeCurrencyWhitelist
#68
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -42,5 +42,6 @@ | |
| "DelayedVetoable", | ||
| "ISemver", | ||
| "CeloRegistry", | ||
| "GoldToken" | ||
| "GoldToken", | ||
| "FeeCurrencyWhitelist" | ||
| ] | ||
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
81 changes: 81 additions & 0 deletions
81
packages/contracts-bedrock/src/celo/FeeCurrencyWhitelist.sol
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,81 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.15; | ||
|
|
||
| import "../../lib/openzeppelin-contracts/contracts/access/Ownable.sol"; | ||
|
|
||
| import "./interfaces/ICeloVersionedContract.sol"; | ||
| import "./interfaces/IFeeCurrencyWhitelist.sol"; | ||
| import "./Initializable.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title Holds a whitelist of the ERC20+ tokens that can be used to pay for gas | ||
| * Not including the native Celo token | ||
| */ | ||
| contract FeeCurrencyWhitelist is | ||
| IFeeCurrencyWhitelist, | ||
| Ownable, | ||
| Initializable, | ||
| ICeloVersionedContract | ||
| { | ||
| // Array of all the tokens enabled | ||
| address[] public whitelist; | ||
|
|
||
| event FeeCurrencyWhitelisted(address token); | ||
|
|
||
| event FeeCurrencyWhitelistRemoved(address token); | ||
|
|
||
| /** | ||
| * @notice Sets initialized == true on implementation contracts | ||
| * @param test Set to true to skip implementation initialization | ||
| */ | ||
| constructor(bool test) Initializable(test) {} | ||
|
|
||
| /** | ||
| * @notice Used in place of the constructor to allow the contract to be upgradable via proxy. | ||
| */ | ||
| function initialize() external initializer { | ||
| _transferOwnership(msg.sender); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Returns the storage, major, minor, and patch version of the contract. | ||
| * @return Storage version of the contract. | ||
| * @return Major version of the contract. | ||
| * @return Minor version of the contract. | ||
| * @return Patch version of the contract. | ||
| */ | ||
| function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { | ||
| return (1, 1, 1, 0); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Removes a Mento token as enabled fee token. Tokens added with addToken should be | ||
| * removed with this function. | ||
| * @param tokenAddress The address of the token to remove. | ||
| * @param index The index of the token in the whitelist array. | ||
| */ | ||
| function removeToken(address tokenAddress, uint256 index) public onlyOwner { | ||
| require(whitelist[index] == tokenAddress, "Index does not match"); | ||
| uint256 length = whitelist.length; | ||
| whitelist[index] = whitelist[length - 1]; | ||
| whitelist.pop(); | ||
| emit FeeCurrencyWhitelistRemoved(tokenAddress); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Add a token to the whitelist | ||
| * @param tokenAddress The address of the token to add. | ||
| */ | ||
| function addToken(address tokenAddress) external onlyOwner { | ||
| whitelist.push(tokenAddress); | ||
| emit FeeCurrencyWhitelisted(tokenAddress); | ||
| } | ||
|
|
||
| /** | ||
| * @return a list of all tokens enabled as gas fee currency. | ||
| */ | ||
| function getWhitelist() external view returns (address[] memory) { | ||
| return whitelist; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary to also add FeeCurrencyWhitelist into CeloPredeploys