Skip to content

Commit 9fe795e

Browse files
committed
fix: merge conflicts
2 parents d76ab8c + 04f2d8d commit 9fe795e

File tree

107 files changed

+1087
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1087
-779
lines changed

kleros-sdk/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-sdk",
3-
"version": "2.1.8",
3+
"version": "2.1.10",
44
"description": "SDK for Kleros version 2",
55
"repository": "[email protected]:kleros/kleros-v2.git",
66
"homepage": "https://github.com/kleros/kleros-v2/tree/master/kleros-sdk#readme",
@@ -39,13 +39,16 @@
3939
"rimraf": "^6.0.1",
4040
"ts-node": "^10.9.2",
4141
"typescript": "^5.6.3",
42+
"viem": "^2.21.48",
4243
"vitest": "^1.6.0"
4344
},
4445
"dependencies": {
4546
"@reality.eth/reality-eth-lib": "^3.2.44",
4647
"@urql/core": "^5.0.8",
4748
"mustache": "^4.2.0",
48-
"viem": "^2.21.48",
4949
"zod": "^3.23.8"
50+
},
51+
"peerDependencies": {
52+
"viem": "^2.21.48"
5053
}
5154
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { type SimulateContractErrorType } from "@wagmi/core";
2+
3+
type ExtendedWagmiError = SimulateContractErrorType & { shortMessage?: string; metaMessages?: string[] };
4+
5+
/**
6+
* @param error
7+
* @description Tries to extract the human readable error message, otherwise reverts to error.message
8+
* @returns Human readable error if possible
9+
*/
10+
export const parseWagmiError = (error: SimulateContractErrorType) => {
11+
const extError = error as ExtendedWagmiError;
12+
13+
const metaMessage = extError?.metaMessages?.[0];
14+
const shortMessage = extError?.shortMessage;
15+
16+
return metaMessage ?? shortMessage ?? error.message;
17+
};

web-devtools/src/utils/wrapWithToast.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { toast, ToastPosition, Theme } from "react-toastify";
22
import { type PublicClient, type TransactionReceipt } from "viem";
33

4+
import { parseWagmiError } from "./parseWagmiError";
5+
46
export const OPTIONS = {
57
position: "top-center" as ToastPosition,
68
autoClose: 5000,
@@ -35,11 +37,11 @@ export async function wrapWithToast(
3537
})
3638
)
3739
.catch((error) => {
38-
toast.error(error.shortMessage ?? error.message, OPTIONS);
40+
toast.error(parseWagmiError(error), OPTIONS);
3941
return { status: false };
4042
});
4143
}
4244

4345
export async function catchShortMessage(promise: Promise<any>) {
44-
return await promise.catch((error) => toast.error(error.shortMessage ?? error.message, OPTIONS));
46+
return await promise.catch((error) => toast.error(parseWagmiError(error), OPTIONS));
4547
}

0 commit comments

Comments
 (0)