refactor: allow to return undefined in getZapSplits function

This commit is contained in:
P. Reis 2024-07-19 19:19:04 -03:00
parent 3bc3e7675d
commit beee0e76e7

View file

@ -6,12 +6,12 @@ type ExtraMessage = string;
/** Number from 1 to 100, stringified. */
type splitPercentages = string;
type DittoZapSplits = {
export type DittoZapSplits = {
[key: Pubkey]: [splitPercentages, ExtraMessage];
};
/** Gets zap splits from NIP-78 in DittoZapSplits format. */
export async function getZapSplits(store: NStore, pubkey: string): Promise<DittoZapSplits> {
export async function getZapSplits(store: NStore, pubkey: string): Promise<DittoZapSplits | undefined> {
const zapSplits: DittoZapSplits = {};
const [event] = await store.query([{
@ -20,7 +20,7 @@ export async function getZapSplits(store: NStore, pubkey: string): Promise<Ditto
'#d': ['pub.ditto.zapSplits'],
limit: 1,
}]);
if (!event) return {};
if (!event) return;
for (const tag of event.tags) {
if (