diff --git a/migrations/1617742522808-zeroConfLimit-migrate.js b/migrations/1617742522808-zeroConfLimit-migrate.js index 03de48d6..e5374441 100644 --- a/migrations/1617742522808-zeroConfLimit-migrate.js +++ b/migrations/1617742522808-zeroConfLimit-migrate.js @@ -19,10 +19,10 @@ exports.up = function (next) { _.forEach(cryptoCode => { const walletConfig = configManager.getWalletSettings(cryptoCode, config) - const zeroConfLimit = _.get('zeroConfLimit', walletConfig) - - if (_.isNil(zeroConfLimit)) { - config[`wallets_${cryptoCode}_zeroConfLimit`] = smallerZeroConf + const zeroConfLimit = cryptoCode === 'ETH' ? 0 : _.get('zeroConfLimit', walletConfig) + const key = `wallets_${cryptoCode}_zeroConfLimit` + if (isNil(zeroConfLimit)) { + config[key] = min } }, cryptoCodes) diff --git a/new-lamassu-admin/src/components/editableTable/Row.js b/new-lamassu-admin/src/components/editableTable/Row.js index 3d8c7836..7a4c60ee 100644 --- a/new-lamassu-admin/src/components/editableTable/Row.js +++ b/new-lamassu-admin/src/components/editableTable/Row.js @@ -136,8 +136,11 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => { } = config const { values } = useFormikContext() - - const isEditing = editing && editable + const isEditable = editable => { + if (typeof editable === 'function') return editable(values) + return editable + } + const isEditing = editing && isEditable(editable) const isField = !bypassField const classes = useStyles({ diff --git a/new-lamassu-admin/src/pages/Wallet/Wizard.js b/new-lamassu-admin/src/pages/Wallet/Wizard.js index 4123f3fd..bfbc4f0c 100644 --- a/new-lamassu-admin/src/pages/Wallet/Wizard.js +++ b/new-lamassu-admin/src/pages/Wallet/Wizard.js @@ -50,6 +50,7 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => { const getValue = code => R.find(R.propEq('code', code))(accounts) + const limit = zeroConfLimit && coin.code !== 'ETH' ? zeroConfLimit : 0 const onContinue = async (stepConfig, stepAccount) => { const newConfig = R.merge(config, stepConfig) const newAccounts = stepAccount @@ -57,8 +58,8 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => { : accountsToSave if (isLastStep) { - const configToSave = { ...newConfig, zeroConfLimit: 0 } - return save(toNamespace(coin.code, configToSave), newAccounts) + newConfig.zeroConfLimit = limit + return save(toNamespace(coin.code, newConfig), newAccounts) } setState({ diff --git a/new-lamassu-admin/src/pages/Wallet/helper.js b/new-lamassu-admin/src/pages/Wallet/helper.js index 5b889e59..d2a9bba3 100644 --- a/new-lamassu-admin/src/pages/Wallet/helper.js +++ b/new-lamassu-admin/src/pages/Wallet/helper.js @@ -3,8 +3,14 @@ import * as Yup from 'yup' import { NumberInput } from 'src/components/inputs/formik' import Autocomplete from 'src/components/inputs/formik/Autocomplete.js' +import { disabledColor } from 'src/styling/variables' import { CURRENCY_MAX } from 'src/utils/constants' +const classes = { + editDisabled: { + color: disabledColor + } +} const filterClass = type => R.filter(it => it.class === type) const filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos)) @@ -21,13 +27,16 @@ const WalletSchema = Yup.object().shape({ }) const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => { + let currentCurrency = '' const widthAdjust = wizard ? 11 : 0 - const viewCryptoCurrency = it => - R.compose( + const viewCryptoCurrency = it => { + const currencyDisplay = R.compose( R.prop(['display']), R.find(R.propEq('code', it)) )(cryptoCurrencies) - + currentCurrency = currencyDisplay + return currencyDisplay + } const filterOptions = type => filterClass(type)(accounts || []) const getDisplayName = type => it => @@ -40,6 +49,12 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => { filterCoins(it)(filterOptions(option)) ) + const getZeroConfLimit = it => { + if (currentCurrency === 'Ethereum') + return
{it}
+ return it + } + return [ { name: 'id', @@ -112,12 +127,13 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => { name: 'zeroConfLimit', size: 'sm', stripe: true, - view: it => it, + view: getZeroConfLimit, input: NumberInput, width: 190 - widthAdjust, inputProps: { decimalPlaces: 0 - } + }, + editable: row => row.id !== 'ETH' } ] }