Skip to content

Commit

Permalink
misc: remove initializing state from Initializable
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnaum committed Jan 5, 2025
1 parent 873ee44 commit 4473c1d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 26 deletions.
4 changes: 0 additions & 4 deletions contracts/actions/post/collect/LensCollectedPost.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ contract LensCollectedPost is LensERC721, IERC7572 {
address internal immutable _collectAction;

constructor(address feed, uint256 postId, bool isImmutable) {
// TODO: This is a hack to make it compile for now. Redo properly.
Initializable.$storage().initializing = true;
LensERC721._initialize("Lens Collected Post", "LCP", ITokenURIProvider(address(0)));
Initializable.$storage().initializing = false;
_disableInitializers();
string memory contentURI = IFeed(feed).getPost(postId).contentURI;
require(bytes(contentURI).length > 0, "Post content URI is empty");
_feed = feed;
Expand Down
5 changes: 2 additions & 3 deletions contracts/core/access/AccessControlled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ pragma solidity ^0.8.0;

import {IAccessControl} from "./../interfaces/IAccessControl.sol";
import {AccessControlLib} from "./../libraries/AccessControlLib.sol";
import {Initializable} from "./../upgradeability/Initializable.sol";

abstract contract AccessControlled is Initializable {
abstract contract AccessControlled {
using AccessControlLib for IAccessControl;
using AccessControlLib for address;

Expand All @@ -26,7 +25,7 @@ abstract contract AccessControlled is Initializable {
}
}

function _initialize(IAccessControl accessControl) internal onlyInitializing {
function _initialize(IAccessControl accessControl) internal {
accessControl.verifyHasAccessFunction();
_setAccessControl(accessControl);
}
Expand Down
8 changes: 2 additions & 6 deletions contracts/core/base/LensERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradea
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "./../interfaces/ITokenURIProvider.sol";
import "./../interfaces/IERC4906Events.sol";
import "./../upgradeability/Initializable.sol";

abstract contract LensERC721 is IERC721, Initializable {
abstract contract LensERC721 is IERC721 {
using AddressUpgradeable for address;

event Lens_ERC721_TokenURIProviderSet(address indexed tokenURIProvider);
Expand Down Expand Up @@ -41,10 +40,7 @@ abstract contract LensERC721 is IERC721, Initializable {
}
}

function _initialize(string memory nftName, string memory nftSymbol, ITokenURIProvider tokenURIProvider)
internal
onlyInitializing
{
function _initialize(string memory nftName, string memory nftSymbol, ITokenURIProvider tokenURIProvider) internal {
$erc721Storage().name = nftName;
$erc721Storage().symbol = nftSymbol;
$erc721Storage().tokenURIProvider = tokenURIProvider;
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/primitives/feed/Feed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contract Feed is
AccessControlled._initialize(accessControl);
}

function _initialize(string memory metadataURI) internal onlyInitializing {
function _initialize(string memory metadataURI) internal {
_setMetadataURI(metadataURI);
_emitPIDs();
emit Events.Lens_Contract_Deployed("feed", "lens.feed", "feed", "lens.feed");
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/primitives/graph/Graph.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract Graph is
AccessControlled._initialize(accessControl);
}

function _initialize(string memory metadataURI) internal onlyInitializing {
function _initialize(string memory metadataURI) internal {
_setMetadataURI(metadataURI);
_emitPIDs();
emit Events.Lens_Contract_Deployed("graph", "lens.graph", "graph", "lens.graph");
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/primitives/group/Group.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract Group is
AccessControlled._initialize(accessControl);
}

function _initialize(string memory metadataURI) internal onlyInitializing {
function _initialize(string memory metadataURI) internal {
_setMetadataURI(metadataURI);
_emitPIDs();
emit Events.Lens_Contract_Deployed("group", "lens.group", "group", "lens.group");
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/primitives/namespace/Namespace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract Namespace is
LensERC721._initialize(nftName, nftSymbol, tokenURIProvider);
}

function _initialize(string memory namespace, string memory metadataURI) internal onlyInitializing {
function _initialize(string memory namespace, string memory metadataURI) internal {
Core.$storage().namespace = namespace;
_setMetadataURI(metadataURI);
_emitPIDs();
Expand Down
8 changes: 0 additions & 8 deletions contracts/core/upgradeability/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ abstract contract Initializable {

struct Storage {
bool initialized;
bool initializing;
}

/// @custom:keccak lens.storage.Initializable
Expand All @@ -21,14 +20,7 @@ abstract contract Initializable {

modifier initializer() {
require(!$storage().initialized, "ALREADY_INITIALIZED");
$storage().initializing = true;
_;
$storage().initialized = true;
$storage().initializing = false;
}

modifier onlyInitializing() {
require($storage().initializing, "NOT_INITIALIZING");
_;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/dashboard/primitives/app/App.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract App is IApp, Initializable, BaseSource, AccessControlled {
bool isSourceStampVerificationEnabled,
AppInitialProperties memory initialProps,
KeyValue[] memory extraData
) internal onlyInitializing {
) internal {
_setMetadataURI(metadataURI);
_setSourceStampVerification(isSourceStampVerificationEnabled);
_setTreasury(initialProps.treasury);
Expand Down

0 comments on commit 4473c1d

Please sign in to comment.