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

Feature: override readArtifact during getContractFactory() #1515

Closed
heri16 opened this issue Jun 7, 2021 · 2 comments
Closed

Feature: override readArtifact during getContractFactory() #1515

heri16 opened this issue Jun 7, 2021 · 2 comments

Comments

@heri16
Copy link

heri16 commented Jun 7, 2021

Certain plugins like hardhat-deploy-ethers would benefit from being able to override readArtifact during getContractFactory() from packages/hardhat-ethers/src/internal/helpers.ts.

hardhat-deploy-ethers currently does not extend from @nomiclabs/hardhat-ethers, even though it is mostly the same.

@heri16
Copy link
Author

heri16 commented Jun 7, 2021

After analyzing third party plugin called hardhat-deploy-ethers, it looks like the features added to @nomiclabs/hardhat-ethers are getNamedSigners, getUnnamedSigners, and these line changes below:

https://github.com/wighawag/hardhat-deploy-ethers/blob/main/src/helpers.ts#L237

https://github.com/wighawag/hardhat-deploy-ethers/blob/a6053c7ceb39bc17064b356b628dc381b9aacb9d/src/helpers.ts#L237

async function _getArtifact(
  hre: HardhatRuntimeEnvironment,
  name: string
): Promise<Artifact> {
  const deployments = (hre as any).deployments;
  if (deployments !== undefined) {
    return deployments.getArtifact(name);
  }
  return hre.artifacts.readArtifact(name);
}

async function getContractFactoryByName<T extends ethers.ContractFactory>(
  hre: HardhatRuntimeEnvironment,
  contractName: string,
  signerOrOptions?: ethers.Signer | string | FactoryOptions
): Promise<T> {
  const artifact = await _getArtifact(hre, contractName);
  ...
}

This is a good first step to enable the reuse of @nomiclabs/hardhat-ethers, in such a third-party plugin.

@fvictorio
Copy link
Member

Closing this in favor of #1040.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants