diff --git a/lib/blockchain/install.js b/lib/blockchain/install.js index b4eb81e2..4007256f 100644 --- a/lib/blockchain/install.js +++ b/lib/blockchain/install.js @@ -138,19 +138,33 @@ function getBlockchainSyncStatus (cryptoList) { }) } +function isInstalled (crypto) { + 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 +173,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))