docs(cookbook): upgrade kit examples to plugin client#1469
Conversation
Refactor 8 cookbook kit examples to use the @solana/kit-plugin-rpc + @solana/kit-plugin-signer client pattern introduced in #1465. Replaces manual pipe() / createTransactionMessage / blockhash / sendAndConfirm wiring with createClient().use(payer).use(solanaLocalRpc()).use(airdropPayer()) and client.sendTransaction([...]). - send-sol, add-memo, create-account: full plugin refactor - add-priority-fees: priority fees configured via solanaLocalRpc transactionConfig; planner/executor auto-handle CU price + limit - fee-sponsorship: uses tokenProgram() plugin (createMint, mintToATA, transferToATA) instead of manual ATA derivation - create-token-with-metadata: plugin client for setup, single Metaplex createV1 instruction - calculate-cost: plugin for setup/airdrop, kept manual pipe + getFeeForMessage since fee calculation is the recipe's whole point - mev-protection: plugin for setup, kept manual build + base64 + Jito POST 438 -> 153 lines (~65% reduction). #region markers preserved so MDX includes are unchanged. All 61 docs-examples tests pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
Greptile SummaryThis PR migrates 8 cookbook
Confidence Score: 5/5Safe to merge — the refactoring is mechanically correct across all eight examples, tests are green, and fee sponsorship semantics are preserved. Every changed example was read in full. The plugin client correctly inherits fee-payer semantics (feePayer in fee-sponsorship, signer everywhere else), the two partial refactors deliberately retain manual transaction construction for pedagogical clarity, and the TypeScript compiler confirms type correctness. No logic regressions were found. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Code as Example Code
participant Client as createClient()
participant Payer as payer(signer)
participant RPC as solanaRpc()
participant Airdrop as rpcAirdrop() + airdropPayer()
participant Chain as Solana Localnet
Code->>Client: createClient()
Client->>Payer: .use(payer(signer))
Client->>RPC: ".use(solanaRpc({rpcUrl, rpcSubscriptionsUrl}))"
Client->>Airdrop: .use(rpcAirdrop()).use(airdropPayer(1 SOL))
Airdrop->>Chain: airdrop(signer, 1 SOL)
Chain-->>Airdrop: confirmed
Airdrop-->>Code: client (ready)
Note over Code,Chain: Full-refactor examples (send-sol, add-memo, etc.)
Code->>Client: client.sendTransaction([ix])
Client->>Chain: getLatestBlockhash + sign + sendAndConfirm
Chain-->>Code: "{ context: { signature } }"
Note over Code,Chain: Partial-refactor examples (calculate-cost, mev-protection)
Code->>Chain: client.rpc.getLatestBlockhash().send()
Chain-->>Code: latestBlockhash
Code->>Code: "pipe() -> sign -> base64 / getFeeForMessage"
Code->>Chain: sendAndConfirmTransactionFactory / Jito endpoint
Reviews (4): Last reviewed commit: "remove highlight, line numbers incorrect" | Re-trigger Greptile |
The plugin-client refactor shortened the kit examples — old highlight= directives pointed past the new file ends and codehike crashed the async cookbook compile with "Cannot read properties of undefined (reading 'range')". Repoint each at the new plugin .use() chain and the simplified client.sendTransaction call.
Replace solanaLocalRpc() with solanaRpc({ rpcUrl, rpcSubscriptionsUrl })
+ rpcAirdrop() across all 8 cookbook kit examples so readers can swap
the localhost URL for a surfnet (or any other endpoint) without changing
imports or call shape.
Summary
Refactor 8 cookbook kit examples to the
@solana/kit-plugin-rpc+@solana/kit-plugin-signerclient pattern introduced in #1465. Replaces manualpipe()/createTransactionMessage/ blockhash /sendAndConfirmwiring withcreateClient().use(payer).use(solanaLocalRpc()).use(airdropPayer())+client.sendTransaction([...]).438 → 153 lines (~65% reduction).
Per-file approach
solanaLocalRpc({ transactionConfig: { microLamportsPerComputeUnit } }); planner/executor auto-handle CU price + limittokenProgram()plugin (createMint/mintToATA/transferToATA) instead of manual ATA derivationcreateV1instructionpipe()+getFeeForMessagesince fee calculation is the recipe's whole pointTest plan
pnpm --filter @workspace/docs-examples lint(tsc --noEmit)pnpm --filter @workspace/docs-examples test— all 61 tests pass against surfpool