Skip to content

Add hand-written Anchor-compatible IDL - #65

Open
kaze-cow wants to merge 7 commits into
mainfrom
idl
Open

Add hand-written Anchor-compatible IDL#65
kaze-cow wants to merge 7 commits into
mainfrom
idl

Conversation

@kaze-cow

@kaze-cow kaze-cow commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Generate a Solana IDL using AI, and validate its baseline correctness using smoke tests.

Summary

  • Adds an AI-generated Anchor-compatible IDL (programs/settlement/idl/cow_settlement.json) describing the settlement program's instructions/accounts/types, for IDL-driven tooling (e.g. Solscan). This program is native/Pinocchio, not Anchor, so there's no generated IDL to start from.
  • A few spots can't be fully expressed in the IDL grammar and are documented inline via docs fields instead:
    • BeginSettle's dynamically-shaped tail (order count / bumps / transfer counts / pull amounts) has no Borsh-expressible layout (no length prefixes, and a trailing array whose length is the sum of an earlier array).
    • order_pda's PDA seed is sha256(intent_bytes) — a hash of the whole instruction argument, not a plain field/account reference the PDA-seed grammar can point at.
    • create_buffer's account list only includes the first buffer account, since its not possible to specify more than one account as an array specified. Additional buffer accounts must be specified manually.
  • add some smoke tests to validate that the . In particular, the tests enforce that many changes in instructions, account data, or errors will come with IDL updates.

How to review this PR

The IDL file is quite long. To minimize the amount of excess effort needed, after only a quick review/skim of the IDL file itself, check out the tests and see what properties are checked/validated.

How to test

The smoke tests are run alongside the existing tests crate suite, so you can run just test to verify the tests.

Manually inspect the IDL file itself, especially the instructions and how they were translated. Comment on anything unusual or bad comments.

Check out #73 , which this PR is stacked upon, to see the IDL being used to generate a Javascript library. This Javascript library has its own tests verifying that the program can be interacted with on a LiteSVM instance!

New Dependencies!

jsonschema = "0.30" # Popular package with around a million weekly downloads
serde_json = { version = "1", features = ["preserve_order"] } # Part of the ubiquitous serde suite; one of the most downloaded crates, with something like 5 million weekly downloads
syn = { version = "2", features = ["full"] } # Second most downloaded crate on crates.io

Stacked on by #73

🤖 Generated with Claude Code

Base automatically changed from discriminators to le-encoding-fixes July 16, 2026 05:52
Base automatically changed from le-encoding-fixes to main July 16, 2026 11:17
@socket-security

socket-security Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedsyn@​3.0.3100100100100100
Addedjsonschema@​0.30.0100100100100100

View full report


/// Canonical order intent. Also the exact bytes hashed (SHA-256) to produce the order UID used in the order PDA's seeds,
/// and the exact wire format of create_order's `intent` argument. Field order and encoding here are load-bearing: they
/// must match this program's Rust definition exactly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this comment was added because it probably should have existed in the first place, and not having it triggers an error in the IDL tests.

@kaze-cow
kaze-cow marked this pull request as ready for review July 29, 2026 15:01
@kaze-cow
kaze-cow requested a review from a team as a code owner July 29, 2026 15:01
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.

1 participant