Skip to content

Commit

Permalink
fix: wip debug meerkat
Browse files Browse the repository at this point in the history
  • Loading branch information
jimcase committed Feb 10, 2025
1 parent 3ff0c73 commit b223ac9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/core/cardano/walletConnect/identityWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class IdentityWalletConnect extends CardanoPeerConnect {
seed: seed,
announce: announce,
discoverySeed: discoverySeed,
logLevel: "info",
logLevel: "debug",
});
this.selectedAid = selectedAid;
this.eventEmitter = eventService;
Expand Down Expand Up @@ -139,6 +139,7 @@ class IdentityWalletConnect extends CardanoPeerConnect {
protected submitTx(tx: string): Promise<string> {
throw new Error("Method not implemented.");
}

}

export { IdentityWalletConnect };
6 changes: 4 additions & 2 deletions src/core/cardano/walletConnect/peerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class PeerConnection {
];

private announce = [
"wss://tracker.webtorrent.dev:443/announce",
"wss://dev.btt.cf-identity-wallet.metadata.dev.cf-deployments.org"
"wss://tracker.webtorrent.dev:443/announce"
];

private identityWalletConnect: IdentityWalletConnect | undefined;
Expand Down Expand Up @@ -83,6 +82,8 @@ class PeerConnection {

async start(selectedAid: string) {



const meerkatSeed = await SecureStorage.get(
KeyStoreKeys.MEERKAT_SEED
);
Expand All @@ -103,6 +104,7 @@ class PeerConnection {
selectedAid,
this.eventEmitter
);

this.identityWalletConnect.setOnConnect(
async (connectMessage: IConnectMessage) => {
if (!connectMessage.error) {
Expand Down
11 changes: 9 additions & 2 deletions src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@ionic/react";
import { IonReactRouter } from "@ionic/react-router";
import { StrictMode, useEffect, useState } from "react";
import EventEmitter from "events";
import { Routes } from "../routes";
import { useAppDispatch, useAppSelector } from "../store/hooks";
import {
Expand All @@ -35,6 +36,7 @@ import { SecureStorage } from "../core/storage";
import { compareVersion } from "./utils/version";
import { ANDROID_MIN_VERSION, IOS_MIN_VERSION, WEBVIEW_MIN_VERSION } from "./globals/constants";


setupIonicReact();

const App = () => {
Expand All @@ -49,15 +51,20 @@ const App = () => {
const handleUnknownPromiseError = (event: PromiseRejectionEvent) => {
// prevent log error to console.
event.preventDefault();
event.promise.catch((e) => showError("Unhandled error", e, dispatch));
const reasonMessage = event.reason?.message || JSON.stringify(event.reason);
if (reasonMessage.includes("No torrent with id")) return; // TODO: refactor error

event.promise.catch((e) => {
showError("Unhandled error", e, dispatch)
});
}

window.addEventListener("unhandledrejection", handleUnknownPromiseError);

const handleUnknownError = (event: ErrorEvent) => {
event.preventDefault();
/* eslint-disable no-console */
console.error("Unhandled error", event.error);
console.error("Unhandled error222", event.error);
// showError("Unhandled error", event.error, dispatch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ConfirmConnectModal = ({
isConnectModal,
closeModal,
onConfirm,
onReconnect,
connectionData,
onDeleteConnection,
}: ConfirmConnectModalProps) => {
Expand Down Expand Up @@ -77,6 +78,12 @@ const ConfirmConnectModal = ({
onConfirm();
};


const reconnect = () => {
closeModal();
onReconnect && onReconnect();
};

const confirmClass = combineClassNames("confirm-connect-submit", {
"primary-button": isConnectModal,
"secondary-button": !isConnectModal,
Expand Down Expand Up @@ -150,6 +157,14 @@ const ConfirmConnectModal = ({
>
{buttonTitle}
</IonButton>
<IonButton
disabled={isConnecting}
className={confirmClass}
data-testid="confirm-connect-btn"
onClick={reconnect}
>
Reconnect
</IonButton>
</OptionModal>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface ConfirmConnectModalProps {
openModal: boolean;
closeModal: () => void;
onConfirm: () => void;
onReconnect?: () => void;
onDeleteConnection: (data: ConnectionData) => void;
isConnectModal: boolean;
connectionData?: ConnectionData;
Expand Down
6 changes: 6 additions & 0 deletions src/ui/pages/Menu/components/ConnectWallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ const ConnectWallet = forwardRef<ConnectWalletOptionRef, object>(
const disconnectWallet = () => {
if (!connectedWallet) return;
PeerConnection.peerConnection.disconnectDApp(connectedWallet?.id);

};

const reconnect = async () => {
if (!connectedWallet) return;
await PeerConnection.peerConnection.connectWithDApp(connectedWallet?.id);
}
const toggleConnected = () => {
if (defaultIdentifierCache.length === 0) {
setOpenIdentifierMissingAlert(true);
Expand Down Expand Up @@ -337,6 +342,7 @@ const ConnectWallet = forwardRef<ConnectWalletOptionRef, object>(
openModal={openConfirmConnectModal}
closeModal={() => setOpenConfirmConnectModal(false)}
onConfirm={toggleConnected}
onReconnect={reconnect}
connectionData={actionInfo.data}
onDeleteConnection={handleOpenDeleteAlert}
/>
Expand Down

0 comments on commit b223ac9

Please sign in to comment.