Skip to content

Commit

Permalink
feat(wallets): add legacy key into store
Browse files Browse the repository at this point in the history
  • Loading branch information
tbuchann committed Apr 24, 2020
1 parent 0c1f7aa commit 6329af1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const ADD_SHOWN_BTC_PRIV_KEY = '@COMPONENT.ADD_SHOWN_BTC_PRIV_KEY'

export const ADD_SHOWN_ETH_PRIV_KEY = '@COMPONENT.ADD_SHOWN_ETH_PRIV_KEY'

export const ADD_SHOWN_ETH_LEGACY_PRIV_KEY =
'@COMPONENT.ADD_SHOWN_ETH_LEGACY_PRIV_KEY'

export const ADD_SHOWN_XLM_PRIV_KEY = '@COMPONENT.ADD_SHOWN_XLM_PRIV_KEY'

export const CLEAR_SHOWN_BTC_PRIV_KEY = '@COMPONENT.CLEAR_SHOWN_BTC_PRIV_KEY'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export const addShownEthPrivateKey = priv => ({
payload: { priv }
})

export const addShownEthLegacyPrivateKey = priv => ({
type: AT.ADD_SHOWN_ETH_LEGACY_PRIV_KEY,
payload: { priv }
})

export const addShownXlmPrivateKey = priv => ({
type: AT.ADD_SHOWN_XLM_PRIV_KEY,
payload: { priv }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const settings = (state = INITIAL_STATE, action) => {
case AT.ADD_SHOWN_ETH_PRIV_KEY: {
return assoc('shownEthPrivKey', payload.priv, state)
}
case AT.ADD_SHOWN_ETH_LEGACY_PRIV_KEY: {
return assoc('shownEthLegacyPrivKey', payload.priv, state)
}
case AT.ADD_SHOWN_XLM_PRIV_KEY: {
return assoc('shownXlmPrivKey', payload.priv, state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,14 @@ export default ({ api, coreSagas }) => {
const seedHexT = yield select(getSeedHex)
const seedHex = yield call(() => taskToPromise(seedHexT))
const legPriv = utils.eth.getLegacyPrivateKey(seedHex).toString('hex')
yield put(actions.modules.settings.addShownEthPrivateKey(legPriv))
} else {
const getMnemonic = state =>
selectors.core.wallet.getMnemonic(state, password)
const mnemonicT = yield select(getMnemonic)
const mnemonic = yield call(() => taskToPromise(mnemonicT))
let priv = utils.eth.getPrivateKey(mnemonic, 0).toString('hex')
yield put(actions.modules.settings.addShownEthPrivateKey(priv))
yield put(actions.modules.settings.addShownEthLegacyPrivateKey(legPriv))
}
const getMnemonic = state =>
selectors.core.wallet.getMnemonic(state, password)
const mnemonicT = yield select(getMnemonic)
const mnemonic = yield call(() => taskToPromise(mnemonicT))
let priv = utils.eth.getPrivateKey(mnemonic, 0).toString('hex')
yield put(actions.modules.settings.addShownEthPrivateKey(priv))
} catch (e) {
yield put(
actions.logs.logErrorMessage(logLocation, 'showEthPrivateKey', e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getData = (state, props) => {
const legacyAddressInfo = {
addr: legacyEthAddr,
balance: selectors.core.data.eth.getLegacyBalance(state).getOrElse(0),
priv: state.securityCenter.shownEthPrivKey
priv: state.securityCenter.shownEthLegacyPrivKey
}

const addressInfo = {
Expand Down

0 comments on commit 6329af1

Please sign in to comment.