-
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.
Merge pull request #850 from NomicFoundation/module-params-fix
Allow importing module parameters with filepath in scripts
- Loading branch information
Showing
5 changed files
with
57 additions
and
38 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
30 changes: 30 additions & 0 deletions
30
packages/hardhat-plugin/src/utils/read-deployment-parameters.ts
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 readDeploymentParameters( | ||
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; | ||
} | ||
} |