1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Add Ledger connection flow warning message for failed to connect device error (#12604)

This commit is contained in:
Dan J Miller 2021-11-05 18:02:53 -02:30 committed by ryanml
parent e740f7a436
commit 010e661f8b
2 changed files with 15 additions and 4 deletions

View File

@ -1277,6 +1277,9 @@
"message": "Customize how you connect your Ledger to MetaMask. $1 is recommended, but other options are available. Read more here: $2", "message": "Customize how you connect your Ledger to MetaMask. $1 is recommended, but other options are available. Read more here: $2",
"description": "A description that appears above a dropdown where users can select between up to three options - Ledger Live, U2F or WebHID - depending on what is supported in their browser. $1 is the recommended browser option, it will be either WebHID or U2f. $2 is a link to an article where users can learn more, but will be the translation of the learnMore message." "description": "A description that appears above a dropdown where users can select between up to three options - Ledger Live, U2F or WebHID - depending on what is supported in their browser. $1 is the recommended browser option, it will be either WebHID or U2f. $2 is a link to an article where users can learn more, but will be the translation of the learnMore message."
}, },
"ledgerDeviceOpenFailureMessage": {
"message": "The Ledger device failed to open. Your Ledger might be connected to other software. Please close Ledger Live or other applications connected to your Ledger device, and try to connect again."
},
"ledgerLive": { "ledgerLive": {
"message": "Ledger Live", "message": "Ledger Live",
"description": "The name of a desktop app that can be used with your ledger device. We can also use it to connect a users Ledger device to MetaMask." "description": "The name of a desktop app that can be used with your ledger device. We can also use it to connect a users Ledger device to MetaMask."

View File

@ -402,14 +402,14 @@ export function forgetDevice(deviceName) {
export function connectHardware(deviceName, page, hdPath, t) { export function connectHardware(deviceName, page, hdPath, t) {
log.debug(`background.connectHardware`, deviceName, page, hdPath); log.debug(`background.connectHardware`, deviceName, page, hdPath);
return async (dispatch, getState) => { return async (dispatch, getState) => {
const { ledgerTransportType } = getState().metamask;
dispatch( dispatch(
showLoadingIndication(`Looking for your ${capitalize(deviceName)}...`), showLoadingIndication(`Looking for your ${capitalize(deviceName)}...`),
); );
let accounts; let accounts;
try { try {
const { ledgerTransportType } = getState().metamask;
if (deviceName === 'ledger') { if (deviceName === 'ledger') {
await promisifiedBackground.establishLedgerTransportPreference(); await promisifiedBackground.establishLedgerTransportPreference();
} }
@ -435,8 +435,16 @@ export function connectHardware(deviceName, page, hdPath, t) {
); );
} catch (error) { } catch (error) {
log.error(error); log.error(error);
dispatch(displayWarning(error.message)); if (
throw error; deviceName === 'ledger' &&
ledgerTransportType === LEDGER_TRANSPORT_TYPES.WEBHID &&
error.message.match('Failed to open the device')
) {
dispatch(displayWarning(t('ledgerDeviceOpenFailureMessage')));
} else {
dispatch(displayWarning(error.message));
throw error;
}
} finally { } finally {
dispatch(hideLoadingIndication()); dispatch(hideLoadingIndication());
} }