Feat: disable ETH 0-confLimit edit, in migrations make ETH 0-confLimit 0
This commit is contained in:
parent
23fc689f07
commit
84e7b67635
4 changed files with 33 additions and 13 deletions
|
|
@ -19,10 +19,10 @@ exports.up = function (next) {
|
||||||
|
|
||||||
_.forEach(cryptoCode => {
|
_.forEach(cryptoCode => {
|
||||||
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
||||||
const zeroConfLimit = _.get('zeroConfLimit', walletConfig)
|
const zeroConfLimit = cryptoCode === 'ETH' ? 0 : _.get('zeroConfLimit', walletConfig)
|
||||||
|
const key = `wallets_${cryptoCode}_zeroConfLimit`
|
||||||
if (_.isNil(zeroConfLimit)) {
|
if (isNil(zeroConfLimit)) {
|
||||||
config[`wallets_${cryptoCode}_zeroConfLimit`] = smallerZeroConf
|
config[key] = min
|
||||||
}
|
}
|
||||||
}, cryptoCodes)
|
}, cryptoCodes)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,11 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => {
|
||||||
} = config
|
} = config
|
||||||
|
|
||||||
const { values } = useFormikContext()
|
const { values } = useFormikContext()
|
||||||
|
const isEditable = editable => {
|
||||||
const isEditing = editing && editable
|
if (typeof editable === 'function') return editable(values)
|
||||||
|
return editable
|
||||||
|
}
|
||||||
|
const isEditing = editing && isEditable(editable)
|
||||||
const isField = !bypassField
|
const isField = !bypassField
|
||||||
|
|
||||||
const classes = useStyles({
|
const classes = useStyles({
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => {
|
||||||
|
|
||||||
const getValue = code => R.find(R.propEq('code', code))(accounts)
|
const getValue = code => R.find(R.propEq('code', code))(accounts)
|
||||||
|
|
||||||
|
const limit = zeroConfLimit && coin.code !== 'ETH' ? zeroConfLimit : 0
|
||||||
const onContinue = async (stepConfig, stepAccount) => {
|
const onContinue = async (stepConfig, stepAccount) => {
|
||||||
const newConfig = R.merge(config, stepConfig)
|
const newConfig = R.merge(config, stepConfig)
|
||||||
const newAccounts = stepAccount
|
const newAccounts = stepAccount
|
||||||
|
|
@ -57,8 +58,8 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => {
|
||||||
: accountsToSave
|
: accountsToSave
|
||||||
|
|
||||||
if (isLastStep) {
|
if (isLastStep) {
|
||||||
const configToSave = { ...newConfig, zeroConfLimit: 0 }
|
newConfig.zeroConfLimit = limit
|
||||||
return save(toNamespace(coin.code, configToSave), newAccounts)
|
return save(toNamespace(coin.code, newConfig), newAccounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,14 @@ import * as Yup from 'yup'
|
||||||
|
|
||||||
import { NumberInput } from 'src/components/inputs/formik'
|
import { NumberInput } from 'src/components/inputs/formik'
|
||||||
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
||||||
|
import { disabledColor } from 'src/styling/variables'
|
||||||
import { CURRENCY_MAX } from 'src/utils/constants'
|
import { CURRENCY_MAX } from 'src/utils/constants'
|
||||||
|
|
||||||
|
const classes = {
|
||||||
|
editDisabled: {
|
||||||
|
color: disabledColor
|
||||||
|
}
|
||||||
|
}
|
||||||
const filterClass = type => R.filter(it => it.class === type)
|
const filterClass = type => R.filter(it => it.class === type)
|
||||||
const filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos))
|
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) => {
|
const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
|
||||||
|
let currentCurrency = ''
|
||||||
const widthAdjust = wizard ? 11 : 0
|
const widthAdjust = wizard ? 11 : 0
|
||||||
const viewCryptoCurrency = it =>
|
const viewCryptoCurrency = it => {
|
||||||
R.compose(
|
const currencyDisplay = R.compose(
|
||||||
R.prop(['display']),
|
R.prop(['display']),
|
||||||
R.find(R.propEq('code', it))
|
R.find(R.propEq('code', it))
|
||||||
)(cryptoCurrencies)
|
)(cryptoCurrencies)
|
||||||
|
currentCurrency = currencyDisplay
|
||||||
|
return currencyDisplay
|
||||||
|
}
|
||||||
const filterOptions = type => filterClass(type)(accounts || [])
|
const filterOptions = type => filterClass(type)(accounts || [])
|
||||||
|
|
||||||
const getDisplayName = type => it =>
|
const getDisplayName = type => it =>
|
||||||
|
|
@ -40,6 +49,12 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
|
||||||
filterCoins(it)(filterOptions(option))
|
filterCoins(it)(filterOptions(option))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const getZeroConfLimit = it => {
|
||||||
|
if (currentCurrency === 'Ethereum')
|
||||||
|
return <div style={classes.editDisabled}>{it}</div>
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'id',
|
name: 'id',
|
||||||
|
|
@ -112,12 +127,13 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
|
||||||
name: 'zeroConfLimit',
|
name: 'zeroConfLimit',
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
stripe: true,
|
stripe: true,
|
||||||
view: it => it,
|
view: getZeroConfLimit,
|
||||||
input: NumberInput,
|
input: NumberInput,
|
||||||
width: 190 - widthAdjust,
|
width: 190 - widthAdjust,
|
||||||
inputProps: {
|
inputProps: {
|
||||||
decimalPlaces: 0
|
decimalPlaces: 0
|
||||||
}
|
},
|
||||||
|
editable: row => row.id !== 'ETH'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue