fix zap
This commit is contained in:
@@ -39,15 +39,20 @@ export function usePublish() {
|
|||||||
return event;
|
return event;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createZap = async (event: NostrEvent, amount: number) => {
|
const createZap = async (event: NostrEvent, amount: number, message?: string) => {
|
||||||
if (!privkey) throw new Error('Private key not found');
|
// @ts-expect-error, lumeevent to nostrevent
|
||||||
|
event.id = event.event_id;
|
||||||
|
// @ts-expect-error, lumeevent to nostrevent
|
||||||
|
if (typeof event.content !== 'string') event.content = event.content.original;
|
||||||
if (typeof event.tags === 'string') event.tags = destr(event.tags);
|
if (typeof event.tags === 'string') event.tags = destr(event.tags);
|
||||||
|
if (!privkey) throw new Error('Private key not found');
|
||||||
|
if (!ndk.signer) {
|
||||||
const signer = new NDKPrivateKeySigner(privkey);
|
const signer = new NDKPrivateKeySigner(privkey);
|
||||||
ndk.signer = signer;
|
ndk.signer = signer;
|
||||||
|
}
|
||||||
|
|
||||||
const ndkEvent = new NDKEvent(ndk, event);
|
const ndkEvent = new NDKEvent(ndk, event);
|
||||||
const res = await ndkEvent.zap(amount, 'test zap from lume');
|
const res = await ndkEvent.zap(amount, message ?? 'test zap from lume');
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user