Skip to content

Commit

Permalink
Ultra Green Celo Implementation (#10227)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvol authored Jun 29, 2023
1 parent 067115b commit 49f3dc6
Show file tree
Hide file tree
Showing 68 changed files with 3,755 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"generate:shrinkwrap": "npm install --production && npm shrinkwrap",
"check:shrinkwrap": "npm install --production && npm shrinkwrap && ./scripts/check_shrinkwrap_dirty.sh",
"prepack": "yarn run build && oclif-dev manifest && oclif-dev readme && yarn run check:shrinkwrap",
"test:reset": "yarn --cwd ../protocol devchain generate-tar .tmp/devchain.tar.gz --migration_override ../dev-utils/src/migration-override.json --upto 27 --release_gold_contracts scripts/truffle/releaseGoldExampleConfigs.json",
"test:reset": "yarn --cwd ../protocol devchain:reset --migration_override ../dev-utils/src/migration-override.json --release_gold_contracts scripts/truffle/releaseGoldExampleConfigs.json",
"test:livechain": "yarn --cwd ../protocol devchain run-tar .tmp/devchain.tar.gz",
"test": "TZ=UTC jest --runInBand"
},
Expand Down
44 changes: 43 additions & 1 deletion packages/protocol/contracts/common/FeeCurrencyWhitelist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ import "./interfaces/IFeeCurrencyWhitelist.sol";

import "../common/Initializable.sol";

import "../common/interfaces/ICeloVersionedContract.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 {
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
Expand All @@ -25,14 +38,43 @@ contract FeeCurrencyWhitelist is IFeeCurrencyWhitelist, Ownable, Initializable {
_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;
}
Expand Down
Loading

0 comments on commit 49f3dc6

Please sign in to comment.