1

For Upgradable Smart contract following pattern as specified here:

https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#avoid-initial-values-in-field-declarations

"Constructor"/Initializer has form:

function initialize() public initializer {
       .......
       .......
       .......
    }

Now suppose I have a set of initial value field declarations and I set them in a separate initializer - say:

function initializeInitialValues() public initializer {
       .......
       .......
       .......
    }

The code below does not pick up the initializers

let MyContract;
let mycontract;

describe("MyContract", function() {

  beforeEach(async function () {
     MyContract= await ethers.getContractFactory("MyContract");
     mycontract= await upgrades.deployProxy(MyContract, {initializer: 'initialize', initializer: initializeInitialValues()});
  });
       .......
       .......
       .......

});

Using only await upgrades.deployProxy(MyContract, {initializer: 'initialize'} and putting all values in there works. i.e

function initialize() public initializer {
       constructor values
              &
       initial value field declarations
    }

When deploying/testing the smart contract how do I specify multiple initializers?

Especially as a means to logically separate unrelated components in the upgradable smart contract. i.e. constructor values vs initial value field declarations

1 Answer 1

0

Anyone else wondering about this, see this response: OpenZeppelin Forum

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.