Repository navigation
Conversation
…na-foundation#754) - Implements tokens/nft-operations/native/ to complete the anchor/native/pinocchio trio - Uses native Solana SBF entrypoint with hand-built Metaplex Token Metadata CPIs in mpl_util.rs (no external mpl crate dependency) - Supports CreateCollection, MintNft, and VerifyCollection instructions matching the Anchor and Pinocchio interfaces - Validates canonical mint authority PDA derivation on-chain - Adds LiteSVM unit tests with @solana/kit and litesvm 1.x
|
Hi @sehaha, Thanks for the pull request. We ask that every change references an issue a maintainer has accepted, and there isn't one linked here. These examples are a teaching resource and each one has to stay small enough to read in one sitting, so whether a new example or framework flavor belongs here is worth settling before anyone writes it. Agreeing on the approach in an issue first means nobody writes code that can't be merged. See CONTRIBUTING.md for the full workflow. Please open an issue describing the change, or comment on the existing one. Once a maintainer has labelled it |
[Medium impact] The changes are centered on a new native NFT example and its local setup. Fix the shared lockfile and the broken deployment filename before merging. Findings
SummaryAdds a native NFT example alongside the Anchor and Pinocchio versions.
Reviews (1) · Last reviewed commit: "feat(tokens): add native flavor for toke..." · Reviewed by Greptile |
| "litesvm", | ||
| "solana-keypair", | ||
| "solana-message", | ||
| "solana-signer", | ||
| "solana-transaction", |
There was a problem hiding this comment.
Lockfile adds undeclared dependencies
Cargo.lock adds test dependencies to existing Anchor packages whose manifests do not declare them. For example, account-data-anchor-program declares only anchor-lang, but its lock entry now includes litesvm and four Solana packages. Builds that require an unchanged lockfile cannot use it as committed. Regenerate the lockfile from the committed manifests.
| # Run this bad boy with "bash cicd.sh" or "./cicd.sh" | ||
|
|
||
| cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so | ||
| solana program deploy ./program/target/so/program.so |
There was a problem hiding this comment.
Deploy script names wrong file
cicd.sh deploys program.so, but this crate builds nft_operations_native_program.so. On a clean checkout, the build can succeed and deployment will still fail because the requested file does not exist. Use the same filename as the deploy script in package.json.
| solana program deploy ./program/target/so/program.so | |
| solana program deploy ./program/target/so/nft_operations_native_program.so |
| // Point the Solana CLI at mainnet, where the canonical program lives. | ||
| execSync('solana config set -um', { stdio: 'inherit' }); |
There was a problem hiding this comment.
Install changes the saved cluster
prepare.mjs changes the user's saved Solana cluster to mainnet during package installation and never restores it. A developer using localhost or devnet will run later CLI commands against mainnet instead. Pass --url mainnet-beta to solana program dump rather than changing the saved configuration.
| const metadataAccount = svm.getAccount(metadata); | ||
| if (!metadataAccount?.exists) throw new Error('NFT metadata not found'); | ||
| assert.equal(metadataAccount.programAddress, TOKEN_METADATA_PROGRAM_ID); |
There was a problem hiding this comment.
Test misses skipped verification
The verification test only checks that the metadata account still belongs to Metaplex. That was already true before verification, so the test also passes if verify_collection returns success without doing anything. Decode the metadata and assert that collection.verified changes to true. Also check that the sized collection's count increases.
Linked issue
Fixes #754
What and why
tokens/nft-operationspreviously shipped onlyanchor/andpinocchio/. This PR deliverstokens/nft-operations/native/to complete the trio for NFT examples, matching the pattern established acrosstokens/create-token,tokens/transfer-tokens, andtokens/pda-mint-authority.Approach
CreateMetadataAccountV3,CreateMasterEditionV3, andVerifywithVerificationArgs::CollectionV1) inmpl_util.rs, adhering strictly toAGENTS.md.0->CreateCollection: Creates 0-decimal mint, user ATA, mints 1 token, creates sized collection metadata and master edition signed by the[b"authority"]PDA.1->MintNft: Creates 0-decimal mint, user ATA, mints 1 token, creates metadata referencing collection mint, and master edition.2->VerifyCollection: Verifies the NFT against the collection mint via Metaplex CPI signed by the program authority PDA.[b"authority"], asserts account matches, and signs CPIs with seeds.tokens/nft-operations/native/programto rootCargo.toml.Testing
cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures: compiled clean SBF binary (nft_operations_native_program.so).pnpm run build-and-test(Mocha + tsx + LiteSVM 1.x):cargo fmt --check: clean.cargo clippy -- -D warnings: zero warnings.AI disclosure