Skip to content

Commit

Permalink
Merge branch 'v6/develop' of https://github.com/OriginTrail/ot-node i…
Browse files Browse the repository at this point in the history
…nto v6/develop
  • Loading branch information
zeroxbt committed Oct 20, 2022
2 parents e7c3f2c + 7510639 commit a32c1fb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/migration/network-private-key-migration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'path';
import appRootPath from 'app-root-path';
import { mkdir, writeFile } from 'fs/promises';
import BaseMigration from './base-migration.js';
import { LIBP2P_KEY_DIRECTORY, LIBP2P_KEY_FILENAME } from '../constants/constants.js';
Expand All @@ -9,7 +10,21 @@ class NetworkPrivateKeyMigration extends BaseMigration {
this.config.modules?.network?.implementation?.['libp2p-service']?.config?.privateKey;

if (networkPrivateKey) {
const directoryPath = join(this.config.appDataPath, LIBP2P_KEY_DIRECTORY);
let directoryPath;
if (process.env.NODE_ENV === 'testnet' || process.env.NODE_ENV === 'mainnet') {
directoryPath = join(
appRootPath.path,
'..',
this.config.appDataPath,
LIBP2P_KEY_DIRECTORY,
);
} else {
directoryPath = join(
appRootPath.path,
this.config.appDataPath,
LIBP2P_KEY_DIRECTORY,
);
}
const fullPath = join(directoryPath, LIBP2P_KEY_FILENAME);
await mkdir(directoryPath, { recursive: true });
await writeFile(fullPath, networkPrivateKey);
Expand Down

0 comments on commit a32c1fb

Please sign in to comment.