Bind SendTransactionScreen methods to this in constructor.

This commit is contained in:
Dan 2017-08-28 16:14:56 -02:30
parent a381ce43e8
commit af6e30b8ba
1 changed files with 20 additions and 9 deletions

View File

@ -64,6 +64,17 @@ function SendTransactionScreen () {
}, },
tooltipIsOpen: false, tooltipIsOpen: false,
} }
this.back = this.back.bind(this)
this.back = this.back.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.recipientDidChange = this.recipientDidChange.bind(this)
this.setCurrentCurrency = this.setCurrentCurrency.bind(this)
this.setCurrentCurrency = this.setCurrentCurrency.bind(this)
this.toggleTooltip = this.toggleTooltip.bind(this)
} }
SendTransactionScreen.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { SendTransactionScreen.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) {
@ -206,12 +217,12 @@ SendTransactionScreen.prototype.render = function () {
h('span', {}, [ h('span', {}, [
h('span', { h('span', {
className: currentCurrency === 'ETH' ? 'selected-currency' : 'unselected-currency', className: currentCurrency === 'ETH' ? 'selected-currency' : 'unselected-currency',
onClick: this.setCurrentCurrency.bind(this, 'ETH') onClick: () => this.setCurrentCurrency('ETH')
}, ['ETH']), }, ['ETH']),
'<>', '<>',
h('span', { h('span', {
className: currentCurrency === 'USD' ? 'selected-currency' : 'unselected-currency', className: currentCurrency === 'USD' ? 'selected-currency' : 'unselected-currency',
onClick: this.setCurrentCurrency.bind(this, 'USD'), onClick: () => this.setCurrentCurrency('USD'),
}, ['USD']), }, ['USD']),
]), //holding on icon from design ]), //holding on icon from design
]), ]),
@ -255,7 +266,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.bind(this)(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16)).toString(16), value: this.getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16)).toString(16),
conversionRate, conversionRate,
currentCurrency, currentCurrency,
style: { style: {
@ -277,7 +288,7 @@ SendTransactionScreen.prototype.render = function () {
className: 'send-tooltip', className: 'send-tooltip',
gasPrice: parseInt(this.state.newTx.gasPrice, 16), gasPrice: parseInt(this.state.newTx.gasPrice, 16),
gasLimit: parseInt(this.state.newTx.gas, 16), gasLimit: parseInt(this.state.newTx.gas, 16),
onClose: this.closeTooltip.bind(this), onClose: this.closeTooltip,
onFeeChange: ({gasLimit, gasPrice}) => { onFeeChange: ({gasLimit, gasPrice}) => {
this.setState({ this.setState({
newTx: Object.assign( newTx: Object.assign(
@ -341,7 +352,7 @@ SendTransactionScreen.prototype.render = function () {
h('section.flex-column.flex-center', [ h('section.flex-column.flex-center', [
h('button.btn-light', { h('button.btn-light', {
onClick: this.onSubmit.bind(this), onClick: this.onSubmit,
style: { style: {
marginTop: '8px', marginTop: '8px',
width: '8em', width: '8em',
@ -350,7 +361,7 @@ SendTransactionScreen.prototype.render = function () {
}, 'Next'), }, 'Next'),
h('button.btn-light', { h('button.btn-light', {
onClick: this.back.bind(this), onClick: this.back,
style: { style: {
background: '#F7F7F7', // $alabaster background: '#F7F7F7', // $alabaster
border: 'none', border: 'none',
@ -469,7 +480,7 @@ SendTransactionScreen.prototype.renderSendToken = function () {
h(EnsInput, { h(EnsInput, {
name: 'address', name: 'address',
placeholder: 'Recipient Address', placeholder: 'Recipient Address',
onChange: this.recipientDidChange.bind(this), onChange: this.recipientDidChange,
network, network,
identities, identities,
addressBook, addressBook,
@ -561,7 +572,7 @@ SendTransactionScreen.prototype.renderSendToken = function () {
h('section.flex-column.flex-center', [ h('section.flex-column.flex-center', [
h('button.btn-light', { h('button.btn-light', {
onClick: this.onSubmit.bind(this), onClick: this.onSubmit,
style: { style: {
marginTop: '8px', marginTop: '8px',
width: '8em', width: '8em',
@ -570,7 +581,7 @@ SendTransactionScreen.prototype.renderSendToken = function () {
}, 'Next'), }, 'Next'),
h('button.btn-light', { h('button.btn-light', {
onClick: this.back.bind(this), onClick: this.back,
style: { style: {
background: '#F7F7F7', // $alabaster background: '#F7F7F7', // $alabaster
border: 'none', border: 'none',