UNPKG

applesauce-wallet-connect

Version:

NIP-47 Nostr Wallet Connect implementation for both clients and services.

29 lines (28 loc) 1.28 kB
import { EventFactory, blankEventTemplate } from "applesauce-core/factories"; import { includeSingletonTag } from "applesauce-core/operations/tags"; import { setContent } from "applesauce-core/operations/content"; import { WALLET_INFO_KIND } from "../helpers/support.js"; export class WalletInfoFactory extends EventFactory { static create(info, client, overrideRelay) { const factory = new WalletInfoFactory((res) => res(blankEventTemplate(WALLET_INFO_KIND))).methods(info.methods); if (info.encryption) factory.encryption(info.encryption); if (info.notifications) factory.notifications(info.notifications); if (client) factory.client(client, overrideRelay); return factory; } methods(methods) { return this.chain((draft) => setContent(methods.join(" "))(draft)); } encryption(methods) { return this.chain((draft) => includeSingletonTag(["encryption", methods.join(" ")])(draft)); } notifications(types) { return this.chain((draft) => includeSingletonTag(["notifications", types.join(" ")])(draft)); } client(pubkey, relay) { return this.chain((draft) => includeSingletonTag(relay ? ["p", pubkey, relay] : ["p", pubkey])(draft)); } }