feat: decouple l-s entrypoint
This commit is contained in:
parent
03cb4a3c4c
commit
b0860cdea5
48 changed files with 411 additions and 232 deletions
|
|
@ -2,7 +2,7 @@ require('es6-promise').polyfill()
|
|||
|
||||
var notifier = require('../lib/notifier')
|
||||
var db = require('../lib/postgresql_interface')
|
||||
var psqlUrl = require('../lib/options').postgres
|
||||
const { PSQL_URL } = require('../lib/constants')
|
||||
|
||||
function getBalances () {
|
||||
return [
|
||||
|
|
@ -11,7 +11,7 @@ function getBalances () {
|
|||
]
|
||||
}
|
||||
|
||||
db.init(psqlUrl)
|
||||
db.init(PSQL_URL)
|
||||
notifier.init(db, getBalances, {lowBalanceThreshold: 10})
|
||||
console.log('DEBUG0')
|
||||
notifier.checkStatus()
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
const os = require('os')
|
||||
const bip39 = require('bip39')
|
||||
const options = require('../lib/options-loader')()
|
||||
const setEnvVariable = require('../tools/set-env-var')
|
||||
|
||||
if (options.opts.mnemonicPath && !options.opts.seedPath) {
|
||||
const mnemonic = fs.readFileSync(options.opts.mnemonicPath, 'utf8')
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })
|
||||
|
||||
if (process.env.MNEMONIC_PATH && !process.env.SEED_PATH) {
|
||||
const mnemonic = fs.readFileSync(process.env.MNEMONIC_PATH, 'utf8')
|
||||
const seed = bip39.mnemonicToEntropy(mnemonic.split('\n').join(' ').trim()).toString('hex')
|
||||
|
||||
options.opts.seedPath = path.resolve(os.homedir(), '.lamassu', 'seeds', 'seed.txt')
|
||||
setEnvVariable('SEED_PATH', path.resolve(os.homedir(), '.lamassu', 'seeds', 'seed.txt'))
|
||||
|
||||
if (!fs.existsSync(path.dirname(options.opts.seedPath))) {
|
||||
fs.mkdirSync(path.dirname(options.opts.seedPath))
|
||||
if (!fs.existsSync(path.dirname(process.env.SEED_PATH))) {
|
||||
fs.mkdirSync(path.dirname(process.env.SEED_PATH))
|
||||
}
|
||||
|
||||
if (!fs.existsSync(options.opts.seedPath)) {
|
||||
fs.writeFileSync(options.opts.seedPath, seed, 'utf8')
|
||||
if (!fs.existsSync(process.env.SEED_PATH)) {
|
||||
fs.writeFileSync(process.env.SEED_PATH, seed, 'utf8')
|
||||
}
|
||||
|
||||
fs.writeFileSync(options.path, JSON.stringify(options.opts, null, '\t'), 'utf8')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue