Skip to content

Commit

Permalink
Improves documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ggaabe committed May 1, 2023
1 parent ecbdc4a commit da91422
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/connectors/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ export class InjectedConnector implements Connector {
return this.connectedWalletAPI!.signTx(tx, partialSign);
}

/**
* This will call the injected wallet to see if it is still connected.
* It makes a call to the getNetworkID method of the enabled wallet to see
* if a response is still received.
* If the timeout expires, it will return false.
* @param timeout timeout in milliseconds
* @returns true if the wallet is still interactable, false otherwise
*/
public async isConnected(timeout = 10000): Promise<boolean> {
return new Promise<boolean>((resolve, _) => {
const timeoutId = setTimeout(() => {
Expand Down
6 changes: 6 additions & 0 deletions src/connectors/walletconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ export class WalletConnectConnector implements Connector {
return UniversalProviderFactory.getProvider();
}

/**
* This will ping the wallet relay connection to check if it is connected
* If the timeout expires, it will return false.
* @param timeout timeout in milliseconds
* @returns true if the wallet is still interactable, false otherwise
*/
public async isConnected(timeout = 10000): Promise<boolean> {
return new Promise<boolean>((resolve, _) => {
const timeoutId = setTimeout(() => {
Expand Down

0 comments on commit da91422

Please sign in to comment.