Skip to content

test(tokens): migrate 5 Metaplex/token native examples to mpl 5.x + LiteSVM and re-enable in CI#54

Merged
mikemaccana merged 2 commits into
mainfrom
claude/metaplex-token-natives-litesvm
Jun 5, 2026
Merged

test(tokens): migrate 5 Metaplex/token native examples to mpl 5.x + LiteSVM and re-enable in CI#54
mikemaccana merged 2 commits into
mainfrom
claude/metaplex-token-natives-litesvm

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

Re-enables the five Metaplex/SPL-token native examples that were excluded in .github/.ghaignore as "can't test on localnet". They weren't just untestable — their programs no longer compiled: the code used the old mpl_token_metadata::instruction::* API while the dep had been bumped to mpl-token-metadata 5.1.1, and several pinned stale solana-program/spl-token/spl-associated-token-account versions. So each needed a real migration plus a LiteSVM test.

Per example

  • create-token — create mint + metadata. Asserts mint owner/decimals and that the metadata account exists & is owned by Token-Metadata.
  • token-minter — create + mint SPL (9 decimals, ATA). Mints 150, asserts mint/metadata + ATA balance = 150.
  • transfer-tokens — create + mint + transfer. Mints 150, transfers 15 to a new recipient (creating their ATA), asserts balances 15 / 135. (transfertransfer_checked.)
  • nft-minter — create + mint NFT with master edition (0 decimals). Asserts NFT amount = 1 and the master-edition account is owned by Token-Metadata.
  • pda-mint-authority — init + create + mint, all signed by a program-derived mint authority via invoke_signed. Asserts the PDA-owned mint + master edition.

Migration pattern (consistent across all five)

  • Old mpl instruction::create_metadata_accounts_v3 / create_master_edition_v3 → the mpl 5.x builders (instructions::CreateMetadataAccountV3 / CreateMasterEditionV3, types::DataV2).
  • mpl 5.x rides an older solana-program, so a small shared bridge (to_mpl / bridge_instruction, via an aliased mpl-solana-program dep) converts its returned Instruction/Pubkey to each program's types.
  • solana_program::system_instructionsolana-system-interface; SPL token/ATA → the spl-token-interface / spl-associated-token-account-interface crates.
  • Added each program to the root workspace; added a committed mpl_token_metadata.so fixture per example (LiteSVM doesn't bundle Token-Metadata); added program/tests/test.rs; replaced the devnet TypeScript tests with scripts-only package.json (build-and-test builds the .so the LiteSVM cargo test consumes); and removed all five from .github/.ghaignore.

Verification

All built (cargo build-sbf) and run against the CI toolchain (Solana 3.1.14 / platform-tools v1.52): the 5 LiteSVM integration tests pass, whole-workspace cargo fmt --check is clean, and cargo clippy --tests -- -D warnings is clean for all five. Only mpl_token_metadata.so is committed in each fixtures dir — the program .so files are built by CI.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 2 commits June 5, 2026 17:51
… test

create-token/native was excluded (devnet-only TypeScript test). Its program
also no longer compiled: the code used the old `mpl_token_metadata::instruction`
API while the dep had been bumped to 5.1.1.

- Migrate to the mpl-token-metadata 5.x instruction builders
  (CreateMetadataAccountV3), solana-system-interface for the system program,
  and spl-token-interface for the Mint. mpl 5.x rides an older solana-program,
  so a small bridge converts its returned Instruction to this program's type.
- Add a LiteSVM test that loads the program plus the Token-Metadata program
  (from a committed mpl_token_metadata.so fixture, since LiteSVM does not bundle
  it) and asserts the mint and metadata accounts are created.
- Add the program to the workspace, remove the devnet TS test/tooling, rewire
  build-and-test to build the fixture the LiteSVM cargo test consumes, and drop
  create-token/native from .github/.ghaignore.
…mint-authority natives to mpl 5.x + LiteSVM

Migrate the four Metaplex-using native token examples off the old
mpl-token-metadata 1.x / system_instruction / spl-token APIs onto the
current toolchain, matching the create-token reference:

- mpl-token-metadata 5.x builders (CreateMetadataAccountV3,
  CreateMasterEditionV3) bridged from the older solana-program types the
  builders return via a shared bridge.rs (to_mpl / bridge_instruction).
- solana-system-interface for create_account.
- spl-token-interface + spl-associated-token-account-interface 2.0.0.
- transfer-tokens now uses transfer_checked (reads mint decimals).
- Add each crate to the root workspace members and remove from .ghaignore.
- Add LiteSVM Rust tests (program/tests/test.rs) loading the program plus
  the committed mpl_token_metadata.so fixture, exercising create/mint/
  transfer/master-edition/PDA-authority flows end to end with assertions.
- Replace package.json with scripts-only, delete devnet TS tests +
  tsconfig, regenerate empty pnpm lockfiles.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
@mikemaccana mikemaccana merged commit e4faaa5 into main Jun 5, 2026
19 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