@typesol/cli 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/README.md +64 -17
  3. package/SECURITY.md +9 -7
  4. package/dist/bin.d.ts +2 -0
  5. package/dist/bin.js +9 -0
  6. package/dist/cli.js +33 -15
  7. package/dist/compiler/analyze.js +57 -6
  8. package/dist/compiler/diagnostics.d.ts +4 -3
  9. package/dist/compiler/diagnostics.js +10 -6
  10. package/dist/compiler/emit/base.d.ts +1 -1
  11. package/dist/compiler/emit/calls.js +18 -5
  12. package/dist/compiler/emit/cpi-core.d.ts +3 -1
  13. package/dist/compiler/emit/cpi-core.js +8 -4
  14. package/dist/compiler/emit/expressions.d.ts +14 -0
  15. package/dist/compiler/emit/expressions.js +52 -4
  16. package/dist/compiler/emit/shared.d.ts +8 -1
  17. package/dist/compiler/emit/shared.js +8 -1
  18. package/dist/compiler/emit/statements.d.ts +8 -3
  19. package/dist/compiler/emit/statements.js +68 -3
  20. package/dist/compiler/emit/storage.js +5 -1
  21. package/dist/compiler/hints.d.ts +7 -0
  22. package/dist/compiler/hints.js +58 -9
  23. package/dist/compiler/index.d.ts +5 -0
  24. package/dist/compiler/index.js +10 -1
  25. package/dist/compiler/model.js +3 -2
  26. package/dist/compiler/toolchain.d.ts +50 -2
  27. package/dist/compiler/toolchain.js +96 -11
  28. package/dist/node-version.d.ts +4 -0
  29. package/dist/node-version.js +12 -0
  30. package/dist/tools/doctor.d.ts +41 -0
  31. package/dist/tools/doctor.js +96 -14
  32. package/dist/workspace.d.ts +9 -2
  33. package/dist/workspace.js +13 -3
  34. package/docker/deps/0.46.0.lock.json +1206 -0
  35. package/docs/ai.md +2 -1
  36. package/docs/architecture.md +7 -3
  37. package/docs/audit.md +6 -6
  38. package/docs/case-study-phoenix.md +1 -1
  39. package/docs/case-study-raydium-amm.md +1 -1
  40. package/docs/case-study-spl-stake-pool.md +1 -1
  41. package/docs/cli.md +42 -4
  42. package/docs/errors.md +22 -8
  43. package/docs/glossary.md +210 -0
  44. package/docs/language-accounts.md +499 -0
  45. package/docs/language-basics.md +389 -0
  46. package/docs/language-builtins.md +411 -0
  47. package/docs/language-chain.md +198 -0
  48. package/docs/language-cpi.md +470 -0
  49. package/docs/language-errors-events.md +184 -0
  50. package/docs/language-native.md +493 -0
  51. package/docs/language-pdas.md +198 -0
  52. package/docs/language-statements.md +620 -0
  53. package/docs/language-types.md +601 -0
  54. package/docs/language.md +190 -467
  55. package/docs/mainnet.md +18 -3
  56. package/docs/migrate-from-anchor.md +7 -6
  57. package/docs/security-model.md +3 -3
  58. package/docs/stability.md +3 -1
  59. package/docs/test-your-program.md +52 -15
  60. package/docs/troubleshooting.md +222 -100
  61. package/lib/typesol.d.ts +67 -22
  62. package/llms-full.txt +4915 -634
  63. package/llms.txt +12 -1
  64. package/package.json +2 -2
  65. package/releases/0.45.0.json +732 -0
  66. package/ts-plugin/index.js +16 -5
package/CHANGELOG.md CHANGED
@@ -6,6 +6,233 @@ codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.46.0 — 2026-11-13
10
+
11
+ A minor release: it adds a flag (`init --no-agent-files`) and an export of `typesol/compiler` (`typescriptMessage`),
12
+ accepts what 0.45.0 refused (16 signer seeds, the bump included), and refuses programs 0.45.0 compiled to wrong code
13
+ (an `f64` used with an operator, as an integer or as text; a proof or signature check whose result decides nothing; a
14
+ `@code` tag that is not read; a `Seeds<…>` list over Solana's limit). The package's `bin` entry is now `dist/bin.js`,
15
+ which checks the Node.js version first, and `deploy` stops before building when the payer keypair file is missing (a
16
+ signer URI passes through to the Solana CLI). Programs that use none of these build to the same bytes: the repository's 76 programs build to the same binaries and
17
+ IDLs with 0.45.0 and with this release, and the release manifest's check of test/golden/binaries.json passes.
18
+
19
+ - Fixed: the README's toolchain block failed when pasted. The Agave installer adds its `bin` directory to `PATH` in
20
+ `~/.profile` only, so the next line gave `cargo-build-sbf: command not found`. The block now has the
21
+ `export PATH=…` line between the two commands, and says that the platform-tools install downloads about 0.5 GB and
22
+ prints nothing for a minute or two; docs/troubleshooting.md, CONTRIBUTING.md, `init` and `doctor` print the same
23
+ commands (test/cli/doctor.test.ts compares the README's block with them).
24
+ - Fixed: the commands `init`, `doctor` and the build printed for a missing toolchain did not install it.
25
+ `cargo-build-sbf --version` downloads nothing, and `cargo-build-sbf --force-tools-install` alone needs Cargo and a
26
+ Cargo project. Every message now gives `cargo-build-sbf --install-only --force-tools-install --tools-version v1.52`
27
+ (from `TESTED_TOOLCHAIN`), and says which is missing: "the Agave CLI is not installed" (then the installer, the
28
+ `PATH` line and that command) or "the Agave CLI is installed, but not its platform-tools" (that command only). The
29
+ build's errors were "Solana SBF SDK not found …" and "platform-tools missing under … Run
30
+ `cargo-build-sbf --force-tools-install` once." Each command is printed on a line of its own, with nothing after
31
+ it: what a command does is a `#` line above it, written without a character a shell acts on (the commands had a
32
+ trailing `# …` comment, which an interactive zsh, which reads no comments by default as on macOS, passed on as
33
+ arguments: `zsh: number expected`, `export: not valid in this context`), and no sentence's period follows a command.
34
+ `TYPESOL_SBF_SDK` set to a directory that is not an SDK makes `init` say so, where it printed "Install once:" and
35
+ nothing after it (test/cli/doctor.test.ts, both cases; it pastes the printed blocks into an interactive zsh and bash,
36
+ and fish where installed, with the commands stubbed).
37
+ - Fixed: on Linux arm64 the Agave installer fails with a 404 (Anza publishes no Agave CLI for it) and nothing said so;
38
+ `doctor` and `init` printed that installer. Building and LiteSVM tests work there with the platform-tools'
39
+ `linux-aarch64` package and the SDK's C files from the x86_64 release, pointed at with `TYPESOL_SBF_SDK` (checked
40
+ in a `linux/arm64` container: the three templates build and pass their tests). The README's Requirements give those
41
+ five commands (`$HOME` quoted in each), `doctor`, `init` and the build print them on Linux arm64 (an SDK there
42
+ without its platform-tools is "the SBF SDK at … has no platform-tools", not an installed Agave CLI), and the Solana
43
+ CLI row there says that deploying needs another host. The sentences that say builds are the same on Linux arm64 now say how that host was
44
+ set up (test/cli/doctor.test.ts).
45
+ - Fixed: on Node.js older than 22.12 the CLI ran or crashed without saying why (on 20, `npm install` failed inside
46
+ npm or the tests with `Map.groupBy is not a function`; on 22.11, `init`, `check` and `build` ran although `doctor`
47
+ said 22.12 was needed). The `typesol` command is now `dist/bin.js`, which checks the version before it loads
48
+ anything else and exits 1 with one line naming the version needed, the one running and where to get one
49
+ (test/cli/node-version.test.ts; checked in `node:20-bookworm` and `node:22.11-bookworm` containers).
50
+ - Fixed: `deploy` without a payer keypair printed that the Solana CLI would refuse, built, and went on until
51
+ `solana program deploy` failed. It now stops before building, exit 1: "no payer keypair at
52
+ ~/.config/solana/id.json: create one with `solana-keygen new` (or pass --keypair <file>), then fund it with
53
+ `solana airdrop 2 --url devnet`. Nothing was sent." A `--keypair` file that is not there gets "no keypair file at
54
+ ./payer.json (given with --keypair): check the path. Nothing was sent.", an empty one "--keypair is empty: give the
55
+ path of the payer's keypair file. Nothing was sent.", and a missing `keypair_path` of a Solana CLI config names that
56
+ config. Only a file is checked: a signer the Solana CLI resolves itself (`ASK`, `-`, and the schemes `usb:`,
57
+ `prompt:` and `stdin:`, as in `usb://ledger?key=0`, `prompt://`, `stdin://`) goes to `solana program deploy` as
58
+ before, without the balance check; a `file:` URI (`file:id.json`, `file:///abs/id.json`) is checked as the path it
59
+ names, and anything else is a path. `solana` missing from `PATH` is now said
60
+ first, also before building (it was said after the build) (test/cli/doctor.test.ts, with a fake `solana`).
61
+ - Fixed: `doctor` ended with its rows only, so three `!` rows after a passing test looked like a problem. It now ends
62
+ with one line: "Ready to build and test. The ! rows: deploying still needs: keypair, RPC; …", "Ready to build, test
63
+ and deploy." or "Not ready to build or test: fix the ERR rows (…) first." (test/cli/doctor.test.ts).
64
+ - New flag, `init --no-agent-files`: leaves out the files for AI coding agents (AGENTS.md, CLAUDE.md,
65
+ `.cursor/rules/typesol.mdc`, `.mcp.json`, `.cursor/mcp.json`), which `init` wrote with no way to opt out; without
66
+ it, `init` now names them after the files it created, and where one of them is already there (a repository with
67
+ its own AGENTS.md), its refusal says so: "refusing to overwrite: AGENTS.md (--no-agent-files leaves out the files
68
+ for AI coding agents)" (test/cli/ai.test.ts). `.vscode/settings.json` is written
69
+ either way: it makes the editor show TypeSOL's errors.
70
+ - Hints, text only (test/language/diagnostics.test.ts):
71
+ - an `async` instruction returning `Promise<void>` got "instructions cannot be async or generators" with no hint,
72
+ though the README promised one; it now has one (helper functions too);
73
+ - `console` and other globals a program does not have (`process`, `Buffer`, `setTimeout`, `setInterval`, `fetch`,
74
+ `window`, `document`) led with TypeScript's "Cannot find name 'console'. Do you need to change your target
75
+ library? …"; the message is now "'console' does not exist in a Solana program", with the hint under it where
76
+ there is one (`window` and `document` have none). The editor shows the same message, hint or not, through
77
+ `typesol/ts-plugin` (the new export below);
78
+ - `Date.now()` where an integer is expected now points to `now()`, the cluster's clock, and
79
+ `Math.floor(Date.now() / 1000)` (which was "unsupported call: Math.floor") says to use `now()`;
80
+ `Math.floor`, `trunc`, `ceil` and `round` on their own point to integer division;
81
+ - calling a cast imported with `type` (`import { type u64 }`, as the templates import it, then `u64(x)`) got
82
+ TypeScript's "'u64' cannot be used as a value because it was imported using 'import type'" alone; the hint says
83
+ to import it without `type`. The templates keep `type`: the hint is where the error is;
84
+ - the missing-import hint covered the functions and constants `typesol` exports (`u64`, `require`, …); it now
85
+ covers its types and interfaces too (`import { type Signer } from "typesol"`, `Mut`, `SystemProgram`, …);
86
+ - a `number` field in account data got the list of allowed field types alone; it now has a hint naming the integer
87
+ types (and a `Date` field, one about Unix seconds and `now()`).
88
+ - New export of `typesol/compiler`: `typescriptMessage(diagnostic)`, the message the CLI shows in place of a
89
+ TypeScript error's, or undefined to keep TypeScript's; `typesol/ts-plugin` uses it, so the editor shows what the CLI
90
+ shows (test/cli/ts-plugin.test.ts).
91
+ - Fixed: operators on an `f64` compiled to integer operators on its IEEE 754 bits, a silently wrong result:
92
+ `a.x + a.x` was a checked u64 add of the bits, `a.x < a.y` compared them as integers. Every operator with an `f64`
93
+ operand is now refused (arithmetic, bitwise, shifts, unary `-` and `~`, ordering, compound assignments, `++` / `--`,
94
+ and `min`, `max`, `isqrt`, `mulDiv`): "+ on an f64 is not supported: an f64 is held as its IEEE 754 bits and there
95
+ is no float arithmetic (this would compute on the bits); compute in integers and make the result with
96
+ f64FromBits(bits), or take an f64's bits with f64Bits(x)". Equality (`===`, `!==`, `==`, `!=`, `switch`) is
97
+ refused too, since equal bits are not equal numbers (NaN, 0 and -0): "… to compare the bits, write f64Bits(a) ===
98
+ f64Bits(b)". `??` over an `Option<f64>` now gives an `f64` whatever the other side expects, so `(a.o ?? a.x) * 2n`,
99
+ `a.n < (a.o ?? a.x)`, `min(a.n, a.o ?? a.x)` and `a.n += a.o ?? a.x` are refused too (they computed on the bits).
100
+ - Changed: an `f64` no longer converts to an integer, nor an integer to an `f64`. `a.n = a.x`, `const z: u64 = a.x`,
101
+ an `f64` passed to a helper's `u64` parameter or returned as a `u64`, `xs.get(a.x)`, `u64(a.x)`, `u8(a.x)`,
102
+ `u128(a.x)` and `a.x as u64` compiled and used the bits as the integer; `a.n as f64` made an integer's value the
103
+ bits. They are refused: "an f64 is not an integer, so it is not converted to u64: it is held as its IEEE 754 bits,
104
+ and the integer would be those bits; to use the bits, write f64Bits(x)" (and "a u64 is not an f64, so it is not
105
+ converted: an f64 is made from its IEEE 754 bits with f64FromBits(bits)"). An `f64` in a template string or `log`
106
+ printed its bits as a decimal integer; it is refused: "an f64 cannot be written as text: there is no float
107
+ formatting, and the digits would be its IEEE 754 bits read as an integer; to show the bits, write f64Bits(x)".
108
+ Copying an `f64` to an `f64` (fields, locals, structs, events, `Option<f64>`, ternaries, `??`, helper arguments and
109
+ returns typed `f64`) compiles as before, and so does an `f64` seed (its 8 bytes, as Rust's `to_le_bytes`). No
110
+ program of the repository used a conversion (test/language/f64-operators.test.ts; docs/language-types.md and the
111
+ refused-constructs table of docs/language-statements.md).
112
+ - Changed, now accepted: signer seeds were limited to 14 seeds and the bump, one fewer than Solana allows: the limit of 15 entries,
113
+ meant for lists the derivation adds the bump to, was applied to signer seeds and `createProgramAddress` lists too,
114
+ which end with their bump. They now take 16 entries, 15 seeds and the bump (Solana's `MAX_SEEDS`, checked by
115
+ `invoke_signed` and `create_program_address`); a 17th is refused with "at most 16 seeds, the bump included
116
+ (Solana's limit)", and a 16th seed before a derived bump with "at most 15 seeds: the bump the derivation adds makes
117
+ 16, Solana's limit" (was "at most 15 seeds" for both). test/language/signer-seed-limit.test.ts signs a CPI with
118
+ 16 entries in LiteSVM (a seed list and a bound `signer([...])`) and derives with `createProgramAddress`.
119
+ - Changed, now refused: a `Seeds<…>` constraint had no seed limit, so 16 or more names compiled and failed every call. It now
120
+ has the same limits and messages: with a bump field, "at most 16 seeds, the bump included (Solana's limit)"; with the
121
+ canonical bump, "at most 15 seeds: the bump the derivation adds makes 16, Solana's limit"
122
+ (test/language/signer-seed-limit.test.ts).
123
+ - Fixed, messages only (test/language/diagnostics.test.ts):
124
+ - a `u256` shift amount got "shift by a u64 (or smaller) amount", while a `u128` amount compiles (its range check
125
+ runs on all 128 bits); the message is now "a shift amount is a u128 or smaller integer: convert it (u64(n))";
126
+ - a function in parentheses (`const g = (function (): u64 { … })`) got "function expressions are not supported:
127
+ declare a function at the top level", though function expressions compile; an arrow there got "this syntax
128
+ (ArrowFunction) is not supported". Both now get "a function cannot be used here: bind it with const …". The hint
129
+ for template strings ("template strings are not supported …") was never shown and is gone;
130
+ - the test of `FixedString<0>` matched "capacity 1..1024" as a prefix of the message; it now matches the whole
131
+ "FixedString<N> needs a literal capacity 1..10240", and covers 10241 (refused) and 10240 (accepted).
132
+ - Fixed: a call to `merkleVerify`, `verifyEd25519` or `verifySecp256k1` used as a statement compiled and checked
133
+ nothing. The three return whether the proof or signature holds and fail nothing by themselves, so
134
+ `merkleVerify(leaf, proof, root);` emitted the hash computation and dropped its result. Such a call is now refused:
135
+ "the result of merkleVerify is discarded, so nothing is checked: it returns whether the proof holds; write
136
+ require(merkleVerify(…), error)". Refused as well: such a call as the condition of an `if` with an empty body and no
137
+ `else` or an empty one ("the result of merkleVerify is not acted on: the if around it has an empty body, so nothing
138
+ is checked: …"), and its result (in parentheses or under `as` too) kept in a `const` or `let` (declared or assigned,
139
+ in a closure too) that the function declaring it never reads, a closure inside it included ("the result of
140
+ merkleVerify is never read (ok is not used), so nothing is checked: …"). What is caught is these three forms, not
141
+ every unused result: a helper that returns the result, called as a statement, still compiles. No program of the
142
+ repository called one these ways (test/language/diagnostics.test.ts; rows in the refused-constructs table of
143
+ docs/language-statements.md).
144
+ - Fixed: a `@code` tag that TypeScript attaches to no member was ignored without a word, and the member took the next
145
+ code instead. Written after other code on its line (`A = "a", /** @code 6100 */ B = "b"`), it is now refused,
146
+ naming the member that follows: "this @code tag is not read: other code comes before it on its line; put /** @code …
147
+ */ on its own line above B" (after the last member: "it follows the last member"). Above the enum itself
148
+ (`/** @code 0 */` before `export enum PoolError {`), it is refused too: "this @code tag is not read: a tag above the
149
+ enum numbers no member; put /** @code … */ above its first member, AlreadyInUse". A tag on its own line, or first on
150
+ its member's line, is read as before; no program of the repository changes (test/language/zero-copy-shapes.test.ts).
151
+ The same goes for a tag in a `/* … */` or `//` comment ("this @code tag is not read: only a doc comment (/** … */)
152
+ is, not a // comment; write /** @code … */ above B") and in a doc comment that another one follows before the
153
+ member, of which only the last is read ("… another doc comment follows it, and only the last one above B is read;
154
+ put the tag in that one"). In a doc comment, a tag is any `@code` after the start, whitespace or `*`, as TypeScript
155
+ reads it, so one inside a sentence (`/** The second. @code 6200 */`) is a tag and is refused where it is not read; in
156
+ a `//` or `/* … */` comment only an `@code` first on a line of the comment is reported, so prose there
157
+ (`// see the @code docs`) is not.
158
+ - Docs: README links Quick start from the top, has three lines under the introduction with the two commands and the
159
+ playground, opens Quick start with the playground, says that `npm install`'s advisories come from
160
+ `@anchor-lang/core` (which `typesol/testing` uses to encode instructions and decode accounts, so the tests need it;
161
+ nothing of it is in a deployed program), says what npm's `E404 … typesol` outside a project means and what to run,
162
+ and that the scaffolded counter has one more instruction than the 23-line one shown. docs/troubleshooting.md has a
163
+ heading per symptom.
164
+ - Docs: the language reference is a guide. docs/language.md is an overview: the guide's pages, then an index of where
165
+ each construct is described, then the former reference's sections (their headings kept, so links to them still
166
+ land there). The pages, read in order:
167
+ - docs/language-basics.md: "Solana in a dozen lines", what a program is, one program explained line by line, and
168
+ "Limits and costs" (rent, compute budget, transaction size with its header and a recent blockhash, an address
169
+ lookup table entry at one byte, account growth, with their sources' values at the time of writing; at most 32
170
+ accounts per instruction is TypeSOL's default, not the cluster's);
171
+ - language-types.md: each type with its bytes, limits and error codes, and when to choose `FixedArray`, `FixedVec`
172
+ or `Vec`; `Struct arguments`, `f64` and heap values come last;
173
+ - language-statements.md: exactly which TypeScript is TypeSOL, and a table of what is refused with each message;
174
+ - language-accounts.md, with what happens to existing accounts when an account struct changes (also in
175
+ docs/mainnet.md: a field added fails with 3003 only on an account of exactly the old size; one created with spare
176
+ space or grown since passes and reads the spare bytes, or other fields' bytes when the field was inserted), and
177
+ `Two parameters, one account` (the `Inout` overlap rule for accounts) and `How many accounts` after the
178
+ constraints;
179
+ - language-pdas.md, language-errors-events.md, language-cpi.md, language-chain.md (sysvars, hashes, signatures,
180
+ oracles) and language-native.md (porting native programs, marked advanced);
181
+ - docs/language-builtins.md lists every name `"typesol"` exports, generated from lib/typesol.d.ts by
182
+ `scripts/language-builtins.ts` (`--check` in the tests and in CI).
183
+
184
+ Each page ends with a "Next" line and links a term's first use to the new docs/glossary.md (the three meanings of
185
+ owner, Anchor, associated token account, keypair account, authority, payer, remaining accounts, return data, slot
186
+ and epoch, cluster, syscall, precompile, ProgramData and upgrade authority, zero-copy, and more).
187
+
188
+ What the examples guarantee: every example is a complete program, or a block marked as a fragment whose every line is
189
+ a line of the compiled file it is taken from. test/language/docs-examples.test.ts compiles each program, checks that
190
+ every refused construct of the table is refused with the message it quotes, that links into the docs land on a
191
+ heading (a repeated heading's anchor with GitHub's `-1`, `-2` suffix), that every page but the overview and the
192
+ built-ins list has a compiled program, and that no TypeScript block is fenced so that it would be skipped (`~~~`,
193
+ `typescript`); a claim compiling does not prove is checked against the compiled program (the error codes from 0 of
194
+ docs/language-native.md). An example shows the construct its section is about, and docs/language.md says that,
195
+ unless the text says who may call an instruction, it does not check its caller as a real program must. The examples
196
+ that move value or sign as a PDA do check it: the PDA page's `payOut` takes its config at the singleton PDA
197
+ `["config"]` with `HasOne` and says to gate the config's creation, docs/language-cpi.md's `payOut` has the signer in
198
+ the vault's seeds (and `makeVault` creates the vault at those seeds), `remove` has `HasOne` before `close`, the native
199
+ `bump` checks that `admin` signed and the native Borsh `deposit` checks the pool's owner; the PDA page's first
200
+ example derives its second bump, and `invoke`'s `payOut` and `t.pdaWithBump` point to a stored bump. Those that show
201
+ one mechanism only say so, with the check a real instruction needs, on the first line after the example
202
+ (`invokeInstruction`'s `execute`, `Migrate`'s `upgrade`, a first-caller `InitIfNeeded` setup, FixedVec's
203
+ `setOwners` / `addOwner`, the fallback's `record`, BigVec's `add`, the run-time views' `fill`, the Borsh `deposit`,
204
+ the red-black tree's `place` / `cancel`, the enum's `approve`, the data enum's `apply`; the native `programAt`
205
+ entry and the randomness example's `settle` in their text), and `grow`'s open access is explained as moving no
206
+ value. docs/test-your-program.md has seeds of other widths and asserting an error code, naming the program that
207
+ snippet runs against (test/cli/testing.test.ts runs both). docs/troubleshooting.md is grouped (install, writing and
208
+ running a program, deploy, verify and `--docker`), with entries for running out of compute units, for a
209
+ transaction over 1,232 bytes and for `idl publish` failing on a local validator; the longest table cells (Token-2022
210
+ methods, `init` and `verify` in docs/cli.md) are lists.
211
+
212
+ lib/typesol.d.ts gains doc comments only: the 34 exports that had none have one, the built-ins page's one-liners
213
+ (`currentSlot`, `slotsPerEpoch`, `HasOne`, `Ata`, `transferFee`, `TOKEN_ACCOUNT_SIZE`, `readonly`, `rawArrayAt`,
214
+ `Mut`, `Init`, `Account`, `log`, `invoke`, `Vec`) describe the name itself, the comment of `findProgramAddress` sat
215
+ above `bigEndian` and moves to it, and `isqrt`'s says it takes integers up to `u256` (as the compiler does), not up
216
+ to `u128`.
217
+ - Docs, corrected (statements of the former reference and of other published pages, found while checking them
218
+ against the compiler; no program compiles differently): top-level constants are not listed in the IDL (a constant
219
+ used as a seed is recorded there as a `const` seed); closure parameters need their types where the closure is
220
+ declared (an arrow written at a call takes them from the parameter); a `@layout borsh` struct's `Vec` may be any
221
+ field, not only the last; `signer([…])` is written in a declaration or as a helper's argument, not inside a CPI's
222
+ arguments; `merkleVerify`, `verifyEd25519` and `verifySecp256k1` return whether the proof or signature holds and fail
223
+ nothing by themselves (docs/language-chain.md, with an example, and their doc comments); a program account is
224
+ checked for initialization (3012), owner (3007), size (3003), then discriminator (3002), and the two cases where
225
+ Anchor's order gives another code (another discriminator with fewer bytes than the struct: 3003 here, 3002 under
226
+ Anchor; under 8 bytes: 3003 here, 3001 under Anchor) are listed in docs/errors.md (test/security/anchor-order.test.ts
227
+ pins them); docs/errors.md said accounts are created after every other check, while the creates a body starts with
228
+ run before the constraints (not with an account group, whose arguments are decoded first); a failed instruction
229
+ fails the whole transaction; `>>` fails (5100) like `<<` when the amount is not below the width; `FixedString<N>`
230
+ takes 4 + N bytes; token account and mint codes are stated one way everywhere (3012 / 3007 / 3003); SECURITY.md
231
+ names the review of 0.44.0 and 0.44.1 as the README and docs/security-model.md do (test/cli/repository.test.ts
232
+ checks the three against docs/audit.md); the README's "Safe by default." is "Checked by default."; docs/mainnet.md
233
+ carries the status warning, its counter is built with 0.45.0, and it says what a `verify` match does not prove;
234
+ docs/migrate-from-anchor.md no longer claims `@layout borsh` is "several times cheaper than Anchor".
235
+
9
236
  ## 0.45.0 — 2026-11-12
10
237
 
11
238
  - New: a program builds to the same bytes on macOS arm64, Linux arm64 and Linux x86_64 (the programs and SBPF versions
package/README.md CHANGED
@@ -12,6 +12,7 @@
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
+ <a href="#quick-start">Quick start</a> ·
15
16
  <a href="https://typesol.com">Website</a> ·
16
17
  <a href="https://typesol.com/docs/">Docs</a> ·
17
18
  <a href="https://typesol.com/docs/changelog/">Changelog</a> ·
@@ -27,7 +28,7 @@ clients read TypeSOL programs unchanged.
27
28
 
28
29
  - **One language, end to end.** You write the program and its tests in TypeScript, and every build writes a typed
29
30
  client for it ([docs/client.md](docs/client.md)). Your editor gives you completion and type errors throughout.
30
- - **Safe by default.**
31
+ - **Checked by default.**
31
32
  - Every arithmetic operation is checked.
32
33
  - Account owner, discriminator, signer, writability and aliasing checks are generated from your parameter types.
33
34
  - Constraints follow Anchor's rules and use Anchor's error codes.
@@ -41,12 +42,17 @@ clients read TypeSOL programs unchanged.
41
42
  chain, against its source. Every release records the hashes of its npm tarball and of every program it builds
42
43
  ([releases/](releases), [docs/testing.md](docs/testing.md#reproducing-a-release)).
43
44
  The same source, TypeSOL version and toolchain build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64
44
- (measured: all 76 programs of the sources for SBPF v0, 14 of them for v1 and v2;
45
+ (measured: all 76 programs of the sources for SBPF v0, 14 of them for v1 and v2; Linux arm64 with the platform-tools
46
+ `linux-aarch64` package set up as in [Requirements](#requirements), since there is no Agave CLI for it;
45
47
  [docs/stability.md](docs/stability.md#what-builds-the-same-bytes-where)).
46
48
  `typesol build --docker` builds in a pinned linux/amd64 container that anyone can rebuild from the Dockerfile, and
47
49
  `typesol verify --docker` checks a deployed program against its source in that same environment
48
50
  ([docs/mainnet.md](docs/mainnet.md#6-verify)).
49
51
 
52
+ **Try it** in the browser, with nothing to install: [typesol.com/play](https://typesol.com/play/). On your machine, once
53
+ Node.js and the Solana toolchain are in place ([Quick start](#quick-start), [Requirements](#requirements)):
54
+ `npx @typesol/cli init my-app`, then `cd my-app && npm install && npm test`.
55
+
50
56
  <p align="center">
51
57
  <a href="#numbers">
52
58
  <picture>
@@ -80,7 +86,8 @@ sources are in [`showcase/mainnet`](showcase/mainnet), and where each original b
80
86
 
81
87
  ## At a glance
82
88
 
83
- **`counter.ts`**: a complete program, 23 lines.
89
+ **`counter.ts`**: a complete program, 23 lines. (`typesol init` writes it with one more instruction, a read-only
90
+ `assertAtLeast`.)
84
91
 
85
92
  ```ts
86
93
  import { type Init, type Mut, type Pubkey, type Signer,
@@ -173,22 +180,37 @@ transactions to both and compares the results.
173
180
 
174
181
  ## Quick start
175
182
 
183
+ No install: try TypeSOL in the browser at [typesol.com/play](https://typesol.com/play/).
184
+
176
185
  You need Node.js 22.12 or later and the Agave CLI with its platform-tools, which hold the clang TypeSOL compiles with.
177
186
  Rust is not needed. TypeSOL is tested with **Agave 3.1.10 and platform-tools v1.52** (clang 20.1.7); to install exactly
178
- those:
187
+ those on macOS or Linux x86_64 (Linux arm64: see
188
+ [Requirements](https://github.com/typesol-lang/typesol#requirements)):
179
189
 
180
190
  ```sh
181
191
  sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.10/install)"
192
+ # The installer adds this line to ~/.profile for new shells, and this shell needs it now:
193
+ export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
194
+ # Once: this downloads the platform-tools, about 0.5 GB and up to 1.6 GB unpacked, and prints nothing for a minute or two:
182
195
  cargo-build-sbf --install-only --force-tools-install --tools-version v1.52
183
196
  ```
184
197
 
185
198
  ```sh
186
- npx @typesol/cli init my-app --name counter # typesol.json, programs/counter.ts, tests/counter.test.ts, tsconfig
199
+ npx @typesol/cli init my-app --name counter
187
200
  cd my-app && npm install
188
- npm test # builds the program and runs it in LiteSVM, an in-process Solana runtime
189
- npx --no-install typesol build # target/counter/{counter.so, counter.json (IDL), counter.client.ts, counter.build.json}
201
+ npm test
202
+ npx --no-install typesol build
190
203
  ```
191
204
 
205
+ `init` writes `typesol.json`, `programs/counter.ts`, `tests/counter.test.ts` and a tsconfig. `npm test` builds the program
206
+ and runs it in LiteSVM, an in-process Solana runtime. `build` writes `target/counter/`: `counter.so`, `counter.json` (the
207
+ IDL), `counter.client.ts` and `counter.build.json`.
208
+
209
+ `init` also writes rules and an MCP server config for AI coding agents (AGENTS.md, CLAUDE.md, `.cursor/`, `.mcp.json`)
210
+ and lists them; `--no-agent-files` leaves them out. `npm install` reports advisories (moderate and high) and packages
211
+ with install scripts: they come from `@anchor-lang/core` and the Solana web3.js it depends on, which `typesol/testing`
212
+ uses to encode instructions and decode accounts, so the tests need it; none of it is in the program you deploy.
213
+
192
214
  Other versions work, but their binaries are not covered by the project's tests: `typesol build` warns once when the
193
215
  clang is another one (`--toolchain-strict` or `TYPESOL_TOOLCHAIN=strict` makes that an error), and every build records
194
216
  its clang, platform-tools and host in `<name>.build.json`.
@@ -196,18 +218,23 @@ its clang, platform-tools and host in `<name>.build.json`.
196
218
  `npx --no-install typesol doctor` checks all of this (Node.js, platform-tools and whether they are the tested ones, Solana CLI, keypair, RPC) and prints the command
197
219
  that fixes anything missing. Inside a project, `npx --no-install typesol …` (or `npm run build`, `npm run deploy`) runs the
198
220
  project's own copy; outside one, use `npx @typesol/cli …`. Plain `npx typesol` is not TypeSOL: `typesol` is not the npm
199
- package's name, so where the project's copy is not installed npx would fetch whatever package has that name.
221
+ package's name, so where the project's copy is not installed npx would fetch whatever package has that name. Outside a
222
+ project (or before `npm install`), `npx --no-install typesol …` therefore fails with npm's `E404 … typesol - Not
223
+ found`, which does not mention `@typesol/cli`: run `npx @typesol/cli …` there, or `npm install` in the project first.
200
224
 
201
225
  To deploy, on devnet:
202
226
 
203
227
  ```sh
204
- solana-keygen new # once, if you have no keypair (~/.config/solana/id.json)
205
- solana airdrop 2 --url devnet # test SOL for the rent (rate-limited: https://faucet.solana.com also works)
228
+ # Once, if you have no keypair at ~/.config/solana/id.json:
229
+ solana-keygen new
230
+ # Test SOL for the rent. The airdrop is rate-limited, and https://faucet.solana.com also works:
231
+ solana airdrop 2 --url devnet
206
232
  npx --no-install typesol deploy --url devnet
207
233
  ```
208
234
 
209
235
  or on a local validator: `solana-test-validator` in another terminal, `solana airdrop 5 --url localhost`, then
210
- `npx --no-install typesol deploy --url localhost`. `deploy` checks the RPC and the payer's balance before sending anything.
236
+ `npx --no-install typesol deploy --url localhost`. `deploy` checks the payer's keypair, the RPC and the payer's balance
237
+ before sending anything, and stops with the command to run when one is missing.
211
238
 
212
239
  `--template vault` or `--template escrow` starts from a SOL vault or an SPL token escrow instead of the counter, each
213
240
  with a passing LiteSVM test.
@@ -222,7 +249,8 @@ program's address.
222
249
  **Your first change.** Open `programs/counter.ts`, add an instruction (say `decrement`, with
223
250
  `require(counter.count >= 1n, …)` before `counter.count -= 1n`), call it from `tests/counter.test.ts` and run `npm test`.
224
251
  If the build refuses something, the error points at the line and, for the usual first mistakes (`1` instead of `1n`,
225
- `console.log`, a missing import, `async`), adds a `hint:` with what to write instead; your editor shows the same.
252
+ `console.log`, `Date.now()`, a missing import, `async`), adds a `hint:` with what to write instead; your editor shows
253
+ the same.
226
254
 
227
255
  **Where next**
228
256
  - The language, every type and built-in: [docs/language.md](docs/language.md).
@@ -230,7 +258,7 @@ If the build refuses something, the error points at the line and, for the usual
230
258
  - Coming from Anchor: [docs/migrate-from-anchor.md](docs/migrate-from-anchor.md) maps every construct, and
231
259
  `typesol port` starts from your program's IDL; [docs/case-study-escrow.md](docs/case-study-escrow.md) follows one
232
260
  program through the port.
233
- - Real programs checked against their mainnet binaries: [Showcase](#showcase-ports-checked-against-mainnet), with a
261
+ - Real programs checked against their mainnet binaries: [Showcase](https://github.com/typesol-lang/typesol#showcase-ports-checked-against-mainnet), with a
234
262
  case study each (Marginfi v2 in full: all 124 instructions, the same on 2,081 transactions; Phoenix v1, a native
235
263
  order book, the same on 3,575 transactions down to its event bytes; Raydium AMM v4, a native program, down to its log
236
264
  lines).
@@ -270,7 +298,8 @@ Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts
270
298
  | **Native programs** | a `@fallback` entry over the raw instruction data and accounts by position, Borsh accounts (`loadBorsh`), views of account bytes in place (also at offsets known only at run time) and lib-sokoban's red-black tree over them, byte builders (`pushLE`, `pushBorsh`, …), return data, `closeRaw`, and Rust's panics and overflow messages at the original's source locations |
271
299
  | **Interfaces** | custom discriminators (`@discriminator`), so a TypeSOL program can be a Token-2022 transfer hook, with extra accounts (ExtraAccountMetaList) |
272
300
 
273
- The full reference, with every type, check and built-in, is in [docs/language.md](docs/language.md).
301
+ The [language guide](docs/language.md) explains each construct with a compiled example, and lists every type, check
302
+ and built-in.
274
303
 
275
304
  ## Tooling
276
305
 
@@ -434,9 +463,27 @@ stable already and what is still experimental: [docs/stability.md](docs/stabilit
434
463
 
435
464
  ## Requirements
436
465
 
437
- - Node.js 22.12 or later.
438
- - The Agave CLI with platform-tools.
439
- - macOS or Linux. On Windows, use WSL2.
466
+ - Node.js 22.12 or later (the CLI stops with the version it needs on an older one).
467
+ - The Agave CLI with platform-tools (see [Quick start](#quick-start)).
468
+ - macOS or Linux x86_64 for everything; Linux arm64 to build and test, set up as below (deploying from it needs the
469
+ Solana CLI built from source); on Windows, WSL2.
470
+ - Linux arm64: Anza publishes no Agave CLI for it (the installer fails with a 404), but platform-tools has a
471
+ `linux-aarch64` package. With it and the SDK's C files from the x86_64 release (headers and linker script, as the
472
+ `--docker` image takes them), `typesol build` and LiteSVM tests work (needs `curl` and `bzip2`):
473
+
474
+ ```sh
475
+ mkdir -p "$HOME/.local/share/typesol-sdk/sbf/dependencies/platform-tools"
476
+ # About 215 MB, for the C headers and linker script of the SDK only:
477
+ curl -sSfL https://github.com/anza-xyz/agave/releases/download/v3.1.10/solana-release-x86_64-unknown-linux-gnu.tar.bz2 | tar -xj -C "$HOME/.local/share/typesol-sdk" --strip-components=3 solana-release/bin/platform-tools-sdk/sbf/c
478
+ # About 515 MB, 1.6 GB unpacked, and quiet for a minute or two:
479
+ curl -sSfL https://github.com/anza-xyz/platform-tools/releases/download/v1.52/platform-tools-linux-aarch64.tar.bz2 | tar -xj -C "$HOME/.local/share/typesol-sdk/sbf/dependencies/platform-tools"
480
+ touch "$HOME/.local/share/typesol-sdk/sbf/dependencies/platform-tools-v1.52.md"
481
+ # Add this line to ~/.profile too, for new shells:
482
+ export TYPESOL_SBF_SDK="$HOME/.local/share/typesol-sdk/sbf"
483
+ ```
484
+
485
+ `typesol doctor` prints these commands there. Deploying needs the Solana CLI: deploy from macOS or Linux x86_64,
486
+ or build the Agave CLI from source. `build --docker` (linux/amd64, emulated) works on any host with Docker.
440
487
 
441
488
  TypeSOL finds the SDK under `~/.local/share/solana/install/active_release` or next to `cargo-build-sbf` on `PATH`. Set
442
489
  `TYPESOL_SBF_SDK` to override the location. See [docs/troubleshooting.md](docs/troubleshooting.md).
package/SECURITY.md CHANGED
@@ -5,11 +5,13 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
5
5
  ## Status
6
6
 
7
7
  - The compiler, runtime and tooling have been through internal security reviews by the maintainers. The latest, of
8
- 0.43.0 on 2026-11-11, found defects in the compiler (one of them can break an authorization check in a helper) and
9
- in the tooling; they are fixed in 0.44.0. **Rebuild and redeploy programs built with 0.43.0 or
10
- earlier once it is out**; [docs/security-model.md](docs/security-model.md#review-of-0430-2026-11-11) says how to tell
11
- whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what that review did and did not
12
- cover. Every release is covered by execution tests, differential tests against Anchor, and randomized tests.
8
+ 0.44.0 on 2026-11-11, found defects in the compiler (wrong token-wrapper instruction data, and a reference that could
9
+ outlive a resize and reach another record) and a latent one in the runtime; they are fixed in 0.44.1. The one
10
+ before it, of 0.43.0, found defects fixed in 0.44.0 (one of them could break an authorization check in a helper).
11
+ **Rebuild and redeploy programs built before 0.44.1**;
12
+ [docs/security-model.md](docs/security-model.md#status) gives the status, its sections on each review say how to
13
+ tell whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what each review did and did
14
+ not cover. Every release is covered by execution tests, differential tests against Anchor, and randomized tests.
13
15
  **TypeSOL has not been audited by an independent firm.** Do not put significant value behind programs built with it
14
16
  until an external audit of the compiler and runtime is published, and audit your own programs as you would any
15
17
  Solana program.
@@ -20,6 +22,8 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
20
22
  sha256), packed from a clean export of the release tag; `node scripts/release-check.ts <version> --verify --registry`
21
23
  compares it with the registry.
22
24
  - Only the latest 0.x release receives security fixes, as fix releases (below).
25
+ - What a compiled program can rely on is specified in [docs/security-model.md](docs/security-model.md); the package
26
+ for an external audit is [docs/audit.md](docs/audit.md).
23
27
 
24
28
  ## Fix releases
25
29
 
@@ -36,8 +40,6 @@ release (0.44.0 → 0.44.1), so a team can take the fix without taking new featu
36
40
  Fixes go to the latest minor only; older minors are not maintained. A fix that needs a language or layout change
37
41
  comes in the next minor. 0.44.0 itself is a minor release: besides the fixes from the 0.43.0 review it has behaviour
38
42
  changes (new compile errors, `deploy` refusing to run without a cluster).
39
- - What a compiled program can rely on is specified in [docs/security-model.md](docs/security-model.md); the package
40
- for an external audit is [docs/audit.md](docs/audit.md).
41
43
 
42
44
  ## Reporting a vulnerability
43
45
 
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // The `typesol` command: the Node.js version first, then the CLI (src/cli.ts), loaded only once the check passed.
3
+ import { nodeVersionProblem } from "./node-version.js";
4
+ const problem = nodeVersionProblem(process.versions.node);
5
+ if (problem) {
6
+ console.error(problem);
7
+ process.exit(1);
8
+ }
9
+ await import("./cli.js");
package/dist/cli.js CHANGED
@@ -15,9 +15,9 @@ import { buildIdl } from "./compiler/idl.js";
15
15
  import { base58, decodeAddress, loadOrCreateKeypair, readKeypair } from "./keys.js";
16
16
  import { formatProfile, profileLogs } from "./tools/profile.js";
17
17
  import { TEMPLATE_NAMES } from "./templates.js";
18
- import { addProgram, buildWorkspace, CONFIG, deployArgs, findWorkspace, programAddress, programForEntry, programPaths, scaffold, withBuildLock, } from "./workspace.js";
18
+ import { addProgram, AGENT_FILES, buildWorkspace, CONFIG, deployArgs, findWorkspace, programAddress, programForEntry, programPaths, scaffold, withBuildLock, } from "./workspace.js";
19
19
  import { chooseTypesolVersion, containerBuild, ensureImage, findReleaseRecord, needDocker, repeatCommand, shellQuote, sourceRevision, } from "./tools/docker.js";
20
- import { cliRpc, clusterUrl, deployPreflight, doctorChecks, formatChecks, INSTALL_AGAVE, rpcHost, solanaConfig as readSolanaConfig, toolchainCheck, } from "./tools/doctor.js";
20
+ import { cliRpc, clusterUrl, deployPreflight, doctorChecks, doctorSummary, formatChecks, isSignerUri, keypairFile, requirePayer, requireSolanaCli, rpcHost, solanaNotFound, solanaConfig as readSolanaConfig, toolchainCheck, } from "./tools/doctor.js";
21
21
  const ASSETS = fileURLToPath(new URL("../assets/", import.meta.url));
22
22
  /** A usage problem: printed with the command's help, exit code 2. */
23
23
  class UsageError extends Error {
@@ -75,15 +75,16 @@ const COMMANDS = {
75
75
  },
76
76
  },
77
77
  init: {
78
- usage: "typesol init [<dir>] [--name <program>] [--template counter|vault|escrow]",
78
+ usage: "typesol init [<dir>] [--name <program>] [--template counter|vault|escrow] [--no-agent-files]",
79
79
  help: [
80
80
  "Create a project: typesol.json, programs/<name>.ts, tests/<name>.test.ts (LiteSVM), package.json, tsconfig.json, .gitignore, .vscode/settings.json (editor errors), AGENTS.md / CLAUDE.md / .cursor/rules (the rules for AI coding agents) and .mcp.json / .cursor/mcp.json (the TypeSOL MCP server).",
81
81
  "Refuses to overwrite files. <name> must be snake_case (default: derived from <dir>).",
82
82
  "--template counter a PDA counter per user (default)",
83
83
  "--template vault a SOL vault at a PDA: deposit, withdraw above rent, close",
84
84
  "--template escrow an SPL token escrow: make, take, refund, with the offer PDA signing for its vault",
85
+ "--no-agent-files leave out the files for AI coding agents (AGENTS.md, CLAUDE.md, .cursor/, .mcp.json)",
85
86
  ].join("\n "),
86
- options: { name: { type: "string" }, template: { type: "string" } },
87
+ options: { name: { type: "string" }, template: { type: "string" }, "no-agent-files": { type: "boolean" } },
87
88
  run(v, args) {
88
89
  if (args.length > 1)
89
90
  throw new UsageError("init takes at most one directory");
@@ -100,17 +101,26 @@ const COMMANDS = {
100
101
  .toLowerCase();
101
102
  const name = v.name ?? (/^[a-z]/.test(derived) ? derived : `p_${derived || "program"}`);
102
103
  const rel = path.relative(process.cwd(), root) || ".";
103
- for (const f of scaffold(root, name, template))
104
+ const agentFiles = !v["no-agent-files"];
105
+ for (const f of scaffold(root, name, template, { agentFiles }))
104
106
  log(` created ${path.join(rel, f)}`);
107
+ if (agentFiles)
108
+ log(` (${AGENT_FILES.join(", ")}: rules and the TypeSOL MCP server for AI coding agents; --no-agent-files leaves them out)`);
105
109
  const tools = toolchainCheck();
106
- if (!tools.ok)
107
- log(`\n ! The Solana platform-tools are not installed yet; npm test compiles with them. Install once:\n` +
108
- (tools.fix ?? []).map((f) => ` ${f}`).join("\n"));
110
+ if (!tools.ok) {
111
+ // With install commands: what is missing, then the commands. Without (TYPESOL_SBF_SDK names a directory that is
112
+ // not an SDK): the reason alone, which says what to fix.
113
+ const missing = tools.fix?.length ? tools.detail.replace(/ \(.*$/, "") : tools.detail;
114
+ log(`\n ! ${missing[0].toUpperCase()}${missing.slice(1)}; npm test compiles with the platform-tools.` +
115
+ (tools.fix?.length ? ` Install once:\n${tools.fix.map((f) => ` ${f}`).join("\n")}` : ""));
116
+ }
117
+ // No comment after a command: an interactive zsh would pass it to the command (it reads no comments by default).
109
118
  log(`\n next:\n` +
110
119
  (rel === "." ? "" : ` cd ${shellQuote(rel)}\n`) +
111
120
  ` npm install\n` +
112
- ` npm test # builds ${name} and runs its test in LiteSVM, a Solana runtime in-process\n` +
113
- ` npx --no-install typesol doctor # checks the toolchain, keypair and RPC before a deploy` +
121
+ ` npm test\n` +
122
+ ` npx --no-install typesol doctor\n\n` +
123
+ ` npm test builds ${name} and runs its test in LiteSVM, a Solana runtime in-process; doctor checks the toolchain, keypair and RPC before a deploy.` +
114
124
  (template === "counter" ? `\n\n other starters: typesol init <dir> --template vault (SOL at a PDA) or --template escrow (SPL token escrow)` : ""));
115
125
  return 0;
116
126
  },
@@ -276,7 +286,7 @@ const COMMANDS = {
276
286
  if (v.config !== undefined)
277
287
  solanaConfig(v.config); // a --config that does not exist is a usage error, as elsewhere
278
288
  const checks = await doctorChecks({ cwd: process.cwd(), url: v.url, config: v.config });
279
- log(formatChecks(checks));
289
+ log(`${formatChecks(checks)}\n\n ${doctorSummary(checks)}`);
280
290
  return checks.some((c) => !c.ok && !c.optional) ? 1 : 0;
281
291
  },
282
292
  },
@@ -305,10 +315,15 @@ const COMMANDS = {
305
315
  // Without either, `solana program deploy` would pick its own default cluster (mainnet-beta): never silently.
306
316
  if (!url && !v["dry-run"])
307
317
  throw new Error("no cluster: pass --url (devnet, mainnet-beta, localhost or an RPC URL), or set json_rpc_url in the Solana CLI config (`solana config set --url devnet`)");
318
+ const payer = v.keypair ?? cfg.keypair ?? path.join(os.homedir(), ".config/solana/id.json");
319
+ if (url && !v["dry-run"]) {
320
+ // Before the build: the Solana CLI that sends it, then a payer keypair file (with the command that creates one).
321
+ requireSolanaCli();
322
+ requirePayer(clusterUrl(url), payer, v.keypair !== undefined ? { from: "flag" } : cfg.keypair !== undefined ? { from: "config", config: cfg.file } : { from: "default" });
323
+ }
308
324
  const built = buildWorkspace(ws, names(ws, args), { sbpf: sbpfOf(v), needKeypair: true });
309
325
  if (url && !v["dry-run"]) {
310
326
  // Before any transaction: the RPC answers and the payer can afford it, with what to do if not.
311
- const payer = v.keypair ?? cfg.keypair ?? path.join(os.homedir(), ".config/solana/id.json");
312
327
  await deployPreflight({
313
328
  url: clusterUrl(url),
314
329
  payer,
@@ -328,7 +343,7 @@ const COMMANDS = {
328
343
  }
329
344
  catch (e) {
330
345
  if (e.code === "ENOENT")
331
- throw new Error(`\`solana\` was not found on PATH. Install the Agave CLI: ${INSTALL_AGAVE}`);
346
+ throw new Error(solanaNotFound());
332
347
  throw new Error(`solana program deploy failed for ${b.paths.name} (see its output above)`);
333
348
  }
334
349
  }
@@ -903,7 +918,10 @@ function readJson(file) {
903
918
  }
904
919
  }
905
920
  /** The address of a payer keypair file, for the line printed before a deploy (or why there is none). */
906
- function payerAddress(file) {
921
+ function payerAddress(payer) {
922
+ if (isSignerUri(payer))
923
+ return `${payer} (a signer the Solana CLI resolves)`;
924
+ const file = keypairFile(payer);
907
925
  if (!existsSync(file))
908
926
  return `none at ${file} (the Solana CLI will refuse)`;
909
927
  try {
@@ -918,7 +936,7 @@ function solanaConfig(file) {
918
936
  const cfg = readSolanaConfig(file);
919
937
  if (file && !cfg.exists)
920
938
  throw new UsageError(`${file} does not exist`);
921
- return { url: cfg.url, keypair: cfg.keypair };
939
+ return { url: cfg.url, keypair: cfg.keypair, file: cfg.file };
922
940
  }
923
941
  export async function main(argv) {
924
942
  const [cmd, ...rest] = argv;