diff options
-rw-r--r-- | app/_locales/en/messages.json | 6 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 3 | ||||
-rw-r--r-- | ui/app/components/pages/create-account/connect-hardware/account-list.js | 52 | ||||
-rw-r--r-- | ui/app/components/pages/create-account/connect-hardware/index.js | 15 | ||||
-rw-r--r-- | ui/app/reducers/app.js | 2 |
5 files changed, 53 insertions, 25 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 62ec4ce37..a4ee97525 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -538,6 +538,9 @@ "learnMore": { "message": "Learn more" }, + "ledgerAccountRestriction": { + "message": "You need to make use your last account before you can add a new one." + }, "lessThanMax": { "message": "must be less than or equal to $1.", "description": "helper for inputting hex as decimal input" @@ -922,6 +925,9 @@ "selectAnAccountHelp": { "message": "These are the accounts available in your hardware wallet. Select the one you’d like to use in MetaMask." }, + "selectPathHelp": { + "message": "If you don't see your existing Ledger address(es), please try selecting a different HD Path \"Legacy (MEW / MyCrypto)\"" + }, "sendTokensAnywhere": { "message": "Send Tokens to anyone with an Ethereum account" }, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index beaf04c0d..b1473390b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -556,10 +556,11 @@ module.exports = class MetamaskController extends EventEmitter { keyring = await this.keyringController.addNewKeyring(keyringName) } if (hdPath) { - console.log('[LEDGER]: HDPATH set', hdPath) keyring.hdPath = hdPath } + keyring.network = this.networkController.getProviderConfig().type + return keyring } diff --git a/ui/app/components/pages/create-account/connect-hardware/account-list.js b/ui/app/components/pages/create-account/connect-hardware/account-list.js index 4c6cc67f9..c8fb5030b 100644 --- a/ui/app/components/pages/create-account/connect-hardware/account-list.js +++ b/ui/app/components/pages/create-account/connect-hardware/account-list.js @@ -12,32 +12,47 @@ class AccountList extends Component { getHdPaths () { return [ { - label: `m/44'/60'/0' (Legacy)`, - value: `m/44'/60'/0'`, + label: `Ledger Live`, + value: `m/44'/60'/0'/0/0`, }, { - label: `m/44'/60'/0'/0`, - value: `m/44'/60'/0'/0'`, + label: `Legacy (MEW / MyCrypto)`, + value: `m/44'/60'/0'`, }, ] } + goToNextPage = () => { + if (this.props.accounts === 5) { + this.props.getPage(this.props.device, 1, this.props.selectedPath) + } else { + this.props.onAccountRestriction() + } + } + + goToPreviousPage = () => { + this.props.getPage(this.props.device, -1, this.props.selectedPath) + } + 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) - }, - }), + return h('div', [ + 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) + }, + }), + ]), + h('p.hw-connect__msg', {}, this.context.t('selectPathHelp')), ]) } renderHeader () { @@ -98,7 +113,7 @@ class AccountList extends Component { h( 'button.hw-list-pagination__button', { - onClick: () => this.props.getPage(-1, this.props.device), + onClick: this.goToPreviousPage, }, `< ${this.context.t('prev')}` ), @@ -106,7 +121,7 @@ class AccountList extends Component { h( 'button.hw-list-pagination__button', { - onClick: () => this.props.getPage(1, this.props.device), + onClick: this.goToNextPage, }, `${this.context.t('next')} >` ), @@ -174,6 +189,7 @@ AccountList.propTypes = { history: PropTypes.object, onUnlockAccount: PropTypes.func, onCancel: PropTypes.func, + onAccountRestriction: PropTypes.func, } AccountList.contextTypes = { diff --git a/ui/app/components/pages/create-account/connect-hardware/index.js b/ui/app/components/pages/create-account/connect-hardware/index.js index 0eb2aa16f..e7e94686a 100644 --- a/ui/app/components/pages/create-account/connect-hardware/index.js +++ b/ui/app/components/pages/create-account/connect-hardware/index.js @@ -43,7 +43,7 @@ class ConnectHardwareForm extends Component { const unlocked = await this.props.checkHardwareStatus(device, this.props.defaultHdPaths[device]) if (unlocked) { this.setState({unlocked: true}) - this.getPage(0, device, this.props.defaultHdPaths[device]) + this.getPage(device, 0, this.props.defaultHdPaths[device]) } }) } @@ -55,19 +55,23 @@ class ConnectHardwareForm extends Component { // Default values this.setState({ btnText: this.context.t('connecting')}) - this.getPage(0, device, this.props.defaultHdPaths[device]) + this.getPage(device, 0, 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) + this.getPage(this.state.device, 0, path) } onAccountChange = (account) => { this.setState({selectedAccount: account.toString(), error: null}) } + onAccountRestriction = () => { + this.setState({error: this.context.t('ledgerAccountRestriction') }) + } + showTemporaryAlert () { this.props.showAlert(this.context.t('hardwareWalletConnected')) // Autohide the alert after 5 seconds @@ -76,7 +80,7 @@ class ConnectHardwareForm extends Component { }, 5000) } - getPage = (page, device, hdPath) => { + getPage = (device, page, hdPath) => { this.props .connectHardware(device, page, hdPath) .then(accounts => { @@ -182,6 +186,7 @@ class ConnectHardwareForm extends Component { onUnlockAccount: this.onUnlockAccount, onForgetDevice: this.onForgetDevice, onCancel: this.onCancel, + onAccountRestriction: this.onAccountRestriction, }) } @@ -237,7 +242,7 @@ const mapDispatchToProps = dispatch => { return dispatch(actions.setHardwareWalletDefaultHdPath({device, path})) }, connectHardware: (deviceName, page, hdPath) => { - return dispatch(actions.connectHardware(deviceName, hdPath, page)) + return dispatch(actions.connectHardware(deviceName, page, hdPath)) }, checkHardwareStatus: (deviceName, hdPath) => { return dispatch(actions.checkHardwareStatus(deviceName, hdPath)) diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 4d70d2718..c246e7904 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -69,7 +69,7 @@ function reduceApp (state, action) { networkNonce: null, defaultHdPaths: { trezor: `m/44'/60'/0'/0`, - ledger: `m/44'/60'/0'`, + ledger: `m/44'/60'/0'/0/0`, }, }, state.appState) |