How to manage admin of AccessControl.sol when using clones.sol deployment

I’m using minimal proxies to deploy a contract that has accesscontrol setting, but for some reason the msg.sender is not the wallet that created the clone?

Not sure why, or if init() somehow works differently than constructor for setting default_admin_role.

For reference, this is how I’m running the hardhat test:

 it("deploy DAO contract", async () => {
    const DAOFACTORY = await ethers.getContractFactory(
      "PubDAOfactory"
    )
    daoMProxy = await DAOFACTORY.connect(adminDao).deploy(disk.address, usdc.address, registry.address, startProblem.address); //removed regtoken.address,probtoken.address,conttoken.address
    await daoMProxy.deployed()

    await daoMProxy.connect(adminDao).createDao("First Dao");
    const daoAddress = await daoMProxy.connect(adminDao).getDao("First Dao");
    dao = await ethers.getContractAt("PubDAOclones", daoAddress) 
    
    //set leaders and editors
    await dao.connect(adminDao).manageEditor(editor1.getAddress(),true)
    await dao.connect(adminDao).manageLeader(leader1.getAddress(),true)
    await dao.connect(adminDao).manageLeader(leader2.getAddress(),true)
  })

nevermind, I just passed msg.sender through the initializer for now - not sure if there is a cleaner way to handle access control through a proxy.

1 Like