Skip to content

Conversation

Arrowana
Copy link
Contributor

@Arrowana Arrowana commented Sep 5, 2025

This causes explorer crash and needs to be fixed to allow explorer decoding

https://github.com/anza-xyz/solana-sdk/blob/7d7ff1dcf88849fa1f8f11b915e89a48b75cbba7/system-interface/src/instruction.rs#L120-L122

Strangely it isn't documented properly on all other system instructions but that is the case except for TransferWithSeed

The legacy web3.js instruction https://github.com/solana-foundation/solana-web3.js/blob/99aa3c841895848ea407c85340b036f6aceb877d/src/programs/system.ts#L863-L868
Adds it like this, not sure if codama is capable of automating this or we leave this to the consumer.

@joncinque joncinque requested a review from lorisleiva September 8, 2025 16:28
Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch, thanks for this. Would you be able to add a couple of tests for this change? I'm thinking two createAccountWithSeed tests, one that uses the optional base account and one that doesn't.

The change seems to introduce a lint issue as well. I'm guessing the linter doesn't like the double ternary generated in the type parameters so I might need to adjust the lint settings.

@Arrowana
Copy link
Contributor Author

Ah good catch, thanks for this. Would you be able to add a couple of tests for this change? I'm thinking two createAccountWithSeed tests, one that uses the optional base account and one that doesn't.

The change seems to introduce a lint issue as well. I'm guessing the linter doesn't like the double ternary generated in the type parameters so I might need to adjust the lint settings.

There is now a test, i don't know codama well but is it possible to add more validation regarding baseAccount and base?
ideally specifying base is enough when base == payer

Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I've made a couple of comments. Lmk if you're able to see what's going on with the lint issue but no worries otherwise I'll tackle this when I have a moment.

Regarding more complex account validation, yes you can use things like ConditionalValueNodes to provide different default values based on the value of some other account or argument. Maybe something to think about for another PR if you'd like?

@Arrowana
Copy link
Contributor Author

Arrowana commented Oct 2, 2025

Thanks I've made a couple of comments. Lmk if you're able to see what's going on with the lint issue but no worries otherwise I'll tackle this when I have a moment.

Regarding more complex account validation, yes you can use things like ConditionalValueNodes to provide different default values based on the value of some other account or argument. Maybe something to think about for another PR if you'd like?

For ConditionalValueNodes, i think this PR is mostly to fix parsing, so let's make it work first.

I had a look to the lint issue but i can't locate what causes the issue, the renderer seems to generate the right code but somehow a comma is added afterwards

This is what the linter wants to see

-    ].filter(<T,>(x: T | undefined): x is T => x !== undefined),
+    ].filter(<T>(x: T | undefined): x is T => x !== undefined),

So i'll let you handle it

Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The lint issue is weird. Codama properly uses the given Prettier options but — for some reason — commas after type parameters seem to be an artistic liberty.

Instead of entering a formatting rabbit hole, I decided to just run pnpm format:fix on the JS client after generating clients.

@lorisleiva lorisleiva requested a review from joncinque October 2, 2025 13:50
@joncinque joncinque merged commit 5c1a09e into solana-program:main Oct 2, 2025
5 checks passed
@Arrowana Arrowana deleted the fix/base-is-optional branch October 3, 2025 02:06
jfjeifkvbk

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants