mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: add cashu proof schema
This commit is contained in:
parent
d87f650da3
commit
08d2f7fe3f
2 changed files with 12 additions and 9 deletions
|
|
@ -5,11 +5,11 @@ import { HTTPException } from '@hono/hono/http-exception';
|
|||
import { NostrEvent, NostrFilter, NostrSigner, NSchema as n, NStore } from '@nostrify/nostrify';
|
||||
import { SetRequired } from 'type-fest';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { errorJson } from '@/utils/log.ts';
|
||||
import { createEvent } from '@/utils/api.ts';
|
||||
import { validateAndParseWallet } from '@/utils/cashu.ts';
|
||||
import { proofSchema } from '@/schemas/cashu.ts';
|
||||
|
||||
/**
|
||||
* Swap nutzaps into wallet (create new events) if the user has a wallet, otheriwse, just fallthrough.
|
||||
|
|
@ -172,14 +172,7 @@ async function getMintsToProofs(
|
|||
}
|
||||
|
||||
const parsed = n.json().pipe(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
amount: z.number(),
|
||||
secret: z.string(),
|
||||
C: z.string(),
|
||||
dleq: z.object({ s: z.string(), e: z.string(), r: z.string().optional() }).optional(),
|
||||
dleqValid: z.boolean().optional(),
|
||||
}),
|
||||
proofSchema,
|
||||
).array().safeParse(proofs);
|
||||
|
||||
if (!parsed.success) {
|
||||
|
|
|
|||
10
packages/ditto/schemas/cashu.ts
Normal file
10
packages/ditto/schemas/cashu.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const proofSchema = z.object({
|
||||
id: z.string(),
|
||||
amount: z.number(),
|
||||
secret: z.string(),
|
||||
C: z.string(),
|
||||
dleq: z.object({ s: z.string(), e: z.string(), r: z.string().optional() }).optional(),
|
||||
dleqValid: z.boolean().optional(),
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue