Add convenience methods to append event and pubkey references

This commit is contained in:
Wilson Silva
2023-02-25 15:33:53 +07:00
parent 4c9c35520d
commit 0df4dbb979
3 changed files with 92 additions and 4 deletions

View File

@@ -138,6 +138,34 @@ module Nostr
@content = content
end
# Adds a reference to an event id as an 'e' tag
#
# @api public
#
# @example Adding a reference to a pubkey
# event_id = '189df012cfff8a075785b884bd702025f4a7a37710f581c4ac9d33e24b585408'
# event.add_event_reference(event_id)
#
# @param event_id [String] 32-bytes hex-encoded event id.
#
# @return [Array<String>] The event's updated list of tags
#
def add_event_reference(event_id) = tags.push(['e', event_id])
# Adds a reference to a pubkey as a 'p' tag
#
# @api public
#
# @example Adding a reference to a pubkey
# pubkey = '48df4af6e240ac5f7c5de89bf5941b249880be0e87d03685b178ccb1a315f52e'
# event.add_pubkey_reference(pubkey)
#
# @param pubkey [String] 32-bytes hex-encoded public key.
#
# @return [Array<String>] The event's updated list of tags
#
def add_pubkey_reference(pubkey) = tags.push(['p', pubkey])
# Signs an event with the user's private key
#
# @api public