Skip to content

Commit

Permalink
feat: allow overriding of a connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-HocNguyena committed May 7, 2024
1 parent 77e3f9a commit ce89180
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/cardano/walletConnect/peerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PeerConnection {

private identityWalletConnect: IdentityWalletConnect | undefined;
private connected = false;
private connectedDAppAdress = "";

async start(selectedAid: string) {
let meerkatSeed = null;
Expand All @@ -40,7 +41,12 @@ class PeerConnection {
} catch {
meerkatSeed = null;
}

if (
this.identityWalletConnect &&
this.connectedDAppAdress.trim().length !== 0
) {
this.disconnectDApp(this.connectedDAppAdress);
}
this.identityWalletConnect = new IdentityWalletConnect(
this.walletInfo,
meerkatSeed,
Expand All @@ -49,12 +55,15 @@ class PeerConnection {
);
this.identityWalletConnect.setOnConnect(
(connectMessage: IConnectMessage) => {
this.connected = true;
if (!connectMessage.error) {
this.connected = true;
this.connectedDAppAdress = connectMessage.dApp.address;
}
}
);

this.identityWalletConnect.setOnDisconnect(
(connectMessage: IConnectMessage) => {
(disConnectMessage: IConnectMessage) => {
this.connected = false;
}
);
Expand Down

0 comments on commit ce89180

Please sign in to comment.