Fix consistent-return issues (#9192)

See [`consistent-return`](https://eslint.org/docs/rules/consistent-return) for more information.

This change enables `consistent-return` and fixes the issues raised by the rule.
feature/default_network_editable
Whymarrh Whitby 4 years ago committed by GitHub
parent 885125ad03
commit a8863a3446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc.js
  2. 2
      app/scripts/background.js
  3. 2
      app/scripts/contentscript.js
  4. 12
      app/scripts/controllers/network/middleware/pending.js
  5. 11
      app/scripts/controllers/network/network.js
  6. 3
      app/scripts/controllers/permissions/permissionsLog.js
  7. 4
      app/scripts/controllers/transactions/index.js
  8. 2
      app/scripts/controllers/transactions/pending-tx-tracker.js
  9. 3
      app/scripts/lib/account-tracker.js
  10. 15
      app/scripts/lib/decrypt-message-manager.js
  11. 12
      app/scripts/lib/encryption-public-key-manager.js
  12. 12
      app/scripts/lib/personal-message-manager.js
  13. 2
      app/scripts/lib/setupSentry.js
  14. 4
      app/scripts/lib/util.js
  15. 3
      app/scripts/metamask-controller.js
  16. 6
      app/scripts/ui.js
  17. 4
      development/verify-locale-strings.js
  18. 2
      test/e2e/fixture-server.js
  19. 3
      test/e2e/mock-3box/server.js
  20. 3
      test/unit/app/controllers/metamask-controller-test.js
  21. 6
      test/unit/app/nodeify-test.js
  22. 1
      ui/app/components/app/connected-accounts-list/connected-accounts-list.component.js
  23. 4
      ui/app/components/app/modals/edit-approval-permission/edit-approval-permission.component.js
  24. 2
      ui/app/components/ui/page-container/page-container.component.js
  25. 2
      ui/app/contexts/metametrics.js
  26. 3
      ui/app/helpers/utils/switch-direction.js
  27. 2
      ui/app/helpers/utils/token-util.js
  28. 2
      ui/app/hooks/tests/useCancelTransaction.test.js
  29. 1
      ui/app/hooks/tests/useCurrencyDisplay.test.js
  30. 4
      ui/app/hooks/useTimeout.js
  31. 1
      ui/app/hooks/useTransactionTimeRemaining.js
  32. 2
      ui/app/pages/create-account/connect-hardware/index.js
  33. 3
      ui/app/pages/create-account/import-account/json.js
  34. 4
      ui/app/pages/mobile-sync/mobile-sync.component.js
  35. 3
      ui/app/pages/permissions-connect/permissions-connect.component.js
  36. 2
      ui/app/pages/send/send-content/add-recipient/add-recipient.component.js
  37. 4
      ui/app/pages/send/send-content/add-recipient/ens-input.component.js
  38. 2
      ui/app/pages/send/send-content/send-content.component.js
  39. 3
      ui/app/pages/send/send.component.js
  40. 2
      ui/app/pages/send/send.utils.js
  41. 1
      ui/app/pages/settings/contact-list-tab/contact-list-tab.component.js
  42. 189
      ui/app/store/actions.js
  43. 6
      ui/index.js

@ -44,6 +44,7 @@ module.exports = {
/* TODO: Remove these when upgrading to `@metamask/eslint-config@2` */ /* TODO: Remove these when upgrading to `@metamask/eslint-config@2` */
'array-callback-return': 'error', 'array-callback-return': 'error',
'callback-return': 'error', 'callback-return': 'error',
'consistent-return': 'error',
'global-require': 'error', 'global-require': 'error',
'guard-for-in': 'error', 'guard-for-in': 'error',
'no-case-declarations': 'error', 'no-case-declarations': 'error',

@ -327,7 +327,7 @@ function setupController (initState, initLangCode) {
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName] const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
if (metamaskBlockedPorts.includes(remotePort.name)) { if (metamaskBlockedPorts.includes(remotePort.name)) {
return false return
} }
if (isMetaMaskInternalProcess) { if (isMetaMaskInternalProcess) {

@ -228,7 +228,7 @@ function redirectToPhishingWarning () {
async function domIsReady () { async function domIsReady () {
// already loaded // already loaded
if (['interactive', 'complete'].includes(document.readyState)) { if (['interactive', 'complete'].includes(document.readyState)) {
return return undefined
} }
// wait for load // wait for load
return new Promise((resolve) => window.addEventListener('DOMContentLoaded', resolve, { once: true })) return new Promise((resolve) => window.addEventListener('DOMContentLoaded', resolve, { once: true }))

@ -5,11 +5,13 @@ export function createPendingNonceMiddleware ({ getPendingNonce }) {
return createAsyncMiddleware(async (req, res, next) => { return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req const { method, params } = req
if (method !== 'eth_getTransactionCount') { if (method !== 'eth_getTransactionCount') {
return next() next()
return
} }
const [param, blockRef] = params const [param, blockRef] = params
if (blockRef !== 'pending') { if (blockRef !== 'pending') {
return next() next()
return
} }
res.result = await getPendingNonce(param) res.result = await getPendingNonce(param)
}) })
@ -19,12 +21,14 @@ export function createPendingTxMiddleware ({ getPendingTransactionByHash }) {
return createAsyncMiddleware(async (req, res, next) => { return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req const { method, params } = req
if (method !== 'eth_getTransactionByHash') { if (method !== 'eth_getTransactionByHash') {
return next() next()
return
} }
const [hash] = params const [hash] = params
const txMeta = getPendingTransactionByHash(hash) const txMeta = getPendingTransactionByHash(hash)
if (!txMeta) { if (!txMeta) {
return next() next()
return
} }
res.result = formatTxMetaForRpcResult(txMeta) res.result = formatTxMetaForRpcResult(txMeta)
}) })

@ -93,7 +93,8 @@ export default class NetworkController extends EventEmitter {
setNetworkState (network, type) { setNetworkState (network, type) {
if (network === 'loading') { if (network === 'loading') {
return this.networkStore.putState(network) this.networkStore.putState(network)
return
} }
// type must be defined // type must be defined
@ -101,7 +102,7 @@ export default class NetworkController extends EventEmitter {
return return
} }
network = networks.networkList[type]?.chainId || network network = networks.networkList[type]?.chainId || network
return this.networkStore.putState(network) this.networkStore.putState(network)
} }
isNetworkLoading () { isNetworkLoading () {
@ -111,7 +112,8 @@ export default class NetworkController extends EventEmitter {
lookupNetwork () { lookupNetwork () {
// Prevent firing when provider is not defined. // Prevent firing when provider is not defined.
if (!this._provider) { if (!this._provider) {
return log.warn('NetworkController - lookupNetwork aborted due to missing provider') log.warn('NetworkController - lookupNetwork aborted due to missing provider')
return
} }
const { type } = this.providerStore.getState() const { type } = this.providerStore.getState()
const ethQuery = new EthQuery(this._provider) const ethQuery = new EthQuery(this._provider)
@ -120,7 +122,8 @@ export default class NetworkController extends EventEmitter {
const currentNetwork = this.getNetworkState() const currentNetwork = this.getNetworkState()
if (initialNetwork === currentNetwork) { if (initialNetwork === currentNetwork) {
if (err) { if (err) {
return this.setNetworkState('loading') this.setNetworkState('loading')
return
} }
log.info('web3.getNetwork returned ' + network) log.info('web3.getNetwork returned ' + network)
this.setNetworkState(network, type) this.setNetworkState(network, type)

@ -116,7 +116,8 @@ export default class PermissionsLogController {
requestedMethods = [ 'eth_accounts' ] requestedMethods = [ 'eth_accounts' ]
} else { } else {
// no-op // no-op
return next() next()
return
} }
// call next with a return handler for capturing the response // call next with a return handler for capturing the response

@ -287,11 +287,11 @@ export default class TransactionController extends EventEmitter {
/** /**
* Gets default gas price, or returns `undefined` if gas price is already set * Gets default gas price, or returns `undefined` if gas price is already set
* @param {Object} txMeta - The txMeta object * @param {Object} txMeta - The txMeta object
* @returns {Promise<string>} The default gas price * @returns {Promise<string|undefined>} The default gas price
*/ */
async _getDefaultGasPrice (txMeta) { async _getDefaultGasPrice (txMeta) {
if (txMeta.txParams.gasPrice) { if (txMeta.txParams.gasPrice) {
return return undefined
} }
const gasPrice = await this.query.gasPrice() const gasPrice = await this.query.gasPrice()

@ -129,7 +129,7 @@ export default class PendingTransactionTracker extends EventEmitter {
// Exponential backoff to limit retries at publishing // Exponential backoff to limit retries at publishing
if (txBlockDistance <= Math.pow(2, retryCount) - 1) { if (txBlockDistance <= Math.pow(2, retryCount) - 1) {
return return undefined
} }
// Only auto-submit already-signed txs: // Only auto-submit already-signed txs:

@ -256,7 +256,8 @@ export default class AccountTracker {
ethContract.balances(addresses, ethBalance, (error, result) => { ethContract.balances(addresses, ethBalance, (error, result) => {
if (error) { if (error) {
log.warn(`MetaMask - Account Tracker single call balance fetch failed`, error) log.warn(`MetaMask - Account Tracker single call balance fetch failed`, error)
return Promise.all(addresses.map(this._updateAccount.bind(this))) Promise.all(addresses.map(this._updateAccount.bind(this)))
return
} }
addresses.forEach((address, index) => { addresses.forEach((address, index) => {
const balance = bnToHex(result[index]) const balance = bnToHex(result[index])

@ -82,19 +82,24 @@ export default class DecryptMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) { addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!msgParams.from) { if (!msgParams.from) {
return reject(new Error('MetaMask Decryption: from field is required.')) reject(new Error('MetaMask Decryption: from field is required.'))
return
} }
const msgId = this.addUnapprovedMessage(msgParams, req) const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => { this.once(`${msgId}:finished`, (data) => {
switch (data.status) { switch (data.status) {
case 'decrypted': case 'decrypted':
return resolve(data.rawData) resolve(data.rawData)
return
case 'rejected': case 'rejected':
return reject(ethErrors.provider.userRejectedRequest('MetaMask Decryption: User denied message decryption.')) reject(ethErrors.provider.userRejectedRequest('MetaMask Decryption: User denied message decryption.'))
return
case 'errored': case 'errored':
return reject(new Error('This message cannot be decrypted')) reject(new Error('This message cannot be decrypted'))
return
default: default:
return reject(new Error(`MetaMask Decryption: Unknown problem: ${JSON.stringify(msgParams)}`)) reject(new Error(`MetaMask Decryption: Unknown problem: ${JSON.stringify(msgParams)}`))
return
} }
}) })
}) })

@ -79,17 +79,21 @@ export default class EncryptionPublicKeyManager extends EventEmitter {
addUnapprovedMessageAsync (address, req) { addUnapprovedMessageAsync (address, req) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!address) { if (!address) {
return reject(new Error('MetaMask Message: address field is required.')) reject(new Error('MetaMask Message: address field is required.'))
return
} }
const msgId = this.addUnapprovedMessage(address, req) const msgId = this.addUnapprovedMessage(address, req)
this.once(`${msgId}:finished`, (data) => { this.once(`${msgId}:finished`, (data) => {
switch (data.status) { switch (data.status) {
case 'received': case 'received':
return resolve(data.rawData) resolve(data.rawData)
return
case 'rejected': case 'rejected':
return reject(ethErrors.provider.userRejectedRequest('MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.')) reject(ethErrors.provider.userRejectedRequest('MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.'))
return
default: default:
return reject(new Error(`MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(address)}`)) reject(new Error(`MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(address)}`))
return
} }
}) })
}) })

@ -85,17 +85,21 @@ export default class PersonalMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) { addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!msgParams.from) { if (!msgParams.from) {
return reject(new Error('MetaMask Message Signature: from field is required.')) reject(new Error('MetaMask Message Signature: from field is required.'))
return
} }
const msgId = this.addUnapprovedMessage(msgParams, req) const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => { this.once(`${msgId}:finished`, (data) => {
switch (data.status) { switch (data.status) {
case 'signed': case 'signed':
return resolve(data.rawSig) resolve(data.rawSig)
return
case 'rejected': case 'rejected':
return reject(ethErrors.provider.userRejectedRequest('MetaMask Message Signature: User denied message signature.')) reject(ethErrors.provider.userRejectedRequest('MetaMask Message Signature: User denied message signature.'))
return
default: default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
return
} }
}) })
}) })

@ -72,7 +72,7 @@ export default function setupSentry ({ release, getState }) {
let sentryTarget let sentryTarget
if (METAMASK_DEBUG) { if (METAMASK_DEBUG) {
return return undefined
} else if (METAMASK_ENVIRONMENT === 'production') { } else if (METAMASK_ENVIRONMENT === 'production') {
if (!process.env.SENTRY_DSN) { if (!process.env.SENTRY_DSN) {
throw new Error(`Missing SENTRY_DSN environment variable in production environment`) throw new Error(`Missing SENTRY_DSN environment variable in production environment`)

@ -135,12 +135,12 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) {
/** /**
* Returns an Error if extension.runtime.lastError is present * Returns an Error if extension.runtime.lastError is present
* this is a workaround for the non-standard error object that's used * this is a workaround for the non-standard error object that's used
* @returns {Error} * @returns {Error|undefined}
*/ */
function checkForError () { function checkForError () {
const lastError = extension.runtime.lastError const lastError = extension.runtime.lastError
if (!lastError) { if (!lastError) {
return return undefined
} }
// if it quacks like an Error, its an Error // if it quacks like an Error, its an Error
if (lastError.stack && lastError.message) { if (lastError.stack && lastError.message) {

@ -1349,7 +1349,7 @@ export default class MetamaskController extends EventEmitter {
* Triggers the callback in newUnsignedTypedMessage. * Triggers the callback in newUnsignedTypedMessage.
* *
* @param {Object} msgParams - The params passed to eth_signTypedData. * @param {Object} msgParams - The params passed to eth_signTypedData.
* @returns {Object} - Full state update. * @returns {Object|undefined} - Full state update.
*/ */
async signTypedMessage (msgParams) { async signTypedMessage (msgParams) {
log.info('MetaMaskController - eth_signTypedData') log.info('MetaMaskController - eth_signTypedData')
@ -1372,6 +1372,7 @@ export default class MetamaskController extends EventEmitter {
} catch (error) { } catch (error) {
log.info('MetaMaskController - eth_signTypedData failed.', error) log.info('MetaMaskController - eth_signTypedData failed.', error)
this.typedMessageManager.errorMessage(msgId, error) this.typedMessageManager.errorMessage(msgId, error)
return undefined
} }
} }

@ -62,7 +62,8 @@ async function start () {
const container = document.getElementById('app-content') const container = document.getElementById('app-content')
initializeUi(tab, container, connectionStream, (err, store) => { initializeUi(tab, container, connectionStream, (err, store) => {
if (err) { if (err) {
return displayCriticalError(container, err) displayCriticalError(container, err)
return
} }
const state = store.getState() const state = store.getState()
@ -102,7 +103,8 @@ async function queryCurrentActiveTab (windowType) {
function initializeUi (activeTab, container, connectionStream, cb) { function initializeUi (activeTab, container, connectionStream, cb) {
connectToAccountManager(connectionStream, (err, backgroundConnection) => { connectToAccountManager(connectionStream, (err, backgroundConnection) => {
if (err) { if (err) {
return cb(err) cb(err)
return
} }
launchMetaMaskUi({ launchMetaMaskUi({

@ -97,6 +97,7 @@ async function getLocale (code) {
log.error(`Error opening your locale ("${code}") file: `, e) log.error(`Error opening your locale ("${code}") file: `, e)
} }
process.exit(1) process.exit(1)
return undefined
} }
} }
@ -111,6 +112,7 @@ async function writeLocale (code, locale) {
log.error(`Error writing your locale ("${code}") file: `, e) log.error(`Error writing your locale ("${code}") file: `, e)
} }
process.exit(1) process.exit(1)
return undefined
} }
} }
@ -156,6 +158,8 @@ async function verifyLocale (code, fix = false) {
} }
return true return true
} }
return false
} }
async function verifyEnglishLocale (fix = false) { async function verifyEnglishLocale (fix = false) {

@ -44,7 +44,7 @@ class FixtureServer {
return return
} }
return new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
this._server.close() this._server.close()
this._server.once('error', reject) this._server.once('error', reject)
this._server.once('close', resolve) this._server.once('close', resolve)

@ -32,6 +32,7 @@ const server = http.createServer(requestHandler)
server.listen(port, (err) => { server.listen(port, (err) => {
if (err) { if (err) {
return console.log('mock 3box server error: ', err) console.log('mock 3box server error: ', err)
return
} }
}) })

@ -819,7 +819,8 @@ describe('MetaMaskController', function () {
const { promise, resolve } = deferredPromise() const { promise, resolve } = deferredPromise()
const streamTest = createThoughStream((chunk, _, cb) => { const streamTest = createThoughStream((chunk, _, cb) => {
if (chunk.name !== 'phishing') { if (chunk.name !== 'phishing') {
return cb() cb()
return
} }
assert.equal(chunk.data.hostname, (new URL(phishingMessageSender.url)).hostname) assert.equal(chunk.data.hostname, (new URL(phishingMessageSender.url)).hostname)
resolve() resolve()

@ -37,7 +37,8 @@ describe('nodeify', function () {
try { try {
nodified((err, result) => { nodified((err, result) => {
if (err) { if (err) {
return done(new Error(`should not have thrown any error: ${err.message}`)) done(new Error(`should not have thrown any error: ${err.message}`))
return
} }
assert.equal(42, result, 'got expected result') assert.equal(42, result, 'got expected result')
}) })
@ -54,7 +55,8 @@ describe('nodeify', function () {
try { try {
nodified((err, result) => { nodified((err, result) => {
if (result) { if (result) {
return done(new Error('should not have returned any result')) done(new Error('should not have returned any result'))
return
} }
assert.ok(err, 'got expected error') assert.ok(err, 'got expected error')
assert.ok(err.message.includes('boom!'), 'got expected error message') assert.ok(err.message.includes('boom!'), 'got expected error message')

@ -37,6 +37,7 @@ export default class ConnectedAccountsList extends PureComponent {
`Warning: Failed prop type: '${propName}' of component '${componentName}' requires prop 'removePermittedAccount'.`, `Warning: Failed prop type: '${propName}' of component '${componentName}' requires prop 'removePermittedAccount'.`,
) )
} }
return undefined
}, },
} }

@ -167,7 +167,7 @@ export default class EditApprovalPermission extends PureComponent {
const { selectedOptionIsUnlimited, customSpendLimit } = this.state const { selectedOptionIsUnlimited, customSpendLimit } = this.state
if (selectedOptionIsUnlimited || !customSpendLimit) { if (selectedOptionIsUnlimited || !customSpendLimit) {
return return undefined
} }
let customSpendLimitNumber let customSpendLimitNumber
@ -186,6 +186,8 @@ export default class EditApprovalPermission extends PureComponent {
if (customSpendLimitNumber.greaterThan(maxTokenAmount)) { if (customSpendLimitNumber.greaterThan(maxTokenAmount)) {
return t('spendLimitTooLarge') return t('spendLimitTooLarge')
} }
return undefined
} }
render () { render () {

@ -41,7 +41,7 @@ export default class PageContainer extends PureComponent {
const { tabsComponent } = this.props const { tabsComponent } = this.props
if (!tabsComponent) { if (!tabsComponent) {
return return null
} }
const numberOfTabs = React.Children.count(tabsComponent.props.children) const numberOfTabs = React.Children.count(tabsComponent.props.children)

@ -80,6 +80,8 @@ export function MetaMetricsProvider ({ children }) {
...overrides, ...overrides,
}) })
} }
return undefined
}, [ }, [
network, network,
environmentType, environmentType,

@ -1,6 +1,7 @@
/** /**
* Switch the CSS stylesheet used between 'rtl' and 'ltr' * Switch the CSS stylesheet used between 'rtl' and 'ltr'
* @param {('ltr' | 'rtl')} direction - Text direction, either left-to-right (ltr) or right-to-left (rtl) * @param {('ltr' | 'rtl')} direction - Text direction, either left-to-right (ltr) or right-to-left (rtl)
* @return {Promise<void>}
*/ */
const switchDirection = async (direction) => { const switchDirection = async (direction) => {
if (direction === 'auto') { if (direction === 'auto') {
@ -25,6 +26,8 @@ const switchDirection = async (direction) => {
updatedLink.onerror = () => reject(new Error(`Failed to load '${direction}' stylesheet`)) updatedLink.onerror = () => reject(new Error(`Failed to load '${direction}' stylesheet`))
}) })
} }
return undefined
} }
export default switchDirection export default switchDirection

@ -23,6 +23,7 @@ async function getSymbolFromContract (tokenAddress) {
return result[0] return result[0]
} catch (error) { } catch (error) {
log.warn(`symbol() call for token at address ${tokenAddress} resulted in error:`, error) log.warn(`symbol() call for token at address ${tokenAddress} resulted in error:`, error)
return undefined
} }
} }
@ -35,6 +36,7 @@ async function getDecimalsFromContract (tokenAddress) {
return decimalsBN && decimalsBN.toString() return decimalsBN && decimalsBN.toString()
} catch (error) { } catch (error) {
log.warn(`decimals() call for token at address ${tokenAddress} resulted in error:`, error) log.warn(`decimals() call for token at address ${tokenAddress} resulted in error:`, error)
return undefined
} }
} }

@ -32,6 +32,7 @@ describe('useCancelTransaction', function () {
balance: '0x3', balance: '0x3',
} }
} }
return undefined
}) })
}) })
transactions.forEach((transactionGroup) => { transactions.forEach((transactionGroup) => {
@ -75,6 +76,7 @@ describe('useCancelTransaction', function () {
balance: '0x9C2007651B2500000', balance: '0x9C2007651B2500000',
} }
} }
return undefined
}) })
}) })
transactions.forEach((transactionGroup) => { transactions.forEach((transactionGroup) => {

@ -108,6 +108,7 @@ describe('useCurrencyDisplay', function () {
} else if (selector === getConversionRate) { } else if (selector === getConversionRate) {
return 280.45 return 280.45
} }
return undefined
}) })
const hookReturn = renderHook(() => useCurrencyDisplay(value, restProps)) const hookReturn = renderHook(() => useCurrencyDisplay(value, restProps))
const [ displayValue, parts ] = hookReturn.result.current const [ displayValue, parts ] = hookReturn.result.current

@ -7,7 +7,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'
* @param {number} delay - delay in ms * @param {number} delay - delay in ms
* @param {boolean} [immediate] - determines whether the timeout is invoked immediately * @param {boolean} [immediate] - determines whether the timeout is invoked immediately
* *
* @return {Function} * @return {Function|undefined}
*/ */
export function useTimeout (cb, delay, immediate = true) { export function useTimeout (cb, delay, immediate = true) {
const saveCb = useRef() const saveCb = useRef()
@ -19,7 +19,7 @@ export function useTimeout (cb, delay, immediate = true) {
useEffect(() => { useEffect(() => {
if (timeoutId !== 'start') { if (timeoutId !== 'start') {
return return undefined
} }
const id = setTimeout(() => { const id = setTimeout(() => {

@ -85,6 +85,7 @@ export function useTransactionTimeRemaining (
}, 10000) }, 10000)
return () => clearInterval(interval.current) return () => clearInterval(interval.current)
} }
return undefined
}, [ }, [
isMainNet, isMainNet,
transactionTimeFeatureActive, transactionTimeFeatureActive,

@ -46,7 +46,7 @@ class ConnectHardwareForm extends Component {
connectToHardwareWallet = (device) => { connectToHardwareWallet = (device) => {
if (this.state.accounts.length) { if (this.state.accounts.length) {
return null return
} }
// Default values // Default values

@ -101,7 +101,8 @@ class JsonImportSubview extends Component {
if (!fileContents) { if (!fileContents) {
const message = this.context.t('needImportFile') const message = this.context.t('needImportFile')
return displayWarning(message) displayWarning(message)
return
} }
const password = this.inputRef.current.value const password = this.inputRef.current.value

@ -131,7 +131,7 @@ export default class MobileSyncPage extends Component {
const { channel, message } = data const { channel, message } = data
// handle message // handle message
if (channel !== this.channelName || !message) { if (channel !== this.channelName || !message) {
return false return
} }
if (message.event === 'start-sync') { if (message.event === 'start-sync') {
@ -203,7 +203,7 @@ export default class MobileSyncPage extends Component {
async startSyncing () { async startSyncing () {
if (this.syncing) { if (this.syncing) {
return false return
} }
this.syncing = true this.syncing = true
this.setState({ syncing: true }) this.setState({ syncing: true })

@ -85,7 +85,8 @@ export default class PermissionConnect extends Component {
getRequestAccountTabIds() getRequestAccountTabIds()
if (!permissionsRequest) { if (!permissionsRequest) {
return history.push(DEFAULT_ROUTE) history.push(DEFAULT_ROUTE)
return
} }
const environmentType = getEnvironmentType() const environmentType = getEnvironmentType()

@ -233,6 +233,8 @@ export default class AddRecipient extends Component {
</Dialog> </Dialog>
) )
} }
return null
} }
} }

@ -236,7 +236,7 @@ export default class EnsInput extends Component {
const { loadingEns, ensFailure, ensResolution, toError } = this.state const { loadingEns, ensFailure, ensResolution, toError } = this.state
if (toError) { if (toError) {
return return null
} }
if (loadingEns) { if (loadingEns) {
@ -269,6 +269,8 @@ export default class EnsInput extends Component {
/> />
) )
} }
return null
} }
} }

@ -48,7 +48,7 @@ export default class SendContent extends Component {
const { isOwnedAccount, showAddToAddressBookModal, contact = {} } = this.props const { isOwnedAccount, showAddToAddressBookModal, contact = {} } = this.props
if (isOwnedAccount || contact.name) { if (isOwnedAccount || contact.name) {
return return null
} }
return ( return (

@ -225,7 +225,8 @@ export default class SendTransactionScreen extends Component {
} = this.props } = this.props
if (!query) { if (!query) {
return this.setState({ toError: '', toWarning: '' }) this.setState({ toError: '', toWarning: '' })
return
} }
const toErrorObject = getToErrorObject(query, hasHexData, network) const toErrorObject = getToErrorObject(query, hasHexData, network)

@ -301,7 +301,7 @@ function addGasBuffer (initialGasLimitHex, blockGasLimitHex, bufferMultiplier =
function generateTokenTransferData ({ toAddress = '0x0', amount = '0x0', sendToken }) { function generateTokenTransferData ({ toAddress = '0x0', amount = '0x0', sendToken }) {
if (!sendToken) { if (!sendToken) {
return return undefined
} }
return TOKEN_TRANSFER_FUNCTION_SIGNATURE + Array.prototype.map.call( return TOKEN_TRANSFER_FUNCTION_SIGNATURE + Array.prototype.map.call(
abi.rawEncode(['address', 'uint256'], [toAddress, ethUtil.addHexPrefix(amount)]), abi.rawEncode(['address', 'uint256'], [toAddress, ethUtil.addHexPrefix(amount)]),

@ -121,6 +121,7 @@ export default class ContactListTab extends Component {
} else if (!hideAddressBook && showingMyAccounts) { } else if (!hideAddressBook && showingMyAccounts) {
return (<MyAccounts />) return (<MyAccounts />)
} }
return null
} }
render () { render () {

@ -46,7 +46,8 @@ export function tryUnlockMetamask (password) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.submitPassword(password, (error) => { background.submitPassword(password, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve() resolve()
@ -61,7 +62,8 @@ export function tryUnlockMetamask (password) {
background.verifySeedPhrase((err) => { background.verifySeedPhrase((err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
@ -87,7 +89,8 @@ export function createNewVaultAndRestore (password, seed) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.createNewVaultAndRestore(password, seed, (err, _vault) => { background.createNewVaultAndRestore(password, seed, (err, _vault) => {
if (err) { if (err) {
return reject(err) reject(err)
return
} }
vault = _vault vault = _vault
resolve() resolve()
@ -146,7 +149,8 @@ export function submitPassword (password) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.submitPassword(password, (error) => { background.submitPassword(password, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve() resolve()
@ -158,7 +162,8 @@ export function createNewVault (password) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.createNewVaultAndKeychain(password, (error) => { background.createNewVaultAndKeychain(password, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve(true) resolve(true)
@ -170,7 +175,8 @@ export function verifyPassword (password) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.verifyPassword(password, (error) => { background.verifyPassword(password, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve(true) resolve(true)
@ -182,7 +188,8 @@ export function verifySeedPhrase () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.verifySeedPhrase((error, seedWords) => { background.verifySeedPhrase((error, seedWords) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve(seedWords) resolve(seedWords)
@ -228,7 +235,8 @@ export function fetchInfoToSync () {
background.fetchInfoToSync((err, result) => { background.fetchInfoToSync((err, result) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve(result) resolve(result)
}) })
@ -245,7 +253,8 @@ export function resetAccount () {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
log.info('Transaction history reset for ' + account) log.info('Transaction history reset for ' + account)
@ -264,9 +273,11 @@ export function removeAccount (address) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
background.removeAccount(address, (error, account) => { background.removeAccount(address, (error, account) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
return resolve(account) resolve(account)
return
}) })
}) })
await forceUpdateMetamaskState(dispatch) await forceUpdateMetamaskState(dispatch)
@ -395,11 +406,13 @@ export function unlockHardwareWalletAccount (index, deviceName, hdPath) {
if (err) { if (err) {
log.error(err) log.error(err)
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
return resolve() resolve()
return
}) })
}) })
} }
@ -576,7 +589,8 @@ export function signTx (txData) {
return (dispatch) => { return (dispatch) => {
global.ethQuery.sendTransaction(txData, (err) => { global.ethQuery.sendTransaction(txData, (err) => {
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
dispatch(showConfTxPage()) dispatch(showConfTxPage())
@ -776,7 +790,8 @@ const updateMetamaskStateFromBackground = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.getState((error, newState) => { background.getState((error, newState) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve(newState) resolve(newState)
@ -795,7 +810,8 @@ export function updateTransaction (txData) {
dispatch(txError(err)) dispatch(txError(err))
dispatch(goHome()) dispatch(goHome())
log.error(err.message) log.error(err.message)
return reject(err) reject(err)
return
} }
resolve(txData) resolve(txData)
@ -823,7 +839,8 @@ export function updateAndApproveTx (txData) {
dispatch(txError(err)) dispatch(txError(err))
dispatch(goHome()) dispatch(goHome())
log.error(err.message) log.error(err.message)
return reject(err) reject(err)
return
} }
resolve(txData) resolve(txData)
@ -975,7 +992,8 @@ export function cancelTx (txData) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.cancelTransaction(txData.id, (err) => { background.cancelTransaction(txData.id, (err) => {
if (err) { if (err) {
return reject(err) reject(err)
return
} }
resolve() resolve()
@ -1006,7 +1024,8 @@ export function cancelTxs (txDataList) {
const cancellations = txIds.map((id) => new Promise((resolve, reject) => { const cancellations = txIds.map((id) => new Promise((resolve, reject) => {
background.cancelTransaction(id, (err) => { background.cancelTransaction(id, (err) => {
if (err) { if (err) {
return reject(err) reject(err)
return
} }
resolve() resolve()
@ -1025,7 +1044,8 @@ export function cancelTxs (txDataList) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) { if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
return global.platform.closeCurrentWindow() global.platform.closeCurrentWindow()
return
} }
} }
} }
@ -1036,9 +1056,11 @@ export function markPasswordForgotten () {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
return background.markPasswordForgotten((error) => { return background.markPasswordForgotten((error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
return resolve() resolve()
return
}) })
}) })
} finally { } finally {
@ -1130,7 +1152,8 @@ const backgroundSetLocked = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.setLocked((error) => { background.setLocked((error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve() resolve()
}) })
@ -1220,7 +1243,8 @@ export function addPermittedAccount (origin, address) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
background.addPermittedAccount(origin, address, (error) => { background.addPermittedAccount(origin, address, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve() resolve()
}) })
@ -1234,7 +1258,8 @@ export function removePermittedAccount (origin, address) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
background.removePermittedAccount(origin, address, (error) => { background.removePermittedAccount(origin, address, (error) => {
if (error) { if (error) {
return reject(error) reject(error)
return
} }
resolve() resolve()
}) })
@ -1264,7 +1289,8 @@ export function addToken (address, symbol, decimals, image) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(updateTokens(tokens)) dispatch(updateTokens(tokens))
resolve(tokens) resolve(tokens)
@ -1281,7 +1307,8 @@ export function removeToken (address) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(updateTokens(tokens)) dispatch(updateTokens(tokens))
resolve(tokens) resolve(tokens)
@ -1319,7 +1346,8 @@ export function removeSuggestedTokens () {
} }
dispatch(clearPendingTokens()) dispatch(clearPendingTokens())
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) { if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
return global.platform.closeCurrentWindow() global.platform.closeCurrentWindow()
return
} }
resolve(suggestedTokens) resolve(suggestedTokens)
}) })
@ -1357,7 +1385,8 @@ export function createCancelTransaction (txId, customGasPrice) {
background.createCancelTransaction(txId, customGasPrice, (err, newState) => { background.createCancelTransaction(txId, customGasPrice, (err, newState) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
const { currentNetworkTxList } = newState const { currentNetworkTxList } = newState
@ -1380,7 +1409,8 @@ export function createSpeedUpTransaction (txId, customGasPrice, customGasLimit)
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => { background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
const { currentNetworkTxList } = newState const { currentNetworkTxList } = newState
@ -1402,7 +1432,8 @@ export function createRetryTransaction (txId, customGasPrice, customGasLimit) {
background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => { background.createSpeedUpTransaction(txId, customGasPrice, customGasLimit, (err, newState) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
const { currentNetworkTxList } = newState const { currentNetworkTxList } = newState
@ -1517,7 +1548,8 @@ export function delRpcTarget (oldRpc) {
if (err) { if (err) {
log.error(err) log.error(err)
dispatch(displayWarning('Had a problem removing network!')) dispatch(displayWarning('Had a problem removing network!'))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -1541,7 +1573,8 @@ export function addToAddressBook (recipient, nickname = '', memo = '') {
throw error throw error
} }
if (!set) { if (!set) {
return dispatch(displayWarning('Address book failed to update')) dispatch(displayWarning('Address book failed to update'))
return
} }
} }
} }
@ -1688,21 +1721,24 @@ export function exportAccount (password, address) {
log.error('Error in submitting password.') log.error('Error in submitting password.')
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
dispatch(displayWarning('Incorrect Password.')) dispatch(displayWarning('Incorrect Password.'))
return reject(err) reject(err)
return
} }
log.debug(`background.exportAccount`) log.debug(`background.exportAccount`)
return background.exportAccount(address, function (err, result) { background.exportAccount(address, function (err, result) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
log.error(err) log.error(err)
dispatch(displayWarning('Had a problem exporting the account.')) dispatch(displayWarning('Had a problem exporting the account.'))
return reject(err) reject(err)
return
} }
dispatch(showPrivateKey(result)) dispatch(showPrivateKey(result))
return resolve(result) resolve(result)
return
}) })
}) })
}) })
@ -1716,7 +1752,8 @@ export function exportAccounts (password, addresses) {
background.submitPassword(password, function (err) { background.submitPassword(password, function (err) {
if (err) { if (err) {
log.error('Error in submitting password.') log.error('Error in submitting password.')
return reject(err) reject(err)
return
} }
log.debug(`background.exportAccounts`) log.debug(`background.exportAccounts`)
const accountPromises = addresses.map((address) => const accountPromises = addresses.map((address) =>
@ -1725,13 +1762,16 @@ export function exportAccounts (password, addresses) {
if (err) { if (err) {
log.error(err) log.error(err)
dispatch(displayWarning('Had a problem exporting the account.')) dispatch(displayWarning('Had a problem exporting the account.'))
return reject(err) reject(err)
return
} }
return resolve(result) resolve(result)
return
}), }),
), ),
) )
return resolve(Promise.all(accountPromises)) resolve(Promise.all(accountPromises))
return
}) })
}) })
} }
@ -1755,7 +1795,8 @@ export function setAccountLabel (account, label) {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch({ dispatch({
@ -1793,7 +1834,8 @@ export function setFeatureFlag (feature, activated, notificationType) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(updateFeatureFlags(updatedFeatureFlags)) dispatch(updateFeatureFlags(updatedFeatureFlags))
notificationType && dispatch(showModal({ name: notificationType })) notificationType && dispatch(showModal({ name: notificationType }))
@ -1819,7 +1861,8 @@ export function setPreference (preference, value) {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(updatePreferences(updatedPreferences)) dispatch(updatePreferences(updatedPreferences))
@ -1912,7 +1955,8 @@ export function setParticipateInMetaMetrics (val) {
log.debug(err) log.debug(err)
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch({ dispatch({
@ -1933,7 +1977,8 @@ export function setMetaMetricsSendCount (val) {
background.setMetaMetricsSendCount(val, (err) => { background.setMetaMetricsSendCount(val, (err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch({ dispatch({
@ -1954,7 +1999,8 @@ export function setUseBlockie (val) {
background.setUseBlockie(val, (err) => { background.setUseBlockie(val, (err) => {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
dispatch({ dispatch({
@ -1971,7 +2017,8 @@ export function setUseNonceField (val) {
background.setUseNonceField(val, (err) => { background.setUseNonceField(val, (err) => {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
dispatch({ dispatch({
@ -1988,7 +2035,8 @@ export function setUsePhishDetect (val) {
background.setUsePhishDetect(val, (err) => { background.setUsePhishDetect(val, (err) => {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
} }
@ -2001,7 +2049,8 @@ export function setIpfsGateway (val) {
background.setIpfsGateway(val, (err) => { background.setIpfsGateway(val, (err) => {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} else { } else {
dispatch({ dispatch({
type: actionConstants.SET_IPFS_GATEWAY, type: actionConstants.SET_IPFS_GATEWAY,
@ -2022,7 +2071,8 @@ export function updateCurrentLocale (key) {
background.setCurrentLocale(key, (err, textDirection) => { background.setCurrentLocale(key, (err, textDirection) => {
if (err) { if (err) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
switchDirection(textDirection) switchDirection(textDirection)
dispatch(setCurrentLocale(key, localeMessages)) dispatch(setCurrentLocale(key, localeMessages))
@ -2086,9 +2136,10 @@ export function rejectPermissionsRequest (requestId) {
background.rejectPermissionsRequest(requestId, (err) => { background.rejectPermissionsRequest(requestId, (err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
return forceUpdateMetamaskState(dispatch) forceUpdateMetamaskState(dispatch)
.then(resolve) .then(resolve)
.catch(reject) .catch(reject)
}) })
@ -2119,7 +2170,8 @@ export function setFirstTimeFlowType (type) {
log.debug(`background.setFirstTimeFlowType`) log.debug(`background.setFirstTimeFlowType`)
background.setFirstTimeFlowType(type, (err) => { background.setFirstTimeFlowType(type, (err) => {
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
dispatch({ dispatch({
@ -2147,7 +2199,8 @@ export function setLastActiveTime () {
return (dispatch) => { return (dispatch) => {
background.setLastActiveTime((err) => { background.setLastActiveTime((err) => {
if (err) { if (err) {
return dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return
} }
}) })
} }
@ -2252,9 +2305,10 @@ export function setSeedPhraseBackedUp (seedPhraseBackupState) {
background.setSeedPhraseBackedUp(seedPhraseBackupState, (err) => { background.setSeedPhraseBackedUp(seedPhraseBackupState, (err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
return forceUpdateMetamaskState(dispatch) forceUpdateMetamaskState(dispatch)
.then(resolve) .then(resolve)
.catch(reject) .catch(reject)
}) })
@ -2268,7 +2322,8 @@ export function initializeThreeBox () {
background.initializeThreeBox((err) => { background.initializeThreeBox((err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -2282,7 +2337,8 @@ export function setShowRestorePromptToFalse () {
background.setShowRestorePromptToFalse((err) => { background.setShowRestorePromptToFalse((err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -2296,7 +2352,8 @@ export function turnThreeBoxSyncingOn () {
background.turnThreeBoxSyncingOn((err) => { background.turnThreeBoxSyncingOn((err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -2310,7 +2367,8 @@ export function restoreFromThreeBox (accountAddress) {
background.restoreFromThreeBox(accountAddress, (err) => { background.restoreFromThreeBox(accountAddress, (err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -2324,7 +2382,8 @@ export function getThreeBoxLastUpdated () {
background.getThreeBoxLastUpdated((err, lastUpdated) => { background.getThreeBoxLastUpdated((err, lastUpdated) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve(lastUpdated) resolve(lastUpdated)
}) })
@ -2338,7 +2397,8 @@ export function setThreeBoxSyncingPermission (threeBoxSyncingAllowed) {
background.setThreeBoxSyncingPermission(threeBoxSyncingAllowed, (err) => { background.setThreeBoxSyncingPermission(threeBoxSyncingAllowed, (err) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
resolve() resolve()
}) })
@ -2368,7 +2428,8 @@ export function getNextNonce () {
background.getNextNonce(address, (err, nextNonce) => { background.getNextNonce(address, (err, nextNonce) => {
if (err) { if (err) {
dispatch(displayWarning(err.message)) dispatch(displayWarning(err.message))
return reject(err) reject(err)
return
} }
dispatch(setNextNonce(nextNonce)) dispatch(setNextNonce(nextNonce))
resolve(nextNonce) resolve(nextNonce)

@ -28,7 +28,8 @@ export default function launchMetamaskUi (opts, cb) {
// check if we are unlocked first // check if we are unlocked first
backgroundConnection.getState(function (err, metamaskState) { backgroundConnection.getState(function (err, metamaskState) {
if (err) { if (err) {
return cb(err) cb(err)
return
} }
startApp(metamaskState, backgroundConnection, opts) startApp(metamaskState, backgroundConnection, opts)
.then((store) => { .then((store) => {
@ -188,7 +189,8 @@ window.logStateString = function (cb) {
const state = window.getCleanAppState() const state = window.getCleanAppState()
global.platform.getPlatformInfo((err, platform) => { global.platform.getPlatformInfo((err, platform) => {
if (err) { if (err) {
return cb(err) cb(err)
return
} }
state.platform = platform state.platform = platform
const stateString = JSON.stringify(state, null, 2) const stateString = JSON.stringify(state, null, 2)

Loading…
Cancel
Save