Skip to content

Commit

Permalink
Added detectProvider to detect whether a WebLN provider is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpp committed Oct 29, 2022
1 parent ab22196 commit 5eaf0a6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export interface GetProviderParameters {
pubkey?: string;
}

export function detectProvider(): boolean {
const webln: WebLNProvider = (window as any).webln;
if (!webln) {
return false;
}

return true;
}

export function requestProvider(_: GetProviderParameters = {}): Promise<WebLNProvider> {
return new Promise((resolve, reject) => {
if (typeof window === 'undefined') {
Expand Down

0 comments on commit 5eaf0a6

Please sign in to comment.