-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow importing module parameters with filepath in scripts
- Loading branch information
Showing
5 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { DeploymentParameters } from "@nomicfoundation/ignition-core"; | ||
import { readFile } from "fs-extra"; | ||
import { NomicLabsHardhatPluginError } from "hardhat/plugins"; | ||
import { parse as json5Parse } from "json5"; | ||
|
||
import { bigintReviver } from "./bigintReviver"; | ||
|
||
export async function resolveConfigPath( | ||
filepath: string | ||
): Promise<DeploymentParameters> { | ||
try { | ||
const rawFile = await readFile(filepath); | ||
|
||
return await json5Parse(rawFile.toString(), bigintReviver); | ||
} catch (e) { | ||
if (e instanceof NomicLabsHardhatPluginError) { | ||
throw e; | ||
} | ||
|
||
if (e instanceof Error) { | ||
throw new NomicLabsHardhatPluginError( | ||
"@nomicfoundation/hardhat-ignition", | ||
`Could not parse parameters from ${filepath}`, | ||
e | ||
); | ||
} | ||
|
||
throw e; | ||
} | ||
} |