Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion op-bindings/artifacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"DelayedVetoable",
"ISemver",
"CeloRegistry",
"GoldToken"
"GoldToken",
"FeeCurrencyWhitelist"
]
886 changes: 886 additions & 0 deletions op-bindings/bindings/feecurrencywhitelist.go

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions op-bindings/bindings/feecurrencywhitelist_more.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions op-bindings/predeploys/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
EAS = "0x4200000000000000000000000000000000000021"
CeloRegistry = "0x000000000000000000000000000000000000ce10"
GoldToken = "0x471ece3750da237f93b8e339c536989b8978a438"
FeeCurrencyWhitelist = "0xBB024E9cdCB2f9E34d893630D19611B8A5381b3c"
)

var (
Expand All @@ -50,8 +51,9 @@ var (
SchemaRegistryAddr = common.HexToAddress(SchemaRegistry)
EASAddr = common.HexToAddress(EAS)

CeloRegistryAddr = common.HexToAddress(CeloRegistry)
GoldTokenAddr = common.HexToAddress(GoldToken)
CeloRegistryAddr = common.HexToAddress(CeloRegistry)
GoldTokenAddr = common.HexToAddress(GoldToken)
FeeCurrencyWhitelistAddr = common.HexToAddress(FeeCurrencyWhitelist)

Predeploys = make(map[string]*common.Address)
CeloPredeploys = make(map[string]*common.Address)
Expand Down Expand Up @@ -90,6 +92,7 @@ func init() {
Predeploys["EAS"] = &EASAddr
Predeploys["CeloRegistry"] = &CeloRegistryAddr
Predeploys["GoldToken"] = &GoldTokenAddr
Predeploys["FeeCurrencyWhitelist"] = &FeeCurrencyWhitelistAddr

CeloPredeploys[Predeploys["CeloRegistry"].String()] = Predeploys["CeloRegistry"]
Copy link

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

CeloPredeploys[Predeploys["GoldToken"].String()] = Predeploys["GoldToken"]
Expand Down
4 changes: 4 additions & 0 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.Storage
"0xd7e89ade8430819f08bf97a087285824af3351ee12d72a2d132b0c6c0687bfaf": predeploys.GoldTokenAddr, // keccak256(abi.encodePacked("GoldToken"));
},
}
storage["FeeCurrencyWhitelist"] = state.StorageValues{
"initialized": true,
"_owner": config.ProxyAdminOwner,
}
return storage, nil
}

Expand Down
8 changes: 8 additions & 0 deletions op-chain-ops/immutables/immutables.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ func BuildOptimism(immutable ImmutableConfig) (DeploymentResults, error) {
false,
},
},
{
Name: "FeeCurrencyWhitelist",
Args: []interface{}{
false,
},
},
}
return BuildL2(deployments)
}
Expand Down Expand Up @@ -261,6 +267,8 @@ func l2Deployer(backend *backends.SimulatedBackend, opts *bind.TransactOpts, dep
_, tx, _, err = bindings.DeployCeloRegistry(opts, backend, false)
case "GoldToken":
_, tx, _, err = bindings.DeployGoldToken(opts, backend, false)
case "FeeCurrencyWhitelist":
_, tx, _, err = bindings.DeployFeeCurrencyWhitelist(opts, backend, false)
default:
return tx, fmt.Errorf("unknown contract: %s", deployment.Name)
}
Expand Down
6 changes: 6 additions & 0 deletions op-chain-ops/immutables/immutables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestBuildOptimism(t *testing.T) {
"minimumWithdrawalAmount": minimumWithdrawalAmount,
"withdrawalNetwork": uint8(0),
},
"FeeCurrencyWhitelist": {
"recipient": common.HexToAddress("0x1234567890123456789012345678901234567890"),
"minimumWithdrawalAmount": minimumWithdrawalAmount,
"withdrawalNetwork": uint8(0),
},
})
require.Nil(t, err)
require.NotNil(t, results)
Expand All @@ -77,6 +82,7 @@ func TestBuildOptimism(t *testing.T) {
"SchemaRegistry": true,
"CeloRegistry": true,
"GoldToken": true,
"FeeCurrencyWhitelist": true,
}

// Only the exact contracts that we care about are being
Expand Down
81 changes: 81 additions & 0 deletions packages/contracts-bedrock/src/celo/FeeCurrencyWhitelist.sol
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;
}
}