diff --git a/packages/ethereum-contracts/CHANGELOG.md b/packages/ethereum-contracts/CHANGELOG.md index 174b4d1e45..a7b85fe633 100644 --- a/packages/ethereum-contracts/CHANGELOG.md +++ b/packages/ethereum-contracts/CHANGELOG.md @@ -18,11 +18,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Expose `_toUnderlyingAmount(uint256 amount)` with `toUnderlyingAmount(uint256 amount)` - `batchCall` supports payable `OPERATION_TYPE_SUPERFLUID_CALL_APP_ACTION`: only the first `OPERATION_TYPE_SUPERFLUID_CALL_APP_ACTION` will be payable - Added two new functions to `SuperfluidGovernanceBase.sol`: `changeSuperTokenAdmin` and `batchChangeSuperTokenAdmin` -- `Superfluid.changeSuperTokenAdmin()` function added to be called via governance for tokens with no admin override -- Added an overloaded `initialize` to `SuperToken.sol`, which additionally takes `address adminOverride` if you want to initialize the token with an admin override +- `Superfluid.changeSuperTokenAdmin()` function added to be called via governance for tokens with no admin address +- Added an overloaded `initialize` to `SuperToken.sol`, which additionally takes `address admin` if you want to initialize the token with an admin address - `SuperToken.changeAdmin(address newAdmin)` added which is only callable by the current admin, the "admin" of a SuperToken can change the admin and update the proxy contract's pointer to a logic contract > Note that the default admin (when address(0)) is the host contract as is currently the case -- `SuperToken.getAdminOverride()` added to retrieve the AdminOverride struct (currently only holds one property: `address admin`), but is future-proofed with 12 additional bits that can be packed in the struct +- Note that the admin is stored in the EIP-1967 admin storage slot (`0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`) +- `SuperToken.getAdmin()` added to retrieve the admin address - `SuperTokenFactory.createERC20Wrapper()` overloads added to create a SuperToken AND explicitly initialize a SuperToken with an admin ### Changed diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol index cf75d42d43..ab588f7106 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol @@ -13,12 +13,6 @@ import { IConstantInflowNFT } from "./IConstantInflowNFT.sol"; */ interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 { - struct AdminOverride { - address admin; - /// @note we use a struct so the 12 remaining - /// packed bytes may be used later on - } - /************************************************************************** * Errors *************************************************************************/ @@ -48,30 +42,30 @@ interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 { ) external; /** - * @dev Initialize the contract with admin override + * @dev Initialize the contract with an admin */ - function initializeWithAdminOverride( + function initializeWithAdmin( IERC20 underlyingToken, uint8 underlyingDecimals, string calldata n, string calldata s, - address adminOverride + address admin ) external; /** - * @notice Changes the admin override for the SuperToken + * @notice Changes the admin for the SuperToken * @dev Only the current admin can call this function - * if adminOverride is address(0), it is implicitly the host address - * @param newAdmin New admin override address + * if admin is address(0), it is implicitly the host address + * @param newAdmin New admin address */ function changeAdmin(address newAdmin) external; event AdminChanged(address indexed oldAdmin, address indexed newAdmin); /** - * @dev Returns the admin override struct for the SuperToken + * @dev Returns the admin address for the SuperToken */ - function getAdminOverride() external view returns (AdminOverride memory); + function getAdmin() external view returns (address admin); /************************************************************************** * Immutable variables diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol index 134438082a..16d40c13f1 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol @@ -55,7 +55,7 @@ interface ISuperTokenFactory { * @param upgradability Upgradability mode * @param name Super token name * @param symbol Super token symbol - * @param adminOverride Admin address override + * @param admin Admin address * @return superToken The deployed and initialized wrapper super token */ function createERC20Wrapper( @@ -64,7 +64,7 @@ interface ISuperTokenFactory { Upgradability upgradability, string calldata name, string calldata symbol, - address adminOverride + address admin ) external returns (ISuperToken superToken); @@ -94,7 +94,7 @@ interface ISuperTokenFactory { * @param upgradability Upgradability mode * @param name Super token name * @param symbol Super token symbol - * @param adminOverride Admin address override + * @param admin Admin address * @return superToken The deployed and initialized wrapper super token */ function createERC20Wrapper( @@ -102,7 +102,7 @@ interface ISuperTokenFactory { Upgradability upgradability, string calldata name, string calldata symbol, - address adminOverride + address admin ) external returns (ISuperToken superToken); diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol index 39f508fd12..21a773f7aa 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol @@ -234,8 +234,8 @@ interface ISuperfluid { event SuperTokenLogicUpdated(ISuperToken indexed token, address code); /** - * @notice Change the SuperToken admin override - * @dev The admin override is the only account allowed to update the token logic + * @notice Change the SuperToken admin address + * @dev The admin is the only account allowed to update the token logic * For backward compatibility, the "host" is the default "admin" if unset (address(0)). */ function changeSuperTokenAdmin(ISuperToken token, address newAdmin) external; diff --git a/packages/ethereum-contracts/contracts/mocks/SuperTokenMock.sol b/packages/ethereum-contracts/contracts/mocks/SuperTokenMock.sol index 092c698862..f70d5c4b95 100644 --- a/packages/ethereum-contracts/contracts/mocks/SuperTokenMock.sol +++ b/packages/ethereum-contracts/contracts/mocks/SuperTokenMock.sol @@ -59,11 +59,8 @@ contract SuperTokenStorageLayoutTester is SuperToken { require (slot == 18 && offset == 0, "_operators changed location"); // uses 4 slots - assembly { slot:= _adminOverride.slot offset := _adminOverride.offset } - require (slot == 22 && offset == 0, "_adminOverride changed location"); - - assembly { slot:= _reserve23.slot offset := _reserve23.offset } - require (slot == 23 && offset == 0, "_reserve23 changed location"); + assembly { slot:= _reserve22.slot offset := _reserve22.offset } + require (slot == 22 && offset == 0, "_reserve22 changed location"); assembly { slot:= _reserve31.slot offset := _reserve31.offset } require (slot == 31 && offset == 0, "_reserve31 changed location"); diff --git a/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol b/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol index a67183252d..00a4e3f950 100644 --- a/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol +++ b/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol @@ -38,6 +38,9 @@ contract SuperToken is using ERC777Helper for ERC777Helper.Operators; using SafeERC20 for IERC20; + // See: https://eips.ethereum.org/EIPS/eip-1967#admin-address + bytes32 constant private _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + uint8 constant private _STANDARD_DECIMALS = 18; // solhint-disable-next-line var-name-mixedcase @@ -69,9 +72,6 @@ contract SuperToken is /// @dev ERC777 operators support data ERC777Helper.Operators internal _operators; - /// @dev A struct which contains the address of the admin override - AdminOverride internal _adminOverride; - // NOTE: for future compatibility, these are reserved solidity slots // The sub-class of SuperToken solidity slot will start after _reserve22 @@ -79,7 +79,8 @@ contract SuperToken is // function in its respective mock contract to ensure that it doesn't break anything or lead to unexpected // behaviors/layout when upgrading - uint256 internal _reserve23; + uint256 internal _reserve22; + uint256 private _reserve23; uint256 private _reserve24; uint256 private _reserve25; uint256 private _reserve26; @@ -130,13 +131,13 @@ contract SuperToken is _initialize(underlyingToken, underlyingDecimals, n, s, address(0)); } - /// @dev Initialize the Super Token proxy with an admin override - function initializeWithAdminOverride( + /// @dev Initialize the Super Token proxy with an admin + function initializeWithAdmin( IERC20 underlyingToken, uint8 underlyingDecimals, string calldata n, string calldata s, - address adminOverride + address admin ) external virtual @@ -147,7 +148,7 @@ contract SuperToken is // deployment of the proxy contract. // initialize the Super Token - _initialize(underlyingToken, underlyingDecimals, n, s, adminOverride); + _initialize(underlyingToken, underlyingDecimals, n, s, admin); } function proxiableUUID() public pure virtual override returns (bytes32) { @@ -156,7 +157,7 @@ contract SuperToken is /** * @notice Updates the logic contract the proxy is pointing at - * @dev Only the admin can call this function (host if adminOverride.admin == address(0)) + * @dev Only the admin can call this function (host if admin == address(0)) * @param newAddress Address of the new logic contract */ function updateCode(address newAddress) external virtual override onlyAdmin { @@ -176,16 +177,31 @@ contract SuperToken is } function changeAdmin(address newAdmin) external override onlyAdmin { - address oldAdmin = _adminOverride.admin; - _adminOverride.admin = newAdmin; + address oldAdmin = _getAdmin(); + _setAdmin(newAdmin); emit AdminChanged(oldAdmin, newAdmin); } - function getAdminOverride() external view override returns (AdminOverride memory) { - return _adminOverride; + function getAdmin() external view override returns (address) { + return _getAdmin(); + } + + function _getAdmin() internal view returns (address admin) { + assembly { + // solium-disable-line + admin := sload(_ADMIN_SLOT) + } } + function _setAdmin(address newAdmin) internal { + assembly { + // solium-disable-line + sstore(_ADMIN_SLOT, newAdmin) + } + } + + /************************************************************************** * ERC20 Token Info *************************************************************************/ @@ -211,7 +227,7 @@ contract SuperToken is uint8 underlyingDecimals, string calldata n, string calldata s, - address adminOverride + address admin ) internal { _underlyingToken = underlyingToken; _underlyingDecimals = underlyingDecimals; @@ -219,7 +235,7 @@ contract SuperToken is _name = n; _symbol = s; - _adminOverride.admin = adminOverride; + _setAdmin(admin); // register interfaces ERC777Helper.register(address(this)); @@ -228,7 +244,7 @@ contract SuperToken is emit Transfer(address(0), address(0), 0); // previous admin will always be the zero address in an uninitialized contract - emit AdminChanged(address(0), adminOverride); + emit AdminChanged(address(0), admin); } /** @@ -865,7 +881,8 @@ contract SuperToken is * override address */ modifier onlyAdmin() { - address admin = _adminOverride.admin == address(0) ? address(_host) : _adminOverride.admin; + address adminSlotAdmin = _getAdmin(); + address admin = adminSlotAdmin == address(0) ? address(_host) : adminSlotAdmin; if (msg.sender != admin) revert SUPER_TOKEN_ONLY_ADMIN(); _; } diff --git a/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol b/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol index 67e33a1c15..9d4c09464e 100644 --- a/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol +++ b/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol @@ -212,7 +212,7 @@ abstract contract SuperTokenFactoryBase is Upgradability upgradability, string calldata name, string calldata symbol, - address adminOverride + address admin ) public override returns (ISuperToken superToken) { if (address(underlyingToken) == address(0)) { revert SUPER_TOKEN_FACTORY_ZERO_ADDRESS(); @@ -232,12 +232,12 @@ abstract contract SuperTokenFactoryBase is } // initialize the token - superToken.initializeWithAdminOverride( + superToken.initializeWithAdmin( underlyingToken, underlyingDecimals, name, symbol, - adminOverride + admin ); emit SuperTokenCreated(superToken); @@ -270,7 +270,7 @@ abstract contract SuperTokenFactoryBase is Upgradability upgradability, string calldata name, string calldata symbol, - address adminOverride + address admin ) external override returns (ISuperToken superToken) @@ -281,7 +281,7 @@ abstract contract SuperTokenFactoryBase is upgradability, name, symbol, - adminOverride + admin ); } diff --git a/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol b/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol index 7a29ce6b68..45a876d1d2 100644 --- a/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol +++ b/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol @@ -161,21 +161,21 @@ contract SuperfluidFrameworkDeployer is SuperfluidFrameworkDeploymentSteps { /// @param _underlyingSymbol The token symbol /// @param _decimals The token decimals /// @param _mintLimit The mint limit of the underlying token - /// @param adminOverride The admin override address for the Super Token + /// @param _admin The admin address for the Super Token /// @return underlyingToken and superToken function deployWrapperSuperToken( string calldata _underlyingName, string calldata _underlyingSymbol, uint8 _decimals, uint256 _mintLimit, - address adminOverride + address _admin ) external requiresSuperTokenFactory deploySuperTokenRequires1820 returns (TestToken underlyingToken, SuperToken superToken) { - return _deployWrapperSuperToken(_underlyingName, _underlyingSymbol, _decimals, _mintLimit, adminOverride); + return _deployWrapperSuperToken(_underlyingName, _underlyingSymbol, _decimals, _mintLimit, _admin); } /// @notice Deploys an ERC20 and a Wrapper Super Token for the ERC20 and lists both in the resolver @@ -257,7 +257,7 @@ contract SuperfluidFrameworkDeployer is SuperfluidFrameworkDeploymentSteps { string calldata _underlyingSymbol, uint8 _decimals, uint256 _mintLimit, - address _adminOverride + address _admin ) internal returns (TestToken underlyingToken, SuperToken superToken) { underlyingToken = TokenDeployerLibrary.deployTestToken(_underlyingName, _underlyingSymbol, _decimals, _mintLimit); @@ -272,7 +272,7 @@ contract SuperfluidFrameworkDeployer is SuperfluidFrameworkDeploymentSteps { ISuperTokenFactory.Upgradability.SEMI_UPGRADABLE, string.concat("Super ", _underlyingSymbol), superTokenSymbol, - _adminOverride + _admin ) ) ); diff --git a/packages/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol b/packages/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol index 22b3042193..12939650d1 100644 --- a/packages/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol +++ b/packages/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol @@ -614,14 +614,14 @@ contract FoundrySuperfluidTester is Test { uint8 underlyingDecimals, string memory name, string memory symbol, - address adminOverride + address admin ) internal returns (SuperToken localSuperToken) { localSuperToken = new SuperToken( sf.host, previousSuperToken.CONSTANT_OUTFLOW_NFT(), previousSuperToken.CONSTANT_INFLOW_NFT() ); - localSuperToken.initializeWithAdminOverride(underlyingToken, underlyingDecimals, name, symbol, adminOverride); + localSuperToken.initializeWithAdmin(underlyingToken, underlyingDecimals, name, symbol, admin); } // Write Helpers - ConstantFlowAgreementV1 diff --git a/packages/ethereum-contracts/test/foundry/gov/SuperfluidGovernanceII.t.sol b/packages/ethereum-contracts/test/foundry/gov/SuperfluidGovernanceII.t.sol index 4c4da1d1e7..eefd1fba31 100644 --- a/packages/ethereum-contracts/test/foundry/gov/SuperfluidGovernanceII.t.sol +++ b/packages/ethereum-contracts/test/foundry/gov/SuperfluidGovernanceII.t.sol @@ -21,7 +21,7 @@ contract SuperfluidGovernanceIntegrationTest is FoundrySuperfluidTester { sf.governance.changeSuperTokenAdmin(sf.host, superToken, newAdmin); vm.stopPrank(); - assertEq(superToken.getAdminOverride().admin, newAdmin, "Superfluid.t: super token admin not changed"); + assertEq(superToken.getAdmin(), newAdmin, "Superfluid.t: super token admin not changed"); } function testRevertChangeSuperTokenAdminWhenCallerIsNotNotGovOwner(address newAdmin) public { @@ -64,7 +64,7 @@ contract SuperfluidGovernanceIntegrationTest is FoundrySuperfluidTester { sf.governance.batchChangeSuperTokenAdmin(sf.host, superTokens, newAdmins); vm.stopPrank(); - assertEq(superToken.getAdminOverride().admin, newAdmin, "Superfluid.t: super token admin not changed"); + assertEq(superToken.getAdmin(), newAdmin, "Superfluid.t: super token admin not changed"); } function testRevertBatchChangeSuperTokenAdminWhenHostNotAdmin(address newAdmin) public { diff --git a/packages/ethereum-contracts/test/foundry/superfluid/SuperToken.t.sol b/packages/ethereum-contracts/test/foundry/superfluid/SuperToken.t.sol index 3f80f3d779..9639a11401 100644 --- a/packages/ethereum-contracts/test/foundry/superfluid/SuperToken.t.sol +++ b/packages/ethereum-contracts/test/foundry/superfluid/SuperToken.t.sol @@ -120,67 +120,67 @@ contract SuperTokenIntegrationTest is FoundrySuperfluidTester { UUPSProxiable(address(superToken)).updateCode(address(superTokenLogic)); } - function testInitializeSuperTokenWithAndWithoutAdminOverride(address adminOverride) public { + function testInitializeSuperTokenWithAndWithoutAdmin(address _admin) public { (, ISuperToken localSuperToken) = - sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, adminOverride); + sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, _admin); assertEq( - localSuperToken.getAdminOverride().admin, - adminOverride, - "testInitializeSuperTokenWithAndWithoutAdminOverride: admin override not set correctly" + localSuperToken.getAdmin(), + _admin, + "testInitializeSuperTokenWithAndWithoutAdmin: _admin address not set correctly" ); } - function testOnlyHostCanChangeAdminWhenNoAdminOverride(address adminOverride) public { + function testOnlyHostCanChangeAdminWhenNoAdmin(address _admin) public { (, ISuperToken localSuperToken) = sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max); vm.startPrank(address(sf.host)); - localSuperToken.changeAdmin(adminOverride); + localSuperToken.changeAdmin(_admin); vm.stopPrank(); assertEq( - localSuperToken.getAdminOverride().admin, - adminOverride, - "testOnlyHostCanChangeAdminWhenNoAdminOverride: admin override not set correctly" + localSuperToken.getAdmin(), + _admin, + "testOnlyHostCanChangeAdminWhenNoAdmin: admin address not set correctly" ); } - function testOnlyAdminOverrideCanChangeAdmin(address adminOverride, address newAdminOverride) public { - if (adminOverride == address(0)) { - adminOverride = address(sf.host); + function testOnlyAdminCanChangeAdmin(address _admin, address newAdmin) public { + if (_admin == address(0)) { + _admin = address(sf.host); } (, ISuperToken localSuperToken) = - sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, adminOverride); + sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, _admin); - vm.startPrank(adminOverride); - localSuperToken.changeAdmin(newAdminOverride); + vm.startPrank(_admin); + localSuperToken.changeAdmin(newAdmin); vm.stopPrank(); assertEq( - localSuperToken.getAdminOverride().admin, - newAdminOverride, - "testOnlyAdminOverrideCanChangeAdmin: admin override not set correctly" + localSuperToken.getAdmin(), + newAdmin, + "testOnlyAdminCanChangeAdmin: admin address not set correctly" ); } - function testRevertWhenNonAdminTriesToChangeAdmin(address adminOverride, address nonAdminOverride) public { - vm.assume(adminOverride != nonAdminOverride); - vm.assume(nonAdminOverride != address(0)); - if (adminOverride == address(0)) { - adminOverride = address(sf.host); + function testRevertWhenNonAdminTriesToChangeAdmin(address _admin, address nonAdmin) public { + vm.assume(_admin != nonAdmin); + vm.assume(nonAdmin != address(0)); + if (_admin == address(0)) { + _admin = address(sf.host); } (, ISuperToken localSuperToken) = - sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, adminOverride); + sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, _admin); - vm.startPrank(nonAdminOverride); + vm.startPrank(nonAdmin); vm.expectRevert(ISuperToken.SUPER_TOKEN_ONLY_ADMIN.selector); - localSuperToken.changeAdmin(nonAdminOverride); + localSuperToken.changeAdmin(nonAdmin); vm.stopPrank(); } - function testOnlyHostCanUpdateCodeWhenNoAdminOverride() public { + function testOnlyHostCanUpdateCodeWhenNoAdmin() public { (TestToken localTestToken, ISuperToken localSuperToken) = sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max); @@ -194,42 +194,42 @@ contract SuperTokenIntegrationTest is FoundrySuperfluidTester { assertEq( UUPSProxiable(address(localSuperToken)).getCodeAddress(), address(newSuperTokenLogic), - "testOnlyHostCanUpdateCodeWhenNoAdminOverride: super token logic not updated correctly" + "testOnlyHostCanUpdateCodeWhenNoAdmin: super token logic not updated correctly" ); } - function testOnlyAdminOverrideCanUpdateCode(address adminOverride) public { - if (adminOverride == address(0)) { - adminOverride = address(sf.host); + function testOnlyAdminCanUpdateCode(address _admin) public { + if (_admin == address(0)) { + _admin = address(sf.host); } (TestToken localTestToken, ISuperToken localSuperToken) = - sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, adminOverride); + sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max, _admin); SuperToken newSuperTokenLogic = - _helperDeploySuperTokenAndInitialize(localSuperToken, localTestToken, 18, "FTT", "FTT", adminOverride); + _helperDeploySuperTokenAndInitialize(localSuperToken, localTestToken, 18, "FTT", "FTT", _admin); - vm.startPrank(adminOverride); + vm.startPrank(_admin); UUPSProxiable(address(localSuperToken)).updateCode(address(newSuperTokenLogic)); vm.stopPrank(); assertEq( UUPSProxiable(address(localSuperToken)).getCodeAddress(), address(newSuperTokenLogic), - "testOnlyHostCanUpdateCodeWhenNoAdminOverride: super token logic not updated correctly" + "testOnlyHostCanUpdateCodeWhenNoAdmin: super token logic not updated correctly" ); } - function testRevertWhenNonAdminTriesToUpdateCode(address adminOverride, address nonAdminOverride) public { - vm.assume(adminOverride != address(sf.host)); + function testRevertWhenNonAdminTriesToUpdateCode(address _admin, address nonAdmin) public { + vm.assume(_admin != address(sf.host)); (TestToken localTestToken, ISuperToken localSuperToken) = sfDeployer.deployWrapperSuperToken("FTT", "FTT", 18, type(uint256).max); SuperToken newSuperTokenLogic = - _helperDeploySuperTokenAndInitialize(localSuperToken, localTestToken, 18, "FTT", "FTT", adminOverride); + _helperDeploySuperTokenAndInitialize(localSuperToken, localTestToken, 18, "FTT", "FTT", _admin); - vm.startPrank(nonAdminOverride); + vm.startPrank(nonAdmin); vm.expectRevert(ISuperToken.SUPER_TOKEN_ONLY_ADMIN.selector); UUPSProxiable(address(localSuperToken)).updateCode(address(newSuperTokenLogic)); vm.stopPrank(); diff --git a/packages/ethereum-contracts/test/foundry/superfluid/Superfluid.t.sol b/packages/ethereum-contracts/test/foundry/superfluid/Superfluid.t.sol index 1fbbb090f7..ff5d9e51c4 100644 --- a/packages/ethereum-contracts/test/foundry/superfluid/Superfluid.t.sol +++ b/packages/ethereum-contracts/test/foundry/superfluid/Superfluid.t.sol @@ -57,10 +57,10 @@ contract SuperfluidIntegrationTest is FoundrySuperfluidTester { sf.host.changeSuperTokenAdmin(superToken, newAdmin); vm.stopPrank(); - assertEq(superToken.getAdminOverride().admin, newAdmin, "Superfluid.t: super token admin not changed"); + assertEq(superToken.getAdmin(), newAdmin, "Superfluid.t: super token admin not changed"); } - function testRevertChangeSuperTokenAdminWhenHostIsNotAdminOverride(address initialAdmin, address newAdmin) public { + function testRevertChangeSuperTokenAdminWhenHostIsNotAdmin(address initialAdmin, address newAdmin) public { vm.assume(initialAdmin != address(0)); vm.assume(newAdmin != address(0)); vm.assume(initialAdmin != address(sf.host));