Skip to content

Commit

Permalink
fix: init No matching key
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jun 19, 2024
1 parent ce0adfb commit 007d333
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class WalletConnectTransport<
) {
super(
name,
WalletConnectCommunicationClient.getInstance(wcOptions),
WalletConnectCommunicationClient.getInstance(wcOptions, isLeader),
new PeerManager<K>(storage, storageKey)
)
}
Expand Down Expand Up @@ -93,7 +93,7 @@ export class WalletConnectTransport<
}

public async getPeers(): Promise<T[]> {
const client = WalletConnectCommunicationClient.getInstance(this.wcOptions)
const client = WalletConnectCommunicationClient.getInstance(this.wcOptions, this.isLeader)
const session = client.currentSession()
if (!session) {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,22 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
*/
private messageIds: string[] = []

constructor(private wcOptions: { network: NetworkType; opts: SignClientTypes.Options }) {
constructor(
private wcOptions: { network: NetworkType; opts: SignClientTypes.Options },
private isLeader: Function
) {
super()
}

static getInstance(wcOptions: {
network: NetworkType
opts: SignClientTypes.Options
}): WalletConnectCommunicationClient {
static getInstance(
wcOptions: {
network: NetworkType
opts: SignClientTypes.Options
},
isLeader: Function
): WalletConnectCommunicationClient {
if (!this.instance) {
this.instance = new WalletConnectCommunicationClient(wcOptions)
this.instance = new WalletConnectCommunicationClient(wcOptions, isLeader)
}
return WalletConnectCommunicationClient.instance
}
Expand Down Expand Up @@ -675,6 +681,12 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
this.notifyListeners(_pairingTopic, errorResponse)
}
})
.then(async () => {
const isLeader = await this.isLeader()
if (!isLeader) {
await this.closeSignClient()
}
})

logger.warn('return uri and topic')

Expand Down

0 comments on commit 007d333

Please sign in to comment.