From 480d3f82dcf9d7b9f90a90dcd928986192908262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Chavarr=C3=ADa?= Date: Thu, 17 Jun 2021 20:49:25 -0600 Subject: [PATCH 1/7] feat: enable custom gas price and limit --- src/pages/wallet/transfer.js | 121 ++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 45 deletions(-) diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 87a0e951..52770961 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -310,7 +310,8 @@ class Transfer extends Component { enableConfirm: false, isCustomFee: false, customFee: null, - customFeeValue: new BigNumber(0), + customGasPrice: new BigNumber(0), + customGasLimit: new BigNumber(0), feeSymbol: null, feeSliderValue: 0, amountPlaceholderText: '', @@ -338,10 +339,11 @@ class Transfer extends Component { const { symbol, type } = this.coin; if (prices && prices !== curPrices) { - const { customFee, feeSymbol } = this.state; - const customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); + // const { customFee, feeSymbol } = this.state; + // const customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); const amountPlaceholderText = Transfer.generateAmountPlaceholderText(symbol, type, currency, prices); - this.setState({ customFeeValue, amountPlaceholderText }); + // this.setState({ customFeeValue amountPlaceholderText }); + this.setState({ amountPlaceholderText }); } } @@ -391,7 +393,8 @@ class Transfer extends Component { if (value) { const feeSliderValue = 0.5; this.setState({ feeSliderValue }); - this.onCustomFeeSlideValueChange(feeSliderValue); + this.onCustomGasPriceSlideValueChange(feeSliderValue); + this.onCustomGasLimitSlideValueChange(feeSliderValue); } } @@ -399,20 +402,20 @@ class Transfer extends Component { * onCustomFeeSlideValueChange * @param {number} value slider value, 0-1 */ - onCustomFeeSlideValueChange = (value) => { - const { - levelFees, isCustomFee, feeLevel, - } = this.state; + onCustomGasPriceSlideValueChange = (value) => { + this.setState({ customGasPrice: value }); + } - const { customFee: newCustomFee, customFeeValue } = this.calcCustomFee(value); - this.setState({ customFee: newCustomFee, customFeeValue }, () => { - // When the fee is changed by the user, modify the amount in the text box. - this.adjustSendAllAmount(levelFees, feeLevel, isCustomFee, newCustomFee); - }); + onGasPriceSlidingComplete = (value) => { + this.setState({ customGasPrice: value }); } - onCustomFeeSlidingComplete = (value) => { - this.setState({ feeSliderValue: value }); + onCustomGasLimitSlideValueChange = (value) => { + this.setState({ customGasLimit: value }); + } + + onGasLimitSlidingComplete = (value) => { + this.setState({ customGasLimit: value }); } onSendAllPress() { @@ -840,9 +843,12 @@ class Transfer extends Component { // Update custom fee if (isCustomFee) { - const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); + // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); + // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); + const { customFee: newFee } = this.calcCustomFee(feeSliderValue); newCustomFee = newFee; - this.setState({ customFee: newCustomFee, customFeeValue }); + // this.setState({ customFee: newCustomFee, customFeeValue }); + this.setState({ customFee: newCustomFee }); } // If user request send all, we need to adjust amount text. @@ -964,34 +970,58 @@ class Transfer extends Component { } } - renderCustomFee(isCustomFee) { + renderCustomFee() { const { - customFee, feeSymbol, customFeeValue, feeSliderValue, + customGasPrice, customGasLimit, feeSymbol, feeSliderValue, } = this.state; - const { type } = this.coin; - const { currency } = this.props; - const currencySymbol = common.getCurrencySymbol(currency); + return ( - - { isCustomFee && ( - - this.onCustomFeeSlideValueChange(value)} - onSlidingComplete={(value) => this.onCustomFeeSlidingComplete(value)} - /> - - {`${common.getBalanceString(customFee, feeSymbol)} ${common.getSymbolName(feeSymbol, type)}`} - {customFeeValue && ` = ${currencySymbol}${common.getAssetValueString(customFeeValue)}`} - - - )} + + + + this.onCustomGasPriceSlideValueChange(value)} + onSlidingComplete={(value) => this.onGasPriceSlidingComplete(value)} + /> + + Gas Price: + {' '} + {customGasPrice} + + + + this.onCustomGasLimitSlideValueChange(value)} + onSlidingComplete={(value) => this.onGasLimitSlidingComplete(value)} + /> + + + Gas Limit: + {' '} + {customGasLimit} + + + + + + {`Fee: ${customGasPrice * customGasLimit} ${feeSymbol}`} + + + ); @@ -1139,15 +1169,16 @@ class Transfer extends Component { - + this.onCustomFeeSwitchValueChange(v)} /> - {this.renderCustomFee(isCustomFee)} + {isCustomFee && this.renderCustomFee(isCustomFee)} + Date: Tue, 22 Jun 2021 09:17:50 -0600 Subject: [PATCH 2/7] feat: calculate fiat value --- src/pages/wallet/transfer.js | 55 +++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 52770961..014b6e51 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -314,6 +314,8 @@ class Transfer extends Component { customGasLimit: new BigNumber(0), feeSymbol: null, feeSliderValue: 0, + customGasPriceSliderValue: 0, + customGasLimitSliderValue: 0, amountPlaceholderText: '', levelFees: null, // [ { fee, value }... ] addressError: null, @@ -333,7 +335,7 @@ class Transfer extends Component { } } - componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps) { const { prices, currency } = nextProps; const { prices: curPrices } = this.props; const { symbol, type } = this.coin; @@ -385,16 +387,27 @@ class Transfer extends Component { // } onCustomFeeSwitchValueChange(value) { + console.log('testsss'); + console.log(this.state); + console.log(this); + + const latestBlockMinimumGasPrice = this.latestBlockMinimumGasPrice.toNumber(); + const estimatedGasLimit = this.estimatedGasLimit.toNumber(); + console.log({ latestBlockMinimumGasPrice }); + console.log({ estimatedGasLimit }); + const { customFee } = this.state; this.setState({ isCustomFee: value }); if (customFee) { return; } if (value) { - const feeSliderValue = 0.5; - this.setState({ feeSliderValue }); - this.onCustomGasPriceSlideValueChange(feeSliderValue); - this.onCustomGasLimitSlideValueChange(feeSliderValue); + const feeSliderValue = latestBlockMinimumGasPrice; + const customGasPriceSliderValue = latestBlockMinimumGasPrice; + const customGasLimitSliderValue = estimatedGasLimit; + this.setState({ feeSliderValue, customGasPriceSliderValue, customGasLimitSliderValue }); + this.onCustomGasPriceSlideValueChange(customGasPriceSliderValue); + this.onCustomGasLimitSlideValueChange(customGasLimitSliderValue); } } @@ -792,6 +805,17 @@ class Transfer extends Component { return { customFee, customFeeValue }; } + calculateCoinValue(txFees) { + const { coin } = this; + const { type } = coin; + const { prices, currency } = this.props; + const { + feeSymbol, + } = this.state; + const fee = common.convertUnitToCoinAmount(feeSymbol, txFees); + return common.getCoinValue(fee, feeSymbol, type, currency, prices); + } + processFees(transactionFees) { console.log('processFees, transactionFees: ', transactionFees); const { prices, currency } = this.props; @@ -824,6 +848,8 @@ class Transfer extends Component { // Calculates Rootstock tokens(RBTC, RIF, DOC...) levelFees const { gas, gasPrice: { low, medium, high } } = transactionFees; this.gas = new BigNumber(gas); + this.latestBlockMinimumGasPrice = new BigNumber(low); + this.estimatedGasLimit = new BigNumber(gas); const txPrices = [low, medium, high]; for (let i = 0; i < NUM_OF_FEE_LEVELS; i += 1) { const gasPrice = new BigNumber(txPrices[i]); @@ -972,18 +998,19 @@ class Transfer extends Component { renderCustomFee() { const { - customGasPrice, customGasLimit, feeSymbol, feeSliderValue, + customGasPrice, customGasLimit, feeSliderValue, customGasPriceSliderValue, customGasLimitSliderValue, } = this.state; - + const valueCoin = this.calculateCoinValue(customGasPrice * customGasLimit); + console.log(feeSliderValue); return ( - {`Fee: ${customGasPrice * customGasLimit} ${feeSymbol}`} + {`Fee: ${valueCoin} USD`} From be3a68419e3f176a58ebe6c3c79dccbbd6c8f338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Chavarr=C3=ADa?= Date: Wed, 23 Jun 2021 12:05:30 -0600 Subject: [PATCH 3/7] feat: fix custom btc fee --- src/pages/wallet/transfer.js | 144 ++++++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 38 deletions(-) diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 014b6e51..7b5878ed 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -316,6 +316,7 @@ class Transfer extends Component { feeSliderValue: 0, customGasPriceSliderValue: 0, customGasLimitSliderValue: 0, + customBtcFeeSliderValue: 0, amountPlaceholderText: '', levelFees: null, // [ { fee, value }... ] addressError: null, @@ -386,15 +387,13 @@ class Transfer extends Component { // await this.confirm(); // } - onCustomFeeSwitchValueChange(value) { - console.log('testsss'); + onCustomFeeSwitchValueChange(value, symbol) { + console.log('Test test'); console.log(this.state); console.log(this); - const latestBlockMinimumGasPrice = this.latestBlockMinimumGasPrice.toNumber(); - const estimatedGasLimit = this.estimatedGasLimit.toNumber(); - console.log({ latestBlockMinimumGasPrice }); - console.log({ estimatedGasLimit }); + /* console.log({ latestBlockMinimumGasPrice }); + console.log({ estimatedGasLimit }); */ const { customFee } = this.state; this.setState({ isCustomFee: value }); @@ -402,12 +401,23 @@ class Transfer extends Component { return; } if (value) { - const feeSliderValue = latestBlockMinimumGasPrice; - const customGasPriceSliderValue = latestBlockMinimumGasPrice; - const customGasLimitSliderValue = estimatedGasLimit; - this.setState({ feeSliderValue, customGasPriceSliderValue, customGasLimitSliderValue }); - this.onCustomGasPriceSlideValueChange(customGasPriceSliderValue); - this.onCustomGasLimitSlideValueChange(customGasLimitSliderValue); + // const feeSliderValue = latestBlockMinimumGasPrice; + + if (symbol !== 'BTC') { + const latestBlockMinimumGasPrice = this.latestBlockMinimumGasPrice.toNumber(); + const estimatedGasLimit = this.estimatedGasLimit.toNumber(); + + const customGasPriceSliderValue = latestBlockMinimumGasPrice; + const customGasLimitSliderValue = estimatedGasLimit; + this.setState({ customGasPriceSliderValue, customGasLimitSliderValue }); + this.onCustomGasPriceSlideValueChange(customGasPriceSliderValue); + this.onCustomGasLimitSlideValueChange(customGasLimitSliderValue); + } else { + const customBtcFeeSliderValue = this.btcLowEstimatedFee.toNumber(); + this.setState({ customBtcFeeSliderValue }); + // this.onCustomGasPriceSlideValueChange(customGasPriceSliderValue); + this.onCustomBtcFeeSlideValueChange(customBtcFeeSliderValue); + } } } @@ -416,19 +426,33 @@ class Transfer extends Component { * @param {number} value slider value, 0-1 */ onCustomGasPriceSlideValueChange = (value) => { - this.setState({ customGasPrice: value }); + const customGasPrice = new BigNumber(value); + this.setState({ customGasPrice }); } onGasPriceSlidingComplete = (value) => { - this.setState({ customGasPrice: value }); + const customGasPrice = new BigNumber(value); + this.setState({ customGasPrice }); } onCustomGasLimitSlideValueChange = (value) => { - this.setState({ customGasLimit: value }); + const customGasLimit = new BigNumber(value); + this.setState({ customGasLimit }); } onGasLimitSlidingComplete = (value) => { - this.setState({ customGasLimit: value }); + const customGasLimit = new BigNumber(value); + this.setState({ customGasLimit }); + } + + onCustomBtcFeeSlideValueChange = (value) => { + const customBtcFee = new BigNumber(value); + this.setState({ customBtcFee }); + } + + onCustomBtcFeeSlidingComplete = (value) => { + const customBtcFee = new BigNumber(value); + this.setState({ customBtcFee }); } onSendAllPress() { @@ -542,16 +566,20 @@ class Transfer extends Component { getFeeParams() { const { - levelFees, feeSymbol, isCustomFee, feeLevel, customFee, + levelFees, feeSymbol, isCustomFee, feeLevel, customBtcFee, customGasPrice, customGasLimit, } = this.state; let feeParams = null; if (feeSymbol === 'BTC') { - const fee = isCustomFee ? customFee : levelFees[feeLevel].fee; + const fee = isCustomFee ? customBtcFee : levelFees[feeLevel].fee; feeParams = { fees: common.btcToSatoshiHex(fee) }; + } else if (isCustomFee) { + const gas = customGasLimit; + const gasPrice = customGasPrice.decimalPlaces(0).toString(); + return { gas, gasPrice }; } else { - const { gas, customGasPrice } = this; - const gasPrice = isCustomFee ? customGasPrice : levelFees[feeLevel].gasPrice; - feeParams = { gas, gasPrice: gasPrice.decimalPlaces(0).toString() }; + const { gas } = this; + const { gasPrice } = levelFees[feeLevel]; + return { gas, gasPrice: gasPrice.decimalPlaces(0).toString() }; } return feeParams; } @@ -797,10 +825,10 @@ class Transfer extends Component { customFee = minCustomFee.plus((maxCustomFee.minus(minCustomFee)).times(value)); customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); } else { - const { minCustomGasPrice, maxCustomGasPrice, gas } = this; - this.customGasPrice = minCustomGasPrice.plus((maxCustomGasPrice.minus(minCustomGasPrice)).times(value)); - customFee = common.convertUnitToCoinAmount(feeSymbol, this.customGasPrice.times(gas)); - customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); + // const { minCustomGasPrice, maxCustomGasPrice, gas } = this; + // this.customGasPrice = minCustomGasPrice.plus((maxCustomGasPrice.minus(minCustomGasPrice)).times(value)); + // customFee = common.convertUnitToCoinAmount(feeSymbol, this.customGasPrice.times(gas)); + customFeeValue = common.getCoinValue(value, feeSymbol, type, currency, prices); } return { customFee, customFeeValue }; } @@ -820,7 +848,7 @@ class Transfer extends Component { console.log('processFees, transactionFees: ', transactionFees); const { prices, currency } = this.props; const { - feeSymbol, feeSliderValue, isCustomFee, feeLevel, customFee, + feeSymbol, customGasPriceSliderValue, customGasLimitSliderValue, isCustomFee, feeLevel, customFee, } = this.state; const { coin, txSize } = this; const { symbol, type } = coin; @@ -836,6 +864,7 @@ class Transfer extends Component { const { fees: { low, medium, high } } = transactionFees; for (let i = 0; i < NUM_OF_FEE_LEVELS; i += 1) { const txFees = [low, medium, high]; + this.btcLowEstimatedFee = new BigNumber(common.satoshiToBtc(low)); const fee = common.convertUnitToCoinAmount(feeSymbol, txFees[i]); const value = common.getCoinValue(fee, feeSymbol, type, currency, prices); levelFees.push({ fee, value }); @@ -848,6 +877,7 @@ class Transfer extends Component { // Calculates Rootstock tokens(RBTC, RIF, DOC...) levelFees const { gas, gasPrice: { low, medium, high } } = transactionFees; this.gas = new BigNumber(gas); + this.latestBlockMinimumGasPrice = new BigNumber(low); this.estimatedGasLimit = new BigNumber(gas); const txPrices = [low, medium, high]; @@ -871,7 +901,8 @@ class Transfer extends Component { if (isCustomFee) { // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); - const { customFee: newFee } = this.calcCustomFee(feeSliderValue); + const { customFee: newFee } = this.calcCustomFee(customGasPriceSliderValue * customGasLimitSliderValue); + newCustomFee = newFee; // this.setState({ customFee: newCustomFee, customFeeValue }); this.setState({ customFee: newCustomFee }); @@ -996,12 +1027,11 @@ class Transfer extends Component { } } - renderCustomFee() { + renderAdvancedGasOptions() { const { - customGasPrice, customGasLimit, feeSliderValue, customGasPriceSliderValue, customGasLimitSliderValue, + customGasPrice, customGasLimit, customGasPriceSliderValue, customGasLimitSliderValue, } = this.state; - const valueCoin = this.calculateCoinValue(customGasPrice * customGasLimit); - console.log(feeSliderValue); + const valueCoin = new BigNumber(this.calculateCoinValue(customGasPrice * customGasLimit)); return ( @@ -1009,7 +1039,7 @@ class Transfer extends Component { Gas Price: {' '} - {customGasPrice} + {customGasPrice.div(1000000000).decimalPlaces(2).toString()} + {' '} + GWEI Gas Limit: {' '} - {customGasLimit} + {customGasLimit.decimalPlaces(2).toString()} + {' '} + Units - {`Fee: ${valueCoin} USD`} + {`Fee: ${valueCoin.decimalPlaces(2).toString()} USD`} @@ -1054,6 +1088,38 @@ class Transfer extends Component { ); } + renderAdvancedBtcFeeOptions() { + const { + customBtcFee, customBtcFeeSliderValue, + } = this.state; + // const valueCoin = new BigNumber(this.calculateCoinValue(customGasPrice * customGasLimit)); + console.log(customBtcFeeSliderValue); + return ( + + + this.onCustomBtcFeeSlideValueChange(value)} + onSlidingComplete={(value) => this.onCustomBtcFeeSlidingComplete(value)} + /> + + + Fee: + {' '} + {customBtcFee.toString()} + {' '} + BTC + + + ); + } + renderFeeOptions() { const { currency } = this.props; const { @@ -1200,10 +1266,12 @@ class Transfer extends Component { this.onCustomFeeSwitchValueChange(v)} + onValueChange={(v) => this.onCustomFeeSwitchValueChange(v, symbol)} /> - {isCustomFee && this.renderCustomFee(isCustomFee)} + {isCustomFee && symbol !== 'BTC' && this.renderAdvancedGasOptions()} + {isCustomFee && symbol === 'BTC' && this.renderAdvancedBtcFeeOptions()} + From d9e10e3dae5ca7a988916394aa8b74e5eed869e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Chavarr=C3=ADa?= Date: Wed, 23 Jun 2021 16:04:17 -0600 Subject: [PATCH 4/7] feat: translate advanced gas options --- src/common/translations/en.json | 8 ++++++-- src/common/translations/es.json | 6 +++++- src/pages/wallet/transfer.js | 29 ++++++++++++----------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/common/translations/en.json b/src/common/translations/en.json index 4434a647..b4ded94d 100644 --- a/src/common/translations/en.json +++ b/src/common/translations/en.json @@ -55,7 +55,7 @@ "transfer": { "to": "To", "memo": "Memo (optional)", - "fee": "Transaction fee", + "fee": "Transaction Fee", "custom": "Custom", "feeQuestion": "How fast do you want this done?", "Slow": "Slow", @@ -65,7 +65,11 @@ "enterMemo": "Enter a transaction memo", "slideConfirm": "Slide to Confirm", "balance": "Balance", - "unavailableAddress": "The wallet address you’ve entered is not valid" + "unavailableAddress": "The wallet address you’ve entered is not valid", + "advanced": "Advanced", + "gasPrice": "Gas Price", + "gasLimit": "Gas Limit", + "units": "Units" }, "add": { "title": "Add Wallet", diff --git a/src/common/translations/es.json b/src/common/translations/es.json index 497ba075..26b31561 100644 --- a/src/common/translations/es.json +++ b/src/common/translations/es.json @@ -65,7 +65,11 @@ "enterMemo": "Ingrese una nota de transacción", "slideConfirm": "Deslice para confirmar", "balance": "Equilibrar", - "unavailableAddress": "La dirección de la billetera que ingresó no es válida" + "unavailableAddress": "La dirección de la billetera que ingresó no es válida", + "advanced": "Avanzado", + "gasPrice": "Precio de Gas", + "gasLimit": "Límite de Gas", + "units": "Units" }, "add": { "title": "Agregar Wallet", diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 7b5878ed..66abf569 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -1048,11 +1048,9 @@ class Transfer extends Component { onSlidingComplete={(value) => this.onGasPriceSlidingComplete(value)} /> - Gas Price: - {' '} - {customGasPrice.div(1000000000).decimalPlaces(2).toString()} - {' '} - GWEI + + {` ${customGasPrice.div(1000000000).decimalPlaces(2).toString()} GWEI`} + @@ -1069,17 +1067,17 @@ class Transfer extends Component { /> - Gas Limit: - {' '} - {customGasLimit.decimalPlaces(2).toString()} - {' '} - Units + + + {` ${customGasLimit.decimalPlaces(2).toString()} `} + - {`Fee: ${valueCoin.decimalPlaces(2).toString()} USD`} + + {` ${valueCoin.decimalPlaces(2).toString()} USD`} @@ -1110,11 +1108,8 @@ class Transfer extends Component { /> - Fee: - {' '} - {customBtcFee.toString()} - {' '} - BTC + + {` ${customBtcFee.decimalPlaces(8).toString()} BTC`} ); @@ -1262,7 +1257,7 @@ class Transfer extends Component { - + Date: Wed, 23 Jun 2021 16:13:43 -0600 Subject: [PATCH 5/7] format: clear out comments --- src/pages/wallet/transfer.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 66abf569..54f7d109 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -313,7 +313,6 @@ class Transfer extends Component { customGasPrice: new BigNumber(0), customGasLimit: new BigNumber(0), feeSymbol: null, - feeSliderValue: 0, customGasPriceSliderValue: 0, customGasLimitSliderValue: 0, customBtcFeeSliderValue: 0, @@ -382,27 +381,13 @@ class Transfer extends Component { }); } - // async onConfirmSliderVerified() { - // this.setState({ isConfirm: true }); - // await this.confirm(); - // } - onCustomFeeSwitchValueChange(value, symbol) { - console.log('Test test'); - console.log(this.state); - console.log(this); - - /* console.log({ latestBlockMinimumGasPrice }); - console.log({ estimatedGasLimit }); */ - const { customFee } = this.state; this.setState({ isCustomFee: value }); if (customFee) { return; } if (value) { - // const feeSliderValue = latestBlockMinimumGasPrice; - if (symbol !== 'BTC') { const latestBlockMinimumGasPrice = this.latestBlockMinimumGasPrice.toNumber(); const estimatedGasLimit = this.estimatedGasLimit.toNumber(); @@ -415,7 +400,6 @@ class Transfer extends Component { } else { const customBtcFeeSliderValue = this.btcLowEstimatedFee.toNumber(); this.setState({ customBtcFeeSliderValue }); - // this.onCustomGasPriceSlideValueChange(customGasPriceSliderValue); this.onCustomBtcFeeSlideValueChange(customBtcFeeSliderValue); } } @@ -825,9 +809,6 @@ class Transfer extends Component { customFee = minCustomFee.plus((maxCustomFee.minus(minCustomFee)).times(value)); customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); } else { - // const { minCustomGasPrice, maxCustomGasPrice, gas } = this; - // this.customGasPrice = minCustomGasPrice.plus((maxCustomGasPrice.minus(minCustomGasPrice)).times(value)); - // customFee = common.convertUnitToCoinAmount(feeSymbol, this.customGasPrice.times(gas)); customFeeValue = common.getCoinValue(value, feeSymbol, type, currency, prices); } return { customFee, customFeeValue }; @@ -899,12 +880,9 @@ class Transfer extends Component { // Update custom fee if (isCustomFee) { - // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); - // const { customFee: newFee, customFeeValue } = this.calcCustomFee(feeSliderValue); const { customFee: newFee } = this.calcCustomFee(customGasPriceSliderValue * customGasLimitSliderValue); newCustomFee = newFee; - // this.setState({ customFee: newCustomFee, customFeeValue }); this.setState({ customFee: newCustomFee }); } @@ -1090,7 +1068,6 @@ class Transfer extends Component { const { customBtcFee, customBtcFeeSliderValue, } = this.state; - // const valueCoin = new BigNumber(this.calculateCoinValue(customGasPrice * customGasLimit)); console.log(customBtcFeeSliderValue); return ( From abc08ff3e5c9e77ed6e1d10396c93f1b84130027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Chavarr=C3=ADa?= Date: Thu, 24 Jun 2021 11:57:18 -0600 Subject: [PATCH 6/7] feat: translate advanced gas options --- src/common/translations/ja.json | 8 ++++++-- src/common/translations/ko.json | 8 ++++++-- src/common/translations/pt-BR.json | 6 +++++- src/common/translations/pt.json | 6 +++++- src/common/translations/ru.json | 8 ++++++-- src/common/translations/zh.json | 6 +++++- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/common/translations/ja.json b/src/common/translations/ja.json index 56adae1d..7e311b45 100644 --- a/src/common/translations/ja.json +++ b/src/common/translations/ja.json @@ -65,7 +65,11 @@ "enterMemo": "取引メモを入力", "slideConfirm": "スライドして確定", "balance": "残高", - "unavailableAddress": "入力したウォレットアドレスが無効です" + "unavailableAddress": "入力したウォレットアドレスが無効です", + "advanced": "高度な", + "gasPrice": "ガス価格", + "gasLimit": "ガス制限", + "units": "単位" }, "add": { "title": "ウォレットを追加", @@ -249,7 +253,7 @@ "address": "アドレス", "rnsName": "RNSニックネーム", "anotherAddress": "別のアドレス", - "nameTooShort": "ニックネームは、{{count}}文字以上で構成されています", + "nameTooShort": "ニックネームは、{{count}}文字以上で構成されています", "nameUnavailable": "入力したニックネームは使用できません", "nameAvailable": "入力したニックネームは利用可能です", "selectAddress": "アドレスを選択", diff --git a/src/common/translations/ko.json b/src/common/translations/ko.json index bee393d0..ebaa1857 100644 --- a/src/common/translations/ko.json +++ b/src/common/translations/ko.json @@ -65,7 +65,11 @@ "enterMemo": "거래 메모 입력", "slideConfirm": "화면을 밀어서 확인하십시오", "balance": "잔액", - "unavailableAddress": "유효하지 않은 월렛 주소를 입력하셨습니다" + "unavailableAddress": "유효하지 않은 월렛 주소를 입력하셨습니다", + "advanced": "많은", + "gasPrice": "가스 가격", + "gasLimit": "가스 한도", + "units": "단위" }, "add": { "title": "월렛 추가하기", @@ -249,7 +253,7 @@ "address": "주소", "rnsName": "RNS 별명", "anotherAddress": "다른 주소", - "nameTooShort": "별명은 최소 {{count}}자여야 합니다", + "nameTooShort": "별명은 최소 {{count}}자여야 합니다", "nameUnavailable": "입력하신 닉네임을 사용할 수 없습니다", "nameAvailable": "입력 한 별명을 사용할 수 있습니다.", "selectAddress": "주소 선택", diff --git a/src/common/translations/pt-BR.json b/src/common/translations/pt-BR.json index bcd79c2a..bfe4bfb7 100644 --- a/src/common/translations/pt-BR.json +++ b/src/common/translations/pt-BR.json @@ -66,7 +66,11 @@ "enterMemo": "Inserir uma nota de transação", "slideConfirm": "Deslize para confirmar", "balance": "Saldo", - "unavailableAddress": "O endereço da carteira digitado não é válido" + "unavailableAddress": "O endereço da carteira digitado não é válido", + "advanced": "Opciones Avanzadas", + "gasPrice": "Preço da Gás", + "gasLimit": "Limite de Gás", + "units": "Unidades" }, "add": { "title": "Adicionar carteira", diff --git a/src/common/translations/pt.json b/src/common/translations/pt.json index 372ae950..8334c804 100644 --- a/src/common/translations/pt.json +++ b/src/common/translations/pt.json @@ -66,7 +66,11 @@ "enterMemo": "Inserir uma nota de transação", "slideConfirm": "Deslize para confirmar", "balance": "Saldo", - "unavailableAddress": "O endereço da carteira digitado não é válido" + "unavailableAddress": "O endereço da carteira digitado não é válido", + "advanced": "Opciones Avanzadas", + "gasPrice": "Preço da Gás", + "gasLimit": "Limite de Gás", + "units": "Unidades" }, "add": { "title": "Adicionar carteira", diff --git a/src/common/translations/ru.json b/src/common/translations/ru.json index a2cf1f3d..a49d1614 100644 --- a/src/common/translations/ru.json +++ b/src/common/translations/ru.json @@ -65,7 +65,11 @@ "enterMemo": "Введите напоминание о транзакции", "slideConfirm": "Проведите для подтверждения", "balance": "Баланс", - "unavailableAddress": "Указанный адрес кошелька является недействительным" + "unavailableAddress": "Указанный адрес кошелька является недействительным", + "advanced": "Передовой", + "gasPrice": "Цена на газ", + "gasLimit": "Лимит газа", + "units": "Единицы измерения" }, "add": { "title": "Добавить кошелек", @@ -249,7 +253,7 @@ "address": "Адрес", "rnsName": "Псевдоним RNS", "anotherAddress": "Другой адрес", - "nameTooShort": "Псевдоним содержит не менее {{count}} символов", + "nameTooShort": "Псевдоним содержит не менее {{count}} символов", "nameUnavailable": "Извините, введенный ник недоступен", "nameAvailable": "Введенный никнейм доступен", "selectAddress": "Выберите адрес", diff --git a/src/common/translations/zh.json b/src/common/translations/zh.json index 202bdf07..0d408e39 100644 --- a/src/common/translations/zh.json +++ b/src/common/translations/zh.json @@ -65,7 +65,11 @@ "enterMemo": "请输入转账备注", "slideConfirm": "滑动以确认", "balance": "余额", - "unavailableAddress": "您输入的钱包地址无效" + "unavailableAddress": "您输入的钱包地址无效", + "advanced": "先进的", + "gasPrice": "汽油价格", + "gasLimit": "气体限制", + "units": "单位" }, "add": { "title": "创建钱包", From a0297c79be53ee0d2c32a575cae2a18b49ee8aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Chavarr=C3=ADa?= Date: Mon, 28 Jun 2021 09:19:59 -0600 Subject: [PATCH 7/7] format: remove comments and fix translations typos --- src/common/translations/pt-BR.json | 6 +++--- src/pages/wallet/transfer.js | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/common/translations/pt-BR.json b/src/common/translations/pt-BR.json index bfe4bfb7..37cc614c 100644 --- a/src/common/translations/pt-BR.json +++ b/src/common/translations/pt-BR.json @@ -67,9 +67,9 @@ "slideConfirm": "Deslize para confirmar", "balance": "Saldo", "unavailableAddress": "O endereço da carteira digitado não é válido", - "advanced": "Opciones Avanzadas", - "gasPrice": "Preço da Gás", - "gasLimit": "Limite de Gás", + "advanced": "Opções avançadas", + "gasPrice": "Preço Gás", + "gasLimit": "Limite Gás", "units": "Unidades" }, "add": { diff --git a/src/pages/wallet/transfer.js b/src/pages/wallet/transfer.js index 54f7d109..9c426927 100644 --- a/src/pages/wallet/transfer.js +++ b/src/pages/wallet/transfer.js @@ -341,10 +341,7 @@ class Transfer extends Component { const { symbol, type } = this.coin; if (prices && prices !== curPrices) { - // const { customFee, feeSymbol } = this.state; - // const customFeeValue = common.getCoinValue(customFee, feeSymbol, type, currency, prices); const amountPlaceholderText = Transfer.generateAmountPlaceholderText(symbol, type, currency, prices); - // this.setState({ customFeeValue amountPlaceholderText }); this.setState({ amountPlaceholderText }); } } @@ -920,11 +917,6 @@ class Transfer extends Component { this.setState({ feeSymbol, amountPlaceholderText }); } - // resetConfirm() { - // this.setState({ isConfirm: false }); - // this.confirmSlider.reset(); - // } - showInvalidAddressNotification() { const { addNotification } = this.props; const notification = createErrorNotification( @@ -988,7 +980,6 @@ class Transfer extends Component { symbol, type, address, needFetch: true, }); } - // this.resetConfirm(); } }