Skip to content

Commit

Permalink
[ALC-5] update initialized from uint8 to uint64
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypaik committed Sep 20, 2023
1 parent 4a6de2e commit 9b88fbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/CustomSlotInitializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions test/CustomSlotInitializable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion test/LightAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9b88fbd

Please sign in to comment.