|
|
@ -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 |
|
|
|
|
|
|
|
dispatch(actions.showLoadingIndication('This may take a while, please be patient.')) |
|
|
|
|
|
|
|
try { |
|
|
|
log.debug(`background.importAccountWithStrategy`) |
|
|
|
log.debug(`background.importAccountWithStrategy`) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
await pify(background.importAccountWithStrategy).call(background, strategy, args) |
|
|
|
background.importAccountWithStrategy(strategy, args, (err) => { |
|
|
|
|
|
|
|
if (err) { |
|
|
|
|
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
|
|
|
|
return reject(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.debug(`background.getState`) |
|
|
|
log.debug(`background.getState`) |
|
|
|
background.getState((err, newState) => { |
|
|
|
newState = await pify(background.getState).call(background) |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
if (err) { |
|
|
|
|
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
dispatch(actions.displayWarning(err.message)) |
|
|
|
return reject(err) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.updateMetamaskState(newState)) |
|
|
|
dispatch(actions.updateMetamaskState(newState)) |
|
|
|
dispatch({ |
|
|
|
dispatch({ |
|
|
|
type: actions.SHOW_ACCOUNT_DETAIL, |
|
|
|
type: actions.SHOW_ACCOUNT_DETAIL, |
|
|
|
value: newState.selectedAddress, |
|
|
|
value: newState.selectedAddress, |
|
|
|
}) |
|
|
|
}) |
|
|
|
resolve(newState) |
|
|
|
return newState |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|