add pinocchio escrow example#598
Merged
Perelyn-sama merged 3 commits intoJun 21, 2026
Merged
Conversation
The whole-repo `biome check ./` (TypeScript CI job) was failing on three
files unrelated to this PR, which kept the check red:
- basics/cross-program-invocation/pinocchio/tests/test.ts: remove an unused
discriminator constant and replace non-null assertions with explicit null
guards
- tokens/token-swap/anchor/tests/deposit-liquidity.ts: apply the biome formatter
- tokens/token-2022/.../app/public/{next,vercel}.svg: add a <title> element
(noSvgWithoutTitle)
Perelyn-sama
approved these changes
Jun 21, 2026
This was referenced Jun 21, 2026
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.
What
Adds a Pinocchio implementation of
tokens/escrow, alongside the existinganchorandnativeversions. This is the second Pinocchio token example (aftertransfer-tokens) and the first Pinocchio example to use a PDA-owned vault.Scope
A faithful port of the native escrow with two instructions:
[b"offer", maker, id]), creates a vault associated token account owned by that PDA, transfers the maker's token A into the vault, and stores the offer terms.It's pure SPL (token + associated-token-account CPIs) — no Metaplex — using
pinocchio-token,pinocchio-associated-token-account,pinocchio-system, andpinocchio-pubkey.Notes
tokens/escrow/nativeso the three options stay directly comparable.MakeOfferinstruction data (and stored), so the program usespinocchio_pubkey::derive_addressinstead of an on-chainfind_program_address.TakeOfferreads the bump back from the stored offer.pinocchio-token = "0.5.0"andpinocchio-associated-token-account = "0.3.0"to[workspace.dependencies]— the same two deps introduced by thetransfer-tokensPinocchio PR (add pinocchio transfer-tokens example #596). If that merges first, this rebases trivially (the lines are identical).package.json/pnpm-lock.yaml/tsconfig.json) is copied fromtokens/escrow/native, so the lockfile is self-consistent and the bankrun test reuses the same setup helpers.Tests
tests/test.tsruns under bankrun and mirrors the native escrow's assertions: it mints token A to the maker and token B to the taker, makes an offer (asserting the stored offer fields and the vault balance), then takes it (asserting both accounts are closed and the tokens landed correctly).Locally green:
cargo fmt --check,cargo clippy -- -D warnings, andbiome checkall pass on the new files.