Skip to content

Commit

Permalink
refactor(nostr): remove enable from provide because we always need to…
Browse files Browse the repository at this point in the history
… check for unlock #1727
  • Loading branch information
escapedcat committed Nov 29, 2022
1 parent 880e75a commit af6e7c8
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/extension/ln/nostr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ import { Event } from "./types";

export default class NostrProvider {
nip04 = new Nip04(this);
enabled: boolean;

constructor() {
this.enabled = false;
}

private enable() {
// if (this.enabled) {
// return Promise.resolve({ enabled: true });
// }
private async enable() {
return this.execute<{
enabled: boolean;
remember: boolean;
}>("enable").then((result) => {
if (typeof result.enabled === "boolean") {
this.enabled = result.enabled;
}
return result;
});
}
Expand All @@ -28,24 +17,9 @@ export default class NostrProvider {
}

async signEvent(event: Event): Promise<Event | boolean> {
// if (!this.enabled) {
// throw new Error("Provider must be enabled before calling signEvent");
// }
console.log("signEvent 1");
await this.enable();

// this.enable();
console.log("signEvent 2");

return this.execute<{
enabled: boolean;
remember: boolean;
}>("enable").then((result) => {
if (result.enabled) {
return this.execute("signEventOrPrompt", { event });
} else {
return false;
}
});
return this.execute("signEventOrPrompt", { event });
}

async getRelays(): Promise<string[]> {
Expand Down

0 comments on commit af6e7c8

Please sign in to comment.