mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
good progress adding paths
This commit is contained in:
parent
77ad856730
commit
4e1d8ba19d
@ -539,7 +539,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
// Hardware
|
// Hardware
|
||||||
//
|
//
|
||||||
|
|
||||||
async getKeyringForDevice (deviceName) {
|
async getKeyringForDevice (deviceName, hdPath = null) {
|
||||||
let keyringName = null
|
let keyringName = null
|
||||||
switch (deviceName) {
|
switch (deviceName) {
|
||||||
case 'trezor':
|
case 'trezor':
|
||||||
@ -555,6 +555,10 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
if (!keyring) {
|
if (!keyring) {
|
||||||
keyring = await this.keyringController.addNewKeyring(keyringName)
|
keyring = await this.keyringController.addNewKeyring(keyringName)
|
||||||
}
|
}
|
||||||
|
if (hdPath) {
|
||||||
|
console.log('[LEDGER]: HDPATH set', hdPath)
|
||||||
|
keyring.hdPath = hdPath
|
||||||
|
}
|
||||||
|
|
||||||
return keyring
|
return keyring
|
||||||
|
|
||||||
@ -565,9 +569,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @returns [] accounts
|
* @returns [] accounts
|
||||||
*/
|
*/
|
||||||
async connectHardware (deviceName, page) {
|
async connectHardware (deviceName, page, hdPath) {
|
||||||
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
||||||
const keyring = await this.getKeyringForDevice(deviceName)
|
|
||||||
let accounts = []
|
let accounts = []
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case -1:
|
case -1:
|
||||||
@ -593,8 +596,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
async checkHardwareStatus (deviceName) {
|
async checkHardwareStatus (deviceName, hdPath) {
|
||||||
const keyring = await this.getKeyringForDevice(deviceName)
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
||||||
return keyring.isUnlocked()
|
return keyring.isUnlocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +618,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @returns {} keyState
|
* @returns {} keyState
|
||||||
*/
|
*/
|
||||||
async unlockHardwareWalletAccount (index, deviceName) {
|
async unlockHardwareWalletAccount (index, deviceName, hdPath) {
|
||||||
const keyring = await this.getKeyringForDevice(deviceName)
|
const keyring = await this.getKeyringForDevice(deviceName, hdPath)
|
||||||
|
|
||||||
keyring.setAccountToUnlock(index)
|
keyring.setAccountToUnlock(index)
|
||||||
const oldAccounts = await this.keyringController.getAccounts()
|
const oldAccounts = await this.keyringController.getAccounts()
|
||||||
|
43
package-lock.json
generated
43
package-lock.json
generated
@ -317,29 +317,6 @@
|
|||||||
"through2": "^2.0.3"
|
"through2": "^2.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@ledgerhq/hw-app-eth": {
|
|
||||||
"version": "4.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@ledgerhq/hw-app-eth/-/hw-app-eth-4.21.0.tgz",
|
|
||||||
"integrity": "sha1-LYv75fCbkujWlRrmhQNtnVrqlv8=",
|
|
||||||
"requires": {
|
|
||||||
"@ledgerhq/hw-transport": "^4.21.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@ledgerhq/hw-transport": {
|
|
||||||
"version": "4.21.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-4.21.0.tgz",
|
|
||||||
"integrity": "sha1-UPhc/hFbo/nVv5R1XHAeknF1eU8=",
|
|
||||||
"requires": {
|
|
||||||
"events": "^2.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"events": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz",
|
|
||||||
"integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@material-ui/core": {
|
"@material-ui/core": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@material-ui/core/-/core-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@material-ui/core/-/core-1.0.0.tgz",
|
||||||
@ -8459,8 +8436,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eth-ledger-bridge-keyring": {
|
"eth-ledger-bridge-keyring": {
|
||||||
"version": "github:brunobar79/eth-ledger-bridge-keyring#f8f05925519a34e2d5ee3083ca95960fa70ddd11",
|
"version": "github:MetaMask/eth-ledger-bridge-keyring#d882deaae4c2ab0b83c3fac495f1972c47a1c8cd",
|
||||||
"from": "github:brunobar79/eth-ledger-bridge-keyring",
|
"from": "github:MetaMask/eth-ledger-bridge-keyring#master",
|
||||||
"requires": {
|
"requires": {
|
||||||
"eth-sig-util": "^1.4.2",
|
"eth-sig-util": "^1.4.2",
|
||||||
"ethereumjs-tx": "^1.3.4",
|
"ethereumjs-tx": "^1.3.4",
|
||||||
@ -8653,13 +8630,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||||
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ethereumjs-abi": {
|
"ethereumjs-abi": {
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.10.0",
|
"bn.js": "^4.10.0",
|
||||||
"ethereumjs-util": "^5.0.0"
|
"ethereumjs-util": "^5.0.0"
|
||||||
@ -30519,7 +30495,6 @@
|
|||||||
"version": "3.1.5",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-typedarray": "^1.0.0"
|
"is-typedarray": "^1.0.0"
|
||||||
}
|
}
|
||||||
@ -31524,7 +31499,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
|
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
|
||||||
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
|
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
|
|
||||||
"crypto-js": "^3.1.4",
|
"crypto-js": "^3.1.4",
|
||||||
"utf8": "^2.1.1",
|
"utf8": "^2.1.1",
|
||||||
"xhr2": "*",
|
"xhr2": "*",
|
||||||
@ -31533,7 +31507,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignumber.js": {
|
"bignumber.js": {
|
||||||
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
|
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
|
||||||
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
|
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -32032,8 +32006,7 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"underscore": "1.8.3",
|
"underscore": "1.8.3",
|
||||||
"web3-core-helpers": "1.0.0-beta.34",
|
"web3-core-helpers": "1.0.0-beta.34"
|
||||||
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"underscore": {
|
"underscore": {
|
||||||
@ -32044,8 +32017,7 @@
|
|||||||
},
|
},
|
||||||
"websocket": {
|
"websocket": {
|
||||||
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||||
"from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
|
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
"nan": "^2.3.3",
|
"nan": "^2.3.3",
|
||||||
@ -33395,8 +33367,7 @@
|
|||||||
"yaeti": {
|
"yaeti": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
||||||
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
|
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
"eth-hd-keyring": "^1.2.2",
|
"eth-hd-keyring": "^1.2.2",
|
||||||
"eth-json-rpc-filters": "^1.2.6",
|
"eth-json-rpc-filters": "^1.2.6",
|
||||||
"eth-json-rpc-infura": "^3.0.0",
|
"eth-json-rpc-infura": "^3.0.0",
|
||||||
"eth-ledger-bridge-keyring": "github:brunobar79/eth-ledger-bridge-keyring",
|
"eth-ledger-bridge-keyring": "github:MetaMask/eth-ledger-bridge-keyring#master",
|
||||||
"eth-method-registry": "^1.0.0",
|
"eth-method-registry": "^1.0.0",
|
||||||
"eth-phishing-detect": "^1.1.4",
|
"eth-phishing-detect": "^1.1.4",
|
||||||
"eth-query": "^2.1.2",
|
"eth-query": "^2.1.2",
|
||||||
|
@ -235,6 +235,8 @@ var actions = {
|
|||||||
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
||||||
setRpcTarget: setRpcTarget,
|
setRpcTarget: setRpcTarget,
|
||||||
setProviderType: setProviderType,
|
setProviderType: setProviderType,
|
||||||
|
SET_HARDWARE_WALLET_DEFAULT_HD_PATH: 'SET_HARDWARE_WALLET_DEFAULT_HD_PATH',
|
||||||
|
setHardwareWalletDefaultHdPath,
|
||||||
updateProviderType,
|
updateProviderType,
|
||||||
// loading overlay
|
// loading overlay
|
||||||
SHOW_LOADING: 'SHOW_LOADING_INDICATION',
|
SHOW_LOADING: 'SHOW_LOADING_INDICATION',
|
||||||
@ -639,12 +641,12 @@ function addNewAccount () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkHardwareStatus (deviceName) {
|
function checkHardwareStatus (deviceName, hdPath) {
|
||||||
log.debug(`background.checkHardwareStatus`, deviceName)
|
log.debug(`background.checkHardwareStatus`, deviceName, hdPath)
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.checkHardwareStatus(deviceName, (err, unlocked) => {
|
background.checkHardwareStatus(deviceName, hdPath, (err, unlocked) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(err)
|
log.error(err)
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
@ -681,12 +683,12 @@ function forgetDevice (deviceName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectHardware (deviceName, page) {
|
function connectHardware (deviceName, page, hdPath) {
|
||||||
log.debug(`background.connectHardware`, deviceName, page)
|
log.debug(`background.connectHardware`, deviceName, page, hdPath)
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.connectHardware(deviceName, page, (err, accounts) => {
|
background.connectHardware(deviceName, page, hdPath, (err, accounts) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(err)
|
log.error(err)
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
@ -702,12 +704,12 @@ function connectHardware (deviceName, page) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlockHardwareWalletAccount (index, deviceName) {
|
function unlockHardwareWalletAccount (index, deviceName, hdPath) {
|
||||||
log.debug(`background.unlockHardwareWalletAccount`, index, deviceName)
|
log.debug(`background.unlockHardwareWalletAccount`, index, deviceName, hdPath)
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.unlockHardwareWalletAccount(index, deviceName, (err, accounts) => {
|
background.unlockHardwareWalletAccount(index, deviceName, hdPath, (err, accounts) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(err)
|
log.error(err)
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
@ -1854,6 +1856,13 @@ function showLoadingIndication (message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setHardwareWalletDefaultHdPath ({ device, path }) {
|
||||||
|
return {
|
||||||
|
type: actions.SET_HARDWARE_WALLET_DEFAULT_HD_PATH,
|
||||||
|
value: {device, path},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hideLoadingIndication () {
|
function hideLoadingIndication () {
|
||||||
return {
|
return {
|
||||||
type: actions.HIDE_LOADING,
|
type: actions.HIDE_LOADING,
|
||||||
|
@ -2,16 +2,53 @@ const { Component } = require('react')
|
|||||||
const PropTypes = require('prop-types')
|
const PropTypes = require('prop-types')
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const genAccountLink = require('../../../../../lib/account-link.js')
|
const genAccountLink = require('../../../../../lib/account-link.js')
|
||||||
|
const Select = require('react-select').default
|
||||||
|
|
||||||
class AccountList extends Component {
|
class AccountList extends Component {
|
||||||
constructor (props, context) {
|
constructor (props, context) {
|
||||||
super(props)
|
super(props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHdPaths () {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: `m/44'/60'/0' (Legacy)`,
|
||||||
|
value: `m/44'/60'/0'`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: `m/44'/60'/0'/0`,
|
||||||
|
value: `m/44'/60'/0'/0'`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
renderHdPathSelector () {
|
||||||
|
const { onPathChange, selectedPath } = this.props
|
||||||
|
|
||||||
|
const options = this.getHdPaths()
|
||||||
|
return h('div.hw-connect__hdPath', [
|
||||||
|
h('h3.hw-connect__hdPath__title', {}, `HD Path`),
|
||||||
|
h(Select, {
|
||||||
|
className: 'hw-connect__hdPath__select',
|
||||||
|
name: 'hd-path-select',
|
||||||
|
clearable: false,
|
||||||
|
value: selectedPath,
|
||||||
|
options,
|
||||||
|
onChange: (opt) => {
|
||||||
|
onPathChange(opt.value)
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
}
|
||||||
renderHeader () {
|
renderHeader () {
|
||||||
|
const { device } = this.props
|
||||||
return (
|
return (
|
||||||
h('div.hw-connect', [
|
h('div.hw-connect', [
|
||||||
h('h3.hw-connect__title', {}, `${this.props.device.toUpperCase()} - ${this.context.t('selectAnAccount')}`),
|
|
||||||
|
h('h3.hw-connect__title', {}, `${device.toUpperCase()} - ${this.context.t('selectAnAccount')}`),
|
||||||
|
|
||||||
|
device.toLowerCase() === 'ledger' ? this.renderHdPathSelector() : null,
|
||||||
|
|
||||||
h('p.hw-connect__msg', {}, this.context.t('selectAnAccountHelp')),
|
h('p.hw-connect__msg', {}, this.context.t('selectAnAccountHelp')),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@ -125,6 +162,8 @@ class AccountList extends Component {
|
|||||||
|
|
||||||
|
|
||||||
AccountList.propTypes = {
|
AccountList.propTypes = {
|
||||||
|
onPathChange: PropTypes.func.isRequired,
|
||||||
|
selectedPath: PropTypes.string.isRequired,
|
||||||
device: PropTypes.string.isRequired,
|
device: PropTypes.string.isRequired,
|
||||||
accounts: PropTypes.array.isRequired,
|
accounts: PropTypes.array.isRequired,
|
||||||
onAccountChange: PropTypes.func.isRequired,
|
onAccountChange: PropTypes.func.isRequired,
|
||||||
|
@ -18,7 +18,7 @@ class ConnectHardwareForm extends Component {
|
|||||||
accounts: [],
|
accounts: [],
|
||||||
browserSupported: true,
|
browserSupported: true,
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
device: null
|
device: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ class ConnectHardwareForm extends Component {
|
|||||||
|
|
||||||
async checkIfUnlocked () {
|
async checkIfUnlocked () {
|
||||||
['trezor', 'ledger'].forEach(async device => {
|
['trezor', 'ledger'].forEach(async device => {
|
||||||
const unlocked = await this.props.checkHardwareStatus(device)
|
const unlocked = await this.props.checkHardwareStatus(device, this.props.defaultHdPaths[device])
|
||||||
if (unlocked) {
|
if (unlocked) {
|
||||||
this.setState({unlocked: true})
|
this.setState({unlocked: true})
|
||||||
this.getPage(0, device)
|
this.getPage(0, device, this.props.defaultHdPaths[device])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -52,8 +52,16 @@ class ConnectHardwareForm extends Component {
|
|||||||
if (this.state.accounts.length) {
|
if (this.state.accounts.length) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default values
|
||||||
this.setState({ btnText: this.context.t('connecting')})
|
this.setState({ btnText: this.context.t('connecting')})
|
||||||
this.getPage(0, device)
|
this.getPage(0, device, this.props.defaultHdPaths[device])
|
||||||
|
}
|
||||||
|
|
||||||
|
onPathChange = (path) => {
|
||||||
|
console.log('BRUNO: path changed', path)
|
||||||
|
this.props.setHardwareWalletDefaultHdPath({device: this.state.device, path})
|
||||||
|
this.getPage(0, this.state.device, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccountChange = (account) => {
|
onAccountChange = (account) => {
|
||||||
@ -68,9 +76,9 @@ class ConnectHardwareForm extends Component {
|
|||||||
}, 5000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
getPage = (page, device) => {
|
getPage = (page, device, hdPath) => {
|
||||||
this.props
|
this.props
|
||||||
.connectHardware(device, page)
|
.connectHardware(device, page, hdPath)
|
||||||
.then(accounts => {
|
.then(accounts => {
|
||||||
if (accounts.length) {
|
if (accounts.length) {
|
||||||
|
|
||||||
@ -162,6 +170,8 @@ class ConnectHardwareForm extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return h(AccountList, {
|
return h(AccountList, {
|
||||||
|
onPathChange: this.onPathChange,
|
||||||
|
selectedPath: this.props.defaultHdPaths[this.state.device],
|
||||||
device: this.state.device,
|
device: this.state.device,
|
||||||
accounts: this.state.accounts,
|
accounts: this.state.accounts,
|
||||||
selectedAccount: this.state.selectedAccount,
|
selectedAccount: this.state.selectedAccount,
|
||||||
@ -193,12 +203,14 @@ ConnectHardwareForm.propTypes = {
|
|||||||
showAlert: PropTypes.func,
|
showAlert: PropTypes.func,
|
||||||
hideAlert: PropTypes.func,
|
hideAlert: PropTypes.func,
|
||||||
unlockHardwareWalletAccount: PropTypes.func,
|
unlockHardwareWalletAccount: PropTypes.func,
|
||||||
|
setHardwareWalletDefaultHdPath: PropTypes.func,
|
||||||
numberOfExistingAccounts: PropTypes.number,
|
numberOfExistingAccounts: PropTypes.number,
|
||||||
history: PropTypes.object,
|
history: PropTypes.object,
|
||||||
t: PropTypes.func,
|
t: PropTypes.func,
|
||||||
network: PropTypes.string,
|
network: PropTypes.string,
|
||||||
accounts: PropTypes.object,
|
accounts: PropTypes.object,
|
||||||
address: PropTypes.string,
|
address: PropTypes.string,
|
||||||
|
defaultHdPaths: PropTypes.object,
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
@ -206,28 +218,35 @@ const mapStateToProps = state => {
|
|||||||
metamask: { network, selectedAddress, identities = {}, accounts = [] },
|
metamask: { network, selectedAddress, identities = {}, accounts = [] },
|
||||||
} = state
|
} = state
|
||||||
const numberOfExistingAccounts = Object.keys(identities).length
|
const numberOfExistingAccounts = Object.keys(identities).length
|
||||||
|
const {
|
||||||
|
appState: { defaultHdPaths },
|
||||||
|
} = state
|
||||||
|
|
||||||
return {
|
return {
|
||||||
network,
|
network,
|
||||||
accounts,
|
accounts,
|
||||||
address: selectedAddress,
|
address: selectedAddress,
|
||||||
numberOfExistingAccounts,
|
numberOfExistingAccounts,
|
||||||
|
defaultHdPaths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
connectHardware: (deviceName, page) => {
|
setHardwareWalletDefaultHdPath: ({device, path}) => {
|
||||||
return dispatch(actions.connectHardware(deviceName, page))
|
return dispatch(actions.setHardwareWalletDefaultHdPath({device, path}))
|
||||||
},
|
},
|
||||||
checkHardwareStatus: (deviceName) => {
|
connectHardware: (deviceName, page, hdPath) => {
|
||||||
return dispatch(actions.checkHardwareStatus(deviceName))
|
return dispatch(actions.connectHardware(deviceName, hdPath, page))
|
||||||
|
},
|
||||||
|
checkHardwareStatus: (deviceName, hdPath) => {
|
||||||
|
return dispatch(actions.checkHardwareStatus(deviceName, hdPath))
|
||||||
},
|
},
|
||||||
forgetDevice: (deviceName) => {
|
forgetDevice: (deviceName) => {
|
||||||
return dispatch(actions.forgetDevice(deviceName))
|
return dispatch(actions.forgetDevice(deviceName))
|
||||||
},
|
},
|
||||||
unlockHardwareWalletAccount: (index, deviceName) => {
|
unlockHardwareWalletAccount: (index, deviceName, hdPath) => {
|
||||||
return dispatch(actions.unlockHardwareWalletAccount(index, deviceName))
|
return dispatch(actions.unlockHardwareWalletAccount(index, deviceName, hdPath))
|
||||||
},
|
},
|
||||||
showImportPage: () => dispatch(actions.showImportPage()),
|
showImportPage: () => dispatch(actions.showImportPage()),
|
||||||
showConnectPage: () => dispatch(actions.showConnectPage()),
|
showConnectPage: () => dispatch(actions.showConnectPage()),
|
||||||
|
@ -178,6 +178,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__hdPath {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
display: flex;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__select {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__learn-more {
|
&__learn-more {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
@ -67,6 +67,10 @@ function reduceApp (state, action) {
|
|||||||
isMouseUser: false,
|
isMouseUser: false,
|
||||||
gasIsLoading: false,
|
gasIsLoading: false,
|
||||||
networkNonce: null,
|
networkNonce: null,
|
||||||
|
defaultHdPaths: {
|
||||||
|
trezor: `m/44'/60'/0'/0`,
|
||||||
|
ledger: `m/44'/60'/0'`,
|
||||||
|
},
|
||||||
}, state.appState)
|
}, state.appState)
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
@ -525,6 +529,15 @@ function reduceApp (state, action) {
|
|||||||
warning: '',
|
warning: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case actions.SET_HARDWARE_WALLET_DEFAULT_HD_PATH:
|
||||||
|
const { device, path } = action.value
|
||||||
|
const newDefaults = {...appState.defaultHdPaths}
|
||||||
|
newDefaults[device] = path
|
||||||
|
|
||||||
|
return extend(appState, {
|
||||||
|
defaultHdPaths: newDefaults,
|
||||||
|
})
|
||||||
|
|
||||||
case actions.SHOW_LOADING:
|
case actions.SHOW_LOADING:
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user