Skip to content

Commit

Permalink
fix: put password in config.yaml (#235)
Browse files Browse the repository at this point in the history
* Update README.md

* fix: put password in config.yaml

Co-authored-by: significance <daniel.nickless@gmail.com>
  • Loading branch information
Cafe137 and significance committed Jul 27, 2022
1 parent 6780201 commit 6465fc0
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { mkdirSync, readFileSync, writeFileSync } from 'fs'
import fetch from 'node-fetch'
import { platform } from 'os'
import { join } from 'path'
import { v4 } from 'uuid'
import { writeConfigYaml } from './config-yaml'
import { rebuildElectronTray } from './electron'
import { BeeManager } from './lifecycle'
import { logger } from './logger'
Expand Down Expand Up @@ -37,7 +39,7 @@ export async function createInitialTransaction() {
const { address } = JSON.parse(readFileSync(getPath('data-dir/keys/swarm.key')).toString())
logger.info('Sending transaction to address', address)
const { transaction, blockHash } = await sendTransaction(address)
writeFileSync(getPath('config.yaml'), createConfiguration(transaction, blockHash))
createConfiguration(transaction, blockHash)
}
}

Expand All @@ -61,7 +63,7 @@ export async function runLauncher() {
const { address } = JSON.parse(readFileSync(getPath(join('data-dir', 'keys', 'swarm.key'))).toString())
logger.info('Sending transaction to address', address)
const { transaction, blockHash } = await sendTransaction(address)
writeFileSync(getPath('config.yaml'), createConfiguration(transaction, blockHash))
createConfiguration(transaction, blockHash)
}
BeeManager.setUserIntention(true)
const subprocess = launchBee(abortController).catch(reason => {
Expand Down Expand Up @@ -98,23 +100,21 @@ chain-enable: false
cors-allowed-origins: '*'
use-postage-snapshot: true
resolver-options: https://cloudflare-eth.com
data-dir: ${getPath('data-dir')}`
data-dir: ${getPath('data-dir')}
password: ${v4()}`
}

function createConfiguration(transaction: string, blockHash: string) {
return `${createStubConfiguration()}
transaction: ${transaction}
block-hash: ${blockHash}`
writeConfigYaml({
transaction,
'block-hash': blockHash,
})
}

async function initializeBee() {
const configPath = getPath('config.yaml')

return runProcess(
getPath(getBeeExecutable()),
['init', `--config=${configPath}`, `--password=Test`],
new AbortController(),
)
return runProcess(getPath(getBeeExecutable()), ['init', `--config=${configPath}`], new AbortController())
}

async function launchBee(abortController?: AbortController) {
Expand All @@ -123,11 +123,7 @@ async function launchBee(abortController?: AbortController) {
}
const configPath = getPath('config.yaml')

return runProcess(
getPath(getBeeExecutable()),
['start', `--config=${configPath}`, '--password=Test'],
abortController,
)
return runProcess(getPath(getBeeExecutable()), ['start', `--config=${configPath}`], abortController)
}

async function runProcess(command: string, args: string[], abortController: AbortController): Promise<number> {
Expand Down

0 comments on commit 6465fc0

Please sign in to comment.