Repository navigation
Conversation
Ports the memo-transfer Token-2022 example to Pinocchio (the anchor example has no native sibling), matching the token-2022 pinocchio account-extension template (kit + litesvm, official @solana-program packages, real Rent::get()). The program hand-rolls three Token-2022 CPIs to create a token account with the MemoTransfer extension enabled: it creates the account, runs InitializeAccount3, then (unlike ImmutableOwner, which is pre-init) enables required memo transfers via EnableRequiredMemoTransfers after initialization, which the account owner signs. The owner is the payer. Account size is 171 bytes (a 1-byte MemoTransfer TLV value). The litesvm test decodes the account with the official Token-2022 codec and asserts the requirement is enabled.
Adds a behavior test alongside the extension-state assertion: it funds a source account, then verifies a TransferChecked into the memo-required account is rejected without a preceding memo and succeeds when preceded by one (SPL Memo program, bundled by LiteSVM). Addresses review feedback that the example's advertised transfer behavior was untested.
Matches the versions solana-foundation#765 set for the other non-anchor examples (kit 8.5, mocha 12, typescript 7) and adds the same pnpm-workspace.yaml overrides, which clears pnpm-audit. The signer roles in the hand-built instruction take 'as const' so kit 8 keeps them as signer roles, as the sibling tests on main do.
1 of 2 tasks
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues remain from this review. SummaryAdds a Pinocchio example that creates a Token-2022 account with
Reviews (3) · Last reviewed commit: "token-2022 memo-transfer pinocchio: depl..." · Reviewed by Greptile |
cargo build-sbf names the artifact after the crate, so deploy the *.so in the output dir instead of program.so, and stop cicd.sh if the build fails. pinocchio-token-2022 now exists in the workspace, so the comment says the instructions are hand-built to show their layout rather than claiming there is no crate.
pnpm runs package.json scripts through cmd.exe on Windows, which does not expand the *.so glob. Name the file cargo build-sbf writes instead, matching solana-foundation#794.
Contributor
Author
|
@dev-jodee #792 and #793 only fail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Fixes #785
Replaces #700, which the PR-hygiene bot closed before the issue was accepted; GitHub doesn't let the author reopen it.
What and why
Adds a Pinocchio version of
tokens/token-2022/memo-transfer, which only had an Anchor one. It follows the same kit + LiteSVM +@solana-programtemplate as the merged Token-2022 Pinocchio examples and builds on the account-extension shape fromimmutable-owner(#696).The single instruction creates a Token-2022 token account with the
MemoTransferextension enabled, so every transfer into it must be preceded by a memo. The program hand-builds three CPIs:CreateAccount, with space for the extension.InitializeAccount3(variant 18):[18] + owner(32).EnableRequiredMemoTransfers:MemoTransferExtension(30), sub-instructionEnable(0) →[30, 0].Unlike
ImmutableOwner, this extension is enabled after the account is initialized, and the enable must be signed by the account owner (the payer here). The account is 171 bytes: 165 base + 1 account-type byte + a 5-byteMemoTransferTLV.The JS dependencies match the versions #765 set for the other non-anchor examples.
Testing
pnpm install --frozen-lockfile,tsc --noEmit,pnpm build,pnpm build-and-testandpnpm auditin a Linux container, pluscargo fmt --check,cargo clippy -D warningsandprettier --check:The first test decodes the account with the official Token-2022 codec and checks the program owner, size, mint, token owner and
requireIncomingTransferMemos. The second checks that a transfer without a memo is rejected and the same transfer with a memo moves the balance.bash cicd.shandpnpm run deployboth nametoken_2022_memo_transfer_pinocchio_program.so, the filecargo build-sbfwrites; checked in Linux with a real build (same check as #794). The name is explicit rather than a*.soglob because pnpm runs scripts throughcmd.exeon Windows, which doesn't expand globs.AI disclosure
Check exactly one. See CONTRIBUTING.md.