Skip to content

add pinocchio multiple-extensions example - #682

Merged
dev-jodee merged 1 commit into
solana-foundation:mainfrom
MarkFeder:tokens-token-2022-multiple-extensions-pinocchio
Aug 11, 2026
Merged

add pinocchio multiple-extensions example#682
dev-jodee merged 1 commit into
solana-foundation:mainfrom
MarkFeder:tokens-token-2022-multiple-extensions-pinocchio

Conversation

@MarkFeder

Copy link
Copy Markdown
Contributor

Adds a pinocchio port of tokens/token-2022/multiple-extensions, filling the last missing variant for this example (previously native-only).

What it does

Creates a Token-2022 mint carrying two extensions at onceMintCloseAuthority and NonTransferable — both initialized via hand-built CPIs before InitializeMint (Token-2022 rejects initializing extensions once the mint is initialized). There is no pinocchio crate for Token-2022, so the instructions are serialized by hand, consistent with the merged mint-close-authority, non-transferable, default-account-state, and transfer-fee pinocchio examples.

Notes

  • Instruction wire format ([token_decimals: u8]) matches the native example.
  • MINT_SIZE = 206 = base 165 + account-type 1 + MintCloseAuthority TLV (36) + NonTransferable TLV (4), mirroring ExtensionType::try_calculate_account_len::<Mint>(&[MintCloseAuthority, NonTransferable]).
  • Test stack follows the repo standard (mocha + tsx, @solana/kit ^7, litesvm); the test decodes the mint with the official Token-2022 codec and asserts both extensions are present and the extended size.

Testing

cargo build-sbf + litesvm test pass on the Linux/Docker path; cargo clippy -- -D warnings, cargo fmt --check, tsc --noEmit, and prettier (root 3.9.6) all clean.

@MarkFeder
MarkFeder requested a review from dev-jodee as a code owner August 8, 2026 10:01
@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds the missing Pinocchio variant of the Token-2022 multiple-extensions example.

  • Creates a rent-exempt Token-2022 mint and initializes MintCloseAuthority and NonTransferable before InitializeMint.
  • Adds workspace registration, package/build configuration, and a LiteSVM integration test that decodes and validates both extensions.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tokens/token-2022/multiple-extensions/pinocchio/program/src/instructions/create_mint.rs Implements mint creation and hand-built Token-2022 CPIs in the required extension-before-mint order.
tokens/token-2022/multiple-extensions/pinocchio/program/src/instructions/mod.rs Defines the Token-2022 program address, 206-byte extended mint size, and one-byte instruction argument parser.
tokens/token-2022/multiple-extensions/pinocchio/tests/test.ts Exercises mint creation in LiteSVM and validates ownership, size, base mint fields, and both decoded extensions.
tokens/token-2022/multiple-extensions/pinocchio/package.json Adds the standard build, deploy, and test scripts with dependencies resolved by the committed frozen lockfile.
Cargo.toml Registers the new Pinocchio program as a root Cargo workspace member.

Reviews (3): Last reviewed commit: "add pinocchio multiple-extensions exampl..." | Re-trigger Greptile

Comment thread Cargo.toml
"tokens/token-2022/default-account-state/native/program",
"tokens/token-2022/default-account-state/pinocchio/program",
"tokens/token-2022/transfer-fee/native/program",
"tokens/token-2022/transfer-fee/pinocchio/program",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unsigned pull request commit

Commit f3ac044af7521baf8d9d60091baf0b428d16646d has no signature, violating the repository requirement that pull request commits have verified signatures and blocking this change from being merged.

Context Used: Request changes if the commits are not signed (ver... (source)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a false positive — the commit is signed and GitHub reports it verified. gh api repos/solana-foundation/program-examples/pulls/682/commits returns verification.verified = true, reason = valid for f3ac044a, signed with my registered ED25519 SSH key (SHA256:UVyyOf24fM8y73sfUoms0okbKMJobxlKQjwweQs4BhU); the commit shows a Verified badge in the PR. No re-sign needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I apologize for the false positive. The GitHub API confirms verification.verified = true with reason = valid for f3ac044a, and the commit shows the Verified badge on the PR. My original comment was incorrect — no action needed on your end.

@dev-jodee dev-jodee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix the merge conflicts pls :)

@MarkFeder
MarkFeder force-pushed the tokens-token-2022-multiple-extensions-pinocchio branch from f3ac044 to ebad3a3 Compare August 11, 2026 14:23
@MarkFeder

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main — the Cargo.toml conflict (from #684's interest-bearing line) is resolved and the commit is now signed/verified. Ready for another look 🙌

@MarkFeder
MarkFeder requested a review from dev-jodee August 11, 2026 14:31
@dev-jodee

Copy link
Copy Markdown
Collaborator

@MarkFeder youll ahve to again ahah

Port the token-2022/multiple-extensions example to pinocchio. Creates a
Token-2022 mint that carries both the MintCloseAuthority and NonTransferable
extensions, initialized via hand-built CPIs before InitializeMint (there is no
pinocchio crate for Token-2022). Mirrors the native example's instruction wire
format and the structure of the merged pinocchio token-2022 siblings.

The litesvm test decodes the resulting mint with the official Token-2022 codec
and asserts both extensions are present (close authority set, non-transferable),
plus the extended mint size (206 bytes).
@MarkFeder
MarkFeder force-pushed the tokens-token-2022-multiple-extensions-pinocchio branch from ebad3a3 to 05bb8f6 Compare August 11, 2026 14:39
@MarkFeder

MarkFeder commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #683 merged. Conflict resolved, commit signed. 🙌

@dev-jodee
dev-jodee merged commit 4120f25 into solana-foundation:main Aug 11, 2026
31 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