From 5ee69edf82de6369cb1f067e0d6c99ebb5baa4b4 Mon Sep 17 00:00:00 2001 From: Jay Paik Date: Wed, 20 Sep 2023 09:21:40 -0400 Subject: [PATCH] [ALC-5] update initialized from uint8 to uint64 --- src/CustomSlotInitializable.sol | 12 ++++++------ test/CustomSlotInitializable.t.sol | 6 +++--- test/LightAccount.t.sol | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CustomSlotInitializable.sol b/src/CustomSlotInitializable.sol index 6de945a..3147267 100644 --- a/src/CustomSlotInitializable.sol +++ b/src/CustomSlotInitializable.sol @@ -66,7 +66,7 @@ abstract contract CustomSlotInitializable { * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ - uint8 initialized; + uint64 initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ @@ -76,7 +76,7 @@ abstract contract CustomSlotInitializable { /** * @dev Triggered when the contract has been initialized or reinitialized. */ - event Initialized(uint8 version); + event Initialized(uint64 version); constructor(bytes32 storagePosition) { _storagePosition = storagePosition; @@ -160,16 +160,16 @@ abstract contract CustomSlotInitializable { function _disableInitializers() internal virtual { CustomSlotInitializableStorage storage _storage = _getInitialiazableStorage(); require(!_storage.initializing, "Initializable: contract is initializing"); - if (_storage.initialized != type(uint8).max) { - _storage.initialized = type(uint8).max; - emit Initialized(type(uint8).max); + if (_storage.initialized != type(uint64).max) { + _storage.initialized = type(uint64).max; + emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ - function _getInitializedVersion() internal view returns (uint8) { + function _getInitializedVersion() internal view returns (uint64) { return _getInitialiazableStorage().initialized; } diff --git a/test/CustomSlotInitializable.t.sol b/test/CustomSlotInitializable.t.sol index d67f516..eb405ec 100644 --- a/test/CustomSlotInitializable.t.sol +++ b/test/CustomSlotInitializable.t.sol @@ -11,7 +11,7 @@ import {CustomSlotInitializable} from "../src/CustomSlotInitializable.sol"; contract CustomSlotInitializableTest is Test { using stdStorage for StdStorage; - event Initialized(uint8 version); + event Initialized(uint64 version); address v1Impl; address v2Impl; @@ -74,7 +74,7 @@ contract CustomSlotInitializableTest is Test { contract V1 is CustomSlotInitializable(keccak256("storage")), UUPSUpgradeable { function initialize() public initializer {} - function getInitializedVersion() public view returns (uint8) { + function getInitializedVersion() public view returns (uint64) { return _getInitializedVersion(); } @@ -90,7 +90,7 @@ contract V1 is CustomSlotInitializable(keccak256("storage")), UUPSUpgradeable { contract V2 is CustomSlotInitializable(keccak256("storage")), UUPSUpgradeable { function initialize() public reinitializer(2) {} - function getInitializedVersion() public view returns (uint8) { + function getInitializedVersion() public view returns (uint64) { return _getInitializedVersion(); } diff --git a/test/LightAccount.t.sol b/test/LightAccount.t.sol index b671991..4662ae5 100644 --- a/test/LightAccount.t.sol +++ b/test/LightAccount.t.sol @@ -29,7 +29,7 @@ contract LightAccountTest is Test { event SimpleAccountInitialized(IEntryPoint indexed entryPoint, address indexed owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - event Initialized(uint8 version); + event Initialized(uint64 version); function setUp() public { eoaAddress = vm.addr(EOA_PRIVATE_KEY);