You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because the storage slots in the typegen outputs aren't properly integrated for these methods.
There are two possible solutions:
Override the two methods in the typegen'd contract factory the same way we do it with the deploy method,
Add a property on ContractFactory that can be overriden in the typegen'd factory and which would be read in all the deployment methods and merged with the deployOptions passed via arguments.
The second option looks better because it encapsulates the logic in ContractFactory, thereby having the typegen'd factory do as little runtime logic as possible. A possible implementation showcasing the core components is shown below.
// contract-factory.tsexportdefaultclassContractFactory{// should it be protected or public?protected_deployOptions: DeployContractOptions={};privategetDeployOptions(deployOptions){returnmergeDeepRight(this._deployOptions,deployOptions);}// same pattern for all other public methods that have deployOptions as a parameterasyncdeploy(deployOptions){constoptions=this.getDeployOptions(deployOptions);}}// typegen/contracts/MyContractFactory.tsexportclassMyContractFactoryextendsContractFactory{protected_deployOptions: DeployContractOptions={storageSlots: MyContract.storageSlots}}
The text was updated successfully, but these errors were encountered:
Given a typegen'd contract factory
MyContractFactory
that has some storage slots, the following works and includes the storage slots:However, the two examples below don't integrate the storage slots:
This is because the storage slots in the typegen outputs aren't properly integrated for these methods.
There are two possible solutions:
deploy
method,ContractFactory
that can be overriden in the typegen'd factory and which would be read in all the deployment methods and merged with thedeployOptions
passed via arguments.The second option looks better because it encapsulates the logic in
ContractFactory
, thereby having the typegen'd factory do as little runtime logic as possible. A possible implementation showcasing the core components is shown below.The text was updated successfully, but these errors were encountered: