openzeppelin-upgrades icon indicating copy to clipboard operation
openzeppelin-upgrades copied to clipboard

Support creating proxies for artifacts from installed packages

Open spalladino opened this issue 5 years ago • 4 comments

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

spalladino avatar Jul 31 '20 21:07 spalladino

Hello, any update or preferred approach for this? Thank you !

clemsos avatar Jun 22 '21 20:06 clemsos

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

Amxx avatar Jun 22 '21 21:06 Amxx

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?

clemsos avatar Jun 23 '21 13:06 clemsos

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.

Amxx avatar Jun 23 '21 13:06 Amxx