Skip to content

Commit

Permalink
hardhat-deploy-config: Support JSON-formatted deploy configs (#3145)
Browse files Browse the repository at this point in the history
Also adds a new `deployer` network for use with automation.
  • Loading branch information
mslipper authored and maurelian committed Sep 15, 2022
1 parent 55ff7a8 commit 45f41f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-mangos-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/hardhat-deploy-config': patch
---

Support JSON-formatted deploy configs
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const config: HardhatUserConfig = {
url: process.env.L1_RPC || '',
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: {
buildInfo: true,
Expand Down
12 changes: 10 additions & 2 deletions packages/hardhat-deploy-config/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'path'
import * as fs from 'fs'

import { extendEnvironment, extendConfig } from 'hardhat/config'
import {
Expand Down Expand Up @@ -28,9 +29,16 @@ const normalizePath = (
export const loadDeployConfig = (hre: HardhatRuntimeEnvironment): any => {
let config: any
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
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) {
throw new Error(
`error while loading deploy config for network: ${hre.network.name}, ${err}`
Expand Down

0 comments on commit 45f41f2

Please sign in to comment.