@0xsquid/react-hooks 3.0.30-beta.6 → 3.0.30-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,14 @@ export declare const transactionErrorCode: Record<string, TransactionErrorWithMe
|
|
|
8
8
|
* @returns boolean
|
|
9
9
|
*/
|
|
10
10
|
export declare const isTransactionError: (error: any) => error is TransactionError;
|
|
11
|
+
interface GnosisTransactionError {
|
|
12
|
+
code: string;
|
|
13
|
+
error: {
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
shortMessage: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const isGnosisSafeTxError: (error: any) => error is GnosisTransactionError;
|
|
11
19
|
/**
|
|
12
20
|
* Return the error from enum entry
|
|
13
21
|
* @param error
|
|
@@ -23,6 +31,7 @@ export declare const getTransactionError: (error: any) => TransactionErrorWithMe
|
|
|
23
31
|
*/
|
|
24
32
|
export declare const isSwapRouteError: (error: any) => error is SquidRouteError;
|
|
25
33
|
export declare const isStatusError: (error: any) => error is SquidStatusError;
|
|
34
|
+
export {};
|
|
26
35
|
/**
|
|
27
36
|
* Tries to parse as SquidRouteError Type & Return the error from Record entries
|
|
28
37
|
* @param error
|
|
@@ -10,6 +10,11 @@ export const transactionErrorCode = {
|
|
|
10
10
|
type: TransactionErrorType.REJECTED_BY_USER,
|
|
11
11
|
message: "Return to the swap page and try again.",
|
|
12
12
|
},
|
|
13
|
+
// Gnosis Safe
|
|
14
|
+
"Transaction was rejected": {
|
|
15
|
+
type: TransactionErrorType.REJECTED_BY_USER,
|
|
16
|
+
message: "Return to the swap page and try again.",
|
|
17
|
+
},
|
|
13
18
|
// Metamask
|
|
14
19
|
4001: {
|
|
15
20
|
type: TransactionErrorType.REJECTED_BY_USER,
|
|
@@ -39,21 +44,30 @@ export const isTransactionError = (error) => {
|
|
|
39
44
|
typeof error.reason === "string" ||
|
|
40
45
|
typeof error.action === "string"));
|
|
41
46
|
};
|
|
47
|
+
export const isGnosisSafeTxError = (error) => {
|
|
48
|
+
try {
|
|
49
|
+
return (error &&
|
|
50
|
+
typeof error.code === "string" &&
|
|
51
|
+
typeof error.error.message === "string" &&
|
|
52
|
+
typeof error.shortMessage === "string");
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
42
58
|
/**
|
|
43
59
|
* Return the error from enum entry
|
|
44
60
|
* @param error
|
|
45
61
|
* @returns boolean
|
|
46
62
|
*/
|
|
47
63
|
export const getTransactionError = (error) => {
|
|
48
|
-
|
|
49
|
-
error
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
if (isGnosisSafeTxError(error)) {
|
|
65
|
+
const errorWithMessage = transactionErrorCode[error.error.message];
|
|
66
|
+
if (errorWithMessage) {
|
|
67
|
+
return errorWithMessage;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
52
70
|
if (isTransactionError(error)) {
|
|
53
|
-
console.log({
|
|
54
|
-
code: error.code,
|
|
55
|
-
message: error.message,
|
|
56
|
-
});
|
|
57
71
|
const castError = error;
|
|
58
72
|
if (castError.code)
|
|
59
73
|
return transactionErrorCode[castError.code];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorService.js","sourceRoot":"","sources":["../../../src/services/internal/errorService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAC/B;IACE,WAAW;IACX,eAAe,EAAE;QACf,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,QAAQ;IACR,kBAAkB,EAAE;QAClB,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,WAAW;IACX,IAAI,EAAE;QACJ,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,cAAc,EAAE;QACd,IAAI,EAAE,oBAAoB,CAAC,cAAc;QACzC,OAAO,EACL,kFAAkF;KACrF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,oBAAoB,CAAC,OAAO;QAClC,OAAO,EAAE,yCAAyC;KACnD;CACF,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA6B,EAAE;IAC1E,OAAO,CACL,KAAK;QACL,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAC7B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAC9B,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;YACjC,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAChC,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CACpC,CAAC;AACJ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"errorService.js","sourceRoot":"","sources":["../../../src/services/internal/errorService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAC/B;IACE,WAAW;IACX,eAAe,EAAE;QACf,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,QAAQ;IACR,kBAAkB,EAAE;QAClB,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,cAAc;IACd,0BAA0B,EAAE;QAC1B,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,WAAW;IACX,IAAI,EAAE;QACJ,IAAI,EAAE,oBAAoB,CAAC,gBAAgB;QAC3C,OAAO,EAAE,wCAAwC;KAClD;IACD,cAAc,EAAE;QACd,IAAI,EAAE,oBAAoB,CAAC,cAAc;QACzC,OAAO,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