1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix send of USD and backspacing amount to 0

This commit is contained in:
Dan 2017-09-28 11:40:33 -02:30 committed by Chi Kei Chan
parent b55a40c7f1
commit a195427e72
2 changed files with 7 additions and 3 deletions

View File

@ -47,7 +47,7 @@ const toNormalizedDenomination = {
WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER) WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER)
} }
const toSpecifiedDenomination = { const toSpecifiedDenomination = {
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER) WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round()
} }
const baseChange = { const baseChange = {
hex: n => n.toString(16), hex: n => n.toString(16),
@ -83,8 +83,8 @@ const whenPropApplySetterMap = (prop, setterMap) => whenPredSetWithPropAndSetter
const converter = R.pipe( const converter = R.pipe(
whenPropApplySetterMap('fromNumericBase', toBigNumber), whenPropApplySetterMap('fromNumericBase', toBigNumber),
whenPropApplySetterMap('fromDenomination', toNormalizedDenomination), whenPropApplySetterMap('fromDenomination', toNormalizedDenomination),
whenPropApplySetterMap('toDenomination', toSpecifiedDenomination),
whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert), whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert),
whenPropApplySetterMap('toDenomination', toSpecifiedDenomination),
whenPredSetWithPropAndSetter(R.prop('ethToUSDRate'), 'ethToUSDRate', convert), whenPredSetWithPropAndSetter(R.prop('ethToUSDRate'), 'ethToUSDRate', convert),
whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round), whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round),
whenPropApplySetterMap('toNumericBase', baseChange), whenPropApplySetterMap('toNumericBase', baseChange),

View File

@ -230,12 +230,16 @@ SendTransactionScreen.prototype.renderAmountInput = function (activeCurrency) {
placeholder: `0 ${activeCurrency}`, placeholder: `0 ${activeCurrency}`,
type: 'number', type: 'number',
onChange: (event) => { onChange: (event) => {
const amountToSend = event.target.value
? this.getAmountToSend(event.target.value)
: '0x0'
this.setState({ this.setState({
newTx: Object.assign( newTx: Object.assign(
this.state.newTx, this.state.newTx,
{ {
amount: event.target.value, amount: event.target.value,
amountToSend: this.getAmountToSend(event.target.value), amountToSend: amountToSend,
} }
), ),
}) })