fix: block ZEC and XMR from being installed simultaneously
fix: improve error message and organize some code
This commit is contained in:
parent
bd1ed64890
commit
c7880d07de
1 changed files with 29 additions and 5 deletions
|
|
@ -138,19 +138,34 @@ function getBlockchainSyncStatus (cryptoList) {
|
|||
})
|
||||
}
|
||||
|
||||
function isInstalled (crypto) {
|
||||
if (crypto.cryptoCode === 'XMR') return true
|
||||
return isInstalledSoftware(crypto) && isInstalledVolume(crypto)
|
||||
}
|
||||
|
||||
function isDisabled (crypto) {
|
||||
switch (crypto.cryptoCode) {
|
||||
case 'ETH':
|
||||
return 'Use admin\'s Infura plugin'
|
||||
case 'ZEC':
|
||||
return isInstalled(crypto) && 'Installed' || isInstalled(_.find(it => it.code === 'monero', cryptos)) && 'Insufficient resources. Contact support.'
|
||||
case 'XMR':
|
||||
return isInstalled(crypto) && 'Installed' || isInstalled(_.find(it => it.code === 'zcash', cryptos)) && 'Insufficient resources. Contact support.'
|
||||
default:
|
||||
return isInstalled(crypto) && 'Installed'
|
||||
}
|
||||
}
|
||||
|
||||
function run () {
|
||||
const choices = _.flow([
|
||||
_.filter(c => c.type !== 'erc-20'),
|
||||
_.map(c => {
|
||||
const checked = isInstalledSoftware(c) && isInstalledVolume(c)
|
||||
const name = c.code === 'ethereum' ? 'Ethereum and/or USDT' : c.display
|
||||
return {
|
||||
name,
|
||||
value: c.code,
|
||||
checked,
|
||||
disabled: c.cryptoCode === 'ETH'
|
||||
? 'Use admin\'s Infura plugin'
|
||||
: checked && 'Installed'
|
||||
checked: isInstalled(c),
|
||||
disabled: isDisabled(c)
|
||||
}
|
||||
}),
|
||||
])(cryptos)
|
||||
|
|
@ -159,6 +174,15 @@ function run () {
|
|||
|
||||
const validateAnswers = async (answers) => {
|
||||
if (_.size(answers) > 2) return { message: `Please insert a maximum of two coins to install.`, isValid: false }
|
||||
|
||||
if (
|
||||
_.isEmpty(_.difference(['monero', 'zcash'], answers)) ||
|
||||
(_.includes('monero', answers) && isInstalled(_.find(it => it.code === 'zcash', cryptos))) ||
|
||||
(_.includes('zcash', answers) && isInstalled(_.find(it => it.code === 'monero', cryptos)))
|
||||
) {
|
||||
return { message: `Zcash and Monero installations are temporarily mutually exclusive, given the space needed for their blockchains. Contact support for more information.`, isValid: false }
|
||||
}
|
||||
|
||||
return getBlockchainSyncStatus(cryptos)
|
||||
.then(blockchainStatuses => {
|
||||
const result = _.reduce((acc, value) => ({ ...acc, [value]: _.isNil(acc[value]) ? 1 : acc[value] + 1 }), {}, _.values(blockchainStatuses))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue