1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Revert "Add custom hd path option (#9367)" (#9875)

This reverts commit f30d261e69.

The custom HD path option was found to be unsafe to use, because the
displayed list of accounts would differ depending on which application
was open on the Ledger device. Essentially Ledger was accepting invalid
inputs, and returning junk responses.

This was too dangerous to ship, as it could leave users with an account
that they can't reliably recover. If we don't know how the derivation
is happening, then allowing this import puts our users at risk of
losing funds.

We can re-introduce this functionality after adding validation to
ensure that we only allow inputs that are handled correctly by Ledger.
This commit is contained in:
Mark Stacey 2020-11-13 14:25:47 -03:30 committed by GitHub
parent 9da719efef
commit beb6047384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 77 deletions

View File

@ -1425,7 +1425,7 @@
"message": "Select Locale" "message": "Select Locale"
}, },
"selectPathHelp": { "selectPathHelp": {
"message": "If you don't see your existing Ledger accounts below, try a different HD path." "message": "If you don't see your existing Ledger accounts below, try switching paths to \"Legacy (MEW / MyCrypto)\""
}, },
"selectType": { "selectType": {
"message": "Select Type" "message": "Select Type"

View File

@ -5,13 +5,6 @@ import getAccountLink from '../../../../lib/account-link'
import Button from '../../../components/ui/button' import Button from '../../../components/ui/button'
class AccountList extends Component { class AccountList extends Component {
state = {
showCustomInput: false,
customPathSelected: false,
}
inputRef = React.createRef()
getHdPaths() { getHdPaths() {
return [ return [
{ {
@ -22,10 +15,6 @@ class AccountList extends Component {
label: `Legacy (MEW / MyCrypto)`, label: `Legacy (MEW / MyCrypto)`,
value: `m/44'/60'/0'`, value: `m/44'/60'/0'`,
}, },
{
label: `Custom`,
value: `custom`,
},
] ]
} }
@ -43,7 +32,6 @@ class AccountList extends Component {
} }
renderHdPathSelector() { renderHdPathSelector() {
const { showCustomInput } = this.state
const { onPathChange, selectedPath } = this.props const { onPathChange, selectedPath } = this.props
const options = this.getHdPaths() const options = this.getHdPaths()
@ -58,19 +46,13 @@ class AccountList extends Component {
className="hw-connect__hdPath__select" className="hw-connect__hdPath__select"
name="hd-path-select" name="hd-path-select"
clearable={false} clearable={false}
value={showCustomInput ? 'custom' : selectedPath} value={selectedPath}
options={options} options={options}
onChange={(opt) => { onChange={(opt) => {
if (opt.value === 'custom') {
this.setState({ showCustomInput: true })
} else {
this.setState({ showCustomInput: false })
onPathChange(opt.value) onPathChange(opt.value)
}
}} }}
/> />
</div> </div>
{showCustomInput && this.renderCustomInput()}
</div> </div>
) )
} }
@ -79,22 +61,6 @@ class AccountList extends Component {
return device.slice(0, 1).toUpperCase() + device.slice(1) return device.slice(0, 1).toUpperCase() + device.slice(1)
} }
renderCustomInput() {
const hdPaths = this.getHdPaths()
return (
<input
className="hw-connect__custom-input"
type="text"
defaultValue={hdPaths[0].value}
onChange={() => {
this.setState({ customPathSelected: false })
}}
ref={this.inputRef}
autoFocus
/>
)
}
renderHeader() { renderHeader() {
const { device } = this.props const { device } = this.props
return ( return (
@ -177,9 +143,6 @@ class AccountList extends Component {
} }
renderButtons() { renderButtons() {
const { showCustomInput, customPathSelected } = this.state
const { onPathChange } = this.props
const showSelectButton = showCustomInput && !customPathSelected
const disabled = this.props.selectedAccount === null const disabled = this.props.selectedAccount === null
const buttonProps = {} const buttonProps = {}
if (disabled) { if (disabled) {
@ -196,19 +159,6 @@ class AccountList extends Component {
> >
{this.context.t('cancel')} {this.context.t('cancel')}
</Button> </Button>
{showSelectButton ? (
<Button
type="primary"
large
className="new-external-account-form__button unlock"
onClick={() => {
onPathChange(this.inputRef.current.value)
this.setState({ customPathSelected: true })
}}
>
{this.context.t('selectHdPath')}
</Button>
) : (
<Button <Button
type="primary" type="primary"
large large
@ -218,7 +168,6 @@ class AccountList extends Component {
> >
{this.context.t('unlock')} {this.context.t('unlock')}
</Button> </Button>
)}
</div> </div>
) )
} }
@ -234,12 +183,11 @@ class AccountList extends Component {
} }
render() { render() {
const { showCustomInput, customPathSelected } = this.state
return ( return (
<div className="new-external-account-form account-list"> <div className="new-external-account-form account-list">
{this.renderHeader()} {this.renderHeader()}
{(!showCustomInput || customPathSelected) && this.renderAccounts()} {this.renderAccounts()}
{(!showCustomInput || customPathSelected) && this.renderPagination()} {this.renderPagination()}
{this.renderButtons()} {this.renderButtons()}
{this.renderForgetDevice()} {this.renderForgetDevice()}
</div> </div>

View File

@ -196,17 +196,6 @@
margin: 0 auto 20px; margin: 0 auto 20px;
display: flex; display: flex;
} }
&__custom-input {
height: 54px;
width: 335px;
border: 1px solid $geyser;
border-radius: 4px;
background-color: $white;
color: $scorpion;
font-size: 16px;
padding: 0 20px;
}
} }
.hw-account-list { .hw-account-list {