From 239d7ed0e3d8241862260fbcf17d9897929580a0 Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Fri, 7 Jun 2024 12:08:09 +0200 Subject: [PATCH] fix: Remove unnecesary REVISION getter --- src/contracts/gho/UpgradeableGhoToken.sol | 8 -------- src/test/TestUpgradeableGhoToken.t.sol | 9 +++++++-- src/test/mocks/MockUpgradeable.sol | 19 +++---------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/contracts/gho/UpgradeableGhoToken.sol b/src/contracts/gho/UpgradeableGhoToken.sol index bd30cf9e..402788ce 100644 --- a/src/contracts/gho/UpgradeableGhoToken.sol +++ b/src/contracts/gho/UpgradeableGhoToken.sol @@ -137,12 +137,4 @@ contract UpgradeableGhoToken is Initializable, UpgradeableERC20, AccessControl, function getFacilitatorsList() external view returns (address[] memory) { return _facilitatorsList.values(); } - - /** - * @notice Returns the revision number - * @return The revision number - */ - function REVISION() public pure virtual returns (uint256) { - return 1; - } } diff --git a/src/test/TestUpgradeableGhoToken.t.sol b/src/test/TestUpgradeableGhoToken.t.sol index dec6c7d1..36d62b46 100644 --- a/src/test/TestUpgradeableGhoToken.t.sol +++ b/src/test/TestUpgradeableGhoToken.t.sol @@ -385,7 +385,10 @@ contract TestUpgradeableGhoToken is TestUpgradeableGhoTokenSetup { contract TestUpgradeableGhoTokenUpgrade is TestUpgradeableGhoTokenSetup { function testInitialization() public { // Upgradeability - assertEq(ghoToken.REVISION(), 1); + + // version is 1st slot + uint256 version = uint256(vm.load(address(ghoToken), bytes32(uint256(0)))); + assertEq(version, 1); vm.prank(PROXY_ADMIN); (bool ok, bytes memory result) = address(ghoToken).staticcall( abi.encodeWithSelector(TransparentUpgradeableProxy.admin.selector) @@ -429,7 +432,9 @@ contract TestUpgradeableGhoTokenUpgrade is TestUpgradeableGhoTokenSetup { mockImpleParams ); - assertEq(ghoToken.REVISION(), 2); + // version is 1st slot + uint256 version = uint256(vm.load(address(ghoToken), bytes32(uint256(0)))); + assertEq(version, 2); } function testRevertUpgradeUnauthorized() public { diff --git a/src/test/mocks/MockUpgradeable.sol b/src/test/mocks/MockUpgradeable.sol index 37d68cd1..285679b0 100644 --- a/src/test/mocks/MockUpgradeable.sol +++ b/src/test/mocks/MockUpgradeable.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {VersionedInitializable} from '@aave/core-v3/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; +import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; /** * @dev Mock contract to test upgrades, not to be used in production. */ -contract MockUpgradeable is VersionedInitializable { +contract MockUpgradeable is Initializable { /** * @dev Constructor */ @@ -17,20 +17,7 @@ contract MockUpgradeable is VersionedInitializable { /** * @dev Initializer */ - function initialize() public initializer { + function initialize() public reinitializer(2) { // Intentionally left bank } - - /** - * @notice Returns the revision number - * @return The revision number - */ - function REVISION() public pure returns (uint256) { - return 2; - } - - /// @inheritdoc VersionedInitializable - function getRevision() internal pure virtual override returns (uint256) { - return REVISION(); - } }