From 3d8c27d0581922a8a694740da246528dfc1e6d12 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Wed, 19 Jul 2023 15:44:28 +0100 Subject: [PATCH] Hotfix: Improve user rejected check (#3753) * chore: Improve user rejected check * chore: Assume the word rejected is a user rejection --- src/lib/utils/errors.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/utils/errors.ts b/src/lib/utils/errors.ts index 2f59da9b4b..768ebe51bb 100644 --- a/src/lib/utils/errors.ts +++ b/src/lib/utils/errors.ts @@ -222,6 +222,10 @@ function isErrorOfType(error: any, messages: RegExp[]): boolean { return true; } + if (error.cause?.code && error.cause?.code === 4001) { + return true; + } + if (error.cause instanceof Error) return isUserRejected(error.cause); return false; @@ -232,10 +236,12 @@ function isErrorOfType(error: any, messages: RegExp[]): boolean { */ function isUserRejected(error): boolean { const messages = [ + /rejected/, /user rejected transaction/, /request rejected/, /user rejected methods./, /user rejected the transaction/, + /user rejected the request/, /rejected by user/, /user canceled/, /cancelled by user/,