applesauce-core 0.0.0-next-20241212230350 → 0.0.0-next-20241213171848
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Returns the NIP-36 content-warning for an event. returns boolean if there is no "reason" */
|
|
2
|
+
export function getContentWarning(event) {
|
|
3
|
+
const tag = event.tags.find((t) => t[0] === "content-warning");
|
|
4
|
+
if (tag)
|
|
5
|
+
return tag[1] || true;
|
|
6
|
+
else
|
|
7
|
+
return false;
|
|
8
|
+
}
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
package/dist/helpers/zap.d.ts
CHANGED
|
@@ -29,3 +29,11 @@ export declare function getZapRequest(zap: NostrEvent): import("nostr-tools").Ev
|
|
|
29
29
|
* DOES NOT validate LNURL address
|
|
30
30
|
*/
|
|
31
31
|
export declare function isValidZap(zap?: NostrEvent): boolean;
|
|
32
|
+
export type ZapSplit = {
|
|
33
|
+
pubkey: string;
|
|
34
|
+
percent: number;
|
|
35
|
+
weight: number;
|
|
36
|
+
relay?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Returns the zap splits for an event */
|
|
39
|
+
export declare function getZapSplits(event: NostrEvent): ZapSplit[] | undefined;
|
package/dist/helpers/zap.js
CHANGED
|
@@ -81,3 +81,15 @@ export function isValidZap(zap) {
|
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
/** Returns the zap splits for an event */
|
|
85
|
+
export function getZapSplits(event) {
|
|
86
|
+
const tags = event.tags.filter((t) => t[0] === "zap" && t[1] && t[3]);
|
|
87
|
+
if (tags.length > 0) {
|
|
88
|
+
const targets = tags
|
|
89
|
+
.map((t) => ({ pubkey: t[1], relay: t[2], weight: parseFloat(t[3]) }))
|
|
90
|
+
.filter((p) => Number.isFinite(p.weight));
|
|
91
|
+
const total = targets.reduce((v, p) => v + p.weight, 0);
|
|
92
|
+
return targets.map((p) => ({ ...p, percent: p.weight / total }));
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|