Skip to content

fix(token-extensions/nft-meta-data-pointer): modernize deps + LiteSVM test; re-enable in CI#63

Merged
mikemaccana merged 2 commits into
mainfrom
claude/token-ext-nftptr
Jun 5, 2026
Merged

fix(token-extensions/nft-meta-data-pointer): modernize deps + LiteSVM test; re-enable in CI#63
mikemaccana merged 2 commits into
mainfrom
claude/token-ext-nftptr

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

Re-enables the excluded tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor example (extension_nft — a "chop tree" Token-2022 NFT game that uses the metadata-pointer extension and session-keys for gasless session signing). It was tagged "dependency issues".

Root cause: cargo build-sbf failed inside session-keys itself — the "2.0.3" caret resolved to 2.0.8, which targets the old Anchor ≤0.30 API and doesn't compile on Anchor 1.0 / Solana 3.x. The standalone spl-token-2022 v6 / spl-token v4 / spl-token-metadata-interface 0.7 pins also pulled a second solana-pubkey major, causing __Pubkey type mismatches on the CPI builders.

Changes

  • session-keys 2.0.3 → 3.1.1 — the first release declaring anchor-lang >=0.28,<2.0. The gasless-session lesson is kept (no removal of chop_tree/session usage).
  • Dropped the standalone spl pins; Token-2022 + token-metadata now route through anchor-spl's bundled re-exports (anchor_spl::token_interface::spl_token_2022, anchor_spl::token_2022_extensions::spl_token_metadata_interface) → one consistent type universe.
  • API drift: invoke/invoke_signed import path; #[session_auth_or] requires the context param be named ctx; AccountInfoUncheckedAccount for unchecked fields; #[allow(clippy::diverging_sub_expression)] for the Anchor #[program] macro.
  • Test: replaced the devnet TS test with a Rust LiteSVM test (programs/extension_nft/tests/test_extension_nft.rs) driving init_player → mint_nft → chop_tree, asserting player energy/wood, the Token-2022 mint + metadata-pointer extension, and ATA creation. The session path runs via its main-wallet fallback (session_token = None) — the program only reads the session token, never CPIs into the session-keys program, so no fixture .so is needed. Program id referenced via extension_nft::ID (survives CI's anchor keys sync). [scripts] test = "cargo test".
  • Added a self-contained package.json + pnpm-lock.yaml so pnpm install --frozen-lockfile doesn't walk up into the sibling nx app (same approach as the transfer-hook example).
  • Removed the example from .github/.ghaignore.

Verification (Solana 3.1.x / platform-tools v1.52)

cargo build-sbf ✓ · cargo testtest_init_player_mint_and_chop passes ✓ · cargo fmt --check clean · cargo clippy --tests -D warnings clean · pnpm install --frozen-lockfile ✓. No build artifacts committed.

Note: .ghaignore on this branch still lists metadata/anchor because that fix is in a separate PR (#62); once both merge, .ghaignore is empty.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 2 commits June 5, 2026 22:53
Fix the dependency/API issues that had this Token-2022 metadata-pointer
"chop tree" game example tagged "dependency issues" in .github/.ghaignore,
and re-enable it in CI.

Dependencies:
- Bump session-keys 2.0.3 -> 3.1.1. 2.x pins anchor-lang <=0.30 and fails to
  compile against the Anchor 1.0 / Solana 3.x API; 3.1.1 is the first release
  supporting anchor-lang >=0.28,<2.0. The gasless session-token lesson
  (#[session_auth_or] / SessionToken) is preserved.
- Drop the standalone spl-token-2022 v6 / spl-token v4 / spl-token-metadata-
  interface pins. They dragged a second solana-pubkey major (vs the one
  anchor-lang/anchor-spl 1.0 use), breaking the CPI builders with Pubkey type
  mismatches. Token-2022 + token-metadata now go through anchor-spl's bundled
  re-exports (anchor_spl::token_interface::spl_token_2022 and
  anchor_spl::token_2022_extensions::spl_token_metadata_interface), keeping a
  single consistent type universe.

Source fixes:
- Route program/invoke imports through anchor_lang::solana_program.
- Rename the chop_tree handler context param to `ctx` (the #[session_auth_or]
  macro expands code that refers to the binding by that literal name).
- AccountInfo -> UncheckedAccount for the unchecked mint / token_account
  fields (silences the Anchor 1.0 deprecation warning).
- #![allow(clippy::diverging_sub_expression)] for the #[program] macro.

Test:
- Replace the (untracked) TS test with a Rust LiteSVM integration test
  (Anchor.toml [scripts] test = "cargo test"). It drives
  init_player -> mint_nft -> chop_tree and asserts on-chain state. The
  session path is exercised via its main-wallet fallback (session_token =
  None), so no session-keys program fixture is needed (the program only reads
  the session token, never CPIs into it). The program id is referenced via
  extension_nft::ID so it survives CI's `anchor keys sync`.

CI plumbing:
- Add a self-contained package.json + pnpm-lock.yaml in the anchor dir so
  `pnpm install --frozen-lockfile` resolves there instead of walking up into
  the sibling nx app package.json (which has no lockfile).
- Remove the example from .github/.ghaignore.

Verified: cargo build-sbf, cargo test (LiteSVM passes), cargo fmt --check,
cargo clippy --tests -D warnings, pnpm install --frozen-lockfile.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
@mikemaccana mikemaccana force-pushed the claude/token-ext-nftptr branch from 8cc7597 to b78db00 Compare June 5, 2026 22:55
@mikemaccana mikemaccana merged commit 2dc988f 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