mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor(zap split): rename amount to weight
This commit is contained in:
parent
25bbeceb8d
commit
0a3ed4e160
3 changed files with 7 additions and 7 deletions
|
|
@ -159,7 +159,7 @@ export const nameRequestsController: AppController = async (c) => {
|
|||
const zapSplitSchema = z.record(
|
||||
n.id(),
|
||||
z.object({
|
||||
amount: z.number().int().min(1).max(100),
|
||||
weight: z.number().int().min(1).max(100),
|
||||
message: z.string().max(500),
|
||||
}),
|
||||
);
|
||||
|
|
@ -189,7 +189,7 @@ export const updateZapSplitsController: AppController = async (c) => {
|
|||
{ kinds: [30078], authors: [Conf.pubkey], '#d': ['pub.ditto.zapSplits'], limit: 1 },
|
||||
(tags) =>
|
||||
pubkeys.reduce((accumulator, pubkey) => {
|
||||
return addTag(accumulator, ['p', pubkey, data[pubkey].amount.toString(), data[pubkey].message]);
|
||||
return addTag(accumulator, ['p', pubkey, data[pubkey].weight.toString(), data[pubkey].message]);
|
||||
}, tags),
|
||||
c,
|
||||
);
|
||||
|
|
@ -244,7 +244,7 @@ export const getZapSplitsController: AppController = async (c) => {
|
|||
|
||||
return {
|
||||
account,
|
||||
amount: zap_split[pubkey].amount,
|
||||
weight: zap_split[pubkey].weight,
|
||||
message: zap_split[pubkey].message,
|
||||
};
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -183,8 +183,8 @@ const createStatusController: AppController = async (c) => {
|
|||
if (lnurl && zap_split) {
|
||||
let totalSplit = 0;
|
||||
for (const pubkey in zap_split) {
|
||||
totalSplit += zap_split[pubkey].amount;
|
||||
tags.push(['zap', pubkey, Conf.relay, zap_split[pubkey].amount.toString()]);
|
||||
totalSplit += zap_split[pubkey].weight;
|
||||
tags.push(['zap', pubkey, Conf.relay, zap_split[pubkey].weight.toString()]);
|
||||
}
|
||||
if (totalSplit) {
|
||||
tags.push(['zap', author?.pubkey as string, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ type ExtraMessage = string;
|
|||
type splitPercentages = number;
|
||||
|
||||
export type DittoZapSplits = {
|
||||
[key: Pubkey]: { amount: splitPercentages; message: ExtraMessage };
|
||||
[key: Pubkey]: { weight: splitPercentages; message: ExtraMessage };
|
||||
};
|
||||
|
||||
/** Gets zap splits from NIP-78 in DittoZapSplits format. */
|
||||
|
|
@ -30,7 +30,7 @@ export async function getZapSplits(store: NStore, pubkey: string): Promise<Ditto
|
|||
tag[0] === 'p' && n.id().safeParse(tag[1]).success &&
|
||||
percentageSchema.safeParse(tag[2]).success
|
||||
) {
|
||||
zapSplits[tag[1]] = { amount: Number(tag[2]), message: tag[3] };
|
||||
zapSplits[tag[1]] = { weight: Number(tag[2]), message: tag[3] };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue