-
Notifications
You must be signed in to change notification settings - Fork 64
Vix 75 fix codama vixen account parser #533
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
Vix 75 fix codama vixen account parser #533
Conversation
|
ac60a1b to
d867bab
Compare
d867bab to
fc170a2
Compare
fc170a2 to
74dd91e
Compare
3d84251 to
38067e1
Compare
lorisleiva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused about the approach used here.
The Codama standard was specifically designed to be framework agnostic. It offers DiscriminatorNodes that describes how accounts and instructions are recognised regardless of how that program was created.
When a Codama IDL is given, having to go back to figuring out the program framework feels like a step back and it won't benefit from any further abstraction the standard provides in the future. Nor will it benefit from updates in adapters to and from other IDLs.
If you want to generate helpers that properly leverage the Codama IDL, you have to work with DiscriminatorNodes directly. If it is an Anchor program, the DiscriminatorNodes will already have been set by the @codama/nodes-from-anchor package. There is no need to compute the hashes again.
I strongly recommend looking into how the @codama/renderers-js package deals with DiscriminatorNodes to get an idea on how to implement this properly. For instance the following files could be a good starting point: discriminatorCondition.ts and discriminatorConstants.ts.
|
Hi @lorisleiva! Hope you are doing well. Thanks for your feedback! I've kept working over this in the context of adding support for generating the grpc server related part of the generated vixen parser. In general I have tried to follow your recomendations and now the discriminator processing is abstracted from if it was a shank or anchor idl (you can look at the basic support I've added here https://github.com/abklabs/codama/blob/vix-77-add-support-to-generate-impl-for-proto-structs-and-rust/packages/renderers-vixen-parser/src/getRenderMapVisitor.ts#L305-L366). But the one thing I feel we are missing is a default discriminator generation for shank idls, (and please correct me if I'm missing something) because the So what I did so far is update the codama root object with the "common" approach for shank idls (1 byte at the start of the ix data for ixs and account length for accounts) in the generation script here https://github.com/abklabs/codama/blob/vix-77-add-support-to-generate-impl-for-proto-structs-and-rust/packages/renderers-vixen-parser/e2e/raydium-amm-v4-parser/codama.cjs#L157-L209. But that means that any user of the Also as a side note, I'm finishing polishing a couple of edge cases in the proto generation and once that's done the plan is create a PR from that branch I shared to include all that logic (tests are already passing and the e2e tests have the format we have been using for the new set of parsers we have released in vixen these last days) |
|
Hi @fernandodeluret, that's awesome! Oh well spotted for Shank IDLs that don't use the Anchor discriminator convention. In this case, I'd consider this a bug of |
|
Thanks for the response @lorisleiva! I've created both PRs:
Also I pushed this branch using the changes from the discrminators PR for the shank example idl we had in our e2e tests and is working correctly: abklabs@1f4bac4 |
|
closing this as we have a diff pr which covers this |
|
Thanks guys, I'll take a look at the new PRs asap. |
Problem
Solution