|
1 |
| -import type { Keystore } from "./types.js"; |
| 1 | +import type { Keystore } from "../types.js"; |
2 | 2 |
|
3 | 3 | import path from "node:path";
|
4 | 4 |
|
5 |
| -import { HardhatPluginError } from "@ignored/hardhat-vnext-errors"; |
6 | 5 | import {
|
7 |
| - ensureDir, |
8 | 6 | exists,
|
9 | 7 | readJsonFile,
|
10 | 8 | writeJsonFile,
|
11 | 9 | } from "@ignored/hardhat-vnext-utils/fs";
|
12 | 10 | import chalk from "chalk";
|
13 |
| -import envPaths from "env-paths"; |
14 | 11 |
|
15 |
| -import { PLUGIN_ID } from "./constants.js"; |
16 |
| -import { io } from "./io.js"; |
17 |
| -import { setUpPassword } from "./password-manager.js"; |
| 12 | +import { io } from "../io.js"; |
| 13 | +import { setUpPassword } from "../password-manager.js"; |
| 14 | +import { assertFilePath } from "../utils/assert-file-path.js"; |
| 15 | +import { assertKeyStore } from "../utils/assert-keystore.js"; |
| 16 | +import { getConfigDir } from "../utils/get-config-dir.js"; |
18 | 17 |
|
19 | 18 | let keystoreCache: Keystore | undefined;
|
20 | 19 | let keystoreFilePath: string | undefined;
|
@@ -113,29 +112,3 @@ async function getKeystoreFilePath(): Promise<string> {
|
113 | 112 | const configDirPath = await getConfigDir();
|
114 | 113 | return path.join(configDirPath, "keystore.json");
|
115 | 114 | }
|
116 |
| - |
117 |
| -function assertKeyStore( |
118 |
| - keystore: Keystore | undefined, |
119 |
| -): asserts keystore is Keystore { |
120 |
| - if (keystore === undefined) { |
121 |
| - throw new HardhatPluginError( |
122 |
| - PLUGIN_ID, |
123 |
| - "The keystore should be available at this point!", |
124 |
| - ); |
125 |
| - } |
126 |
| -} |
127 |
| - |
128 |
| -function assertFilePath(fileP: string | undefined): asserts fileP is string { |
129 |
| - if (fileP === undefined) { |
130 |
| - throw new HardhatPluginError( |
131 |
| - PLUGIN_ID, |
132 |
| - "The filePath should be available at this point!", |
133 |
| - ); |
134 |
| - } |
135 |
| -} |
136 |
| - |
137 |
| -async function getConfigDir(): Promise<string> { |
138 |
| - const { config } = envPaths("hardhat"); |
139 |
| - await ensureDir(config); |
140 |
| - return config; |
141 |
| -} |
0 commit comments