How to import with draft-

When an openzeppelin import has draft-… preceding its name, how should it be used in an initializer declaration?

I'm importing "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
When I use it without the word draft-.. in the initializer, I get Undeclared Identifier .
Adding draft-.. breaks the code.

So how should it be used?

You can find the init function name in the actual contract which in this case is __EIP712_init.

Thank you Eric. Would you still import it from contracts-
upgradeable?
This is how I have it and it's still a DeclarationError: Undeclared identifier.

import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
function initialize(address _lc) initializer public {
        __EIP712_init("OC", "2");
        __Ownable_init_unchained();
        __UUPSUpgradeable_init_unchained();
        require(_lc != address(0), "OC: lc not defined");
        lc = _lc;
    }

To clarify, the import should be:

import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";

and the initializer should call:

__EIP712_init("OC", "2");

To see an example, go to https://wizard.openzeppelin.com/#erc721 and enable Votes and Upgradeability.

1 Like