From 397afde68eab90f77caf139b333b3df2ecd23606 Mon Sep 17 00:00:00 2001 From: mucahit Date: Mon, 4 Jul 2022 12:14:49 +0100 Subject: [PATCH 1/2] fix: `connect` reject error type --- src/modal/peraWalletConnectModalUtils.tsx | 4 ++-- src/util/PeraWalletConnectError.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modal/peraWalletConnectModalUtils.tsx b/src/modal/peraWalletConnectModalUtils.tsx index 64395d4..66482c9 100644 --- a/src/modal/peraWalletConnectModalUtils.tsx +++ b/src/modal/peraWalletConnectModalUtils.tsx @@ -54,9 +54,9 @@ function openPeraWalletConnectModal(rejectPromise?: (error: any) => void) { rejectPromise( new PeraWalletConnectError( { - type: "SESSION_CONNECT" + type: "CONNECT_MODAL_CLOSED" }, - "The action canceled by the user." + "The modal has been closed by the user." ) ); } diff --git a/src/util/PeraWalletConnectError.ts b/src/util/PeraWalletConnectError.ts index 224583b..c7d4964 100644 --- a/src/util/PeraWalletConnectError.ts +++ b/src/util/PeraWalletConnectError.ts @@ -4,7 +4,8 @@ interface PeraWalletConnectErrorData { | "SESSION_DISCONNECT" | "SESSION_UPDATE" | "SESSION_CONNECT" - | "SESSION_RECONNECT"; + | "SESSION_RECONNECT" + | "CONNECT_MODAL_CLOSED"; detail?: any; } From 2731ee8afeb46f5fe7926bc76bce807da45cdf30 Mon Sep 17 00:00:00 2001 From: mucahit Date: Mon, 4 Jul 2022 12:23:56 +0100 Subject: [PATCH 2/2] fix: Update readme with the new reject type --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 129b144..5a58bef 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,9 @@ function App() { .reject((error) => { // You MUST handle the reject because once the user closes the modal, peraWallet.connect() promise will be rejected. // For the async/await syntax you MUST use try/catch + if (error?.data?.type !== "CONNECT_MODAL_CLOSED") { + // log the necessary errors + } }); }