Skip to content
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

Add error message for user when ledger fails when attempting to sign #692

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/intl/compiled/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5791,6 +5791,28 @@
"value": "In other words, you maximize your rewards by providing the greatest benefit to the network as a whole."
}
],
"hc8EGX": [
{
"type": 0,
"value": "There was a problem trying to sign with your Ledger device. Please verify your Ledger device has both "
},
{
"type": 1,
"value": "blindSigning"
},
{
"type": 0,
"value": " and "
},
{
"type": 1,
"value": "debugData"
},
{
"type": 0,
"value": " enabled. These can be accessed by selecting the Ethereum application and then entering the Settings menu."
}
],
"hfXlpq": [
{
"type": 0,
Expand Down
3 changes: 3 additions & 0 deletions src/intl/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,9 @@
"hZrkPB": {
"message": "In other words, you maximize your rewards by providing the greatest benefit to the network as a whole."
},
"hc8EGX": {
"message": "There was a problem trying to sign with your Ledger device. Please verify your Ledger device has both {blindSigning} and {debugData} enabled. These can be accessed by selecting the Ethereum application and then entering the Settings menu."
},
"hfXlpq": {
"message": "Hungarian"
},
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Transactions/Keylist/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ export const ActionButton = ({
);
}

if (transactionStatus === TransactionStatus.REJECTED) {
if (
[TransactionStatus.REJECTED, TransactionStatus.LEDGER_ERROR].includes(
transactionStatus
)
) {
return (
<Container onClick={onClick}>
<ButtonText>
Expand Down
22 changes: 19 additions & 3 deletions src/pages/Transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ import { AbstractConnector } from '@web3-react/abstract-connector';
import _every from 'lodash/every';
import _some from 'lodash/some';
import { DepositKeyInterface, StoreState } from '../../store/reducers';
import { Alert } from '../../components/Alert';
import { Button } from '../../components/Button';
import { Heading } from '../../components/Heading';
import { Link } from '../../components/Link';
import { Paper } from '../../components/Paper';
import { Text } from '../../components/Text';
import { Button } from '../../components/Button';
import { Link } from '../../components/Link';
import { WorkflowPageTemplate } from '../../components/WorkflowPage/WorkflowPageTemplate';
import { routesEnum } from '../../Routes';
import { KeyList } from './Keylist';
import { handleMultipleTransactions } from './transactionUtils';
import { TARGET_NETWORK_CHAIN_ID } from '../ConnectWallet/web3Utils';
import { web3ReactInterface } from '../ConnectWallet';
import { WalletDisconnected } from '../ConnectWallet/WalletDisconnected';
import { WrongNetwork } from '../ConnectWallet/WrongNetwork';
import { WorkflowPageTemplate } from '../../components/WorkflowPage/WorkflowPageTemplate';
import {
DepositStatus,
DispatchTransactionStatusUpdateType,
Expand Down Expand Up @@ -156,6 +157,21 @@ const _TransactionsPage = ({
title={formatMessage({ defaultMessage: 'Transactions' })}
>
<Paper className="mt20">
{depositKeys.find(
k => k.transactionStatus === TransactionStatus.LEDGER_ERROR
) && (
<Alert variant="error" className="mb20">
<FormattedMessage
defaultMessage="There was a problem trying to sign with your Ledger device. Please verify your Ledger
device has both {blindSigning} and {debugData} enabled. These can be accessed by selecting the Ethereum
application and then entering the Settings menu."
values={{
blindSigning: <b>Blind Signing</b>,
debugData: <b>Debug Data</b>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valefar-on-discord Double checking here, do we want these to be translated? I'm not deeply familiar with any non-English Ledger interface. If we want these terms to be translated, we'll need to wrap them in their own FormattedMessage component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great question but I don't believe they are translated.

If you take a look at the ledger documentation in a different language, it will show "Blind Signing"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to update the instructions based on this little discovery.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to extract hard-coded words and used <strong>

}}
/>
</Alert>
)}
<Heading level={3} size="small" color="blueMedium">
{depositKeys.length === 1 ? (
<FormattedMessage defaultMessage="Confirm deposit" />
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Transactions/transactionUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const isUserRejectionError = (error: any) => {
return false;
};

// Error message when rejecting from ledger or blind signing and debug not enabled
const isLedgerError = (error: any) =>
error.code === -32603 && error.message.toLowerCase().includes('ledger');

/*
Recursive func for calling each transaction in succession after
the previous one has been signed
Expand Down Expand Up @@ -79,7 +83,8 @@ export const handleMultipleTransactions = async (
const remainingTxs = depositKeys.filter(
key =>
key.transactionStatus === TransactionStatus.READY ||
key.transactionStatus === TransactionStatus.REJECTED
key.transactionStatus === TransactionStatus.REJECTED ||
key.transactionStatus === TransactionStatus.LEDGER_ERROR
);

const nextTransaction = remainingTxs.shift();
Expand Down Expand Up @@ -134,6 +139,8 @@ export const handleMultipleTransactions = async (
.on('error', (error: any) => {
if (isUserRejectionError(error)) {
updateTransactionStatus(pubkey, TransactionStatus.REJECTED);
} else if (isLedgerError(error)) {
updateTransactionStatus(pubkey, TransactionStatus.LEDGER_ERROR);
} else {
updateTransactionStatus(pubkey, TransactionStatus.FAILED);
}
Expand Down
1 change: 1 addition & 0 deletions src/store/actions/depositFileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum TransactionStatus {
'STARTED',
'SUCCEEDED',
'FAILED',
'LEDGER_ERROR',
'REJECTED',
}

Expand Down