Closed ngundotra closed 1 year ago
Going to fix merge conflicts later, just wanted to show what I was thinking
@callensm It might be worth actually writing out some more smaller JSON examples of what we want to support and then bringing this up for greater review
@callensm It might be worth actually writing out some more smaller JSON examples of what we want to support and then bringing this up for greater review
yeah for sure. I'll try and get some more examples on my branch with smaller scopes up at some point today.
want to merge this so the types are in and then work from there with the examples?
Nice!
@ngundotra could you try to generate the zod parts from the TypeScript types via ts-to-zod(like I discussed in #2 )?
Then we could include those inside a zod
subfolder to separate generated files.
I hope this works since I wouldn't want us to have to manually update the spec in two places, but I can read the TypeScript definitions much easier :)
@thlorenz! Hey yes. The issue is that the IdlType
typescript Type itself is recursive, so that has to be manually crafted using z.lazy(() => z.object({...})
. ts-to-zod
does not support "complex circular dependencies" so any other typescript Type that references IdlType
has to be manually crafted as well 😪.
I'm in favor of posting only the Typescript definitions at first + along with validation requirements, and then writing the validation code later.
Add Idl types in from anchor-ts package, and add some explicit recursive typing.