|
|
@ -10,12 +10,14 @@ const BN = ethUtil.BN |
|
|
|
const hexToBn = require('../../app/scripts/lib/hex-to-bn') |
|
|
|
const hexToBn = require('../../app/scripts/lib/hex-to-bn') |
|
|
|
const numericBalance = require('./util').numericBalance |
|
|
|
const numericBalance = require('./util').numericBalance |
|
|
|
const addressSummary = require('./util').addressSummary |
|
|
|
const addressSummary = require('./util').addressSummary |
|
|
|
|
|
|
|
const bnMultiplyByFraction = require('./util').bnMultiplyByFraction |
|
|
|
const isHex = require('./util').isHex |
|
|
|
const isHex = require('./util').isHex |
|
|
|
const EthBalance = require('./components/eth-balance') |
|
|
|
const EthBalance = require('./components/eth-balance') |
|
|
|
const EnsInput = require('./components/ens-input') |
|
|
|
const EnsInput = require('./components/ens-input') |
|
|
|
const FiatValue = require('./components/fiat-value.js') |
|
|
|
const FiatValue = require('./components/fiat-value.js') |
|
|
|
const GasTooltip = require('./components/gas-tooltip.js') |
|
|
|
const GasTooltip = require('./components/gas-tooltip.js') |
|
|
|
const { getSelectedIdentity } = require('./selectors') |
|
|
|
const { getSelectedIdentity } = require('./selectors') |
|
|
|
|
|
|
|
const getTxFeeBn = require('./util').getTxFeeBn |
|
|
|
|
|
|
|
|
|
|
|
const ARAGON = '960b236A07cf122663c4303350609A66A7B288C0' |
|
|
|
const ARAGON = '960b236A07cf122663c4303350609A66A7B288C0' |
|
|
|
|
|
|
|
|
|
|
@ -67,7 +69,6 @@ function SendTransactionScreen () { |
|
|
|
this.back = this.back.bind(this) |
|
|
|
this.back = this.back.bind(this) |
|
|
|
this.back = this.back.bind(this) |
|
|
|
this.back = this.back.bind(this) |
|
|
|
this.closeTooltip = this.closeTooltip.bind(this) |
|
|
|
this.closeTooltip = this.closeTooltip.bind(this) |
|
|
|
this.getTxFeeBn = this.getTxFeeBn.bind(this) |
|
|
|
|
|
|
|
this.onSubmit = this.onSubmit.bind(this) |
|
|
|
this.onSubmit = this.onSubmit.bind(this) |
|
|
|
this.onSubmit = this.onSubmit.bind(this) |
|
|
|
this.onSubmit = this.onSubmit.bind(this) |
|
|
|
this.recipientDidChange = this.recipientDidChange.bind(this) |
|
|
|
this.recipientDidChange = this.recipientDidChange.bind(this) |
|
|
@ -76,28 +77,6 @@ function SendTransactionScreen () { |
|
|
|
this.toggleTooltip = this.toggleTooltip.bind(this) |
|
|
|
this.toggleTooltip = this.toggleTooltip.bind(this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { |
|
|
|
|
|
|
|
const numBN = new BN(numerator) |
|
|
|
|
|
|
|
const denomBN = new BN(denominator) |
|
|
|
|
|
|
|
return targetBN.mul(numBN).div(denomBN) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.getTxFeeBn = function (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16)) { |
|
|
|
|
|
|
|
const { blockGasLimit } = this.props; |
|
|
|
|
|
|
|
const gasBn = hexToBn(gas) |
|
|
|
|
|
|
|
const gasLimit = new BN(parseInt(blockGasLimit)) |
|
|
|
|
|
|
|
const safeGasLimit = this.bnMultiplyByFraction(gasLimit, 19, 20).toString(10) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Gas Price
|
|
|
|
|
|
|
|
const gasPriceBn = hexToBn(gasPrice) |
|
|
|
|
|
|
|
const txFeeBn = gasBn.mul(gasPriceBn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fiatMultiplier = hexToBn((1000000000).toString(16)) |
|
|
|
|
|
|
|
const txFeeAsFiatBn = txFeeBn.mul(fiatMultiplier) |
|
|
|
|
|
|
|
return txFeeAsFiatBn; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendTransactionScreen.prototype.render = function () { |
|
|
|
SendTransactionScreen.prototype.render = function () { |
|
|
|
this.persistentFormParentId = 'send-tx-form' |
|
|
|
this.persistentFormParentId = 'send-tx-form' |
|
|
|
|
|
|
|
|
|
|
@ -113,6 +92,7 @@ SendTransactionScreen.prototype.render = function () { |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
currentCurrency, |
|
|
|
currentCurrency, |
|
|
|
} = props |
|
|
|
} = props |
|
|
|
|
|
|
|
const { blockGasLimit } = this.state |
|
|
|
|
|
|
|
|
|
|
|
console.log({ selectedIdentity, identities }) |
|
|
|
console.log({ selectedIdentity, identities }) |
|
|
|
console.log("SendTransactionScreen state:", this.state) |
|
|
|
console.log("SendTransactionScreen state:", this.state) |
|
|
@ -265,7 +245,7 @@ SendTransactionScreen.prototype.render = function () { |
|
|
|
h('div.large-input.send-screen-gas-input', {}, [ |
|
|
|
h('div.large-input.send-screen-gas-input', {}, [ |
|
|
|
currentCurrency === 'USD' |
|
|
|
currentCurrency === 'USD' |
|
|
|
? h(FiatValue, { |
|
|
|
? h(FiatValue, { |
|
|
|
value: this.getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16)).toString(16), |
|
|
|
value: getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16), blockGasLimit).toString(16), |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
currentCurrency, |
|
|
|
currentCurrency, |
|
|
|
style: { |
|
|
|
style: { |
|
|
@ -276,7 +256,7 @@ SendTransactionScreen.prototype.render = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
: h(EthBalance, { |
|
|
|
: h(EthBalance, { |
|
|
|
value: this.getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16)).toString(16), |
|
|
|
value: getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16), blockGasLimit).toString(16), |
|
|
|
currentCurrency, |
|
|
|
currentCurrency, |
|
|
|
conversionRate, |
|
|
|
conversionRate, |
|
|
|
showFiat: false, |
|
|
|
showFiat: false, |
|
|
|