Skip to content

Commit

Permalink
fix: WalletConnect does not connect a second time (#44)
Browse files Browse the repository at this point in the history
* fix: walletconnect provider modal bug

* fix: typing
  • Loading branch information
Addminus authored Jan 30, 2023
1 parent 13998ad commit 72b5373
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/wallet-management/src/connectors/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ interface MockWalletConnectProvider
export class WalletConnect extends Connector {
private readonly options?: WalletConnectOptions;

public provider: MockWalletConnectProvider;
public provider: MockWalletConnectProvider | undefined;

public walletConnectProvider: WalletConnectProvider;
public walletConnectProvider: WalletConnectProvider | undefined;

public isCurrentlyUsed: boolean = false;

constructor(actions: Actions, options?: WalletConnectOptions) {
super(actions);
this.options = options;

const walletConnectProvider = new WalletConnectProvider({
rpc: this.options!.rpc,
});
this.provider =
walletConnectProvider as unknown as MockWalletConnectProvider;
this.walletConnectProvider = walletConnectProvider;
}

private async startListening(): Promise<void> {
Expand Down Expand Up @@ -61,6 +54,14 @@ export class WalletConnect extends Connector {
this.actions.startActivation();
this.isCurrentlyUsed = true;

// Reset provider for every connection attempt
const walletConnectProvider = new WalletConnectProvider({
rpc: this.options!.rpc,
});
this.provider =
walletConnectProvider as unknown as MockWalletConnectProvider;
this.walletConnectProvider = walletConnectProvider;

await this.provider?.enable(); // open modal
this.startListening();

Expand Down

0 comments on commit 72b5373

Please sign in to comment.