Skip to content

token-2022 immutable-owner: add pinocchio example - #696

Merged
dev-jodee merged 2 commits into
solana-foundation:mainfrom
MarkFeder:tokens-token-2022-immutable-owner-pinocchio
Aug 25, 2026
Merged

token-2022 immutable-owner: add pinocchio example#696
dev-jodee merged 2 commits into
solana-foundation:mainfrom
MarkFeder:tokens-token-2022-immutable-owner-pinocchio

Conversation

@MarkFeder

Copy link
Copy Markdown
Contributor

Adds a Pinocchio variant of the tokens/token-2022/immutable-owner example, porting the existing Anchor version.

What it does

Creates a Token-2022 token account carrying the ImmutableOwner extension. Once initialized, the account's owner can never be reassigned — a SetAuthority(AccountOwner) on it always fails.

Notes

  • No Pinocchio Token-2022 crate exists, so the CPIs are hand-built: InitializeImmutableOwner (variant 22) is invoked before InitializeAccount3 (variant 18), since the extension can only be added to an uninitialized account.
  • Account size is 170 bytes: base account (165) + account-type byte (1) + ImmutableOwner TLV (4).
  • Tests use litesvm + @solana/kit (mocha via tsx), matching the merged token-2022 pinocchio siblings. The test creates a real Token-2022 mint, initializes the account through the program, decodes it with getTokenDecoder() to assert the extension and stored owner, and verifies an owner change is rejected.

Verification (Linux/Docker)

  • cargo build-sbf
  • cargo fmt --check ✓ · cargo clippy -- -D warnings ✓ · cargo test
  • tsc --noEmit ✓ · prettier --check
  • litesvm tests: 2 passing ✓

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

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a Pinocchio implementation of the Token-2022 Immutable Owner example.

  • Creates and rent-funds a 170-byte Token-2022 account.
  • Initializes Immutable Owner before the base token account through hand-built CPIs.
  • Adds LiteSVM tests covering account decoding and rejection of owner reassignment.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tokens/token-2022/immutable-owner/pinocchio/program/src/instructions/create_token_account.rs Creates the extended Token-2022 account and performs ImmutableOwner and InitializeAccount3 CPIs in the required order.
tokens/token-2022/immutable-owner/pinocchio/program/src/processor.rs Dispatches the example's single instruction to the token-account creation handler.
tokens/token-2022/immutable-owner/pinocchio/tests/test.ts Verifies the initialized account layout and extension, and now fails immediately if either rejection-test setup transaction fails.
tokens/token-2022/immutable-owner/pinocchio/package.json Defines the build and LiteSVM test commands with dependencies pinned through the committed lockfile.
Cargo.toml Adds the new Pinocchio program to the Cargo workspace.

Reviews (2): Last reviewed commit: "test: assert setup transactions succeed ..." | Re-trigger Greptile

Comment thread tokens/token-2022/immutable-owner/pinocchio/tests/test.ts Outdated
@MarkFeder

Copy link
Copy Markdown
Contributor Author

Fixed in a094423 — the rejection test now asserts both setup transactions (mint + account creation) succeed before checking the owner-change rejection.

@dev-jodee
dev-jodee merged commit 3d0c206 into solana-foundation:main Aug 25, 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