Hi,
I use OpenZeppelin SDK & and all the good things in @openzeppelin/contracts-ethereum-package/contracts/...
I have a simple function initialize() public initializer { ... }
at the very beginning of my contract to setup everything.
But I inherit others in initializers from the OpenZeppelin contracts like the ERC721.
I noticed that sometime initialize() (meaning without args) can’t be call anymore what bring the hell everywhere (including in truffle tests where I call let init = await instance.initialize({from: accounts[0]});
or in the truffle console.
I noticed it happens randomly and when for eg when I call oz create
initialize()
is not first anymore in the list :
All contracts have been deployed
? Do you want to call a function on the instance after creating
it? Yes
? Select which function (Use arrow keys)
❯ * initialize(sender: address)
* initialize(name: string, symbol: string)
* initialize()
For now the solution I found is to create an initialize2()
to be sure it is the only function with that name but it feels hacky, break the convention & might bite me sometime soon.
Do you experience the same behavior? if yes what is the best solution?
Many thanks
Environment
I am using the truffle, sdk version advised in the starter kit
npm install -g truffle@5.0.41 ganache-cli@6.7.0 @openzeppelin/cli@2.5.3
Node is v10.16.3
Solidity compiler is 0.5.11
Code to reproduce
Hard to tell, when you change some solidity code, sometimes after compiling initialize()
won’t be first anymore.