Repository navigation
Conversation
[Medium impact] The changes stay within a new Token-2022 example and its workspace setup. Fix the two deployment paths before merging so users can deploy the example after building it. Findings
SummaryAdds a Pinocchio example that creates a Token-2022 account with required incoming memos.
Reviews (3) · Last reviewed commit: "token-2022 memo-transfer pinocchio: test..." · Reviewed by Greptile |
|
@amilz could you take a look at this one when you get a chance? No open review threads left on it, so it is ready for maintainer review. It is one of 23 open Pinocchio ports I have up — they are independent and self-contained, so they can be reviewed and merged in any order: https://github.com/solana-developers/program-examples/pulls/MarkFeder |
|
@dev-jodee friendly ping, could you review this when you get a chance? CI is green and it's mergeable. Thanks! |
|
@dev-jodee gentle ping: this has been open since Aug 26 with no review. It's still green and mergeable, and I'm happy to rebase or change anything. These 3 are also what's blocking me from reopening the closed ports under the 3-PR limit. Thanks! |
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.
80a66da to
1778ffb
Compare
|
Hi @MarkFeder, 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 |
| # 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.
Deployment uses the wrong filename
Both deployment commands point to program.so, but this crate builds as token_2022_memo_transfer_pinocchio_program.so. After a clean build, bash cicd.sh and the deploy script in package.json fail because the named file does not exist. Update both commands to use the built filename.
|
Superseded by #792 (the bot closed this one and GitHub won't let me reopen it). |
Linked issue
Fixes #785
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 owner, size, mint, owner and
requireIncomingTransferMemos. The second checks that a transfer without a memo is rejected and the same transfer with a memo moves the balance.AI disclosure
Check exactly one. See CONTRIBUTING.md.