add pinocchio escrow example#597
Closed
MarkFeder wants to merge 1 commit into
Closed
Conversation
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.