Skip to content

Commit

Permalink
Merge pull request #17 from perawallet/fix/connect-reject-error-type
Browse files Browse the repository at this point in the history
fix: `connect` reject error type
  • Loading branch information
mucahit authored Jul 4, 2022
2 parents 7df147e + 2731ee8 commit 0377eb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/modal/peraWalletConnectModalUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/util/PeraWalletConnectError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ interface PeraWalletConnectErrorData {
| "SESSION_DISCONNECT"
| "SESSION_UPDATE"
| "SESSION_CONNECT"
| "SESSION_RECONNECT";
| "SESSION_RECONNECT"
| "CONNECT_MODAL_CLOSED";
detail?: any;
}

Expand Down

0 comments on commit 0377eb9

Please sign in to comment.