Commit 6ce47f38 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

hardhat-deploy-config: Support JSON-formatted deploy configs (#3145)

Also adds a new `deployer` network for use with automation.
parent 70bf922a
---
'@eth-optimism/hardhat-deploy-config': patch
---
Support JSON-formatted deploy configs
...@@ -46,6 +46,11 @@ const config: HardhatUserConfig = { ...@@ -46,6 +46,11 @@ const config: HardhatUserConfig = {
url: process.env.L1_RPC || '', url: process.env.L1_RPC || '',
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero], accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
}, },
deployer: {
chainId: Number(process.env.CHAIN_ID),
url: process.env.L1_RPC || '',
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
},
}, },
foundry: { foundry: {
buildInfo: true, buildInfo: true,
......
import * as path from 'path' import * as path from 'path'
import * as fs from 'fs'
import { extendEnvironment, extendConfig } from 'hardhat/config' import { extendEnvironment, extendConfig } from 'hardhat/config'
import { import {
...@@ -28,9 +29,16 @@ const normalizePath = ( ...@@ -28,9 +29,16 @@ const normalizePath = (
export const loadDeployConfig = (hre: HardhatRuntimeEnvironment): any => { export const loadDeployConfig = (hre: HardhatRuntimeEnvironment): any => {
let config: any let config: any
try { try {
config = const base = `${hre.config.paths.deployConfig}/${hre.network.name}`
if (fs.existsSync(`${base}.ts`)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
require(`${hre.config.paths.deployConfig}/${hre.network.name}.ts`).default config = require(`${base}.ts`).default
} else if (fs.existsSync(`${base}.json`)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
config = require(`${base}.json`)
} else {
throw new Error('not found')
}
} catch (err) { } catch (err) {
throw new Error( throw new Error(
`error while loading deploy config for network: ${hre.network.name}, ${err}` `error while loading deploy config for network: ${hre.network.name}, ${err}`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment