Skip to content

Commit

Permalink
Hotfix: Improve user rejected check (#3753)
Browse files Browse the repository at this point in the history
* chore: Improve user rejected check

* chore: Assume the word rejected is a user rejection
  • Loading branch information
garethfuller authored Jul 19, 2023
1 parent a87887e commit 3d8c27d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/,
Expand Down

0 comments on commit 3d8c27d

Please sign in to comment.