-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start cashu lib with bun tests #215
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 81add7c. ♻️ This comment has been updated with latest results. |
I'm getting this type error and I think it's because I added the bun types. Should we try to change the types in app/lib/timeout or figure out why adding bun types causes this error. Makes sense to me to use Bun's types for error TS2322: Type 'Timer' is not assignable to type 'number | Timeout | null'.
Property '[Symbol.dispose]' is missing in type 'Timer' but required in type 'Timeout'.
30 longTimeout.id = setTimeout(
~~~~~~~~~~~~~~
node_modules/@types/node/timers.d.ts:130:17
130 [Symbol.dispose](): void;
~~~~~~~~~~~~~~~~
'[Symbol.dispose]' is declared here.
Found 1 error in app/lib/timeout.ts:30 |
I am not sure why it happens. Let's fix it by defining type like this:
this way we are safe no matter the runtime |
Nice! fixed |
* remove ParsedNUT10Secret and NUT10SecretData types * use safe json parsing * return success in safeJsonParse and use zod in guest-account-storage * move schemas to types and infer from zod * redefined types using the schemas
I started to create the cashu library we will need. This is in lib/cashu.
In types.ts I added types for proof secrets which I would appreciate feedback on. For now we are only using the P2PK secret but as we want to add advanced functionality like DLCs, we will be using these secrets a lot.
A secret can be a string (NUT00) or of the well-known secret format described in NUT10. For NUT10 secrets I created two types. There is the tuple type ParsedNUT10Secret that is what we get when we call JSON.parse(secret), and then I convert that to NUT10Secret which is easier to work with.
I also setup testing using bun. All that was needed was to add bun's types to the project