Support creating proxies for artifacts from installed packages
Truffle supports loading an artifact from an installed package:
const ERC20 = artifacts.require("@openzeppelin/contracts-ethereum-package/ERC20PresetMinterPauserUpgradeSafe");
But trying to deployProxy it currently fails with the following error:
Error: The requested contract was not found. Make sure the source code is available for compilation
at getContractName (/home/spalladino/Projects/sdk/truffle/foo/node_modules/@openzeppelin/upgrades-truffle/node_modules/@openzeppelin/upgrades-core/src/validate.ts:123:11)
at Object.assertUpgradeSafe (/home/spalladino/Projects/sdk/truffle/foo/node_modules/@openzeppelin/upgrades-truffle/node_modules/@openzeppelin/upgrades-core/src/validate.ts:141:24)
at deployProxy (/home/spalladino/Projects/sdk/truffle/foo/node_modules/@openzeppelin/upgrades-truffle/src/deploy-proxy.ts:30:3)
Truffle v5.1.37 (core: 5.1.37)
Node v12.7.0
Hello, any update or preferred approach for this? Thank you !
Hello @clemsos, there hasn't been any news, and I can't promise it will be supported anytime soon.
The best option, in my opinion, is to have an "importer" contract in your contracts folder
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "path/to/the/source/file.sol";
This will cause truffle to recompile the contract, and make it available as a "local artifact" that you can deploy
thanks @Amxx . The problem here is that we don't have the .sol files - just ABIs. From what I understood, the upgrades lib require the .sol contract files to check storage layout etc. Is that correct?
The upgrade plugin compares the new artifact against the storage layout stored in the manifest that was produced when the previous version was deployed (assuming it was deployed using OZ's tolling).
You should have a .openzeppelin/network.json with this infos.