aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-11-14 00:36:52 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:22 +0800
commit7f2c5c09de67a67972fcbaae254d39aac6c96f56 (patch)
tree827332f85c8086dbdb427d6addbf10eef03a9bb6 /ui/app/components/send
parentfe535159bb3ec5849d670d9bc53067f5d6f330b7 (diff)
downloadtangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.tar.gz
tangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.tar.zst
tangerine-wallet-browser-7f2c5c09de67a67972fcbaae254d39aac6c96f56.zip
Uses more reliable api on main send screen; caches basic api results in modal
Diffstat (limited to 'ui/app/components/send')
-rw-r--r--ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js4
-rw-r--r--ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js2
-rw-r--r--ui/app/components/send/send.component.js4
-rw-r--r--ui/app/components/send/send.container.js2
-rw-r--r--ui/app/components/send/send.selectors.js4
-rw-r--r--ui/app/components/send/tests/send-component.test.js18
6 files changed, 9 insertions, 25 deletions
diff --git a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
index 39266e590..977f8ab3c 100644
--- a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
+++ b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
@@ -7,7 +7,7 @@ import {
} from '../../send.selectors.js'
import {
getBasicGasEstimateLoadingStatus,
- getRenderableEstimateDataForSmallButtons,
+ getRenderableEstimateDataForSmallButtonsFromGWEI,
getDefaultActiveButtonIndex,
} from '../../../../selectors/custom-gas'
import {
@@ -23,7 +23,7 @@ import SendGasRow from './send-gas-row.component'
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
function mapStateToProps (state) {
- const gasButtonInfo = getRenderableEstimateDataForSmallButtons(state)
+ const gasButtonInfo = getRenderableEstimateDataForSmallButtonsFromGWEI(state)
const activeButtonIndex = getDefaultActiveButtonIndex(gasButtonInfo, getGasPrice(state))
return {
diff --git a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
index 766bf6cab..f0c82e4f7 100644
--- a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
+++ b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
@@ -42,7 +42,7 @@ proxyquire('../send-gas-row.container.js', {
'../../../../actions': actionSpies,
'../../../../selectors/custom-gas': {
getBasicGasEstimateLoadingStatus: (s) => `mockBasicGasEstimateLoadingStatus:${s}`,
- getRenderableEstimateDataForSmallButtons: (s) => `mockGasButtonInfo:${s}`,
+ getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => `mockGasButtonInfo:${s}`,
getDefaultActiveButtonIndex: (gasButtonInfo, gasPrice) => gasButtonInfo.length + gasPrice.length,
},
'../../../../ducks/send.duck': sendDuckSpies,
diff --git a/ui/app/components/send/send.component.js b/ui/app/components/send/send.component.js
index 301acb1db..9b512aaf6 100644
--- a/ui/app/components/send/send.component.js
+++ b/ui/app/components/send/send.component.js
@@ -35,6 +35,7 @@ export default class SendTransactionScreen extends PersistentForm {
selectedToken: PropTypes.object,
tokenBalance: PropTypes.string,
tokenContract: PropTypes.object,
+ fetchBasicGasEstimates: PropTypes.func,
updateAndSetGasTotal: PropTypes.func,
updateSendErrors: PropTypes.func,
updateSendTokenBalance: PropTypes.func,
@@ -164,9 +165,8 @@ export default class SendTransactionScreen extends PersistentForm {
componentDidMount () {
this.props.fetchBasicGasEstimates()
- .then(basicEstimates => {
+ .then(() => {
this.updateGas()
- this.props.fetchGasEstimates(basicEstimates.blockTime)
})
}
diff --git a/ui/app/components/send/send.container.js b/ui/app/components/send/send.container.js
index ac804cf2a..402e4bbe5 100644
--- a/ui/app/components/send/send.container.js
+++ b/ui/app/components/send/send.container.js
@@ -38,7 +38,6 @@ import {
} from '../../ducks/send.duck'
import {
fetchBasicGasEstimates,
- fetchGasEstimates,
} from '../../ducks/gas.duck'
import {
calcGasTotal,
@@ -109,6 +108,5 @@ function mapDispatchToProps (dispatch) {
qrCodeDetected: (data) => dispatch(qrCodeDetected(data)),
updateSendTo: (to, nickname) => dispatch(updateSendTo(to, nickname)),
fetchBasicGasEstimates: () => dispatch(fetchBasicGasEstimates()),
- fetchGasEstimates: (blockTime) => dispatch(fetchGasEstimates(blockTime)),
}
}
diff --git a/ui/app/components/send/send.selectors.js b/ui/app/components/send/send.selectors.js
index 71eb93d61..443c82af5 100644
--- a/ui/app/components/send/send.selectors.js
+++ b/ui/app/components/send/send.selectors.js
@@ -11,7 +11,7 @@ const {
calcGasTotal,
} = require('./send.utils')
import {
- getAveragePriceEstimateInHexWEI,
+ getFastPriceEstimateInHexWEI,
} from '../../selectors/custom-gas'
const selectors = {
@@ -139,7 +139,7 @@ function getGasLimit (state) {
}
function getGasPrice (state) {
- return state.metamask.send.gasPrice || getAveragePriceEstimateInHexWEI(state)
+ return state.metamask.send.gasPrice || getFastPriceEstimateInHexWEI(state)
}
function getGasPriceFromRecentBlocks (state) {
diff --git a/ui/app/components/send/tests/send-component.test.js b/ui/app/components/send/tests/send-component.test.js
index 68d2fc47e..81955cc1d 100644
--- a/ui/app/components/send/tests/send-component.test.js
+++ b/ui/app/components/send/tests/send-component.test.js
@@ -3,17 +3,12 @@ import assert from 'assert'
import proxyquire from 'proxyquire'
import { shallow } from 'enzyme'
import sinon from 'sinon'
+import timeout from '../../../../lib/test-timeout'
import SendHeader from '../send-header/send-header.container'
import SendContent from '../send-content/send-content.component'
import SendFooter from '../send-footer/send-footer.container'
-function timeout (time) {
- return new Promise((resolve, reject) => {
- setTimeout(resolve, time || 1500)
- })
-}
-
const mockBasicGasEstimates = {
blockTime: 'mockBlockTime',
}
@@ -88,7 +83,7 @@ describe('Send Component', function () {
})
describe('componentDidMount', () => {
- it('should call props.fetchBasicGasEstimates', () => {
+ it('should call props.fetchBasicGasAndTimeEstimates', () => {
propsMethodSpies.fetchBasicGasEstimates.resetHistory()
assert.equal(propsMethodSpies.fetchBasicGasEstimates.callCount, 0)
wrapper.instance().componentDidMount()
@@ -103,15 +98,6 @@ describe('Send Component', function () {
await timeout(250)
assert.equal(SendTransactionScreen.prototype.updateGas.callCount, 1)
})
-
- it('should call props.fetchGasEstimates with the block time returned by fetchBasicGasEstimates', async () => {
- propsMethodSpies.fetchGasEstimates.resetHistory()
- assert.equal(propsMethodSpies.fetchGasEstimates.callCount, 0)
- wrapper.instance().componentDidMount()
- await timeout(250)
- assert.equal(propsMethodSpies.fetchGasEstimates.callCount, 1)
- assert.equal(propsMethodSpies.fetchGasEstimates.getCall(0).args[0], 'mockBlockTime')
- })
})
describe('componentWillUnmount', () => {