feat: message zaps

This commit is contained in:
Alejandro Gomez
2023-07-02 19:53:13 +02:00
parent 3224b03a98
commit a48991c13e
6 changed files with 204 additions and 28 deletions

View File

@ -13,6 +13,7 @@ interface SendZapsProps {
lnurl: string;
pubkey?: string;
aTag?: string;
eTag?: string;
targetName?: string;
onFinish: () => void;
button?: ReactNode;
@ -22,6 +23,7 @@ function SendZaps({
lnurl,
pubkey,
aTag,
eTag,
targetName,
onFinish,
}: SendZapsProps) {
@ -57,7 +59,7 @@ function SendZaps({
const amountInSats = isFiat ? Math.floor((amount / UsdRate) * 1e8) : amount;
let zap: NostrEvent | undefined;
if (pubkey && aTag) {
if (pubkey) {
zap = await pub.zap(
amountInSats * 1000,
pubkey,
@ -65,7 +67,13 @@ function SendZaps({
undefined,
comment,
(eb) => {
return eb.tag(["a", aTag]);
if (aTag) {
eb.tag(["a", aTag]);
}
if (eTag) {
eb.tag(["e", eTag]);
}
return eb;
}
);
}