@nomicfoundation/hardhat-keystore
Version:
A module for managing keystore files that store a map from IDs to encrypted string values.
45 lines (36 loc) • 1.23 kB
text/typescript
import type { ConfigHooks } from "hardhat/types/hooks";
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
import {
getDevKeystoreFilePath,
getDevKeystorePasswordFilePath,
getKeystoreFilePath,
} from "../utils/get-keystore-file-path.js";
const log = createDebug("hardhat:keystore:hook-handlers:config");
export default async (): Promise<Partial<ConfigHooks>> => {
const handlers: Partial<ConfigHooks> = {
resolveUserConfig: async (
userConfig,
resolveConfigurationVariable,
next,
) => {
const resolvedConfig = await next(
userConfig,
resolveConfigurationVariable,
);
const defaultKeystoreFilePath = await getKeystoreFilePath();
const defaultDevKeystoreFilePath = await getDevKeystoreFilePath();
const defaultDevKeystorePasswordFilePath =
await getDevKeystorePasswordFilePath();
log(`path to keystore file: ${defaultKeystoreFilePath}`);
return {
...resolvedConfig,
keystore: {
filePath: defaultKeystoreFilePath,
devFilePath: defaultDevKeystoreFilePath,
devPasswordFilePath: defaultDevKeystorePasswordFilePath,
},
};
},
};
return handlers;
};