diff options
Diffstat (limited to 'ui/app/components')
6 files changed, 38 insertions, 34 deletions
diff --git a/ui/app/components/input-number.js b/ui/app/components/input-number.js index 01f751b69..59c6842ef 100644 --- a/ui/app/components/input-number.js +++ b/ui/app/components/input-number.js @@ -2,8 +2,10 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const { + addCurrencies, conversionGTE, conversionLTE, + subtractCurrencies, } = require('../conversion-util') module.exports = InputNumber @@ -49,11 +51,7 @@ InputNumber.prototype.setValue = function (newValue) { } InputNumber.prototype.render = function () { -<<<<<<< HEAD const { unitLabel, step = 1, placeholder, value } = this.props -======= - const { unitLabel, step = 1, placeholder, value = 0, min = -1, max = Infinity } = this.props ->>>>>>> Refactor and redesign confirm transaction views return h('div.customize-gas-input-wrapper', {}, [ h('input', { @@ -69,19 +67,11 @@ InputNumber.prototype.render = function () { h('span.gas-tooltip-input-detail', {}, [unitLabel]), h('div.gas-tooltip-input-arrows', {}, [ h('i.fa.fa-angle-up', { -<<<<<<< HEAD onClick: () => this.setValue(addCurrencies(value, step, { toNumericBase: 'dec' })), }), h('i.fa.fa-angle-down', { style: { cursor: 'pointer' }, onClick: () => this.setValue(subtractCurrencies(value, step, { toNumericBase: 'dec' })), -======= - onClick: () => this.setValue(Math.min(+value + step, max)), - }), - h('i.fa.fa-angle-down', { - style: { cursor: 'pointer' }, - onClick: () => this.setValue(Math.max(+value - step, min)), ->>>>>>> Refactor and redesign confirm transaction views }), ]), ]) diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js index dfbbd0177..1a399a464 100644 --- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -18,6 +18,7 @@ export default class ConfirmTransactionBase extends Component { // Redux props txData: PropTypes.object, tokenData: PropTypes.object, + methodData: PropTypes.object, tokenProps: PropTypes.object, isTxReprice: PropTypes.bool, nonce: PropTypes.string, @@ -245,7 +246,7 @@ export default class ConfirmTransactionBase extends Component { data, } = {}, } = {}, - tokenData: { + methodData: { name, params, } = {}, @@ -266,7 +267,12 @@ export default class ConfirmTransactionBase extends Component { </span> </div> <div className="confirm-page-container-content__data-box"> - { JSON.stringify(params, null, 2) } + <div className="confirm-page-container-content__data-field-label"> + { `${t('parameters')}:` } + </div> + <div> + <pre>{ JSON.stringify(params, null, 2) }</pre> + </div> </div> <div className="confirm-page-container-content__data-box-label"> {`${t('hexData')}:`} @@ -318,7 +324,7 @@ export default class ConfirmTransactionBase extends Component { fromAddress, toName, toAddress, - tokenData, + methodData, ethTransactionAmount, fiatTransactionAmount, valid: propsValid, @@ -336,7 +342,7 @@ export default class ConfirmTransactionBase extends Component { warning, } = this.props - const { name } = tokenData + const { name } = methodData const fiatConvertedAmount = formatCurrency(fiatTransactionAmount, currentCurrency) const { valid, errorMessage } = this.getError() diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js index 19c39aed9..4f1fb86c1 100644 --- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -21,6 +21,7 @@ const mapStateToProps = (state, props) => { fiatTransactionTotal, hexGasTotal, tokenData, + methodData, txData, tokenProps, nonce, @@ -60,6 +61,7 @@ const mapStateToProps = (state, props) => { hexGasTotal, txData, tokenData, + methodData, tokenProps, isTxReprice, currentCurrency, diff --git a/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.component.js b/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.component.js index 9ec0fc623..db28d0bad 100644 --- a/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.component.js +++ b/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.component.js @@ -11,7 +11,7 @@ import { CONFIRM_TOKEN_METHOD_PATH, SIGNATURE_REQUEST_PATH, } from '../../../routes' -import { isConfirmDeployContract, getTokenData } from './confirm-transaction-switch.util' +import { isConfirmDeployContract } from './confirm-transaction-switch.util' import { TOKEN_METHOD_TRANSFER, TOKEN_METHOD_APPROVE } from './confirm-transaction-switch.constants' export default class ConfirmTransactionSwitch extends Component { @@ -19,19 +19,29 @@ export default class ConfirmTransactionSwitch extends Component { confirmTransaction: PropTypes.object, } - redirectToTransaction (txData) { - const { id, txParams: { data } } = txData + redirectToTransaction () { + const { + confirmTransaction: { + txData, + methodData: { name }, + fetchingMethodData, + }, + } = this.props + const { id } = txData if (isConfirmDeployContract(txData)) { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_DEPLOY_CONTRACT_PATH}` return <Redirect to={{ pathname }} /> } - if (data) { - const tokenData = getTokenData(data) - const { name: tokenMethodName } = tokenData || {} + if (fetchingMethodData) { + return <Loading /> + } + + if (name) { + const methodName = name.toLowerCase() - switch (tokenMethodName) { + switch (methodName.toLowerCase()) { case TOKEN_METHOD_TRANSFER: { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${id}${CONFIRM_SEND_TOKEN_PATH}` return <Redirect to={{ pathname }} /> @@ -55,7 +65,7 @@ export default class ConfirmTransactionSwitch extends Component { const { confirmTransaction: { txData } } = this.props if (txData.txParams) { - return this.redirectToTransaction(txData) + return this.redirectToTransaction() } else if (txData.msgParams) { const pathname = `${CONFIRM_TRANSACTION_ROUTE}/${txData.id}${SIGNATURE_REQUEST_PATH}` return <Redirect to={{ pathname }} /> diff --git a/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.util.js b/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.util.js index dd1dec6ae..536aa5212 100644 --- a/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.util.js +++ b/ui/app/components/pages/confirm-transaction-switch/confirm-transaction-switch.util.js @@ -1,12 +1,4 @@ -import abi from 'human-standard-token-abi' -import abiDecoder from 'abi-decoder' -abiDecoder.addABI(abi) - export function isConfirmDeployContract (txData = {}) { const { txParams = {} } = txData return !txParams.to } - -export function getTokenData (data = {}) { - return abiDecoder.decodeMethod(data) -} diff --git a/ui/app/components/pages/confirm-transaction/confirm-transaction.component.js b/ui/app/components/pages/confirm-transaction/confirm-transaction.component.js index d4581e8ed..219f5b49a 100644 --- a/ui/app/components/pages/confirm-transaction/confirm-transaction.component.js +++ b/ui/app/components/pages/confirm-transaction/confirm-transaction.component.js @@ -85,8 +85,12 @@ export default class ConfirmTransaction extends Component { } } else if (unconfirmedTransactions.length) { const totalUnconfirmed = unconfirmedTransactions.length - const transactionId = unconfirmedTransactions[totalUnconfirmed - 1].id - setTransactionToConfirm(transactionId) + const transaction = unconfirmedTransactions[totalUnconfirmed - 1] + const { id: transactionId, loadingDefaults } = transaction + + if (!loadingDefaults) { + setTransactionToConfirm(transactionId) + } } } |