@typesol/cli 0.45.0 → 0.47.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.
- package/CHANGELOG.md +250 -0
- package/README.md +63 -17
- package/SECURITY.md +9 -7
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/cli.js +33 -15
- package/dist/compiler/analyze.js +57 -6
- package/dist/compiler/diagnostics.d.ts +4 -3
- package/dist/compiler/diagnostics.js +10 -6
- package/dist/compiler/emit/base.d.ts +1 -1
- package/dist/compiler/emit/calls.js +18 -5
- package/dist/compiler/emit/cpi-core.d.ts +3 -1
- package/dist/compiler/emit/cpi-core.js +8 -4
- package/dist/compiler/emit/expressions.d.ts +14 -0
- package/dist/compiler/emit/expressions.js +52 -4
- package/dist/compiler/emit/shared.d.ts +8 -1
- package/dist/compiler/emit/shared.js +8 -1
- package/dist/compiler/emit/statements.d.ts +8 -3
- package/dist/compiler/emit/statements.js +68 -3
- package/dist/compiler/emit/storage.js +5 -1
- package/dist/compiler/hints.d.ts +7 -0
- package/dist/compiler/hints.js +58 -9
- package/dist/compiler/index.d.ts +5 -0
- package/dist/compiler/index.js +10 -1
- package/dist/compiler/model.js +3 -2
- package/dist/compiler/toolchain.d.ts +50 -2
- package/dist/compiler/toolchain.js +96 -11
- package/dist/idl-coder.d.ts +110 -0
- package/dist/idl-coder.js +529 -0
- package/dist/node-version.d.ts +4 -0
- package/dist/node-version.js +12 -0
- package/dist/testing.d.ts +44 -7
- package/dist/testing.js +30 -19
- package/dist/tools/doctor.d.ts +41 -0
- package/dist/tools/doctor.js +96 -14
- package/dist/workspace.d.ts +9 -2
- package/dist/workspace.js +13 -4
- package/docker/deps/0.46.0.lock.json +1206 -0
- package/docker/deps/0.47.0.lock.json +1206 -0
- package/docs/ai.md +2 -1
- package/docs/architecture.md +7 -3
- package/docs/audit.md +6 -6
- package/docs/case-study-phoenix.md +1 -1
- package/docs/case-study-raydium-amm.md +1 -1
- package/docs/case-study-spl-stake-pool.md +1 -1
- package/docs/cli.md +42 -4
- package/docs/errors.md +22 -8
- package/docs/glossary.md +210 -0
- package/docs/language-accounts.md +499 -0
- package/docs/language-basics.md +389 -0
- package/docs/language-builtins.md +411 -0
- package/docs/language-chain.md +198 -0
- package/docs/language-cpi.md +470 -0
- package/docs/language-errors-events.md +184 -0
- package/docs/language-native.md +493 -0
- package/docs/language-pdas.md +198 -0
- package/docs/language-statements.md +620 -0
- package/docs/language-types.md +601 -0
- package/docs/language.md +190 -467
- package/docs/mainnet.md +18 -3
- package/docs/migrate-from-anchor.md +7 -6
- package/docs/security-model.md +3 -3
- package/docs/stability.md +3 -1
- package/docs/test-your-program.md +54 -15
- package/docs/troubleshooting.md +222 -100
- package/lib/typesol.d.ts +67 -22
- package/llms-full.txt +4920 -638
- package/llms.txt +12 -1
- package/package.json +2 -6
- package/releases/0.45.0.json +732 -0
- package/releases/0.46.0.json +817 -0
- package/ts-plugin/index.js +16 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,256 @@ codes, and says so here.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 0.47.0 — 2026-11-13
|
|
10
|
+
|
|
11
|
+
A minor release: it removes an optional peer dependency (`@anchor-lang/core`) and changes what `t.coder` of
|
|
12
|
+
`typesol/testing` needs. Compiled programs do not change: every program builds to the same bytes as with 0.46.0.
|
|
13
|
+
|
|
14
|
+
- Changed: `typesol init` no longer adds `@anchor-lang/core` to a project's `devDependencies`, and `@typesol/cli` no
|
|
15
|
+
longer lists it as an optional peer dependency. `typesol/testing` used that package (and through it Solana web3.js
|
|
16
|
+
1.x) only to encode instruction arguments and decode accounts and return data; it now does both with its own Borsh
|
|
17
|
+
coder, read from the IDL as Anchor's `BorshCoder` reads it (test/client/idl-coder.test.ts compares the two on random
|
|
18
|
+
values for every example, template and shape program). A new project's `npm install` adds 96 packages instead of 156
|
|
19
|
+
and reports 0 vulnerabilities instead of 7 (4 moderate, 3 high). Existing projects can remove `@anchor-lang/core`
|
|
20
|
+
from `devDependencies` after upgrading, unless their tests import it or read `t.coder`. Compiled programs and IDLs
|
|
21
|
+
do not change.
|
|
22
|
+
- Changed: `t.coder` is still Anchor's `BorshCoder`, now loaded from `@anchor-lang/core` the first time it is read; it
|
|
23
|
+
throws an error saying to install the package when it is missing. `TestProgram.idl` and `programHarness`'s `idl`
|
|
24
|
+
parameter are typed with `TestIdl`, a structural type an Anchor `Idl` satisfies, and `t.coder` with
|
|
25
|
+
`AnchorBorshCoder`.
|
|
26
|
+
- Changed: an integer of 64 bits or more outside its type's range now fails with an error naming the argument; Anchor's
|
|
27
|
+
coder wrote it wrong (a negative `u64` as its absolute value, `2n ** 63n` as an `i64` as that type's minimum). A
|
|
28
|
+
missing argument of variable size (a string, a Vec) fails with an error naming it instead of a buffer offset error.
|
|
29
|
+
`bytes` arguments also take a `Uint8Array` or a `number[]` (Anchor's coder took only a Buffer), and instruction data
|
|
30
|
+
is no longer limited to 1,000 bytes.
|
|
31
|
+
|
|
32
|
+
## 0.46.0 — 2026-11-13
|
|
33
|
+
|
|
34
|
+
A minor release: it adds a flag (`init --no-agent-files`) and an export of `typesol/compiler` (`typescriptMessage`),
|
|
35
|
+
accepts what 0.45.0 refused (16 signer seeds, the bump included), and refuses programs 0.45.0 compiled to wrong code
|
|
36
|
+
(an `f64` used with an operator, as an integer or as text; a proof or signature check whose result decides nothing; a
|
|
37
|
+
`@code` tag that is not read; a `Seeds<…>` list over Solana's limit). The package's `bin` entry is now `dist/bin.js`,
|
|
38
|
+
which checks the Node.js version first, and `deploy` stops before building when the payer keypair file is missing (a
|
|
39
|
+
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
|
|
40
|
+
IDLs with 0.45.0 and with this release, and the release manifest's check of test/golden/binaries.json passes.
|
|
41
|
+
|
|
42
|
+
- Fixed: the README's toolchain block failed when pasted. The Agave installer adds its `bin` directory to `PATH` in
|
|
43
|
+
`~/.profile` only, so the next line gave `cargo-build-sbf: command not found`. The block now has the
|
|
44
|
+
`export PATH=…` line between the two commands, and says that the platform-tools install downloads about 0.5 GB and
|
|
45
|
+
prints nothing for a minute or two; docs/troubleshooting.md, CONTRIBUTING.md, `init` and `doctor` print the same
|
|
46
|
+
commands (test/cli/doctor.test.ts compares the README's block with them).
|
|
47
|
+
- Fixed: the commands `init`, `doctor` and the build printed for a missing toolchain did not install it.
|
|
48
|
+
`cargo-build-sbf --version` downloads nothing, and `cargo-build-sbf --force-tools-install` alone needs Cargo and a
|
|
49
|
+
Cargo project. Every message now gives `cargo-build-sbf --install-only --force-tools-install --tools-version v1.52`
|
|
50
|
+
(from `TESTED_TOOLCHAIN`), and says which is missing: "the Agave CLI is not installed" (then the installer, the
|
|
51
|
+
`PATH` line and that command) or "the Agave CLI is installed, but not its platform-tools" (that command only). The
|
|
52
|
+
build's errors were "Solana SBF SDK not found …" and "platform-tools missing under … Run
|
|
53
|
+
`cargo-build-sbf --force-tools-install` once." Each command is printed on a line of its own, with nothing after
|
|
54
|
+
it: what a command does is a `#` line above it, written without a character a shell acts on (the commands had a
|
|
55
|
+
trailing `# …` comment, which an interactive zsh, which reads no comments by default as on macOS, passed on as
|
|
56
|
+
arguments: `zsh: number expected`, `export: not valid in this context`), and no sentence's period follows a command.
|
|
57
|
+
`TYPESOL_SBF_SDK` set to a directory that is not an SDK makes `init` say so, where it printed "Install once:" and
|
|
58
|
+
nothing after it (test/cli/doctor.test.ts, both cases; it pastes the printed blocks into an interactive zsh and bash,
|
|
59
|
+
and fish where installed, with the commands stubbed).
|
|
60
|
+
- Fixed: on Linux arm64 the Agave installer fails with a 404 (Anza publishes no Agave CLI for it) and nothing said so;
|
|
61
|
+
`doctor` and `init` printed that installer. Building and LiteSVM tests work there with the platform-tools'
|
|
62
|
+
`linux-aarch64` package and the SDK's C files from the x86_64 release, pointed at with `TYPESOL_SBF_SDK` (checked
|
|
63
|
+
in a `linux/arm64` container: the three templates build and pass their tests). The README's Requirements give those
|
|
64
|
+
five commands (`$HOME` quoted in each), `doctor`, `init` and the build print them on Linux arm64 (an SDK there
|
|
65
|
+
without its platform-tools is "the SBF SDK at … has no platform-tools", not an installed Agave CLI), and the Solana
|
|
66
|
+
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
|
|
67
|
+
set up (test/cli/doctor.test.ts).
|
|
68
|
+
- Fixed: on Node.js older than 22.12 the CLI ran or crashed without saying why (on 20, `npm install` failed inside
|
|
69
|
+
npm or the tests with `Map.groupBy is not a function`; on 22.11, `init`, `check` and `build` ran although `doctor`
|
|
70
|
+
said 22.12 was needed). The `typesol` command is now `dist/bin.js`, which checks the version before it loads
|
|
71
|
+
anything else and exits 1 with one line naming the version needed, the one running and where to get one
|
|
72
|
+
(test/cli/node-version.test.ts; checked in `node:20-bookworm` and `node:22.11-bookworm` containers).
|
|
73
|
+
- Fixed: `deploy` without a payer keypair printed that the Solana CLI would refuse, built, and went on until
|
|
74
|
+
`solana program deploy` failed. It now stops before building, exit 1: "no payer keypair at
|
|
75
|
+
~/.config/solana/id.json: create one with `solana-keygen new` (or pass --keypair <file>), then fund it with
|
|
76
|
+
`solana airdrop 2 --url devnet`. Nothing was sent." A `--keypair` file that is not there gets "no keypair file at
|
|
77
|
+
./payer.json (given with --keypair): check the path. Nothing was sent.", an empty one "--keypair is empty: give the
|
|
78
|
+
path of the payer's keypair file. Nothing was sent.", and a missing `keypair_path` of a Solana CLI config names that
|
|
79
|
+
config. Only a file is checked: a signer the Solana CLI resolves itself (`ASK`, `-`, and the schemes `usb:`,
|
|
80
|
+
`prompt:` and `stdin:`, as in `usb://ledger?key=0`, `prompt://`, `stdin://`) goes to `solana program deploy` as
|
|
81
|
+
before, without the balance check; a `file:` URI (`file:id.json`, `file:///abs/id.json`) is checked as the path it
|
|
82
|
+
names, and anything else is a path. `solana` missing from `PATH` is now said
|
|
83
|
+
first, also before building (it was said after the build) (test/cli/doctor.test.ts, with a fake `solana`).
|
|
84
|
+
- Fixed: `doctor` ended with its rows only, so three `!` rows after a passing test looked like a problem. It now ends
|
|
85
|
+
with one line: "Ready to build and test. The ! rows: deploying still needs: keypair, RPC; …", "Ready to build, test
|
|
86
|
+
and deploy." or "Not ready to build or test: fix the ERR rows (…) first." (test/cli/doctor.test.ts).
|
|
87
|
+
- New flag, `init --no-agent-files`: leaves out the files for AI coding agents (AGENTS.md, CLAUDE.md,
|
|
88
|
+
`.cursor/rules/typesol.mdc`, `.mcp.json`, `.cursor/mcp.json`), which `init` wrote with no way to opt out; without
|
|
89
|
+
it, `init` now names them after the files it created, and where one of them is already there (a repository with
|
|
90
|
+
its own AGENTS.md), its refusal says so: "refusing to overwrite: AGENTS.md (--no-agent-files leaves out the files
|
|
91
|
+
for AI coding agents)" (test/cli/ai.test.ts). `.vscode/settings.json` is written
|
|
92
|
+
either way: it makes the editor show TypeSOL's errors.
|
|
93
|
+
- Hints, text only (test/language/diagnostics.test.ts):
|
|
94
|
+
- an `async` instruction returning `Promise<void>` got "instructions cannot be async or generators" with no hint,
|
|
95
|
+
though the README promised one; it now has one (helper functions too);
|
|
96
|
+
- `console` and other globals a program does not have (`process`, `Buffer`, `setTimeout`, `setInterval`, `fetch`,
|
|
97
|
+
`window`, `document`) led with TypeScript's "Cannot find name 'console'. Do you need to change your target
|
|
98
|
+
library? …"; the message is now "'console' does not exist in a Solana program", with the hint under it where
|
|
99
|
+
there is one (`window` and `document` have none). The editor shows the same message, hint or not, through
|
|
100
|
+
`typesol/ts-plugin` (the new export below);
|
|
101
|
+
- `Date.now()` where an integer is expected now points to `now()`, the cluster's clock, and
|
|
102
|
+
`Math.floor(Date.now() / 1000)` (which was "unsupported call: Math.floor") says to use `now()`;
|
|
103
|
+
`Math.floor`, `trunc`, `ceil` and `round` on their own point to integer division;
|
|
104
|
+
- calling a cast imported with `type` (`import { type u64 }`, as the templates import it, then `u64(x)`) got
|
|
105
|
+
TypeScript's "'u64' cannot be used as a value because it was imported using 'import type'" alone; the hint says
|
|
106
|
+
to import it without `type`. The templates keep `type`: the hint is where the error is;
|
|
107
|
+
- the missing-import hint covered the functions and constants `typesol` exports (`u64`, `require`, …); it now
|
|
108
|
+
covers its types and interfaces too (`import { type Signer } from "typesol"`, `Mut`, `SystemProgram`, …);
|
|
109
|
+
- a `number` field in account data got the list of allowed field types alone; it now has a hint naming the integer
|
|
110
|
+
types (and a `Date` field, one about Unix seconds and `now()`).
|
|
111
|
+
- New export of `typesol/compiler`: `typescriptMessage(diagnostic)`, the message the CLI shows in place of a
|
|
112
|
+
TypeScript error's, or undefined to keep TypeScript's; `typesol/ts-plugin` uses it, so the editor shows what the CLI
|
|
113
|
+
shows (test/cli/ts-plugin.test.ts).
|
|
114
|
+
- Fixed: operators on an `f64` compiled to integer operators on its IEEE 754 bits, a silently wrong result:
|
|
115
|
+
`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`
|
|
116
|
+
operand is now refused (arithmetic, bitwise, shifts, unary `-` and `~`, ordering, compound assignments, `++` / `--`,
|
|
117
|
+
and `min`, `max`, `isqrt`, `mulDiv`): "+ on an f64 is not supported: an f64 is held as its IEEE 754 bits and there
|
|
118
|
+
is no float arithmetic (this would compute on the bits); compute in integers and make the result with
|
|
119
|
+
f64FromBits(bits), or take an f64's bits with f64Bits(x)". Equality (`===`, `!==`, `==`, `!=`, `switch`) is
|
|
120
|
+
refused too, since equal bits are not equal numbers (NaN, 0 and -0): "… to compare the bits, write f64Bits(a) ===
|
|
121
|
+
f64Bits(b)". `??` over an `Option<f64>` now gives an `f64` whatever the other side expects, so `(a.o ?? a.x) * 2n`,
|
|
122
|
+
`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).
|
|
123
|
+
- Changed: an `f64` no longer converts to an integer, nor an integer to an `f64`. `a.n = a.x`, `const z: u64 = a.x`,
|
|
124
|
+
an `f64` passed to a helper's `u64` parameter or returned as a `u64`, `xs.get(a.x)`, `u64(a.x)`, `u8(a.x)`,
|
|
125
|
+
`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
|
|
126
|
+
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,
|
|
127
|
+
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
|
|
128
|
+
converted: an f64 is made from its IEEE 754 bits with f64FromBits(bits)"). An `f64` in a template string or `log`
|
|
129
|
+
printed its bits as a decimal integer; it is refused: "an f64 cannot be written as text: there is no float
|
|
130
|
+
formatting, and the digits would be its IEEE 754 bits read as an integer; to show the bits, write f64Bits(x)".
|
|
131
|
+
Copying an `f64` to an `f64` (fields, locals, structs, events, `Option<f64>`, ternaries, `??`, helper arguments and
|
|
132
|
+
returns typed `f64`) compiles as before, and so does an `f64` seed (its 8 bytes, as Rust's `to_le_bytes`). No
|
|
133
|
+
program of the repository used a conversion (test/language/f64-operators.test.ts; docs/language-types.md and the
|
|
134
|
+
refused-constructs table of docs/language-statements.md).
|
|
135
|
+
- Changed, now accepted: signer seeds were limited to 14 seeds and the bump, one fewer than Solana allows: the limit of 15 entries,
|
|
136
|
+
meant for lists the derivation adds the bump to, was applied to signer seeds and `createProgramAddress` lists too,
|
|
137
|
+
which end with their bump. They now take 16 entries, 15 seeds and the bump (Solana's `MAX_SEEDS`, checked by
|
|
138
|
+
`invoke_signed` and `create_program_address`); a 17th is refused with "at most 16 seeds, the bump included
|
|
139
|
+
(Solana's limit)", and a 16th seed before a derived bump with "at most 15 seeds: the bump the derivation adds makes
|
|
140
|
+
16, Solana's limit" (was "at most 15 seeds" for both). test/language/signer-seed-limit.test.ts signs a CPI with
|
|
141
|
+
16 entries in LiteSVM (a seed list and a bound `signer([...])`) and derives with `createProgramAddress`.
|
|
142
|
+
- Changed, now refused: a `Seeds<…>` constraint had no seed limit, so 16 or more names compiled and failed every call. It now
|
|
143
|
+
has the same limits and messages: with a bump field, "at most 16 seeds, the bump included (Solana's limit)"; with the
|
|
144
|
+
canonical bump, "at most 15 seeds: the bump the derivation adds makes 16, Solana's limit"
|
|
145
|
+
(test/language/signer-seed-limit.test.ts).
|
|
146
|
+
- Fixed, messages only (test/language/diagnostics.test.ts):
|
|
147
|
+
- a `u256` shift amount got "shift by a u64 (or smaller) amount", while a `u128` amount compiles (its range check
|
|
148
|
+
runs on all 128 bits); the message is now "a shift amount is a u128 or smaller integer: convert it (u64(n))";
|
|
149
|
+
- a function in parentheses (`const g = (function (): u64 { … })`) got "function expressions are not supported:
|
|
150
|
+
declare a function at the top level", though function expressions compile; an arrow there got "this syntax
|
|
151
|
+
(ArrowFunction) is not supported". Both now get "a function cannot be used here: bind it with const …". The hint
|
|
152
|
+
for template strings ("template strings are not supported …") was never shown and is gone;
|
|
153
|
+
- the test of `FixedString<0>` matched "capacity 1..1024" as a prefix of the message; it now matches the whole
|
|
154
|
+
"FixedString<N> needs a literal capacity 1..10240", and covers 10241 (refused) and 10240 (accepted).
|
|
155
|
+
- Fixed: a call to `merkleVerify`, `verifyEd25519` or `verifySecp256k1` used as a statement compiled and checked
|
|
156
|
+
nothing. The three return whether the proof or signature holds and fail nothing by themselves, so
|
|
157
|
+
`merkleVerify(leaf, proof, root);` emitted the hash computation and dropped its result. Such a call is now refused:
|
|
158
|
+
"the result of merkleVerify is discarded, so nothing is checked: it returns whether the proof holds; write
|
|
159
|
+
require(merkleVerify(…), error)". Refused as well: such a call as the condition of an `if` with an empty body and no
|
|
160
|
+
`else` or an empty one ("the result of merkleVerify is not acted on: the if around it has an empty body, so nothing
|
|
161
|
+
is checked: …"), and its result (in parentheses or under `as` too) kept in a `const` or `let` (declared or assigned,
|
|
162
|
+
in a closure too) that the function declaring it never reads, a closure inside it included ("the result of
|
|
163
|
+
merkleVerify is never read (ok is not used), so nothing is checked: …"). What is caught is these three forms, not
|
|
164
|
+
every unused result: a helper that returns the result, called as a statement, still compiles. No program of the
|
|
165
|
+
repository called one these ways (test/language/diagnostics.test.ts; rows in the refused-constructs table of
|
|
166
|
+
docs/language-statements.md).
|
|
167
|
+
- Fixed: a `@code` tag that TypeScript attaches to no member was ignored without a word, and the member took the next
|
|
168
|
+
code instead. Written after other code on its line (`A = "a", /** @code 6100 */ B = "b"`), it is now refused,
|
|
169
|
+
naming the member that follows: "this @code tag is not read: other code comes before it on its line; put /** @code …
|
|
170
|
+
*/ on its own line above B" (after the last member: "it follows the last member"). Above the enum itself
|
|
171
|
+
(`/** @code 0 */` before `export enum PoolError {`), it is refused too: "this @code tag is not read: a tag above the
|
|
172
|
+
enum numbers no member; put /** @code … */ above its first member, AlreadyInUse". A tag on its own line, or first on
|
|
173
|
+
its member's line, is read as before; no program of the repository changes (test/language/zero-copy-shapes.test.ts).
|
|
174
|
+
The same goes for a tag in a `/* … */` or `//` comment ("this @code tag is not read: only a doc comment (/** … */)
|
|
175
|
+
is, not a // comment; write /** @code … */ above B") and in a doc comment that another one follows before the
|
|
176
|
+
member, of which only the last is read ("… another doc comment follows it, and only the last one above B is read;
|
|
177
|
+
put the tag in that one"). In a doc comment, a tag is any `@code` after the start, whitespace or `*`, as TypeScript
|
|
178
|
+
reads it, so one inside a sentence (`/** The second. @code 6200 */`) is a tag and is refused where it is not read; in
|
|
179
|
+
a `//` or `/* … */` comment only an `@code` first on a line of the comment is reported, so prose there
|
|
180
|
+
(`// see the @code docs`) is not.
|
|
181
|
+
- Docs: README links Quick start from the top, has three lines under the introduction with the two commands and the
|
|
182
|
+
playground, opens Quick start with the playground, says that `npm install`'s advisories come from
|
|
183
|
+
`@anchor-lang/core` (which `typesol/testing` uses to encode instructions and decode accounts, so the tests need it;
|
|
184
|
+
nothing of it is in a deployed program), says what npm's `E404 … typesol` outside a project means and what to run,
|
|
185
|
+
and that the scaffolded counter has one more instruction than the 23-line one shown. docs/troubleshooting.md has a
|
|
186
|
+
heading per symptom.
|
|
187
|
+
- Docs: the language reference is a guide. docs/language.md is an overview: the guide's pages, then an index of where
|
|
188
|
+
each construct is described, then the former reference's sections (their headings kept, so links to them still
|
|
189
|
+
land there). The pages, read in order:
|
|
190
|
+
- docs/language-basics.md: "Solana in a dozen lines", what a program is, one program explained line by line, and
|
|
191
|
+
"Limits and costs" (rent, compute budget, transaction size with its header and a recent blockhash, an address
|
|
192
|
+
lookup table entry at one byte, account growth, with their sources' values at the time of writing; at most 32
|
|
193
|
+
accounts per instruction is TypeSOL's default, not the cluster's);
|
|
194
|
+
- language-types.md: each type with its bytes, limits and error codes, and when to choose `FixedArray`, `FixedVec`
|
|
195
|
+
or `Vec`; `Struct arguments`, `f64` and heap values come last;
|
|
196
|
+
- language-statements.md: exactly which TypeScript is TypeSOL, and a table of what is refused with each message;
|
|
197
|
+
- language-accounts.md, with what happens to existing accounts when an account struct changes (also in
|
|
198
|
+
docs/mainnet.md: a field added fails with 3003 only on an account of exactly the old size; one created with spare
|
|
199
|
+
space or grown since passes and reads the spare bytes, or other fields' bytes when the field was inserted), and
|
|
200
|
+
`Two parameters, one account` (the `Inout` overlap rule for accounts) and `How many accounts` after the
|
|
201
|
+
constraints;
|
|
202
|
+
- language-pdas.md, language-errors-events.md, language-cpi.md, language-chain.md (sysvars, hashes, signatures,
|
|
203
|
+
oracles) and language-native.md (porting native programs, marked advanced);
|
|
204
|
+
- docs/language-builtins.md lists every name `"typesol"` exports, generated from lib/typesol.d.ts by
|
|
205
|
+
`scripts/language-builtins.ts` (`--check` in the tests and in CI).
|
|
206
|
+
|
|
207
|
+
Each page ends with a "Next" line and links a term's first use to the new docs/glossary.md (the three meanings of
|
|
208
|
+
owner, Anchor, associated token account, keypair account, authority, payer, remaining accounts, return data, slot
|
|
209
|
+
and epoch, cluster, syscall, precompile, ProgramData and upgrade authority, zero-copy, and more).
|
|
210
|
+
|
|
211
|
+
What the examples guarantee: every example is a complete program, or a block marked as a fragment whose every line is
|
|
212
|
+
a line of the compiled file it is taken from. test/language/docs-examples.test.ts compiles each program, checks that
|
|
213
|
+
every refused construct of the table is refused with the message it quotes, that links into the docs land on a
|
|
214
|
+
heading (a repeated heading's anchor with GitHub's `-1`, `-2` suffix), that every page but the overview and the
|
|
215
|
+
built-ins list has a compiled program, and that no TypeScript block is fenced so that it would be skipped (`~~~`,
|
|
216
|
+
`typescript`); a claim compiling does not prove is checked against the compiled program (the error codes from 0 of
|
|
217
|
+
docs/language-native.md). An example shows the construct its section is about, and docs/language.md says that,
|
|
218
|
+
unless the text says who may call an instruction, it does not check its caller as a real program must. The examples
|
|
219
|
+
that move value or sign as a PDA do check it: the PDA page's `payOut` takes its config at the singleton PDA
|
|
220
|
+
`["config"]` with `HasOne` and says to gate the config's creation, docs/language-cpi.md's `payOut` has the signer in
|
|
221
|
+
the vault's seeds (and `makeVault` creates the vault at those seeds), `remove` has `HasOne` before `close`, the native
|
|
222
|
+
`bump` checks that `admin` signed and the native Borsh `deposit` checks the pool's owner; the PDA page's first
|
|
223
|
+
example derives its second bump, and `invoke`'s `payOut` and `t.pdaWithBump` point to a stored bump. Those that show
|
|
224
|
+
one mechanism only say so, with the check a real instruction needs, on the first line after the example
|
|
225
|
+
(`invokeInstruction`'s `execute`, `Migrate`'s `upgrade`, a first-caller `InitIfNeeded` setup, FixedVec's
|
|
226
|
+
`setOwners` / `addOwner`, the fallback's `record`, BigVec's `add`, the run-time views' `fill`, the Borsh `deposit`,
|
|
227
|
+
the red-black tree's `place` / `cancel`, the enum's `approve`, the data enum's `apply`; the native `programAt`
|
|
228
|
+
entry and the randomness example's `settle` in their text), and `grow`'s open access is explained as moving no
|
|
229
|
+
value. docs/test-your-program.md has seeds of other widths and asserting an error code, naming the program that
|
|
230
|
+
snippet runs against (test/cli/testing.test.ts runs both). docs/troubleshooting.md is grouped (install, writing and
|
|
231
|
+
running a program, deploy, verify and `--docker`), with entries for running out of compute units, for a
|
|
232
|
+
transaction over 1,232 bytes and for `idl publish` failing on a local validator; the longest table cells (Token-2022
|
|
233
|
+
methods, `init` and `verify` in docs/cli.md) are lists.
|
|
234
|
+
|
|
235
|
+
lib/typesol.d.ts gains doc comments only: the 34 exports that had none have one, the built-ins page's one-liners
|
|
236
|
+
(`currentSlot`, `slotsPerEpoch`, `HasOne`, `Ata`, `transferFee`, `TOKEN_ACCOUNT_SIZE`, `readonly`, `rawArrayAt`,
|
|
237
|
+
`Mut`, `Init`, `Account`, `log`, `invoke`, `Vec`) describe the name itself, the comment of `findProgramAddress` sat
|
|
238
|
+
above `bigEndian` and moves to it, and `isqrt`'s says it takes integers up to `u256` (as the compiler does), not up
|
|
239
|
+
to `u128`.
|
|
240
|
+
- Docs, corrected (statements of the former reference and of other published pages, found while checking them
|
|
241
|
+
against the compiler; no program compiles differently): top-level constants are not listed in the IDL (a constant
|
|
242
|
+
used as a seed is recorded there as a `const` seed); closure parameters need their types where the closure is
|
|
243
|
+
declared (an arrow written at a call takes them from the parameter); a `@layout borsh` struct's `Vec` may be any
|
|
244
|
+
field, not only the last; `signer([…])` is written in a declaration or as a helper's argument, not inside a CPI's
|
|
245
|
+
arguments; `merkleVerify`, `verifyEd25519` and `verifySecp256k1` return whether the proof or signature holds and fail
|
|
246
|
+
nothing by themselves (docs/language-chain.md, with an example, and their doc comments); a program account is
|
|
247
|
+
checked for initialization (3012), owner (3007), size (3003), then discriminator (3002), and the two cases where
|
|
248
|
+
Anchor's order gives another code (another discriminator with fewer bytes than the struct: 3003 here, 3002 under
|
|
249
|
+
Anchor; under 8 bytes: 3003 here, 3001 under Anchor) are listed in docs/errors.md (test/security/anchor-order.test.ts
|
|
250
|
+
pins them); docs/errors.md said accounts are created after every other check, while the creates a body starts with
|
|
251
|
+
run before the constraints (not with an account group, whose arguments are decoded first); a failed instruction
|
|
252
|
+
fails the whole transaction; `>>` fails (5100) like `<<` when the amount is not below the width; `FixedString<N>`
|
|
253
|
+
takes 4 + N bytes; token account and mint codes are stated one way everywhere (3012 / 3007 / 3003); SECURITY.md
|
|
254
|
+
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
|
|
255
|
+
checks the three against docs/audit.md); the README's "Safe by default." is "Checked by default."; docs/mainnet.md
|
|
256
|
+
carries the status warning, its counter is built with 0.45.0, and it says what a `verify` match does not prove;
|
|
257
|
+
docs/migrate-from-anchor.md no longer claims `@layout borsh` is "several times cheaper than Anchor".
|
|
258
|
+
|
|
9
259
|
## 0.45.0 — 2026-11-12
|
|
10
260
|
|
|
11
261
|
- 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
|
-
- **
|
|
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,36 @@ 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
|
|
199
|
+
npx @typesol/cli init my-app --name counter
|
|
187
200
|
cd my-app && npm install
|
|
188
|
-
npm test
|
|
189
|
-
npx --no-install typesol build
|
|
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. `typesol/testing` encodes instructions and decodes accounts from
|
|
211
|
+
the IDL itself, so a new project installs neither Anchor's TypeScript package nor Solana web3.js 1.x.
|
|
212
|
+
|
|
192
213
|
Other versions work, but their binaries are not covered by the project's tests: `typesol build` warns once when the
|
|
193
214
|
clang is another one (`--toolchain-strict` or `TYPESOL_TOOLCHAIN=strict` makes that an error), and every build records
|
|
194
215
|
its clang, platform-tools and host in `<name>.build.json`.
|
|
@@ -196,18 +217,23 @@ its clang, platform-tools and host in `<name>.build.json`.
|
|
|
196
217
|
`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
218
|
that fixes anything missing. Inside a project, `npx --no-install typesol …` (or `npm run build`, `npm run deploy`) runs the
|
|
198
219
|
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.
|
|
220
|
+
package's name, so where the project's copy is not installed npx would fetch whatever package has that name. Outside a
|
|
221
|
+
project (or before `npm install`), `npx --no-install typesol …` therefore fails with npm's `E404 … typesol - Not
|
|
222
|
+
found`, which does not mention `@typesol/cli`: run `npx @typesol/cli …` there, or `npm install` in the project first.
|
|
200
223
|
|
|
201
224
|
To deploy, on devnet:
|
|
202
225
|
|
|
203
226
|
```sh
|
|
204
|
-
|
|
205
|
-
solana
|
|
227
|
+
# Once, if you have no keypair at ~/.config/solana/id.json:
|
|
228
|
+
solana-keygen new
|
|
229
|
+
# Test SOL for the rent. The airdrop is rate-limited, and https://faucet.solana.com also works:
|
|
230
|
+
solana airdrop 2 --url devnet
|
|
206
231
|
npx --no-install typesol deploy --url devnet
|
|
207
232
|
```
|
|
208
233
|
|
|
209
234
|
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
|
|
235
|
+
`npx --no-install typesol deploy --url localhost`. `deploy` checks the payer's keypair, the RPC and the payer's balance
|
|
236
|
+
before sending anything, and stops with the command to run when one is missing.
|
|
211
237
|
|
|
212
238
|
`--template vault` or `--template escrow` starts from a SOL vault or an SPL token escrow instead of the counter, each
|
|
213
239
|
with a passing LiteSVM test.
|
|
@@ -222,7 +248,8 @@ program's address.
|
|
|
222
248
|
**Your first change.** Open `programs/counter.ts`, add an instruction (say `decrement`, with
|
|
223
249
|
`require(counter.count >= 1n, …)` before `counter.count -= 1n`), call it from `tests/counter.test.ts` and run `npm test`.
|
|
224
250
|
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
|
|
251
|
+
`console.log`, `Date.now()`, a missing import, `async`), adds a `hint:` with what to write instead; your editor shows
|
|
252
|
+
the same.
|
|
226
253
|
|
|
227
254
|
**Where next**
|
|
228
255
|
- The language, every type and built-in: [docs/language.md](docs/language.md).
|
|
@@ -230,7 +257,7 @@ If the build refuses something, the error points at the line and, for the usual
|
|
|
230
257
|
- Coming from Anchor: [docs/migrate-from-anchor.md](docs/migrate-from-anchor.md) maps every construct, and
|
|
231
258
|
`typesol port` starts from your program's IDL; [docs/case-study-escrow.md](docs/case-study-escrow.md) follows one
|
|
232
259
|
program through the port.
|
|
233
|
-
- Real programs checked against their mainnet binaries: [Showcase](#showcase-ports-checked-against-mainnet), with a
|
|
260
|
+
- Real programs checked against their mainnet binaries: [Showcase](https://github.com/typesol-lang/typesol#showcase-ports-checked-against-mainnet), with a
|
|
234
261
|
case study each (Marginfi v2 in full: all 124 instructions, the same on 2,081 transactions; Phoenix v1, a native
|
|
235
262
|
order book, the same on 3,575 transactions down to its event bytes; Raydium AMM v4, a native program, down to its log
|
|
236
263
|
lines).
|
|
@@ -270,7 +297,8 @@ Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts
|
|
|
270
297
|
| **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
298
|
| **Interfaces** | custom discriminators (`@discriminator`), so a TypeSOL program can be a Token-2022 transfer hook, with extra accounts (ExtraAccountMetaList) |
|
|
272
299
|
|
|
273
|
-
The
|
|
300
|
+
The [language guide](docs/language.md) explains each construct with a compiled example, and lists every type, check
|
|
301
|
+
and built-in.
|
|
274
302
|
|
|
275
303
|
## Tooling
|
|
276
304
|
|
|
@@ -434,9 +462,27 @@ stable already and what is still experimental: [docs/stability.md](docs/stabilit
|
|
|
434
462
|
|
|
435
463
|
## Requirements
|
|
436
464
|
|
|
437
|
-
- Node.js 22.12 or later.
|
|
438
|
-
- The Agave CLI with platform-tools.
|
|
439
|
-
- macOS or Linux
|
|
465
|
+
- Node.js 22.12 or later (the CLI stops with the version it needs on an older one).
|
|
466
|
+
- The Agave CLI with platform-tools (see [Quick start](#quick-start)).
|
|
467
|
+
- macOS or Linux x86_64 for everything; Linux arm64 to build and test, set up as below (deploying from it needs the
|
|
468
|
+
Solana CLI built from source); on Windows, WSL2.
|
|
469
|
+
- Linux arm64: Anza publishes no Agave CLI for it (the installer fails with a 404), but platform-tools has a
|
|
470
|
+
`linux-aarch64` package. With it and the SDK's C files from the x86_64 release (headers and linker script, as the
|
|
471
|
+
`--docker` image takes them), `typesol build` and LiteSVM tests work (needs `curl` and `bzip2`):
|
|
472
|
+
|
|
473
|
+
```sh
|
|
474
|
+
mkdir -p "$HOME/.local/share/typesol-sdk/sbf/dependencies/platform-tools"
|
|
475
|
+
# About 215 MB, for the C headers and linker script of the SDK only:
|
|
476
|
+
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
|
|
477
|
+
# About 515 MB, 1.6 GB unpacked, and quiet for a minute or two:
|
|
478
|
+
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"
|
|
479
|
+
touch "$HOME/.local/share/typesol-sdk/sbf/dependencies/platform-tools-v1.52.md"
|
|
480
|
+
# Add this line to ~/.profile too, for new shells:
|
|
481
|
+
export TYPESOL_SBF_SDK="$HOME/.local/share/typesol-sdk/sbf"
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
`typesol doctor` prints these commands there. Deploying needs the Solana CLI: deploy from macOS or Linux x86_64,
|
|
485
|
+
or build the Agave CLI from source. `build --docker` (linux/amd64, emulated) works on any host with Docker.
|
|
440
486
|
|
|
441
487
|
TypeSOL finds the SDK under `~/.local/share/solana/install/active_release` or next to `cargo-build-sbf` on `PATH`. Set
|
|
442
488
|
`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.
|
|
9
|
-
in the
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
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,
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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
|
|
113
|
-
` npx --no-install typesol doctor
|
|
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(
|
|
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(
|
|
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;
|