Skip to content

tools: modernize shank example from Solita to Codama; re-enable in CI#61

Merged
mikemaccana merged 2 commits into
mainfrom
claude/shank-codama
Jun 5, 2026
Merged

tools: modernize shank example from Solita to Codama; re-enable in CI#61
mikemaccana merged 2 commits into
mainfrom
claude/shank-codama

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

Modernizes the native "car rental service" example from the dead Solita client generator to Codama, and brings it onto the current toolchain so it runs in CI. Solita's last release was Nov 2023 (superseded by Kinobi → Codama); Shank is still actively maintained (0.4.8, Feb 2026) and remains the standard way to give a native (non-Anchor) program an IDL — so the Shank lesson is kept, only the client generator and the ancient deps are replaced.

Renames tools/shank-and-solitatools/shank-and-codama (the example is named after its tooling).

Changes

Program (program/) — now builds with cargo build-sbf:

  • borsh/borsh-derive 0.9 → 1.5.7, shank 0.0.12 → 0.4.8, solana-program 1.14 → 4.0.
  • solana_program::system_instruction (removed in 4.0) → solana-system-interface; borsh::try_to_vecborsh::to_vec.
  • Made the crate a standalone workspace (it was never a root-workspace member) with its own tracked Cargo.lock.
  • Shank caveat (documented in README + code): Shank 0.4.8's #[seeds(...)] PDA codegen emits unparsable tokens and doesn't write seeds to the IDL, so PDAs are derived explicitly via Car::find_pda / RentalOrder::find_pda (same seed bytes). ShankAccount/ShankInstruction are still used for IDL extraction — the lesson is intact.

IDL → client (Shank → Codama):

  • IDL regenerated with shank-cli 0.4.8 (origin: "shank").
  • New codama.ts generator: rootNodeFromAnchor(idl) (origin shank) → createFromRoot@codama/renderers-js into tests/generated/. Removed .solitarc.js, .crates/, and the old Solita output.

Test (TS + litesvm npm, in-process — no devnet/bankrun):

  • tests/test.ts loads the built .so into litesvm (kit-based, so it interops with the Codama JS client) and runs add_car → book_rental → pick_up_car, asserting on-chain account state. Run via Node's built-in test runner (node --import tsx --test), so failures actually propagate.

CI: package.json scripts (build, generate-client, build-and-test), fresh frozen pnpm-lock.yaml, and removed the stale tools/shank-and-solita/native entry from .github/.ghaignore.

Verification (CI toolchain, Solana 3.1.x)

cargo build-sbf ✓ · pnpm install --frozen-lockfile && pnpm build && pnpm build-and-test → test passes (1/0) ✓ · cargo test ✓ · cargo fmt --check clean · cargo clippy --tests -D warnings clean. No target/, .so, or node_modules committed.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 2 commits June 5, 2026 21:40
Solita is unmaintained and does not work on the current toolchain, so this
example is reworked around Codama and modernised end to end.

- Rename tools/shank-and-solita -> tools/shank-and-codama (Solita is gone).
- Program: bump to borsh 1.x, shank 0.4.8, solana-program 4.0. Replace the
  removed solana_program::system_instruction with solana-system-interface and
  borsh try_to_vec with borsh::to_vec. Shank 0.4's #[seeds(...)] PDA codegen is
  broken (emits unparsable tokens) and is not emitted to the IDL, so seeds are
  dropped and PDAs derived explicitly via Car::find_pda / RentalOrder::find_pda.
  Make the crate standalone (empty [workspace]) so it pins its own deps/lock.
- Regenerate the Shank IDL (origin "shank", u8 discriminants) and generate a
  @solana/kit TypeScript client with Codama via codama.ts. Remove .solitarc.js,
  .crates/, and the old Solita output.
- Replace the devnet test with an in-process LiteSVM (npm) test that loads the
  built .so and exercises add_car/book_rental/pick_up_car through the generated
  client, asserting account state. Runs in CI with no network.
- package.json scripts (build, generate-client, build-and-test) wired for
  native.yml; commit a fresh frozen pnpm-lock.yaml. Drop the stale .ghaignore
  entry; track the standalone program Cargo.lock via .gitignore exception.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
@mikemaccana mikemaccana merged commit 032f321 into main Jun 5, 2026
18 checks passed
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.

2 participants