Hello, I'm trying to make an upgrade of my contracts, in order to do that I want to import the oldAbis so that I can later propose the upgrade with OZ defender.
I have the old abis (the ones that are currently deployed) on a folder in my repository called "oldAbis".
My code looks something like this:
export async function prepareUpgradeContract(name: string, address: string) {
const abi = require('../oldabis/' + (await ethers.provider?.getNetwork())?.name + '/' + name + '.sol/' + name + '.json')['abi'];
const bytecode = require('../oldabis/' + (await ethers.provider?.getNetwork())?.name + '/' + name + '.sol/' + name + '.json')['bytecode'];
const old = await upgrades.forceImport(address, await ethers.getContractFactory(abi, bytecode, undefined));
}
But when running the script, I'm getting the following error:
Error: The requested contract was not found. Make sure the source code is available for compilation
at getContractNameAndRunValidation (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:75:11)
at getStorageLayout (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:83:45)
at getDeployData (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\utils\deploy-impl.ts:55:34)
at async getSimulatedData (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\utils\simulate-deploy.ts:51:22)
at async simulateDeployImpl (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\utils\simulate-deploy.ts:38:42)
at async addImplToManifest (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\force-import.ts:79:3)
at async importProxyToManifest (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\force-import.ts:65:3)
at async Proxy.forceImport (C:\Users\HP\Desktop\ethereum-dev\test\contracts\node_modules\@openzeppelin\hardhat-upgrades\src\force-import.ts:41:7)
But the address points to the deployed contract (the proxy contract) on the right network.
Any help will be greatly appreciated!