refactor: supervisor config pull up method
fix: small fixes
This commit is contained in:
parent
c0808e9bd7
commit
048971fdb3
2 changed files with 29 additions and 28 deletions
|
|
@ -14,16 +14,22 @@ const cryptoRec = utils.getCryptoCurrency('XMR')
|
|||
const configPath = utils.configPath(cryptoRec, blockchainUtils.blockchainDir())
|
||||
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainUtils.blockchainDir()), 'wallets')
|
||||
const unitScale = cryptoRec.unitScale
|
||||
const config = jsonRpc.parseConf(configPath)
|
||||
|
||||
const rpcConfig = {
|
||||
username: config['rpc-login'].split(':')[0],
|
||||
password: config['rpc-login'].split(':')[1],
|
||||
port: cryptoRec.walletPort || cryptoRec.defaultPort
|
||||
function rpcConfig () {
|
||||
try {
|
||||
const config = jsonRpc.parseConf(configPath)
|
||||
return {
|
||||
username: config['rpc-login'].split(':')[0],
|
||||
password: config['rpc-login'].split(':')[1],
|
||||
port: cryptoRec.walletPort || cryptoRec.defaultPort
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error('wallet is currently not installed')
|
||||
}
|
||||
}
|
||||
|
||||
function fetch (method, params) {
|
||||
return jsonRpc.fetchDigest(rpcConfig, method, params)
|
||||
return jsonRpc.fetchDigest(rpcConfig(), method, params)
|
||||
}
|
||||
|
||||
function handleError (error) {
|
||||
|
|
@ -55,11 +61,11 @@ function handleError (error) {
|
|||
}
|
||||
|
||||
function openWallet () {
|
||||
return fetch('open_wallet', { filename: 'Wallet', password: rpcConfig.password })
|
||||
return fetch('open_wallet', { filename: 'Wallet', password: rpcConfig().password })
|
||||
}
|
||||
|
||||
function createWallet () {
|
||||
return fetch('create_wallet', { filename: 'Wallet', password: rpcConfig.password, language: 'English' })
|
||||
return fetch('create_wallet', { filename: 'Wallet', password: rpcConfig().password, language: 'English' })
|
||||
.then(() => new Promise(() => setTimeout(() => openWallet(), 3000)))
|
||||
.then(() => fetch('auto_refresh'))
|
||||
}
|
||||
|
|
@ -173,7 +179,7 @@ function newFunding (account, cryptoCode) {
|
|||
function cryptoNetwork (account, cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
switch(parseInt(rpcConfig.port, 10)) {
|
||||
switch(parseInt(rpcConfig().port, 10)) {
|
||||
case 18083:
|
||||
return 'main'
|
||||
case 28083:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue