-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Implement hardware connectivity confirmation screens #12725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
3e53d72
Implement hardware connectivity confirmation screens
darkwing 1d73fa4
Dropdown progress
darkwing 17cf8b1
Progress
darkwing bac38d0
Remove path config from popover, lint
darkwing a37f51b
Add hardware connectivity functionality
darkwing 5c1a3e6
Remove unused component
darkwing 992f662
Wire up actual calls to the controller to poll for ledger connectivity
darkwing ea43299
Prevent navigation event during connection
darkwing 6099099
Cleanup console logs
darkwing 18a2899
Hide connection popover as soon as connection happens
darkwing bfaabad
Localize Ledger steps
darkwing 132ea45
Remove logs, update state to not show advanced upon connection
darkwing 25863cc
Use constants
darkwing a892954
Fix incorrect keyring localization
darkwing 479f66a
Assume hardware ready upon connection
darkwing eadd017
Fix colors per Thomas' request
darkwing 2d28d74
Add icons
darkwing 7603b49
Fixes ci, lint, and unit test issues for hardware connectivity. (#13…
tmashuang 6090d14
Remove console.logs
darkwing a022ed8
Clear interval upon page unload
darkwing 418754d
Add close button to connect modal
darkwing 4080488
Remove unused LedgerInstructionField component
darkwing 818fd2e
Broaden language
darkwing 66663b7
Rename prop to be more descriptive
darkwing 05d97a8
Turn connection link to button
darkwing dbbced2
Change name of checkLedgerReady to more generic name
darkwing dda02c5
Don't show connect button when connected
darkwing bf0478e
Allow connecting in the popup to work
darkwing 9b59864
Remove duplicate classname declaration
darkwing 6308095
Fix success text color
darkwing 6e0f447
Fix lint
darkwing 219340c
Fix merge issues
darkwing d7cd8bd
Fix colors and prop
darkwing 2ef45f3
Address feedback
darkwing bdf12e6
Fix lint
darkwing 809ed94
Remove unused file
darkwing 93cf4f1
Move transport dropdown to component library
darkwing f331227
Disable ledger connectivity UI for Firefox
darkwing 575f518
Add storybook for LedgerTransportDropdown
darkwing d27c1f6
Fix outdated link
darkwing e912ef3
Rename variable
darkwing f60f7b2
EXPERIMENTAL FOR LINUX: Launch into full screen
darkwing 8b07c09
Let the SEND screen direct when to stop and start keyring connection …
darkwing 9e52c73
HardwareConnectivity: support dark mode ledger svg
digiwand aa5079f
Update ui/pages/confirm-transaction-base/hardware-connectivity/index.…
darkwing 80451ba
Address feedback
darkwing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React, { useState } from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { useI18nContext } from '../../../hooks/useI18nContext'; | ||
|
||
import Dialog from '../../ui/dialog'; | ||
import Button from '../../ui/button'; | ||
import Dropdown from '../../ui/dropdown/dropdown'; | ||
|
||
import { | ||
LEDGER_TRANSPORT_TYPES, | ||
LEDGER_USB_VENDOR_ID, | ||
} from '../../../../shared/constants/hardware-wallets'; | ||
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url'; | ||
|
||
import { | ||
getLedgerTransportType, | ||
doesUserHaveALedgerAccount, | ||
} from '../../../ducks/metamask/metamask'; | ||
|
||
import { setLedgerTransportPreference } from '../../../store/actions'; | ||
|
||
export default function LedgerTransportDropdown() { | ||
const [showLedgerTransportWarning, setShowLedgerTransportWarning] = useState( | ||
false, | ||
); | ||
|
||
const [ledgerTransportType, setLedgerTransportType] = useState( | ||
useSelector(getLedgerTransportType), | ||
); | ||
|
||
const dispatch = useDispatch(); | ||
|
||
const t = useI18nContext(); | ||
|
||
const userHasALedgerAccount = useSelector(doesUserHaveALedgerAccount); | ||
|
||
const LEDGER_TRANSPORT_NAMES = { | ||
LIVE: t('ledgerLive'), | ||
WEBHID: t('webhid'), | ||
U2F: t('u2f'), | ||
}; | ||
|
||
const transportTypeOptions = [ | ||
{ | ||
name: LEDGER_TRANSPORT_NAMES.LIVE, | ||
value: LEDGER_TRANSPORT_TYPES.LIVE, | ||
}, | ||
{ | ||
name: LEDGER_TRANSPORT_NAMES.U2F, | ||
value: LEDGER_TRANSPORT_TYPES.U2F, | ||
}, | ||
]; | ||
|
||
if (window.navigator.hid) { | ||
transportTypeOptions.push({ | ||
name: LEDGER_TRANSPORT_NAMES.WEBHID, | ||
value: LEDGER_TRANSPORT_TYPES.WEBHID, | ||
}); | ||
} | ||
|
||
const recommendedLedgerOption = window.navigator.hid | ||
? LEDGER_TRANSPORT_NAMES.WEBHID | ||
: LEDGER_TRANSPORT_NAMES.U2F; | ||
|
||
return ( | ||
<div className="settings-page__content-row"> | ||
<div className="settings-page__content-item"> | ||
<span>{t('preferredLedgerConnectionType')}</span> | ||
<div className="settings-page__content-description"> | ||
{t('ledgerConnectionPreferenceDescription', [ | ||
recommendedLedgerOption, | ||
<Button | ||
key="ledger-connection-settings-learn-more" | ||
type="link" | ||
href={ZENDESK_URLS.HARDWARE_WALLET_HELP} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="settings-page__inline-link" | ||
> | ||
{t('learnMore')} | ||
</Button>, | ||
])} | ||
</div> | ||
</div> | ||
<div className="settings-page__content-item"> | ||
<div className="settings-page__content-item-col"> | ||
<Dropdown | ||
id="ledger-transport-dropdown" | ||
options={transportTypeOptions} | ||
selectedOption={ledgerTransportType} | ||
onChange={async (transportType) => { | ||
if ( | ||
ledgerTransportType === LEDGER_TRANSPORT_TYPES.LIVE && | ||
transportType === LEDGER_TRANSPORT_TYPES.WEBHID | ||
) { | ||
setShowLedgerTransportWarning(true); | ||
} | ||
setLedgerTransportType(transportType); | ||
dispatch(setLedgerTransportPreference(transportType)); | ||
if ( | ||
transportType === LEDGER_TRANSPORT_TYPES.WEBHID && | ||
userHasALedgerAccount | ||
) { | ||
await window.navigator.hid.requestDevice({ | ||
filters: [{ vendorId: LEDGER_USB_VENDOR_ID }], | ||
}); | ||
} | ||
}} | ||
/> | ||
{showLedgerTransportWarning ? ( | ||
<Dialog type="message"> | ||
<div className="settings-page__content-item-dialog"> | ||
{t('ledgerTransportChangeWarning')} | ||
</div> | ||
</Dialog> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
ui/components/app/ledger-transport-dropdown/index.stories.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import LedgerTransportDropdown from '.'; | ||
|
||
export default { | ||
title: 'Components/App/LedgerTransportDropdown', | ||
id: __filename, | ||
}; | ||
|
||
export const DefaultStory = (args) => { | ||
return <LedgerTransportDropdown {...args} />; | ||
}; | ||
|
||
DefaultStory.storyName = 'Default'; | ||
|
||
DefaultStory.args = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove and replace
showHardwareConnectionContents
in favor ofhideConfirmPageContainerSummaryAndButtons