Class NDKDVMJobResult

This event is published by Data Vending Machines when they have finished processing a job.

Hierarchy (view full)

Constructors

Properties

content: string = ""
created_at?: number
decrypt: ((...args: [sender?: NDKUser, signer?: NDKSigner, type: ENCRYPTION_SCHEMES]) => Promise<void>) = ...
encode: ((...args: [maxRelayCount: number]) => string) = ...

Encodes a bech32 id.

Type declaration

    • (...args: [maxRelayCount: number]): string
    • Parameters

      • Rest...args: [maxRelayCount: number]

      Returns string

      • Encoded naddr, note or nevent.
encrypt: ((...args: [recipient?: NDKUser, signer?: NDKSigner, type: ENCRYPTION_SCHEMES]) => Promise<void>) = ...
fetchReplyEvent: ((...args: [subOpts?: NDKSubscriptionOptions]) => Promise<undefined | null | NDKEvent>) = ...

Fetch the event the current event is replying to.

Type declaration

fetchRootEvent: ((...args: [subOpts?: NDKSubscriptionOptions]) => Promise<undefined | null | NDKEvent>) = ...

Fetch the root event of the current event.

Type declaration

const replyEvent = await ndk.fetchEvent("nevent1qqs8x8vnycyha73grv380gmvlury4wtmx0nr9a5ds2dngqwgu87wn6gpzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgq3ql2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqz4cwjd")
const rootEvent = await replyEvent.fetchRootEvent();
console.log(replyEvent.encode() + " is a reply in the thread " + rootEvent?.encode());
fetchTaggedEvent: ((...args: [tag: string, marker?: string]) => Promise<undefined | null | NDKEvent>) = ...

Fetch an event tagged with the given tag following relay hints if provided.

Type declaration

    • (...args: [tag: string, marker?: string]): Promise<undefined | null | NDKEvent>
    • Parameters

      • Rest...args: [tag: string, marker?: string]

      Returns Promise<undefined | null | NDKEvent>

      The fetched event or null if no event was found, undefined if no matching tag was found in the event *

const replyEvent = await ndk.fetchEvent("nevent1qqs8x8vnycyha73grv380gmvlury4wtmx0nr9a5ds2dngqwgu87wn6gpzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgq3ql2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqz4cwjd")
const originalEvent = await replyEvent.fetchTaggedEvent("e", "reply");
console.log(replyEvent.encode() + " is a reply to event " + originalEvent?.encode());
getEventHash: ((...args: []) => string) = ...
id: string = ""
isEphemeral: ((...args: []) => boolean) = ...
isParamReplaceable: ((...args: []) => boolean) = ...
isReplaceable: ((...args: []) => boolean) = ...
kind?: number
ndk?: default
pubkey: string = ""
publishError?: Error
publishStatus?: "pending" | "success" | "error" = "success"

The status of the publish operation.

relay: undefined | NDKRelay

The relay that this event was first received from.

repost: ((...args: [publish: boolean, signer?: NDKSigner]) => Promise<NDKEvent>) = ...

NIP-18 reposting event.

Type declaration

    • (...args: [publish: boolean, signer?: NDKSigner]): Promise<NDKEvent>
    • Parameters

      • Rest...args: [publish: boolean, signer?: NDKSigner]

      Returns Promise<NDKEvent>

      The reposted event

true
serialize: ((...args: [includeSig: boolean, includeId: boolean]) => string) = ...
sig?: string
signatureVerified?: boolean
tags: NDKTag[] = []
validate: ((...args: []) => boolean) = ...
verifySignature: ((...args: [persist: boolean]) => undefined | boolean) = ...

Accessors

  • get alt(): undefined | string
  • Gets the NIP-31 "alt" tag of the event.

    Returns undefined | string

  • set alt(alt: undefined | string): void
  • Sets the NIP-31 "alt" tag of the event. Use this to set an alt tag so clients that don't handle a particular event kind can display something useful for users.

    Parameters

    • alt: undefined | string

    Returns void

  • get dTag(): undefined | string
  • Gets the NIP-33 "d" tag of the event.

    Returns undefined | string

  • set dTag(value: undefined | string): void
  • Sets the NIP-33 "d" tag of the event.

    Parameters

    • value: undefined | string

    Returns void

  • get isValid(): boolean
  • Checks whether the event is valid per underlying NIPs.

    This method is meant to be overridden by subclasses that implement specific NIPs to allow the enforcement of NIP-specific validation rules.

    Otherwise, it will only check for basic event properties.

    Returns boolean

Methods

  • Provides a deduplication key for the event.

    For kinds 0, 3, 10k-20k this will be the event : For kinds 30k-40k this will be the event :: For all other kinds this will be the event id

    Returns string

  • Generates a deletion event of the current event

    Parameters

    • Optionalreason: string

      The reason for the deletion

    • publish: boolean = true

      Whether to publish the deletion event automatically

    Returns Promise<NDKEvent>

    The deletion event

  • Provides the filter that will return matching events for this event.

    Returns NDKFilter

    The filter that will return matching events for this event

    event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] });
    event.filter(); // { "#a": ["30000:pubkey:d-code"] }
    event = new NDKEvent(ndk, { kind: 1, pubkey: 'pubkey', id: "eventid" });
    event.filter(); // { "#e": ["eventid"] }
  • Generates tags for users, notes, and other events tagged in content. Will also generate random "d" tag for parameterized replaceable events where needed.

    Returns Promise<ContentTag>

    The tags and content of the event.

  • Check if the event has a tag with the given name

    Parameters

    • tagName: string
    • Optionalmarker: string

    Returns boolean

  • Attempt to sign and then publish an NDKEvent to a given relaySet. If no relaySet is provided, the relaySet will be calculated by NDK.

    Parameters

    • OptionalrelaySet: NDKRelaySet

      {NDKRelaySet} The relaySet to publish the even to.

    • OptionaltimeoutMs: number
    • OptionalrequiredRelayCount: number

      The number of relays that must receive the event for the publish to be considered successful.

    Returns Promise<Set<NDKRelay>>

    A promise that resolves to the relays the event was published to.

  • Get the tags that can be used to reference this event from another event

    Parameters

    • Optionalmarker: string

      The marker to use in the tag

    • OptionalskipAuthorTag: boolean

      Whether to explicitly skip adding the author tag of the event

    • OptionalforceTag: string

      Force a specific tag to be used instead of the default "e" or "a" tag

    Returns NDKTag[]

    The NDKTag object referencing this event

    event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] });
    event.referenceTags(); // [["a", "30000:pubkey:d-code"], ["e", "parent-id"]]

    event = new NDKEvent(ndk, { kind: 1, pubkey: 'pubkey', id: "eventid" });
    event.referenceTags(); // [["e", "parent-id"]]
  • Remove all tags with the given name (e.g. "d", "a", "p")

    Parameters

    • tagName: string | string[]

      Tag name(s) to search for and remove

    Returns void

  • Returns the "d" tag of a parameterized replaceable event or throws an error if the event isn't a parameterized replaceable event.

    Returns string

    the "d" tag of the event.

  • Sign the event if a signer is present.

    It will generate tags. Repleacable events will have their created_at field set to the current time.

    Parameters

    • Optionalsigner: NDKSigner

      {NDKSigner} The NDKSigner to use to sign the event

    Returns Promise<string>

    A Promise that resolves to the signature of the signed event.

  • Tag a user with an optional marker.

    Parameters

    • target: NDKEvent | NDKUser | NDKTag

      What is to be tagged. Can be an NDKUser, NDKEvent, or an NDKTag.

    • Optionalmarker: string

      The marker to use in the tag.

    • OptionalskipAuthorTag: boolean

      Whether to explicitly skip adding the author tag of the event.

    • OptionalforceTag: string

      Force a specific tag to be used instead of the default "e" or "a" tag.

    Returns void

    reply.tag(opEvent, "reply");
    // reply.tags => [["e", <id>, <relay>, "reply"]]
  • NIP-73 tagging of external entities

    Parameters

    • entity: string

      to be tagged

    • type: NIP73EntityType

      of the entity

    • OptionalmarkerUrl: string

      to be used as the marker URL

    Returns void

    event.tagExternal("https://example.com/article/123#nostr", "url");
    event.tags => [["i", "https://example.com/123"], ["k", "https://example.com"]]
    event.tagExternal("e32b4890-b9ea-4aef-a0bf-54b787833dc5", "podcast:item:guid");
    event.tags => [["i", "podcast:item:guid:e32b4890-b9ea-4aef-a0bf-54b787833dc5"], ["k", "podcast:item:guid"]]
  • Returns the id of the event or, if it's a parameterized event, the generated id of the event using "d" tag, pubkey, and kind.

    Returns string

    The id

  • Get the tag that can be used to reference this event from another event.

    Consider using referenceTags() instead (unless you have a good reason to use this)

    Parameters

    • Optionalmarker: string

    Returns NDKTag

    The NDKTag object referencing this event

    event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] });
    event.tagReference(); // ["a", "30000:pubkey:d-code"]

    event = new NDKEvent(ndk, { kind: 1, pubkey: 'pubkey', id: "eventid" });
    event.tagReference(); // ["e", "eventid"]
  • Determines the type of tag that can be used to reference this event from another event.

    Returns "a" | "e"

    The tag type

    event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] });
    event.tagType(); // "a"
  • Get the first tag with the given name

    Parameters

    • tagName: string

      Tag name to search for

    Returns undefined | string

    The value of the first tag with the given name, or undefined if no such tag exists

  • Return a NostrEvent object, trying to fill in missing fields when possible, adding tags when necessary.

    Parameters

    • Optionalpubkey: string

      {string} The pubkey of the user who the event belongs to.

    Returns Promise<NostrEvent>

    A promise that resolves to a NostrEvent.