Commit 3c5726d4 authored by smartcontracts's avatar smartcontracts Committed by GitHub

style(ctb): clean up enums (#2972)

Enums should have CapitalCase names and UPPER_SNAKE_CASE values.
Standardizes around that. Also removes an unused enum in MerkleTrie.sol.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 51830af2
---
'@eth-optimism/contracts-bedrock': patch
---
Cleaned up enums, should be CapitalCase enums and UPPER_CASE values
...@@ -14,12 +14,6 @@ library MerkleTrie { ...@@ -14,12 +14,6 @@ library MerkleTrie {
* Data Structures * * Data Structures *
*******************/ *******************/
enum NodeType {
BranchNode,
ExtensionNode,
LeafNode
}
struct TrieNode { struct TrieNode {
bytes encoded; bytes encoded;
RLPReader.RLPItem[] decoded; RLPReader.RLPItem[] decoded;
......
...@@ -52,8 +52,8 @@ contract ProxyAdmin_Test is Test { ...@@ -52,8 +52,8 @@ contract ProxyAdmin_Test is Test {
// Set the proxy types // Set the proxy types
admin.setProxyType(address(proxy), ProxyAdmin.ProxyType.ERC1967); admin.setProxyType(address(proxy), ProxyAdmin.ProxyType.ERC1967);
admin.setProxyType(address(chugsplash), ProxyAdmin.ProxyType.Chugsplash); admin.setProxyType(address(chugsplash), ProxyAdmin.ProxyType.CHUGSPLASH);
admin.setProxyType(address(resolved), ProxyAdmin.ProxyType.ResolvedDelegate); admin.setProxyType(address(resolved), ProxyAdmin.ProxyType.RESOLVED);
vm.stopPrank(); vm.stopPrank();
implementation = new SimpleStorage(); implementation = new SimpleStorage();
...@@ -80,7 +80,7 @@ contract ProxyAdmin_Test is Test { ...@@ -80,7 +80,7 @@ contract ProxyAdmin_Test is Test {
function test_onlyOwnerSetProxyType() external { function test_onlyOwnerSetProxyType() external {
vm.expectRevert("UNAUTHORIZED"); vm.expectRevert("UNAUTHORIZED");
admin.setProxyType(address(0), ProxyAdmin.ProxyType.Chugsplash); admin.setProxyType(address(0), ProxyAdmin.ProxyType.CHUGSPLASH);
} }
function test_owner() external { function test_owner() external {
...@@ -94,11 +94,11 @@ contract ProxyAdmin_Test is Test { ...@@ -94,11 +94,11 @@ contract ProxyAdmin_Test is Test {
); );
assertEq( assertEq(
uint256(admin.proxyType(address(chugsplash))), uint256(admin.proxyType(address(chugsplash))),
uint256(ProxyAdmin.ProxyType.Chugsplash) uint256(ProxyAdmin.ProxyType.CHUGSPLASH)
); );
assertEq( assertEq(
uint256(admin.proxyType(address(resolved))), uint256(admin.proxyType(address(resolved))),
uint256(ProxyAdmin.ProxyType.ResolvedDelegate) uint256(ProxyAdmin.ProxyType.RESOLVED)
); );
} }
...@@ -171,10 +171,10 @@ contract ProxyAdmin_Test is Test { ...@@ -171,10 +171,10 @@ contract ProxyAdmin_Test is Test {
if (proxyType == ProxyAdmin.ProxyType.ERC1967) { if (proxyType == ProxyAdmin.ProxyType.ERC1967) {
vm.expectRevert("Proxy: implementation not initialized"); vm.expectRevert("Proxy: implementation not initialized");
admin.getProxyAdmin(_proxy); admin.getProxyAdmin(_proxy);
} else if (proxyType == ProxyAdmin.ProxyType.Chugsplash) { } else if (proxyType == ProxyAdmin.ProxyType.CHUGSPLASH) {
vm.expectRevert("L1ChugSplashProxy: implementation is not set yet"); vm.expectRevert("L1ChugSplashProxy: implementation is not set yet");
admin.getProxyAdmin(_proxy); admin.getProxyAdmin(_proxy);
} else if (proxyType == ProxyAdmin.ProxyType.ResolvedDelegate) { } else if (proxyType == ProxyAdmin.ProxyType.RESOLVED) {
// Just an empty block to show that all cases are covered // Just an empty block to show that all cases are covered
} else { } else {
vm.expectRevert("ProxyAdmin: unknown proxy type"); vm.expectRevert("ProxyAdmin: unknown proxy type");
...@@ -185,12 +185,12 @@ contract ProxyAdmin_Test is Test { ...@@ -185,12 +185,12 @@ contract ProxyAdmin_Test is Test {
vm.prank(address(128)); vm.prank(address(128));
if (proxyType == ProxyAdmin.ProxyType.ERC1967) { if (proxyType == ProxyAdmin.ProxyType.ERC1967) {
assertEq(Proxy(payable(_proxy)).admin(), address(128)); assertEq(Proxy(payable(_proxy)).admin(), address(128));
} else if (proxyType == ProxyAdmin.ProxyType.Chugsplash) { } else if (proxyType == ProxyAdmin.ProxyType.CHUGSPLASH) {
assertEq( assertEq(
L1ChugSplashProxy(payable(_proxy)).getOwner(), L1ChugSplashProxy(payable(_proxy)).getOwner(),
address(128) address(128)
); );
} else if (proxyType == ProxyAdmin.ProxyType.ResolvedDelegate) { } else if (proxyType == ProxyAdmin.ProxyType.RESOLVED) {
assertEq( assertEq(
addressManager.owner(), addressManager.owner(),
address(128) address(128)
......
...@@ -36,14 +36,14 @@ contract ProxyAdmin is Owned { ...@@ -36,14 +36,14 @@ contract ProxyAdmin is Owned {
/** /**
* @notice The proxy types that the ProxyAdmin can manage. * @notice The proxy types that the ProxyAdmin can manage.
* *
* @custom:value ERC1967 Represents an ERC1967 compliant transparent proxy interface. * @custom:value ERC1967 Represents an ERC1967 compliant transparent proxy interface.
* @custom:value Chugsplash Represents the Chugsplash proxy interface (legacy). * @custom:value CHUGSPLASH Represents the Chugsplash proxy interface (legacy).
* @custom:value ResolvedDelegate Represents the ResolvedDelegate proxy (legacy). * @custom:value RESOLVED Represents the ResolvedDelegate proxy (legacy).
*/ */
enum ProxyType { enum ProxyType {
ERC1967, ERC1967,
Chugsplash, CHUGSPLASH,
ResolvedDelegate RESOLVED
} }
/** /**
...@@ -156,9 +156,9 @@ contract ProxyAdmin is Owned { ...@@ -156,9 +156,9 @@ contract ProxyAdmin is Owned {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
return IStaticERC1967Proxy(_proxy).implementation(); return IStaticERC1967Proxy(_proxy).implementation();
} else if (ptype == ProxyType.Chugsplash) { } else if (ptype == ProxyType.CHUGSPLASH) {
return IStaticL1ChugSplashProxy(_proxy).getImplementation(); return IStaticL1ChugSplashProxy(_proxy).getImplementation();
} else if (ptype == ProxyType.ResolvedDelegate) { } else if (ptype == ProxyType.RESOLVED) {
return addressManager.getAddress(implementationName[_proxy]); return addressManager.getAddress(implementationName[_proxy]);
} else { } else {
revert("ProxyAdmin: unknown proxy type"); revert("ProxyAdmin: unknown proxy type");
...@@ -176,9 +176,9 @@ contract ProxyAdmin is Owned { ...@@ -176,9 +176,9 @@ contract ProxyAdmin is Owned {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
return IStaticERC1967Proxy(_proxy).admin(); return IStaticERC1967Proxy(_proxy).admin();
} else if (ptype == ProxyType.Chugsplash) { } else if (ptype == ProxyType.CHUGSPLASH) {
return IStaticL1ChugSplashProxy(_proxy).getOwner(); return IStaticL1ChugSplashProxy(_proxy).getOwner();
} else if (ptype == ProxyType.ResolvedDelegate) { } else if (ptype == ProxyType.RESOLVED) {
return addressManager.owner(); return addressManager.owner();
} else { } else {
revert("ProxyAdmin: unknown proxy type"); revert("ProxyAdmin: unknown proxy type");
...@@ -195,9 +195,9 @@ contract ProxyAdmin is Owned { ...@@ -195,9 +195,9 @@ contract ProxyAdmin is Owned {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
Proxy(_proxy).changeAdmin(_newAdmin); Proxy(_proxy).changeAdmin(_newAdmin);
} else if (ptype == ProxyType.Chugsplash) { } else if (ptype == ProxyType.CHUGSPLASH) {
L1ChugSplashProxy(_proxy).setOwner(_newAdmin); L1ChugSplashProxy(_proxy).setOwner(_newAdmin);
} else if (ptype == ProxyType.ResolvedDelegate) { } else if (ptype == ProxyType.RESOLVED) {
addressManager.transferOwnership(_newAdmin); addressManager.transferOwnership(_newAdmin);
} else { } else {
revert("ProxyAdmin: unknown proxy type"); revert("ProxyAdmin: unknown proxy type");
...@@ -214,12 +214,12 @@ contract ProxyAdmin is Owned { ...@@ -214,12 +214,12 @@ contract ProxyAdmin is Owned {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
Proxy(_proxy).upgradeTo(_implementation); Proxy(_proxy).upgradeTo(_implementation);
} else if (ptype == ProxyType.Chugsplash) { } else if (ptype == ProxyType.CHUGSPLASH) {
L1ChugSplashProxy(_proxy).setStorage( L1ChugSplashProxy(_proxy).setStorage(
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc,
bytes32(uint256(uint160(_implementation))) bytes32(uint256(uint160(_implementation)))
); );
} else if (ptype == ProxyType.ResolvedDelegate) { } else if (ptype == ProxyType.RESOLVED) {
string memory name = implementationName[_proxy]; string memory name = implementationName[_proxy];
addressManager.setAddress(name, _implementation); addressManager.setAddress(name, _implementation);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment