I am facing the error "Use Of DelegateCall Is Not Allowed" , I have all imports of contracts-upgradeable,similar problem with other contracts too, but the imports are all upgradeable.
We have multiple logic upgrades that we make upgradeable. We're using ERC1967 Proxy in our Factory contract to deploy new proxies for our UUPS upgradeable contracts (UUPSUpgradeable imported in the implementation contracts). Everything was working fine until we tried to make the Factory itself upgradeable. After inheriting UUPSUpgradeable in the Factory contract we're getting the following error:error
(Deploying using hardhat upgrades, kind: uups)
This product contains multiple sub products which are deployed from the Factory and added to our product list. The Factory should be upgradeable. From the Factory we're deploying new instances of our upgradeable contracts (e.g. OffChainRebalancing), so we deploy multiple proxies pointing to the same implementation contract.
So I am making a
1.Factory Contract(Should be upgradeable, will be deploying a proxy of it too)
2.From Factory Contract, any user can deploy their set of contracts(proxy) using the baseContract(UUPS ) upgradeable, every proxies will have same implementation
3.The proxies will be deployed using Proxy Contract(customized code), shared above.
My main motive is to deploy upgradeable proxies poiting same implementation and should be UUPS
Thought of using ERC1967 to deploy, but it's not upgradeable version so used, ERC1967UpgradesUpgradeable, inherited it in another contract and then used it
So whenever I try to deploy Factory proxy and gives the error, deploying using upgrade plugin
The error in your original post shows @openzeppelin/contracts/utils/Address.sol, but the above code looks like it’s mostly using the @openzeppelin/contracts-upgradeable package. Can you identify which dependency or import is using something from @openzeppelin/contracts?
The reason that delegatecall is not generally allowed in upgradeable contracts is that if the contract does a delegatecall into a malicious contract that contains a selfdestruct, then the calling contract will be destroyed.
For a factory which is also upgradeable, the factory can deploy child proxies as ERC1967Proxy because any delegatecall in the child ERC1967Proxy would happen in the context of the child proxy. This means you can ignore a delegatecall error in the factory if it is only caused by this usage.