MCPcopy Create free account
hub / github.com/AztecProtocol/aztec-packages / loadKeystores

Function loadKeystores

yarn-project/node-keystore/src/loader.ts:119–142  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

117 * @throws KeyStoreLoadError When the path is invalid or cannot be accessed.
118 */
119export function loadKeystores(path: string): KeyStore[] {
120 try {
121 const stats = statSync(path);
122
123 if (stats.isFile()) {
124 return [loadKeystoreFile(path)];
125 } else if (stats.isDirectory()) {
126 return loadKeystoreDirectory(path);
127 } else {
128 throw new KeyStoreLoadError('Path is neither a file nor directory', path);
129 }
130 } catch (error) {
131 if (error instanceof KeyStoreLoadError) {
132 throw error;
133 }
134
135 const err = error as NodeJS.ErrnoException;
136 if (err?.code === 'ENOENT') {
137 throw new KeyStoreLoadError('File or directory not found', path, error as Error);
138 }
139
140 throw new KeyStoreLoadError(`Failed to access path: ${err?.code ?? 'UNKNOWN'}`, path, error as Error);
141 }
142}
143
144/**
145 * Loads keystore(s) from multiple paths (comma-separated string or array).

Callers 4

createAndSyncMethod · 0.90
reloadKeystoreMethod · 0.90
verifyKeyStoreFunction · 0.90
loadMultipleKeystoresFunction · 0.85

Calls 2

loadKeystoreFileFunction · 0.85
loadKeystoreDirectoryFunction · 0.85

Tested by 1

verifyKeyStoreFunction · 0.72