aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pending-tx
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-03-29 23:00:44 +0800
committerDan <danjm.com@gmail.com>2018-03-29 23:12:38 +0800
commit0a711f0de0e342b24988a5da4ca5c64342153210 (patch)
tree9dd6014e6389cfad02d5380e6810a12fdf747b0a /ui/app/components/pending-tx
parent650b716f55fcfa809b22708b9ad43c8a0716f9fc (diff)
downloadtangerine-wallet-browser-0a711f0de0e342b24988a5da4ca5c64342153210.tar.gz
tangerine-wallet-browser-0a711f0de0e342b24988a5da4ca5c64342153210.tar.zst
tangerine-wallet-browser-0a711f0de0e342b24988a5da4ca5c64342153210.zip
Removes t from props via metamask-connect and instead places it on context via a provider.
Diffstat (limited to 'ui/app/components/pending-tx')
-rw-r--r--ui/app/components/pending-tx/confirm-deploy-contract.js32
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js26
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js42
-rw-r--r--ui/app/components/pending-tx/index.js2
4 files changed, 59 insertions, 43 deletions
diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js
index f41fa51e6..aa68a9eb0 100644
--- a/ui/app/components/pending-tx/confirm-deploy-contract.js
+++ b/ui/app/components/pending-tx/confirm-deploy-contract.js
@@ -1,5 +1,5 @@
const { Component } = require('react')
-const connect = require('../../metamask-connect')
+const connect = require('react-redux').connect
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const actions = require('../../actions')
@@ -32,7 +32,7 @@ class ConfirmDeployContract extends Component {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.displayWarning(this.props.t('invalidGasParams'))
+ this.props.displayWarning(this.context.t('invalidGasParams'))
this.setState({ submitting: false })
}
}
@@ -177,7 +177,7 @@ class ConfirmDeployContract extends Component {
return (
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency.toUpperCase()}`),
@@ -216,8 +216,8 @@ class ConfirmDeployContract extends Component {
return (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -247,11 +247,11 @@ class ConfirmDeployContract extends Component {
h('.page-container__header-row', [
h('span.page-container__back-button', {
onClick: () => backToAccountDetail(selectedAddress),
- }, this.props.t('back')),
+ }, this.context.t('back')),
window.METAMASK_UI_TYPE === 'notification' && h(NetworkDisplay),
]),
- h('.page-container__title', this.props.t('confirmContract')),
- h('.page-container__subtitle', this.props.t('pleaseReviewTransaction')),
+ h('.page-container__title', this.context.t('confirmContract')),
+ h('.page-container__subtitle', this.context.t('pleaseReviewTransaction')),
]),
// Main Send token Card
h('.page-container__content', [
@@ -274,7 +274,7 @@ class ConfirmDeployContract extends Component {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -282,9 +282,9 @@ class ConfirmDeployContract extends Component {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
h('div.confirm-screen-section-column', [
- h('div.confirm-screen-row-info', this.props.t('newContract')),
+ h('div.confirm-screen-row-info', this.context.t('newContract')),
]),
]),
@@ -302,12 +302,12 @@ class ConfirmDeployContract extends Component {
// Cancel Button
h('button.btn-cancel.page-container__footer-button.allcaps', {
onClick: event => this.cancel(event, txMeta),
- }, this.props.t('cancel')),
+ }, this.context.t('cancel')),
// Accept Button
h('button.btn-confirm.page-container__footer-button.allcaps', {
onClick: event => this.onSubmit(event),
- }, this.props.t('confirm')),
+ }, this.context.t('confirm')),
]),
]),
])
@@ -351,4 +351,8 @@ const mapDispatchToProps = dispatch => {
}
}
-module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract) \ No newline at end of file
+ConfirmDeployContract.contextTypes = {
+ t: PropTypes.func,
+}
+
+module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmDeployContract)
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index 255f0e8a2..b68de4704 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -1,5 +1,6 @@
const Component = require('react').Component
-const connect = require('../../metamask-connect')
+const PropTypes = require('prop-types')
+const connect = require('react-redux').connect
const h = require('react-hyperscript')
const inherits = require('util').inherits
const actions = require('../../actions')
@@ -18,8 +19,13 @@ const NetworkDisplay = require('../network-display')
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
+ConfirmSendEther.contextTypes = {
+ t: PropTypes.func,
+}
+
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmSendEther)
+
function mapStateToProps (state) {
const {
conversionRate,
@@ -196,7 +202,7 @@ ConfirmSendEther.prototype.getData = function () {
},
to: {
address: txParams.to,
- name: identities[txParams.to] ? identities[txParams.to].name : this.props.t('newRecipient'),
+ name: identities[txParams.to] ? identities[txParams.to].name : this.context.t('newRecipient'),
},
memo: txParams.memo || '',
gasFeeInFIAT,
@@ -297,7 +303,7 @@ ConfirmSendEther.prototype.render = function () {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -305,7 +311,7 @@ ConfirmSendEther.prototype.render = function () {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', toName),
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
@@ -313,7 +319,7 @@ ConfirmSendEther.prototype.render = function () {
]),
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h(GasFeeDisplay, {
gasTotal: gasTotal || gasFeeInHex,
@@ -326,8 +332,8 @@ ConfirmSendEther.prototype.render = function () {
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -428,10 +434,10 @@ ConfirmSendEther.prototype.render = function () {
clearSend()
this.cancel(event, txMeta)
},
- }, this.props.t('cancel')),
+ }, this.context.t('cancel')),
// Accept Button
- h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]),
+ h('button.btn-confirm.page-container__footer-button.allcaps', [this.context.t('confirm')]),
]),
]),
])
@@ -447,7 +453,7 @@ ConfirmSendEther.prototype.onSubmit = function (event) {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.dispatch(actions.displayWarning(this.props.t('invalidGasParams')))
+ this.props.dispatch(actions.displayWarning(this.context.t('invalidGasParams')))
this.setState({ submitting: false })
}
}
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index 3e66705ae..7fe260a61 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -1,5 +1,6 @@
const Component = require('react').Component
-const connect = require('../../metamask-connect')
+const PropTypes = require('prop-types')
+const connect = require('react-redux').connect
const h = require('react-hyperscript')
const inherits = require('util').inherits
const tokenAbi = require('human-standard-token-abi')
@@ -28,8 +29,13 @@ const {
getSelectedTokenContract,
} = require('../../selectors')
+ConfirmSendToken.contextTypes = {
+ t: PropTypes.func,
+}
+
module.exports = connect(mapStateToProps, mapDispatchToProps)(ConfirmSendToken)
+
function mapStateToProps (state, ownProps) {
const { token: { symbol }, txData } = ownProps
const { txParams } = txData || {}
@@ -168,7 +174,7 @@ ConfirmSendToken.prototype.getAmount = function () {
? +(sendTokenAmount * tokenExchangeRate * conversionRate).toFixed(2)
: null,
token: typeof value === 'undefined'
- ? this.props.t('unknown')
+ ? this.context.t('unknown')
: +sendTokenAmount.toFixed(decimals),
}
@@ -240,7 +246,7 @@ ConfirmSendToken.prototype.getData = function () {
},
to: {
address: value,
- name: identities[value] ? identities[value].name : this.props.t('newRecipient'),
+ name: identities[value] ? identities[value].name : this.context.t('newRecipient'),
},
memo: txParams.memo || '',
}
@@ -286,7 +292,7 @@ ConfirmSendToken.prototype.renderGasFee = function () {
return (
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('gasFee') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('gasFee') ]),
h('div.confirm-screen-section-column', [
h(GasFeeDisplay, {
gasTotal: gasTotal || gasFeeInHex,
@@ -308,8 +314,8 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () {
? (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
@@ -321,13 +327,13 @@ ConfirmSendToken.prototype.renderTotalPlusGas = function () {
: (
h('section.flex-row.flex-center.confirm-screen-row.confirm-screen-total-box ', [
h('div.confirm-screen-section-column', [
- h('span.confirm-screen-label', [ this.props.t('total') + ' ' ]),
- h('div.confirm-screen-total-box__subtitle', [ this.props.t('amountPlusGas') ]),
+ h('span.confirm-screen-label', [ this.context.t('total') + ' ' ]),
+ h('div.confirm-screen-total-box__subtitle', [ this.context.t('amountPlusGas') ]),
]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', `${tokenAmount} ${symbol}`),
- h('div.confirm-screen-row-detail', `+ ${fiatGas} ${currentCurrency} ${this.props.t('gas')}`),
+ h('div.confirm-screen-row-detail', `+ ${fiatGas} ${currentCurrency} ${this.context.t('gas')}`),
]),
])
)
@@ -350,10 +356,10 @@ ConfirmSendToken.prototype.render = function () {
this.inputs = []
const isTxReprice = Boolean(txMeta.lastGasPrice)
- const title = isTxReprice ? this.props.t('reprice_title') : this.props.t('confirm')
+ const title = isTxReprice ? this.context.t('reprice_title') : this.context.t('confirm')
const subtitle = isTxReprice
- ? this.props.t('reprice_subtitle')
- : this.props.t('pleaseReviewTransaction')
+ ? this.context.t('reprice_subtitle')
+ : this.context.t('pleaseReviewTransaction')
return (
h('div.confirm-screen-container.confirm-send-token', [
@@ -362,7 +368,7 @@ ConfirmSendToken.prototype.render = function () {
h('div.page-container__header', [
!txMeta.lastGasPrice && h('button.confirm-screen-back-button', {
onClick: () => editTransaction(txMeta),
- }, this.props.t('edit')),
+ }, this.context.t('edit')),
h('div.page-container__title', title),
h('div.page-container__subtitle', subtitle),
]),
@@ -406,7 +412,7 @@ ConfirmSendToken.prototype.render = function () {
h('div.confirm-screen-rows', [
h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('from') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('from') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', fromName),
h('div.confirm-screen-row-detail', `...${fromAddress.slice(fromAddress.length - 4)}`),
@@ -414,7 +420,7 @@ ConfirmSendToken.prototype.render = function () {
]),
toAddress && h('section.flex-row.flex-center.confirm-screen-row', [
- h('span.confirm-screen-label.confirm-screen-section-column', [ this.props.t('to') ]),
+ h('span.confirm-screen-label.confirm-screen-section-column', [ this.context.t('to') ]),
h('div.confirm-screen-section-column', [
h('div.confirm-screen-row-info', toName),
h('div.confirm-screen-row-detail', `...${toAddress.slice(toAddress.length - 4)}`),
@@ -436,10 +442,10 @@ ConfirmSendToken.prototype.render = function () {
// Cancel Button
h('button.btn-cancel.page-container__footer-button.allcaps', {
onClick: (event) => this.cancel(event, txMeta),
- }, this.props.t('cancel')),
+ }, this.context.t('cancel')),
// Accept Button
- h('button.btn-confirm.page-container__footer-button.allcaps', [this.props.t('confirm')]),
+ h('button.btn-confirm.page-container__footer-button.allcaps', [this.context.t('confirm')]),
]),
]),
]),
@@ -456,7 +462,7 @@ ConfirmSendToken.prototype.onSubmit = function (event) {
if (valid && this.verifyGasParams()) {
this.props.sendTransaction(txMeta, event)
} else {
- this.props.dispatch(actions.displayWarning(this.props.t('invalidGasParams')))
+ this.props.dispatch(actions.displayWarning(this.context.t('invalidGasParams')))
this.setState({ submitting: false })
}
}
diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js
index 0a8813b03..acdd99364 100644
--- a/ui/app/components/pending-tx/index.js
+++ b/ui/app/components/pending-tx/index.js
@@ -1,5 +1,5 @@
const Component = require('react').Component
-const connect = require('../../metamask-connect')
+const connect = require('react-redux').connect
const h = require('react-hyperscript')
const clone = require('clone')
const abi = require('human-standard-token-abi')