feat: NDK (WIP)

This commit is contained in:
2024-04-23 13:08:23 +01:00
parent ea54ee2b00
commit eee76e64e5
17 changed files with 1048 additions and 381 deletions

View File

@ -156,9 +156,7 @@ export class NostrConnectWallet extends EventEmitter<WalletEvents> implements LN
},
reject,
});
this.#conn?.queueReq(["REQ", "info", { kinds: [13194], limit: 1 }], () => {
// ignored
});
this.#conn?.request(["REQ", "info", { kinds: [13194], limit: 1 }]);
});
} else {
throw new WalletError(WalletErrorCode.GeneralError, rsp.error.message);
@ -292,7 +290,7 @@ export class NostrConnectWallet extends EventEmitter<WalletEvents> implements LN
pending.resolve(e.content);
this.#commandQueue.delete(replyTo[1]);
this.#conn?.closeReq(sub);
this.#conn?.closeRequest(sub);
}
async #rpc<T>(method: string, params: Record<string, string | number | undefined>) {
@ -320,21 +318,16 @@ export class NostrConnectWallet extends EventEmitter<WalletEvents> implements LN
.tag(["p", this.#config.walletPubkey]);
const evCommand = await eb.buildAndSign(this.#config.secret);
this.#conn.queueReq(
[
"REQ",
evCommand.id.slice(0, 12),
{
kinds: [23195 as EventKind],
authors: [this.#config.walletPubkey],
["#e"]: [evCommand.id],
},
],
() => {
// ignored
this.#conn.request([
"REQ",
evCommand.id.slice(0, 12),
{
kinds: [23195 as EventKind],
authors: [this.#config.walletPubkey],
["#e"]: [evCommand.id],
},
);
await this.#conn.sendEventAsync(evCommand);
]);
await this.#conn.publish(evCommand);
return await new Promise<T>((resolve, reject) => {
this.#commandQueue.set(evCommand.id, {
resolve: async (o: string) => {