Skip to content

Commit

Permalink
Merge pull request #10 from lidofinance/feature/ethui-640-add-locked-…
Browse files Browse the repository at this point in the history
…ledger-device-error-message

Device locked error
  • Loading branch information
itaven authored Aug 10, 2023
2 parents ab9cdbe + 3786f43 commit 0c0913a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/getErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum ErrorMessage {
SOMETHING_WRONG = 'Something went wrong.',
ENABLE_BLIND_SIGNING = 'Please enable blind signing on your Ledger hardware wallet.',
LIMIT_REACHED = 'Transaction could not be completed because stake limit is exhausted. Please wait until the stake limit restores and try again. Otherwise, you can swap your Ethereum on 1inch platform instantly.',
DEVICE_LOCKED = 'Please unlock your Ledger hardware wallet',
}

export const getErrorMessage = (error: unknown): ErrorMessage => {
Expand All @@ -27,6 +28,8 @@ export const getErrorMessage = (error: unknown): ErrorMessage => {
return ErrorMessage.LIMIT_REACHED;
case 'ENABLE_BLIND_SIGNING':
return ErrorMessage.ENABLE_BLIND_SIGNING;
case 'DEVICE_LOCKED':
return ErrorMessage.DEVICE_LOCKED;
default:
return ErrorMessage.SOMETHING_WRONG;
}
Expand Down Expand Up @@ -73,8 +76,12 @@ export const extractCodeFromError = (
}

if ('name' in error && typeof error.name == 'string') {
if (error.name.toLocaleLowerCase() === 'ethapppleaseenablecontractdata')
const error_name = error.name.toLowerCase();
if (error_name === 'EthAppPleaseEnableContractData'.toLowerCase())
return 'ENABLE_BLIND_SIGNING';
if (error_name === 'LockedDeviceError'.toLowerCase()) {
return 'DEVICE_LOCKED';
}
}
if ('code' in error) {
if (typeof error.code === 'string') return error.code.toUpperCase();
Expand Down

0 comments on commit 0c0913a

Please sign in to comment.