|
|
@ -1,4 +1,5 @@ |
|
|
|
const abi = require('human-standard-token-abi') |
|
|
|
const abi = require('human-standard-token-abi') |
|
|
|
|
|
|
|
const pify = require('pify') |
|
|
|
const getBuyEthUrl = require('../../app/scripts/lib/buy-eth-url') |
|
|
|
const getBuyEthUrl = require('../../app/scripts/lib/buy-eth-url') |
|
|
|
const { getTokenAddressFromTokenObject } = require('./util') |
|
|
|
const { getTokenAddressFromTokenObject } = require('./util') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
@ -523,31 +524,26 @@ function addNewKeyring (type, opts) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function importNewAccount (strategy, args) { |
|
|
|
function importNewAccount (strategy, args) { |
|
|
|
return (dispatch) => { |
|
|
|
return async (dispatch) => { |
|
|
|
dispatch(actions.showLoadingIndication('This may take a while, be patient.')) |
|
|
|
let newState |
|
|
|
log.debug(`background.importAccountWithStrategy`) |
|
|
|
dispatch(actions.showLoadingIndication('This may take a while, please be patient.')) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
try { |
|
|
|
background.importAccountWithStrategy(strategy, args, (err) => { |
|
|
|
log.debug(`background.importAccountWithStrategy`) |
|
|
|
if (err) { |
|
|
|
await pify(background.importAccountWithStrategy).call(background, strategy, args) |
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
log.debug(`background.getState`) |
|
|
|
return reject(err) |
|
|
|
newState = await pify(background.getState).call(background) |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
log.debug(`background.getState`) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
background.getState((err, newState) => { |
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
return |
|
|
|
if (err) { |
|
|
|
} |
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
return reject(err) |
|
|
|
dispatch(actions.updateMetamaskState(newState)) |
|
|
|
} |
|
|
|
dispatch({ |
|
|
|
dispatch(actions.updateMetamaskState(newState)) |
|
|
|
type: actions.SHOW_ACCOUNT_DETAIL, |
|
|
|
dispatch({ |
|
|
|
value: newState.selectedAddress, |
|
|
|
type: actions.SHOW_ACCOUNT_DETAIL, |
|
|
|
|
|
|
|
value: newState.selectedAddress, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
resolve(newState) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
return newState |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|