fix(token-extensions/nft-meta-data-pointer): modernize deps + LiteSVM test; re-enable in CI#63
Merged
Merged
Conversation
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
… IDL build allows only one)
8cc7597 to
b78db00
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-enables the excluded
tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchorexample (extension_nft— a "chop tree" Token-2022 NFT game that uses the metadata-pointer extension andsession-keysfor gasless session signing). It was tagged "dependency issues".Root cause:
cargo build-sbffailed insidesession-keysitself — 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 standalonespl-token-2022 v6/spl-token v4/spl-token-metadata-interface 0.7pins also pulled a secondsolana-pubkeymajor, causing__Pubkeytype mismatches on the CPI builders.Changes
session-keys2.0.3 → 3.1.1 — the first release declaringanchor-lang >=0.28,<2.0. The gasless-session lesson is kept (no removal ofchop_tree/session usage).anchor_spl::token_interface::spl_token_2022,anchor_spl::token_2022_extensions::spl_token_metadata_interface) → one consistent type universe.invoke/invoke_signedimport path;#[session_auth_or]requires the context param be namedctx;AccountInfo→UncheckedAccountfor unchecked fields;#[allow(clippy::diverging_sub_expression)]for the Anchor#[program]macro.programs/extension_nft/tests/test_extension_nft.rs) drivinginit_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.sois needed. Program id referenced viaextension_nft::ID(survives CI'sanchor keys sync).[scripts] test = "cargo test".package.json+pnpm-lock.yamlsopnpm install --frozen-lockfiledoesn't walk up into the sibling nx app (same approach as the transfer-hook example)..github/.ghaignore.Verification (Solana 3.1.x / platform-tools v1.52)
cargo build-sbf✓ ·cargo test→test_init_player_mint_and_choppasses ✓ ·cargo fmt --checkclean ·cargo clippy --tests -D warningsclean ·pnpm install --frozen-lockfile✓. No build artifacts committed.https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
Generated by Claude Code