Skip to content

Instantly share code, notes, and snippets.

@alexon1234
Created May 11, 2021 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexon1234/43bf4a72a5b06651f04fc8052349ac5a to your computer and use it in GitHub Desktop.
Save alexon1234/43bf4a72a5b06651f04fc8052349ac5a to your computer and use it in GitHub Desktop.
__Ownable_init will be called twice in multiple Eligibility contracts

In NFTXMintRequestEligibility.sol, we can see the following code.

function __NFTXEligibility_init_bytes(bytes memory _configData)
        public
        virtual
        override
        initializer
    {
        __Ownable_init();
        (
            address _owner,
            address _vault,
            bool _reverseElig,
            uint256[] memory _ids
        ) = abi.decode(_configData, (address, address, bool, uint256[]));
        __NFTXEligibility_init(_owner, _vault, _reverseElig, _ids);
    }

    function __NFTXEligibility_init(
        address _owner,
        address vaultAddress,
        bool _reverseEligOnRedeem,
        uint256[] memory tokenIds
    ) public initializer {
        __Ownable_init();
        ...
    }

When calling __NFTXEligibility_init_bytes, this method will call __Ownable_init and then, __NFTXEligibility_init will call again. Because __Ownable_init contains the initializer modifier, when called twice it will revert.

function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

__NFTXEligibility_init_bytes is being called from NFTXEligibilityManager

    // NFTXEligibilityManager.sol

    function deployEligibility(uint256 moduleIndex, bytes calldata configData)
        external
        virtual
        returns (address)
    {
        address eligImpl = modules[moduleIndex].impl;
        address eligibilityClone = ClonesUpgradeable.clone(eligImpl);
        INFTXEligibility(eligibilityClone).__NFTXEligibility_init_bytes(
            configData
        );
        return eligibilityClone;
    }

This same issue happends in:

  • NFTXRangeEligibility
  • NFTXUniqueEligibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment