From b84aebaea3d1a5e62cdddf9c3d5e002ebf50e7cb Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Mon, 20 Nov 2023 16:28:25 +0700 Subject: [PATCH 1/2] feat: added permit signature error --- utils/getErrorMessage.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/getErrorMessage.ts b/utils/getErrorMessage.ts index d5b3a62da..1266756ce 100644 --- a/utils/getErrorMessage.ts +++ b/utils/getErrorMessage.ts @@ -5,6 +5,7 @@ export enum ErrorMessage { 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', + INVALID_SIGNATURE = 'Invalid Permit signature. Perhaps it has expired. Try signing again.', } export const getErrorMessage = (error: unknown): ErrorMessage => { @@ -21,6 +22,8 @@ export const getErrorMessage = (error: unknown): ErrorMessage => { case 'UNPREDICTABLE_GAS_LIMIT': case 'INSUFFICIENT_FUNDS': return ErrorMessage.NOT_ENOUGH_ETHER; + case 'INVALID_SIGNATURE': + return ErrorMessage.INVALID_SIGNATURE; case 'ACTION_REJECTED': case 4001: return ErrorMessage.DENIED_SIG; @@ -43,12 +46,9 @@ export const extractCodeFromError = ( // early exit on non object error if (!error || typeof error != 'object') return 0; - if ( - 'reason' in error && - typeof error.reason == 'string' && - error.reason.includes('STAKE_LIMIT') - ) { - return 'LIMIT_REACHED'; + if ('reason' in error && typeof error.reason == 'string') { + if (error.reason.includes('STAKE_LIMIT')) return 'LIMIT_REACHED'; + if (error.reason.includes('INVALID_SIGNATURE')) return 'INVALID_SIGNATURE'; } // sometimes we have error message but bad error code From ca3373bdd228f3703751ba3c455a1cec071de223 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Mon, 27 Nov 2023 17:09:13 +0700 Subject: [PATCH 2/2] fix: update text --- utils/getErrorMessage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/getErrorMessage.ts b/utils/getErrorMessage.ts index 1266756ce..a488ad760 100644 --- a/utils/getErrorMessage.ts +++ b/utils/getErrorMessage.ts @@ -5,7 +5,7 @@ export enum ErrorMessage { 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', - INVALID_SIGNATURE = 'Invalid Permit signature. Perhaps it has expired. Try signing again.', + INVALID_SIGNATURE = 'Invalid Permit signature. Perhaps it has expired or already been used. Try submitting a withdrawal request again.', } export const getErrorMessage = (error: unknown): ErrorMessage => {