How to use the hardhat/internal/artifacts.Artifacts function in hardhat

To help you get started, we’ve selected a few hardhat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethereum-optimism / optimism / packages / hardhat-ovm / src / index.ts View on Github external
hre.network.ovm = hre.network.config.ovm

    let artifactsPath = hre.config.paths.artifacts
    if (!artifactsPath.endsWith('-ovm')) {
      artifactsPath = artifactsPath + '-ovm'
    }

    let cachePath = hre.config.paths.cache
    if (!cachePath.endsWith('-ovm')) {
      cachePath = cachePath + '-ovm'
    }

    // Forcibly update the artifacts object.
    hre.config.paths.artifacts = artifactsPath
    hre.config.paths.cache = cachePath
    ;(hre as any).artifacts = new Artifacts(artifactsPath)

    // if typechain is present, send the typed bindings to an ovm-specific
    // directory
    if ((hre.config as any).typechain) {
      if (!(hre as any).config.typechain.outDir.endsWith('-ovm')) {
        ;(hre as any).config.typechain.outDir += '-ovm'
      }
    }

    // if ethers is present and the node is running, override the polling interval to not wait the full
    // duration in tests
    if ((hre as any).ethers) {
      const interval = hre.network.config.interval || OVM_POLLING_INTERVAL
      if ((hre as any).ethers.provider.pollingInterval === interval) {
        return
      }