Commit 43c1fae8 authored by Miguel Mota's avatar Miguel Mota Committed by GitHub

fix[hardhat-ovm]: Allow for private key config option for signers (#946)

parent ba72b1d7
---
'@eth-optimism/hardhat-ovm': patch
---
Allow for private key config option for signers
......@@ -4,7 +4,10 @@ import * as path from 'path'
import fetch from 'node-fetch'
import { ethers } from 'ethers'
import { subtask, extendEnvironment } from 'hardhat/config'
import { HardhatNetworkHDAccountsConfig } from 'hardhat/types/config'
import {
HardhatNetworkHDAccountsConfig,
HardhatNetworkAccountUserConfig,
} from 'hardhat/types/config'
import { getCompilersDir } from 'hardhat/internal/util/global-dir'
import { Artifacts } from 'hardhat/internal/artifacts'
import {
......@@ -259,9 +262,17 @@ extendEnvironment(async (hre) => {
// if the node is up, override the getSigners method's signers
try {
let signers: ethers.Signer[]
const accounts = hre.network.config
.accounts as HardhatNetworkHDAccountsConfig
if (accounts) {
const accounts = hre.network.config.accounts as
| HardhatNetworkHDAccountsConfig
| HardhatNetworkAccountUserConfig[]
if (Array.isArray(accounts)) {
signers = (accounts as HardhatNetworkAccountUserConfig[]).map(
(account) =>
new ethers.Wallet(
typeof account === 'string' ? account : account.privateKey
).connect(provider)
)
} else if (accounts) {
const indices = Array.from(Array(20).keys()) // generates array of [0, 1, 2, ..., 18, 19]
signers = indices.map((i) =>
ethers.Wallet.fromMnemonic(
......
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