aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-08-14 13:26:18 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-08-14 13:26:18 +0800
commit61a279204a804ddf4815d0db6103c19c5640bbb9 (patch)
treef2e1bea86e79f1f43191d05ed18d9e870fb2fc45 /ui
parent4e1d8ba19db729f5c282c4e3c6b43433b562a45e (diff)
downloadtangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar.gz
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar.bz2
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar.lz
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar.xz
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.tar.zst
tangerine-wallet-browser-61a279204a804ddf4815d0db6103c19c5640bbb9.zip
legacy and new hd path working
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pages/create-account/connect-hardware/account-list.js52
-rw-r--r--ui/app/components/pages/create-account/connect-hardware/index.js15
-rw-r--r--ui/app/reducers/app.js2
3 files changed, 45 insertions, 24 deletions
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)