Feat: disable ETH 0-confLimit edit, in migrations make ETH 0-confLimit 0

This commit is contained in:
csrapr 2021-04-15 17:09:24 +01:00 committed by Josh Harvey
parent 23fc689f07
commit 84e7b67635
4 changed files with 33 additions and 13 deletions

View file

@ -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)

View file

@ -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({

View file

@ -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({

View file

@ -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 <div style={classes.editDisabled}>{it}</div>
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'
}
]
}