Commit 9cbd90f
docs(cookbook): upgrade kit examples to plugin client (#1469)
* docs(cookbook): upgrade kit examples to plugin client
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.
* fix highlight ranges past the new kit.ts line counts
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.
* docs(cookbook): use explicit solanaRpc URLs in kit examples
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.
* remove highlight, line numbers incorrect
---------
Co-authored-by: catmcgee <helloworld@mcgee.cat>
Co-authored-by: John <75003086+ZYJLiu@users.noreply.github.com>1 parent 53217b7 commit 9cbd90f
12 files changed
Lines changed: 202 additions & 442 deletions
File tree
- apps/docs/content/cookbook
- accounts
- transactions
- packages/docs-examples/cookbook
- accounts/create-account
- tokens/create-token-with-metadata
- transactions
- add-memo
- add-priority-fees
- calculate-cost
- fee-sponsorship
- mev-protection
- send-sol
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
Lines changed: 19 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
18 | 5 | | |
19 | 6 | | |
20 | 7 | | |
21 | 8 | | |
22 | 9 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 10 | | |
27 | 11 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 12 | | |
34 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
35 | 23 | | |
36 | | - | |
37 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
38 | 27 | | |
39 | 28 | | |
40 | 29 | | |
41 | | - | |
| 30 | + | |
42 | 31 | | |
43 | 32 | | |
44 | 33 | | |
45 | 34 | | |
46 | 35 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 36 | + | |
| 37 | + | |
64 | 38 | | |
Lines changed: 18 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
17 | 5 | | |
18 | 6 | | |
19 | 7 | | |
20 | 8 | | |
21 | 9 | | |
22 | 10 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 11 | | |
29 | 12 | | |
30 | 13 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
38 | 24 | | |
39 | 25 | | |
40 | 26 | | |
| |||
48 | 34 | | |
49 | 35 | | |
50 | 36 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 37 | + | |
| 38 | + | |
69 | 39 | | |
70 | 40 | | |
71 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
72 | 44 | | |
73 | 45 | | |
74 | 46 | | |
| |||
Lines changed: 16 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
18 | 5 | | |
19 | 6 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 7 | | |
24 | 8 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
30 | 20 | | |
31 | 21 | | |
32 | 22 | | |
33 | 23 | | |
34 | 24 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 25 | + | |
| 26 | + | |
52 | 27 | | |
Lines changed: 26 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 3 | + | |
9 | 4 | | |
10 | | - | |
11 | | - | |
12 | 5 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 6 | + | |
19 | 7 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 8 | + | |
| 9 | + | |
25 | 10 | | |
26 | 11 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 12 | | |
40 | 13 | | |
41 | 14 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
84 | 37 | | |
0 commit comments