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

add an importPath option for the deploy function #343

Open
nataouze opened this issue Jul 4, 2022 · 4 comments · May be fixed by #344
Open

add an importPath option for the deploy function #343

nataouze opened this issue Jul 4, 2022 · 4 comments · May be fixed by #344

Comments

@nataouze
Copy link
Contributor

nataouze commented Jul 4, 2022

Is your feature request related to a problem? Please describe.
When a project depends on artifacts from external libraries and several artifacts have the same name, calling deploy with a contract name does not allow selecting which artifact to load.

Describe the solution you'd like
An optional importPath field in DeployOptionsBase which allows to retrieve the artifact by its name from a specific folder.

Describe alternatives you've considered
As a workaround, one can do:

const {getArtifactFromFolders} = require('hardhat-deploy/dist/src/utils');
// ...
const options = {
  contract: await getArtifactFromFolders(artifactName, [artifactPath]),
  // ...
};
await deploy(name, options);
@nataouze nataouze linked a pull request Jul 4, 2022 that will close this issue
@wighawag
Copy link
Owner

wighawag commented Jul 4, 2022

did you try specifying contract: "<path>:<contractName>" ?

@nataouze
Copy link
Contributor Author

nataouze commented Jul 4, 2022

It doesn't look like it will help much for my use-case, because the internal structure of the external libraries artifacts is the same:

I have these dependencies:
node_modules/projectA/artifacts/contracts/Contract.sol/
node_modules/projectB/artifacts/contracts/Contract.sol/

To use fully-qualified names, I need to have an external config similar to this:

external: {
  contracts: [
    {artifacts: 'node_modules/projectA/artifacts'},
    {artifacts: 'node_modules/projectB/artifacts'},
  ],
}

In the end, I have the same issue when deploying, still not specifying which folder to read the artifact from:

await deploy("Contract", {contract: "contracts/Contract.sol:Contract"});

@nataouze
Copy link
Contributor Author

nataouze commented Jul 4, 2022

What I am proposing works as follows:

await deploy("Contract", {contract: "Contract", importPath: "node_modules/projectA/artifacts"});

@0xCardinalError
Copy link

0xCardinalError commented Mar 9, 2023

The solution should be to use Full Qualified Name.

await deploy('src/projectA/Contract.sol:ContractName');
or better yet with identifier

await deploy('ContractA, { contract: 'src/projectA/Contract.sol:ContractName'});

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