From 084c29d1b699a321dbd1edf5a78e9ae68f09946c Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Wed, 3 Apr 2024 20:15:18 +0000 Subject: [PATCH] Fix but in JsonRpcClient.call --- packages/core/src/internal/execution/jsonrpc-client.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/core/src/internal/execution/jsonrpc-client.ts b/packages/core/src/internal/execution/jsonrpc-client.ts index 7ba401437..10350e77e 100644 --- a/packages/core/src/internal/execution/jsonrpc-client.ts +++ b/packages/core/src/internal/execution/jsonrpc-client.ts @@ -325,10 +325,16 @@ export class EIP1193JsonRpcClient implements JsonRpcClient { }; } catch (error) { if (error instanceof Error) { - if ("data" in error && typeof error.data === "string") { + const errorWithData = error as { data?: string | { data?: string } }; + const data = + typeof errorWithData.data === "string" + ? errorWithData.data + : errorWithData.data?.data; + + if (data !== undefined) { return { success: false, - returnData: error.data, + returnData: data, customErrorReported: isCustomErrorError(error), }; }