mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
legacy and new hd path working
This commit is contained in:
parent
4e1d8ba19d
commit
61a279204a
@ -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"
|
||||
},
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
@ -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 = {
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user