nostr-tools 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +12 -24
- package/lib/cjs/index.js.map +2 -2
- package/lib/cjs/nip57.js +12 -24
- package/lib/cjs/nip57.js.map +2 -2
- package/lib/esm/index.js +12 -24
- package/lib/esm/index.js.map +2 -2
- package/lib/esm/nip57.js +12 -24
- package/lib/esm/nip57.js.map +2 -2
- package/lib/nostr.bundle.js +12 -24
- package/lib/nostr.bundle.js.map +2 -2
- package/lib/types/nip57.d.ts +13 -6
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -2541,41 +2541,29 @@ async function getZapEndpoint(metadata) {
|
|
|
2541
2541
|
}
|
|
2542
2542
|
return null;
|
|
2543
2543
|
}
|
|
2544
|
-
function makeZapRequest({
|
|
2545
|
-
profile,
|
|
2546
|
-
event,
|
|
2547
|
-
amount,
|
|
2548
|
-
relays,
|
|
2549
|
-
comment = ""
|
|
2550
|
-
}) {
|
|
2551
|
-
if (!amount)
|
|
2552
|
-
throw new Error("amount not given");
|
|
2553
|
-
if (!profile)
|
|
2554
|
-
throw new Error("profile not given");
|
|
2544
|
+
function makeZapRequest(params) {
|
|
2555
2545
|
let zr = {
|
|
2556
2546
|
kind: 9734,
|
|
2557
2547
|
created_at: Math.round(Date.now() / 1e3),
|
|
2558
|
-
content: comment,
|
|
2548
|
+
content: params.comment || "",
|
|
2559
2549
|
tags: [
|
|
2560
|
-
["p",
|
|
2561
|
-
["amount", amount.toString()],
|
|
2562
|
-
["relays", ...relays]
|
|
2550
|
+
["p", "pubkey" in params ? params.pubkey : params.event.pubkey],
|
|
2551
|
+
["amount", params.amount.toString()],
|
|
2552
|
+
["relays", ...params.relays]
|
|
2563
2553
|
]
|
|
2564
2554
|
};
|
|
2565
|
-
if (event
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
if (event && typeof event === "object") {
|
|
2569
|
-
if (isReplaceableKind(event.kind)) {
|
|
2570
|
-
const a = ["a", `${event.kind}:${event.pubkey}:`];
|
|
2555
|
+
if ("event" in params) {
|
|
2556
|
+
if (isReplaceableKind(params.event.kind)) {
|
|
2557
|
+
const a = ["a", `${params.event.kind}:${params.event.pubkey}:`];
|
|
2571
2558
|
zr.tags.push(a);
|
|
2572
|
-
} else if (isAddressableKind(event.kind)) {
|
|
2573
|
-
let d = event.tags.find(([t, v]) => t === "d" && v);
|
|
2559
|
+
} else if (isAddressableKind(params.event.kind)) {
|
|
2560
|
+
let d = params.event.tags.find(([t, v]) => t === "d" && v);
|
|
2574
2561
|
if (!d)
|
|
2575
2562
|
throw new Error("d tag not found or is empty");
|
|
2576
|
-
const a = ["a", `${event.kind}:${event.pubkey}:${d[1]}`];
|
|
2563
|
+
const a = ["a", `${params.event.kind}:${params.event.pubkey}:${d[1]}`];
|
|
2577
2564
|
zr.tags.push(a);
|
|
2578
2565
|
}
|
|
2566
|
+
zr.tags.push(["k", params.event.kind.toString()]);
|
|
2579
2567
|
}
|
|
2580
2568
|
return zr;
|
|
2581
2569
|
}
|