Skip to content

Commit b57156b

Browse files
committed
fix: require enable to be called first in nwc webln provider
1 parent c544b99 commit b57156b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/webln/NostrWeblnProvider.ts

+7
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
118118
walletPubkey: string;
119119
options: NostrWebLNOptions;
120120
subscribers: Record<string, (payload: unknown) => void>;
121+
private _enabled = false;
121122

122123
static parseWalletConnectUrl(walletConnectUrl: string) {
123124
walletConnectUrl = walletConnectUrl
@@ -242,6 +243,7 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
242243
}
243244

244245
async enable() {
246+
this._enabled = true;
245247
return Promise.resolve();
246248
}
247249

@@ -525,6 +527,11 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
525527
}
526528

527529
private async checkConnected() {
530+
if (!this._enabled) {
531+
throw new Error(
532+
"please call enable() and await the promise before calling this function",
533+
);
534+
}
528535
if (!this.secret) {
529536
throw new Error("Missing secret key");
530537
}

0 commit comments

Comments
 (0)