Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for zapping replaceable events #424

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions nip57.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function makeZapRequest({
comment = '',
}: {
profile: string
event: string | null
event: string | Event | null
amount: number
comment: string
relays: string[]
Expand All @@ -68,9 +68,23 @@ export function makeZapRequest({
],
}

if (event) {
if (event && typeof event === 'string') {
zr.tags.push(['e', event])
}
if (event && typeof event === 'object') {
zr.tags.push(['e', event.id])
// replacable event
if ((10000 <= event.kind && event.kind < 20000) || event.kind == 0 || event.kind == 3){
AsaiToshiya marked this conversation as resolved.
Show resolved Hide resolved
const a = ["a", `${event.kind}:${event.pubkey}`]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const a = ["a", `${event.kind}:${event.pubkey}`]
const a = ["a", `${event.kind}:${event.pubkey}:`]

zr.tags.push(a)
// parameterized replacable event
}else if (30000 <= event.kind && event.kind < 40000){
let d = event.tags.find(([t, v]) => t === 'd' && v)
if (!d) throw new Error('d tag not found or is empty')
const a = ["a", `${event.kind}:${event.pubkey}:${d[1]}`]
zr.tags.push(a)
}
}

return zr
}
Expand Down