Initializers vs Constructors

Hi, in the below code, am i right in assuming once deployed that the constructor will automatically disable the initializer function?

Or do i need to make enlist disable method in the constructor to the owner?

 constructor() {
        _disableInitializers();
    }
    // internal onlyInitializing
    // initializer public
    function initialize() internal onlyInitializing {
        __ERC721_init("", "");
        __ERC721URIStorage_init();
        __Pausable_init();
        __Ownable_init();
        __UUPSUpgradeable_init();
    }

Yeah, when you use this in the constructor, it will lock the contract.

And it seems like there is not a public initializer function.

It is always a good idea to write some test cases to test the contract.

Right ok, so how could i write into the initializer function that it can only be called by the contract owner?

This doesn't really make sense because the initializer is what's setting the contract owner. You should just ensure that you deploy the proxy and call the initializer (which sets the owner) in the same transaction -- this can be done using _data in the proxy's constructor.

So I currently have this in my Initializer function. In relation to what you have mentioned, will i not need to insert the "require" function below?

    function initialize() initializer public {
        require(msg.sender == this.owner(), "Only the owner can call this function");
        __ERC721_init("", "");
        __ERC721URIStorage_init();
        __Pausable_init();
        __Ownable_init();
        __UUPSUpgradeable_init();
    }

That won't work because __Ownable_init() is what sets the initial value for this.owner() in the first place.

You don't need that "require" statement. Just make sure to call the initializer in the same transaction as deploying the proxy.

OK great, i assume you can do this by writing the migration files for both the proxy and the implementation? Or is the Initializer and proxy called upon deployment?

The initializer can be called during proxy deployment using the deployProxy function in the Truffle Upgrades plugin.

OK great thanks Eric!