diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index d9ad2fbe6fd8..ce5773edd6ab 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -1318,41 +1318,6 @@ describe('Actions', function () { }) }) - describe('#updateNetworkNonce', function () { - let getTransactionCountSpy - - afterEach(function () { - getTransactionCountSpy.restore() - }) - - it('calls getTransactionCount', async function () { - const store = mockStore() - getTransactionCountSpy = sinon.spy(global.ethQuery, 'getTransactionCount') - - await store.dispatch(actions.updateNetworkNonce()) - assert(getTransactionCountSpy.calledOnce) - }) - - it('errors when getTransactionCount throws', async function () { - const store = mockStore() - const expectedActions = [ - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - getTransactionCountSpy = sinon.stub(global.ethQuery, 'getTransactionCount') - getTransactionCountSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - try { - await store.dispatch(actions.updateNetworkNonce()) - assert.fail('Should have thrown error') - } catch (_) { - assert.deepEqual(store.getActions(), expectedActions) - } - }) - }) - describe('#setUseBlockie', function () { let setUseBlockieSpy diff --git a/test/unit/ui/app/reducers/app.spec.js b/test/unit/ui/app/reducers/app.spec.js index d5a4531f79dc..b58b5306c153 100644 --- a/test/unit/ui/app/reducers/app.spec.js +++ b/test/unit/ui/app/reducers/app.spec.js @@ -376,13 +376,4 @@ describe('App State', function () { assert.equal(state.gasIsLoading, false) }) - - it('sets network nonce', function () { - const state = reduceApp(metamaskState, { - type: actions.SET_NETWORK_NONCE, - value: '33', - }) - - assert.equal(state.networkNonce, '33') - }) }) diff --git a/ui/app/components/app/transaction-list/transaction-list.component.js b/ui/app/components/app/transaction-list/transaction-list.component.js index 3f4a6210e3bd..39ca9ca69340 100644 --- a/ui/app/components/app/transaction-list/transaction-list.component.js +++ b/ui/app/components/app/transaction-list/transaction-list.component.js @@ -19,7 +19,6 @@ export default class TransactionList extends PureComponent { pendingTransactions: PropTypes.array, completedTransactions: PropTypes.array, selectedToken: PropTypes.object, - updateNetworkNonce: PropTypes.func, assetImages: PropTypes.object, fetchBasicGasAndTimeEstimates: PropTypes.func, fetchGasEstimates: PropTypes.func, @@ -30,14 +29,11 @@ export default class TransactionList extends PureComponent { componentDidMount () { const { pendingTransactions, - updateNetworkNonce, fetchBasicGasAndTimeEstimates, fetchGasEstimates, transactionTimeFeatureActive, } = this.props - updateNetworkNonce() - if (transactionTimeFeatureActive && pendingTransactions.length) { fetchBasicGasAndTimeEstimates() .then(({ blockTime }) => fetchGasEstimates(blockTime)) @@ -48,16 +44,11 @@ export default class TransactionList extends PureComponent { const { pendingTransactions: prevPendingTransactions = [] } = prevProps const { pendingTransactions = [], - updateNetworkNonce, fetchBasicGasAndTimeEstimates, fetchGasEstimates, transactionTimeFeatureActive, } = this.props - if (pendingTransactions.length > prevPendingTransactions.length) { - updateNetworkNonce() - } - const transactionTimeFeatureWasActivated = !prevProps.transactionTimeFeatureActive && transactionTimeFeatureActive const pendingTransactionAdded = pendingTransactions.length > 0 && prevPendingTransactions.length === 0 diff --git a/ui/app/components/app/transaction-list/transaction-list.container.js b/ui/app/components/app/transaction-list/transaction-list.container.js index 036d1e8b92eb..be8904974a2e 100644 --- a/ui/app/components/app/transaction-list/transaction-list.container.js +++ b/ui/app/components/app/transaction-list/transaction-list.container.js @@ -7,7 +7,6 @@ import { } from '../../../selectors/transactions' import { getSelectedAddress, getAssetImages, getFeatureFlags } from '../../../selectors/selectors' import { selectedTokenSelector } from '../../../selectors/tokens' -import { updateNetworkNonce } from '../../../store/actions' import { fetchBasicGasAndTimeEstimates, fetchGasEstimates } from '../../../ducks/gas/gas.duck' const mapStateToProps = (state) => { @@ -26,25 +25,12 @@ const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { return { - updateNetworkNonce: (address) => dispatch(updateNetworkNonce(address)), fetchGasEstimates: (blockTime) => dispatch(fetchGasEstimates(blockTime)), fetchBasicGasAndTimeEstimates: () => dispatch(fetchBasicGasAndTimeEstimates()), } } -const mergeProps = (stateProps, dispatchProps, ownProps) => { - const { selectedAddress, ...restStateProps } = stateProps - const { updateNetworkNonce, ...restDispatchProps } = dispatchProps - - return { - ...restStateProps, - ...restDispatchProps, - ...ownProps, - updateNetworkNonce: () => updateNetworkNonce(selectedAddress), - } -} - -const TransactionListContainer = connect(mapStateToProps, mapDispatchToProps, mergeProps)(TransactionList) +const TransactionListContainer = connect(mapStateToProps, mapDispatchToProps)(TransactionList) TransactionListContainer.propTypes = { isWideViewport: PropTypes.bool, diff --git a/ui/app/ducks/app/app.js b/ui/app/ducks/app/app.js index 16feeb73de00..a870f4751340 100644 --- a/ui/app/ducks/app/app.js +++ b/ui/app/ducks/app/app.js @@ -40,7 +40,6 @@ export default function reduceApp (state = {}, action) { buyView: {}, isMouseUser: false, gasIsLoading: false, - networkNonce: null, defaultHdPaths: { trezor: `m/44'/60'/0'/0`, ledger: `m/44'/60'/0'/0/0`, @@ -314,12 +313,6 @@ export default function reduceApp (state = {}, action) { gasIsLoading: false, } - case actionConstants.SET_NETWORK_NONCE: - return { - ...appState, - networkNonce: action.value, - } - case actionConstants.SET_PREVIOUS_PROVIDER: if (action.value === 'loading') { return appState diff --git a/ui/app/store/actionConstants.js b/ui/app/store/actionConstants.js index 3f6d7e2d03a7..10fc6b513631 100644 --- a/ui/app/store/actionConstants.js +++ b/ui/app/store/actionConstants.js @@ -40,7 +40,6 @@ export default { SHOW_SEND_TOKEN_PAGE: 'SHOW_SEND_TOKEN_PAGE', SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY', SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL', - SET_NETWORK_NONCE: 'SET_NETWORK_NONCE', // tx conf screen COMPLETED_TX: 'COMPLETED_TX', TRANSACTION_ERROR: 'TRANSACTION_ERROR', diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 595f62addd3a..4fd1f8500d04 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -1891,28 +1891,6 @@ export function completeOnboarding () { } } -export function setNetworkNonce (networkNonce) { - return { - type: actionConstants.SET_NETWORK_NONCE, - value: networkNonce, - } -} - -export function updateNetworkNonce (address) { - return (dispatch) => { - return new Promise((resolve, reject) => { - global.ethQuery.getTransactionCount(address, (err, data) => { - if (err) { - dispatch(displayWarning(err.message)) - return reject(err) - } - dispatch(setNetworkNonce(data)) - resolve(data) - }) - }) - } -} - export function setMouseUserState (isMouseUser) { return { type: actionConstants.SET_MOUSE_USER_STATE,