Skip to content

Commit

Permalink
Merge pull request #12 from lidofinance/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
itaven authored Aug 10, 2023
2 parents d1d9910 + 0c0913a commit 9991563
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 9991563

Please sign in to comment.