fix(token-2022/metadata/anchor): revive program excluded from CI due to stale spl-token-metadata-interface version - #642
Conversation
Greptile SummaryThe PR restores the Token-2022 metadata Anchor example to CI by aligning SPL interface dependencies, adapting renamed CPI account fields, and correcting incremental metadata rent funding. Confidence Score: 5/5The PR appears safe to merge. No blocking failures remain in the reviewed fix. Important Files Changed
Reviews (4): Last reviewed commit: "fix(#642): pin @types/node to ^22.x and ..." | Re-trigger Greptile |
| // Calculate lamports required for the additional metadata | ||
| let lamports = | ||
| data_len as u64 * DEFAULT_LAMPORTS_PER_BYTE_YEAR * DEFAULT_EXEMPTION_THRESHOLD as u64; | ||
| let lamports = Rent::get()?.minimum_balance(data_len); |
There was a problem hiding this comment.
When initialization runs, Anchor has already rent-funded the mint, but minimum_balance(data_len) includes the fixed account-storage overhead again even though data_len contains only the added metadata TLV bytes, causing every payer to lock excess lamports in the mint.
Knowledge Base Used: Tokens Directory Overview
|
Good catch by @greptile-apps — addressed in
Fixed by computing only the incremental rent for the extension bytes: let rent = Rent::get()?;
let lamports = rent.minimum_balance(data_len).saturating_sub(rent.minimum_balance(0));All 7 tests still pass locally. |
|
The fix is correct. One small thing worth verifying: LGTM on the fix. |
…d fix API drift
The program pinned spl-token-metadata-interface = "0.3.3" and
spl-type-length-value = "0.4.3", while anchor-spl = "1.0.2" transitively
resolves to 0.8.0 / 0.9.1 respectively. Cargo ended up with two
incompatible spl-token-metadata-interface versions in the dependency tree,
pulling in an older solana-program chain that conflicted with the
solana-zk-token-sdk compile unit, causing the build to fail.
Fix: align the two direct pins to the versions anchor-spl already uses:
spl-token-metadata-interface 0.3.3 → 0.8.0
spl-type-length-value 0.4.3 → 0.9.1
Three minor API-drift call-sites also updated:
- initialize.rs: replace removed DEFAULT_LAMPORTS_PER_BYTE_YEAR /
DEFAULT_EXEMPTION_THRESHOLD constants with Rent::get()?.minimum_balance()
- update_field.rs, update_authority.rs: rename struct field
token_program_id → program_id in TokenMetadataUpdateField /
TokenMetadataUpdateAuthority (field was renamed in anchor-spl 1.1.x)
All 7 existing tests pass locally. Removes the entry from .ghaignore so
the program is picked up by CI anchor.yml again.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…in initialize minimum_balance(data_len) prices (128 + data_len) bytes, but the mint's base 128-byte account overhead is already funded by Anchor's `init`. Use minimum_balance(data_len) - minimum_balance(0) to charge only for the incremental metadata extension bytes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2b81753 to
ac19c16
Compare
…fig for token-2022/metadata/anchor @types/node@20.x has Buffer interface incompatible with TypeScript 5.x causing tsc --noEmit to fail in CI. Pinning @types/node to ^22.19.1 resolves this. Also bumps typescript to ^5.5.0, adds skipLibCheck, and updates target/lib to es2020 to match current project requirements. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
tokens/token-2022/metadata/anchorhas been excluded from CI with the comment "build failed - program outdated" since anchor-spl was upgraded to 1.x. This PR fixes the root cause and re-enables the program in CI.Root cause
The program directly pinned two SPL interface crates at 2023-era versions:
while
anchor-spl = "1.0.2"(resolves to1.1.2) already transitively pullsspl-token-metadata-interface 0.8.0andspl-type-length-value 0.9.1. Cargo ended up with two incompatible versions of both crates in the dependency tree. The older chain brought in a stalesolana-programthat conflicted with thesolana-zk-token-sdkcompile unit, causing the build to fail with unresolved symbol errors.Fix
Align the direct pins to the versions
anchor-splalready resolves:Three minor call-site API fixes to match the newer crate versions:
initialize.rs: replace removedDEFAULT_LAMPORTS_PER_BYTE_YEAR/DEFAULT_EXEMPTION_THRESHOLDrent constants withRent::get()?.minimum_balance()(already the pattern used byupdate_field.rsin the same program)update_field.rs,update_authority.rs: rename struct fieldtoken_program_id→program_idinTokenMetadataUpdateField/TokenMetadataUpdateAuthority(field was renamed inanchor-spl 1.1.x)No account structures, instruction logic, or TypeScript test code required changes.
Verification
cargo tree -i spl-token-metadata-interfacenow shows a singlev0.8.0(no morev0.3.4)anchor buildsucceeds locallyTest plan
anchor.ymlmatrix picks uptokens/token-2022/metadata/anchor(no longer in.ghaignore) and goes greenanchor buildsucceedstests/metadata.tspass (initialize mint w/ metadata, update field, update with custom field, remove custom field, change update authority, emit metadata × 2)🤖 Generated with Claude Code