Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Error: The requested contract was not found. #549

Closed
boyuanx opened this issue Mar 24, 2022 · 11 comments · Fixed by #551
Closed

Migration Error: The requested contract was not found. #549

boyuanx opened this issue Mar 24, 2022 · 11 comments · Fixed by #551

Comments

@boyuanx
Copy link

boyuanx commented Mar 24, 2022

I've never had a problem with Truffle upgrades until my current project. Migration gives the following error:
Error: The requested contract was not found. Make sure the source code is available for compilation

Things I've tried:

  • Deleting build folder
  • Deleting the local repo and cloning again
  • Re-adding truffle-upgrades plugin
  • Making sure the plugins are of the latest version

I've tried looking up this issue online and none of the posts helped. Need urgent help on this as this is blocking our entire project. Thanks!

@ericglau
Copy link
Member

Can you share a repo where we can reproduce the issue? Which versions of Truffle, NodeJS, and truffle-upgrades plugin are you using?

@boyuanx
Copy link
Author

boyuanx commented Mar 24, 2022

Yes - do I share it with you? @ericglau

It's private so I cannot share it in public.

@ericglau
Copy link
Member

@boyuanx You can share it with me and I'll take a look.

@boyuanx
Copy link
Author

boyuanx commented Mar 24, 2022

@ericglau invited, it's the revamp branch.

@ericglau
Copy link
Member

I was able to reproduce the issue. Looking into it.

@ericglau
Copy link
Member

@boyuanx I've identified the problem in the upgrades plugin where contracts are ignored if multiple parent contracts have the same name.

In this case, this happens because a contract imports @openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol which imports @openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol. We should fix the plugin to detect this situation.

As a workaround for now, you can change the following line in your contract:

import "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol";

to

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

@boyuanx
Copy link
Author

boyuanx commented Mar 24, 2022

@ericglau Thank you!

@ericglau
Copy link
Member

Minimal example to reproduce this issue:

Contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol";
contract ImportIERC20  {
}

Migration:

const { deployProxy } = require("@openzeppelin/truffle-upgrades");
const ImportIERC20 = artifacts.require("ImportIERC20");
module.exports = async function (deployer) {
  await deployProxy(ImportIERC20, { deployer });
};

@ericglau
Copy link
Member

@boyuanx As this issue can be reproduced with my comment above, please go ahead and remove me from your repo. Thank you for bringing this to our attention.

@boyuanx
Copy link
Author

boyuanx commented Mar 24, 2022

Appreciate the quick response!

@adeebabdulsalam
Copy link

adeebabdulsalam commented Sep 30, 2022

@ericglau I had this same issue with hardhat plugin.

steps to reproduce

in contracts directory
-> contractA.sol (name: A)
-> contractB.sol

interface A { ////}
contract B {  uses interface A }

solution:
changed the name of interface to IA in contractB.sol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants