@typesol/cli 0.43.0 → 0.44.1
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 +173 -0
- package/NOTICE +71 -0
- package/README.md +25 -11
- package/SECURITY.md +32 -5
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +5 -5
- package/dist/cli.js +196 -72
- package/dist/compiler/analyze.js +4 -0
- package/dist/compiler/emit/alias.d.ts +16 -2
- package/dist/compiler/emit/alias.js +70 -6
- package/dist/compiler/emit/base.d.ts +3 -1
- package/dist/compiler/emit/base.js +20 -3
- package/dist/compiler/emit/borsh.js +11 -5
- package/dist/compiler/emit/calls.d.ts +13 -0
- package/dist/compiler/emit/calls.js +105 -14
- package/dist/compiler/emit/cpi-core.d.ts +9 -1
- package/dist/compiler/emit/cpi-core.js +51 -10
- package/dist/compiler/emit/create.js +22 -11
- package/dist/compiler/emit/expressions.js +6 -1
- package/dist/compiler/emit/function.js +15 -5
- package/dist/compiler/emit/metaplex.js +17 -4
- package/dist/compiler/emit/shared.d.ts +17 -0
- package/dist/compiler/emit/shared.js +36 -3
- package/dist/compiler/emit/statements.js +17 -4
- package/dist/compiler/emit/storage.d.ts +2 -0
- package/dist/compiler/emit/storage.js +16 -8
- package/dist/compiler/emit/token.js +64 -39
- package/dist/compiler/index.d.ts +15 -1
- package/dist/compiler/index.js +40 -3
- package/dist/compiler/toolchain.d.ts +41 -1
- package/dist/compiler/toolchain.js +102 -3
- package/dist/testing-stake.d.ts +2 -1
- package/dist/testing-stake.js +2 -1
- package/dist/testing.js +6 -4
- package/dist/tools/clientgen.d.ts +15 -0
- package/dist/tools/clientgen.js +173 -7
- package/dist/tools/cpigen.d.ts +0 -15
- package/dist/tools/cpigen.js +19 -8
- package/dist/tools/doctor.d.ts +17 -2
- package/dist/tools/doctor.js +64 -4
- package/dist/tools/portgen.js +43 -18
- package/dist/workspace.d.ts +20 -0
- package/dist/workspace.js +173 -6
- package/docs/ai.md +10 -5
- package/docs/architecture.md +1 -1
- package/docs/audit.md +103 -18
- package/docs/case-study-escrow.md +1 -1
- package/docs/case-study-phoenix.md +10 -10
- package/docs/case-study-raydium-amm.md +3 -3
- package/docs/case-study-spl-stake-pool.md +5 -5
- package/docs/cli.md +17 -8
- package/docs/client.md +11 -3
- package/docs/errors.md +2 -2
- package/docs/language.md +16 -9
- package/docs/mainnet.md +21 -10
- package/docs/migrate-from-anchor.md +2 -1
- package/docs/runtime.md +11 -1
- package/docs/security-model.md +79 -12
- package/docs/stability.md +21 -2
- package/docs/testing.md +25 -0
- package/docs/troubleshooting.md +12 -0
- package/llms-full.txt +216 -63
- package/llms.txt +1 -1
- package/package.json +3 -1
- package/runtime/typesol_rt.h +30 -18
- package/test/programs/LICENSE-Apache-2.0.txt +201 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,179 @@ codes, and says so here.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 0.44.1 — 2026-11-11
|
|
10
|
+
|
|
11
|
+
Fixes from a second internal review, of 0.44.0 (docs/audit.md). Of the 76 programs of the 0.44.0 sources, 74 compile
|
|
12
|
+
to the same binary as in 0.44.0 and 2 to a different one (mint-close-authority and allow-block-list-token, below); no
|
|
13
|
+
program of those sources is refused.
|
|
14
|
+
|
|
15
|
+
- Fixed: `mint.create(…, { transferFee })` with a `null` (or run-time None) config or withdraw authority made a mint
|
|
16
|
+
with fee 0 and no withdraw authority. Token-2022 reads a None COption as one byte and the compiler sent 33, so the
|
|
17
|
+
32 zero bytes were read as the next fields. A None authority is now one byte, for `transferFee`'s two and
|
|
18
|
+
`closeAuthority` (where Token-2022 ignored the extra bytes, now exact too); `initializeTransferFeeConfig` and the
|
|
19
|
+
other wrappers already encoded it right. Programs using `transferFee` or `closeAuthority` in `mint.create` /
|
|
20
|
+
`createIfNeeded` compile differently (transfer-fee to the same binary, mint-close-authority to another)
|
|
21
|
+
(test/integrations/token-init.test.ts, decoded by the Token-2022 decoder for each authority null, constant and
|
|
22
|
+
run-time).
|
|
23
|
+
- Fixed: a reference into account data held across a resize made through another parameter that may be the same
|
|
24
|
+
account was not refused: with `a: Dup<Mut<Bag>>` and `b: Mut<Bag>` (or a read-only `a: Account<Bag>`, or a struct
|
|
25
|
+
loaded with `loadAccount` / `loadAccountMut`) one account in both slots, `const e = a.entries.get(1n); b.tags.pop();
|
|
26
|
+
e.score = v` wrote another record, and a `for (const x of a.entries)` loop read shifted fields. The reference rule
|
|
27
|
+
now treats parameters that may be one account (a Dup pair, a read-only and a writable account of one type, a loaded
|
|
28
|
+
struct) as one name for push, pop, clear and a helper given the account: such a program is a compile error, as with
|
|
29
|
+
one name. Programs that hold no reference across the resize compile as before; none of the examples and ports is
|
|
30
|
+
refused (test/security/dup.test.ts).
|
|
31
|
+
- Fixed: twelve token wrappers (approve, approveChecked, mintToChecked, burnChecked, setAuthority,
|
|
32
|
+
updateTransferHook, updateInterestRate, transferCheckedWithFee, setTransferFee, initializeTokenGroup,
|
|
33
|
+
updateGroupMaxSize, updateGroupAuthority) and the Stake program's split, authorize and withdraw read
|
|
34
|
+
their signer seeds before an earlier argument ran: `approve(src, d, owner, next(st), ["vault", st.count, bump])`
|
|
35
|
+
signed for the count before `next(st)` changed it. The seeds are now lowered after the other arguments when an
|
|
36
|
+
argument runs code; calls whose arguments run none compile as before (test/integrations/tokenops.test.ts).
|
|
37
|
+
- Fixed: arguments read after later ones ran. The amount of `transfer`, `transferChecked`, `mintTo`, `burn` and
|
|
38
|
+
`systemProgram.transfer` was read at the CPI, after a seed list that runs code (`["vault", next(st), bump]`); account
|
|
39
|
+
text passed to `initializeMetadata`, `removeMetadataKey` and Metaplex `updateMetadataAccountsV2` (and that
|
|
40
|
+
call's `primarySaleHappened` / `isMutable`) changed when a later argument rewrote it. Each is now read first, only
|
|
41
|
+
where a later argument runs code, so other calls compile as before (test/integrations/tokenops.test.ts).
|
|
42
|
+
- Fixed: `mint.create` with extensions adding up to exactly 355 bytes (a Multisig's length) always failed: Token-2022
|
|
43
|
+
sizes such a mint 357 bytes and refuses any other size. The mint is now made 357 bytes; `createIfNeeded` accepts
|
|
44
|
+
that size already, and cannot reach 355 with the extensions it checks (test/integrations/token-init.test.ts).
|
|
45
|
+
- Fixed: `updateExtraAccountMetas` limited growth to 10 KiB past the account's current length instead of its length
|
|
46
|
+
when the instruction started, so after `resizeAccount(metas, metas.dataLen + 10240n)` it could write past the room
|
|
47
|
+
the runtime leaves, into the next account's record. It now counts from the length at entry (3016), in an
|
|
48
|
+
instruction and in a helper. Programs that call it compile differently (allow-block-list-token, to another binary)
|
|
49
|
+
(test/integrations/hook.test.ts).
|
|
50
|
+
- Fixed: the runtime grew a heap Vec (`ts_hvec_reserve`) through its own struct type while the program reads it
|
|
51
|
+
through the generated one, which the C aliasing rules let the optimizer treat as unrelated (no miscompile was
|
|
52
|
+
observed). The runtime's type is `may_alias`; no build flag changed, and no program of the 0.44.0 sources (heap Vecs
|
|
53
|
+
included) builds to another binary (test/language/borsh-vec.test.ts).
|
|
54
|
+
- Docs: docs/security-model.md and docs/language.md say what `pythPrice` and `switchboardValue` leave to the author
|
|
55
|
+
(the price's sign and zero, the confidence, a publish time or result slot in the future, rounding toward zero when
|
|
56
|
+
scaling) and that Switchboard staleness counts from `result.slot`; the review of 0.44.0 is recorded in
|
|
57
|
+
docs/audit.md and docs/security-model.md.
|
|
58
|
+
|
|
59
|
+
## 0.44.0 — 2026-11-11
|
|
60
|
+
|
|
61
|
+
Fixes from an internal review of 0.43.0, and the means to check a release. A helper's Pubkey, Option, string or u256
|
|
62
|
+
argument was not a copy when the helper was not inlined, so a check on a value the helper had just overwritten could
|
|
63
|
+
pass; a named seed list read its seeds when the CPI ran; the stale-reference rule was skipped for account-group fields
|
|
64
|
+
and loaded accounts; the Borsh decoder's length checks could wrap. **Programs built with 0.43.0 or earlier should be
|
|
65
|
+
rebuilt and redeployed** (docs/security-model.md says how to tell whether a program was exposed). New: the npm tarball
|
|
66
|
+
is packed from a clean export of the tag and recorded in `releases/`, the tested toolchain is declared and another one
|
|
67
|
+
warns, and fix-only releases come as patches from here on (SECURITY.md). Of the 76 programs of the 0.43.0 sources, 35
|
|
68
|
+
compile to the same binary as in 0.43.0 and 41 to a different one.
|
|
69
|
+
|
|
70
|
+
- Fixed: a Pubkey, Option, string or u256 argument of a helper was not a copy. The SBF backend passes such a value as a
|
|
71
|
+
pointer to the caller's object, so a helper that was not inlined and wrote that object (`rotate(v, v.admin, caller)`
|
|
72
|
+
with `v.admin = v.pending` inside) then read its own write through the parameter: a check on the old value passed on
|
|
73
|
+
the new one. Whether it happened depended on inlining. The value now arrives by pointer, to a copy taken at the call
|
|
74
|
+
whenever the helper can write (it takes accounts, remaining accounts or `Inout` places) and the value is not out of
|
|
75
|
+
its reach (a local, an instruction argument, an account's key, the program id)
|
|
76
|
+
(test/language/helper-copies.test.ts, inlined and `@noinline`).
|
|
77
|
+
- Fixed: a seed list bound to a name (`const s = signer(["vault", st.count, bump])`), given to a helper, or written
|
|
78
|
+
beside an argument with side effects read its seeds when the CPI ran, so after `st.count += 1n` the program signed
|
|
79
|
+
for another PDA than the one the source names. The seeds are copied where the list is written
|
|
80
|
+
(test/language/pda-signers.test.ts).
|
|
81
|
+
- Fixed: the rule that a reference into an account is not used after a helper that may move its data was skipped when
|
|
82
|
+
the account reached the helper as an account-group field (`grow(g.pool, g.payer)`) or as one loaded with
|
|
83
|
+
`loadAccountMut`; such a program compiled and wrote through the stale reference. Both are refused like a plain
|
|
84
|
+
parameter (test/security/aliasing.test.ts).
|
|
85
|
+
- Fixed: the Borsh decoder's length checks subtracted before comparing, so for an `Option` of a struct that itself
|
|
86
|
+
holds an Option (or a Vec of such structs) a short buffer wrapped the subtraction and the read went past the end
|
|
87
|
+
(up to the struct's size, read only). The checks no longer subtract, and a nested struct's smallest size is checked
|
|
88
|
+
after its tag and for each element; `ts_alloc`, string appends and the stake history reader are written the same
|
|
89
|
+
way (test/language/borsh-nested.test.ts).
|
|
90
|
+
- Fixed: a local read before a closure or list callback that changes it kept the new value (`x += bump()`,
|
|
91
|
+
`two(x, bump())`); it keeps the value it had when read, as the left-to-right order promises
|
|
92
|
+
(test/language/closures.test.ts). A string that views text inside an `Inout` place is copied for the helper that
|
|
93
|
+
takes the place (test/language/inout.test.ts).
|
|
94
|
+
- Fixed: `close()`. Closing an account into itself is a compile error (`CloseTo<…, "self">`, `close(a, a)`), and 2040
|
|
95
|
+
at run time in a helper whose two accounts may be one; `Dup<…>` is refused on an account the body closes; using an
|
|
96
|
+
account after `close()` in the same instruction (its writes were dropped) is a compile error, its `.key` aside
|
|
97
|
+
(test/security/dup.test.ts, test/language/diagnostics.test.ts).
|
|
98
|
+
- Language: `min` / `max`, `switch` and list indexes take a `u256`; a `u256` shift amount or exponent is a compile
|
|
99
|
+
error (it was a C build failure); `x <<= n` and `x >>= n` take an amount of its own integer type, as `<<` does;
|
|
100
|
+
`Ata<Init<TokenAccount>, "@acct.field", …>.create` is a compile error naming the form instead of C that does not
|
|
101
|
+
build (test/language/pow.test.ts, test/language/diagnostics.test.ts).
|
|
102
|
+
- Of the 76 programs of the 0.43.0 sources, 35 compile to the same binary as in 0.43.0 and 41 to a different one:
|
|
103
|
+
those with a helper that takes a Pubkey, Option, string or u256 (the parameter is a pointer now). counter, vault and
|
|
104
|
+
escrow are among the 35. Measured against 0.43.0, the changed example programs move by at most 22 compute units
|
|
105
|
+
either way, and no compared transaction of a port costs more than the original's.
|
|
106
|
+
- Docs: docs/security-model.md says what creation over an existing account returns (the System Program's custom 0;
|
|
107
|
+
3000 is `initAccount<T>`), and docs/runtime.md names the cases that abort (`PANIC_ON_OVERFLOW`, `PANIC_STYLE`, a
|
|
108
|
+
RedBlackTree whose bytes are inconsistent).
|
|
109
|
+
- CLI: generated `.mcp.json` / `.cursor/mcp.json`, the agent rules, hints and docs run the project's own copy with
|
|
110
|
+
`npx --no-install typesol …` (or `npx @typesol/cli …` outside a project): plain `npx typesol` outside an installed
|
|
111
|
+
project asks the registry for a package of that name, which does not exist. docs/migrate-from-anchor.md installs
|
|
112
|
+
before running `port`.
|
|
113
|
+
- typesol/testing: `testProgram` reuses an up-to-date build (same sources, runtime, TypeSOL, TypeScript and clang
|
|
114
|
+
versions), and builds of one program from parallel test workers wait for each other
|
|
115
|
+
(`<out>/<name>/.typesol-build.lock`, taken over when its process is gone or after 15 minutes) instead of writing
|
|
116
|
+
over each other's files.
|
|
117
|
+
- CLI: `typesol cpi` and `typesol port` check the IDL as `typesol client` does (identifiers, base58 addresses, byte
|
|
118
|
+
lists) and keep IDL text inside escaped comments. A pre-0.30 Anchor IDL gets "run `anchor idl convert`" in all
|
|
119
|
+
three, and a null or non-object IDL or a missing `instructions` list is refused with a message.
|
|
120
|
+
- Client: a type that holds itself through a Vec or an Option (`enum Shape { Rec { kids: Vec<Shape> } }`) gets a lazy
|
|
121
|
+
codec; building it overflowed the stack. `u256` / `i256` are supported (bigint, 32 bytes LE), and
|
|
122
|
+
`Option<Option<T>>` is `Option<T> | null` so Some(None) round-trips; one level more is left out with a note.
|
|
123
|
+
- CLI: `clone`, `client --address`, `verify` and `idl publish` time out RPC requests (30 s, `TYPESOL_RPC_TIMEOUT`) and
|
|
124
|
+
report the host and cause as `doctor` / `deploy` do. `deploy` refuses to run without `--url` or a configured
|
|
125
|
+
`json_rpc_url`, and `deploy` / `idl publish` print the cluster and payer before sending. A `--config` that does not
|
|
126
|
+
exist is a usage error in `deploy --dry-run` and `doctor` too.
|
|
127
|
+
- CLI: `check --json` prints JSON for every outcome (a missing file, bad `--files` input). Printed `cd` and deploy
|
|
128
|
+
hints quote paths. `build file.ts --program-id <missing>` explains instead of failing with ENOENT.
|
|
129
|
+
- Docs: docs/cli.md lists `typesol mcp` and every file `init` writes. docs/mainnet.md's counter size and rent are
|
|
130
|
+
measured (11,400 bytes, about 0.080 SOL at 0.43.0). Case studies link to showcase sources on GitHub. docs/client.md
|
|
131
|
+
describes which PDA seeds are filled in. docs/audit.md's figures come from `scripts/audit-stats.ts` (checked by the
|
|
132
|
+
tests), its unreviewed range runs to 0.43.0, and macOS CI is on demand.
|
|
133
|
+
- Tests: the Phoenix and Stake Pool diff helpers compare account bytes without copying them twice or building hex
|
|
134
|
+
strings unless they differ (phoenix-upstream peak RSS 1.53 GB → 0.77 GB), and the per-order market copies left in
|
|
135
|
+
phoenix-cancel and phoenix-upstream are hoisted.
|
|
136
|
+
- Licences: NOTICE records the third-party code the package ships (lib-sokoban's red-black tree in the runtime
|
|
137
|
+
header, MIT; SPL's big_vec layout and the Stake interface's activation function, Apache-2.0) and the Phoenix and
|
|
138
|
+
SPL Stake Pool ports, and ships in the package with the Apache-2.0 text. Every showcase/mainnet file names its
|
|
139
|
+
source and licence.
|
|
140
|
+
- CI: a program binary whose sha256 differs from test/programs/SOURCES.md fails the fetch step (Token Metadata is
|
|
141
|
+
fetched from mainnet, the build the record names; Bubblegum's record is the build devnet runs now). All fetch-only
|
|
142
|
+
binaries are cached, keyed on SOURCES.md. `CI_REQUIRE_ALL` turns a suite skipped for a missing binary into a
|
|
143
|
+
failure (test/binaries.ts).
|
|
144
|
+
- Docs: docs/testing.md lists the SPL Stake Pool and Phoenix random walks and the red-black tree's trace replay
|
|
145
|
+
against lib-sokoban among the checks against an independent oracle.
|
|
146
|
+
- Releases: `scripts/release-check.ts <version>` packs the npm tarball from a clean `git archive` of the tag (frozen
|
|
147
|
+
install, build, lint, the version and CHANGELOG section checked; `--tests` adds the suite) and writes
|
|
148
|
+
`releases/<version>.json`: the commit, the tarball's shasum and integrity as the registry reports them, and each
|
|
149
|
+
file's sha256. The maintainer publishes that tarball (`npm publish <file>.tgz`) instead of a folder with
|
|
150
|
+
`--ignore-scripts`, and `--verify --registry` compares the registry with the record afterwards. `npm pack` is
|
|
151
|
+
reproducible: two clean packs of v0.43.0 and the published 0.43.0 are the same bytes (shasum 10c2883b…), recorded
|
|
152
|
+
in releases/0.43.0.json (CONTRIBUTING.md, docs/testing.md).
|
|
153
|
+
- Toolchain: the toolchain the release is tested with is declared in one place (`TESTED_TOOLCHAIN`, exported from
|
|
154
|
+
`typesol/compiler`: Agave 3.1.10, platform-tools v1.52, its clang 20.1.7 version line). A build with another clang
|
|
155
|
+
(`build`, `deploy`, `verify`, `typesol/testing`, a reused up-to-date build too) prints one warning per process naming
|
|
156
|
+
both and saying its binaries are not covered by the tests; `--toolchain-strict` on `build` and `deploy`, or
|
|
157
|
+
`TYPESOL_TOOLCHAIN=strict` anywhere, makes it an error. `typesol doctor` has a `toolchain` row (tested, or untested
|
|
158
|
+
with both versions; an error under strict), and its install hint is Agave 3.1.10 instead of "stable". CI runs
|
|
159
|
+
`doctor` under strict, so the tests run on the declared toolchain (test/cli/toolchain.test.ts).
|
|
160
|
+
- Build manifests: `<name>.build.json` records `platformTools` (from the SDK's `platform-tools-<version>.md` marker
|
|
161
|
+
and its link into the cache, when they agree) and `host` (`os`, `arch`) beside `clang`. A manifest without `host`
|
|
162
|
+
(from 0.43.0 or earlier) makes the up-to-date check rebuild once instead of reusing the build; a different
|
|
163
|
+
platform-tools or host rebuilds too. `scripts/release-manifest.ts` takes the platform-tools version from the same
|
|
164
|
+
place (its path pattern found none).
|
|
165
|
+
- CLI: `typesol verify` on a mismatch prints the rebuild's toolchain (clang, platform-tools, host, TypeSOL) and the
|
|
166
|
+
deployed build's when a build manifest's binary hash is the deployed bytes' (`--manifest <file>`, `<name>.build.json`
|
|
167
|
+
next to a given `.so`, or the local build's), and which of them differ. A program on chain records no toolchain, so
|
|
168
|
+
without such a manifest it says the deployed side is unknown and names the local manifest as describing another
|
|
169
|
+
binary.
|
|
170
|
+
- Docs: the README's quick start installs the tested Agave and platform-tools exactly; docs/mainnet.md has "the
|
|
171
|
+
toolchain you deploy with" (keep the build manifest with the deployment; `verify` needs the same toolchain);
|
|
172
|
+
docs/troubleshooting.md explains the warning and verify mismatches; docs/cli.md lists the new flags and rows.
|
|
173
|
+
- Docs: docs/audit.md and docs/security-model.md record the internal review of 0.43.0 (2026-11-11): the defects above,
|
|
174
|
+
what it covered (compiler semantics probes, the runtime and generated C, the tooling) and what it did not (the
|
|
175
|
+
Metaplex and token CPI wrappers' emitters, oracles, SBPF v1/v2 builds, Windows); programs built with 0.43.0 or
|
|
176
|
+
earlier should be rebuilt, and docs/security-model.md says how to tell whether a program was exposed to the helper
|
|
177
|
+
argument defect. SECURITY.md and CONTRIBUTING.md add the fix-release rule (from 0.44.0 on, a release that only
|
|
178
|
+
fixes soundness or security defects is a patch of the latest minor, with no new language surface and the binary
|
|
179
|
+
diff in its notes; older minors are not maintained). docs/stability.md lists what a release gives today: the
|
|
180
|
+
checked tarball, the tested toolchain, the build record, fix releases.
|
|
181
|
+
|
|
9
182
|
## 0.43.0 — 2026-11-11
|
|
10
183
|
|
|
11
184
|
Phoenix v1 ported in full, Ellipsis Labs' on-chain limit order book and a native program, from the commit a
|
package/NOTICE
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
TypeSOL
|
|
2
|
+
Copyright (c) 2026 TypeSOL contributors. Licensed under the MIT License (LICENSE).
|
|
3
|
+
|
|
4
|
+
Third-party code in the published @typesol/cli package
|
|
5
|
+
--------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
The package ships this NOTICE and the Apache License 2.0 text (test/programs/LICENSE-Apache-2.0.txt).
|
|
8
|
+
|
|
9
|
+
- runtime/typesol_rt.h, the RedBlackTree section (ts_rbt_*): a statement-for-statement port of the red-black tree and
|
|
10
|
+
node allocator of lib-sokoban 0.3.0 (https://github.com/jarry-xiao/sokoban, src/red_black_tree.rs and
|
|
11
|
+
src/node_allocator.rs). lib-sokoban is offered under "MIT OR Apache-2.0"; TypeSOL uses it under the MIT License:
|
|
12
|
+
|
|
13
|
+
MIT License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2022 Jarry Xiao
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
in the Software without restriction, including without limitation the rights
|
|
20
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
SOFTWARE.
|
|
34
|
+
|
|
35
|
+
- runtime/typesol_rt.h, the BigVec section (ts_bigvec_*), and the BigVec<T> layout the compiler gives account data:
|
|
36
|
+
they follow SPL Stake Pool's big_vec.rs (solana-program/stake-pool, program/src/big_vec.rs; earlier in
|
|
37
|
+
solana-labs/solana-program-library), licensed under the Apache License, Version 2.0. Changes: rewritten in C and
|
|
38
|
+
TypeScript.
|
|
39
|
+
|
|
40
|
+
- dist/testing-stake.js (src/testing-stake.ts), stakeActivation: a port of Delegation::stake_activating_and_deactivating_v2
|
|
41
|
+
of solana-stake-interface 4.3.0 (https://github.com/solana-program/stake, interface crate), Copyright Anza
|
|
42
|
+
Maintainers. Licence: Apache-2.0 (the crate's Cargo metadata for 4.3.0; text in test/programs/LICENSE-Apache-2.0.txt). Changes: rewritten in TypeScript (BigInt arithmetic with the original's u128 saturation).
|
|
43
|
+
|
|
44
|
+
Third-party material in this repository only (not in the published package)
|
|
45
|
+
------------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
- test/programs/: program binaries dumped from Solana clusters. The ones kept in the repository are Apache-2.0:
|
|
48
|
+
SPL Account Compression and SPL Noop (solana-labs/solana-program-library), Program Metadata
|
|
49
|
+
(solana-program/program-metadata), coral-xyz/multisig, Raydium CP-Swap, Raydium CLMM and Raydium AMM v4 (raydium-io), Jito's tip
|
|
50
|
+
payment, tip distribution and priority fee distribution programs (jito-foundation/jito-programs), marginfi v2
|
|
51
|
+
(mrgnlabs/marginfi-v2), Solend's token-lending (solendprotocol/solana-program-library) and SPL Stake Pool
|
|
52
|
+
(solana-program/stake-pool); and, under the MIT licence, Phoenix v1 (Ellipsis-Labs/phoenix-v1). The licence texts are test/programs/LICENSE-Apache-2.0.txt and
|
|
53
|
+
test/programs/LICENSE-MIT-phoenix-v1.txt; each binary's source, program id
|
|
54
|
+
and sha256 are in test/programs/SOURCES.md.
|
|
55
|
+
marginfi v2's Drift v2 test build (drift-labs/protocol-v2) is Apache-2.0 too and kept.
|
|
56
|
+
The Metaplex programs, under the Metaplex(TM) NFT Open Source License 1.0, Kamino's lending and farms programs and
|
|
57
|
+
JupLend's lending, liquidity and rewards programs, under the Business Source License 1.1, and Drift's Merkle
|
|
58
|
+
distributor, under the GNU GPL 3.0, are not kept here: scripts/fetch-programs.sh downloads them.
|
|
59
|
+
- showcase/test/fixtures/marginfi/: Marginfi v2's on-chain IDL and three of its mainnet accounts (mrgnlabs/marginfi-v2,
|
|
60
|
+
Apache-2.0), and I80F48 vectors written with the fixed crate (MIT or Apache-2.0).
|
|
61
|
+
- showcase/test/fixtures/kamino/: the IDLs of Kamino's lending (1.25.0) and farms programs, the interface descriptions
|
|
62
|
+
as mrgnlabs/marginfi-v2 keeps them in idls-complete/ (Apache-2.0); the programs are not here (see above).
|
|
63
|
+
- showcase/test/fixtures/drift/, showcase/test/fixtures/juplend/: the IDLs of Drift v2 and of JupLend's lending,
|
|
64
|
+
liquidity and rewards rate model programs, as mrgnlabs/marginfi-v2 keeps them in idls-complete/ (Apache-2.0).
|
|
65
|
+
- showcase/test/fixtures/clmm/: Raydium CLMM's on-chain IDL and the accounts of one mainnet pool (raydium-io/raydium-clmm,
|
|
66
|
+
Apache-2.0).
|
|
67
|
+
- showcase/mainnet/: TypeSOL ports of mainnet programs, which follow their originals' source: Raydium CP-Swap, CLMM
|
|
68
|
+
and AMM v4, Jito's MEV programs, marginfi v2, coral-xyz/multisig and SPL Stake Pool (Apache-2.0), and Phoenix v1
|
|
69
|
+
(MIT, Copyright Ellipsis Labs). Every file says which program it ports and under which licence in its first line.
|
|
70
|
+
- showcase/program-examples/: ports of solana-developers/program-examples (MIT, Copyright Solana Foundation; the
|
|
71
|
+
licence text is in showcase/program-examples/README.md).
|
package/README.md
CHANGED
|
@@ -141,27 +141,41 @@ transactions to both and compares the results.
|
|
|
141
141
|
|
|
142
142
|
## Quick start
|
|
143
143
|
|
|
144
|
-
You need Node.js 22.12 or later and the Agave CLI
|
|
145
|
-
|
|
144
|
+
You need Node.js 22.12 or later and the Agave CLI with its platform-tools, which hold the clang TypeSOL compiles with.
|
|
145
|
+
Rust is not needed. TypeSOL is tested with **Agave 3.1.10 and platform-tools v1.52** (clang 20.1.7); to install exactly
|
|
146
|
+
those:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.10/install)"
|
|
150
|
+
cargo-build-sbf --install-only --force-tools-install --tools-version v1.52
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Other versions work, but their binaries are not covered by the project's tests: `typesol build` warns once when the
|
|
154
|
+
clang is another one (`--toolchain-strict` or `TYPESOL_TOOLCHAIN=strict` makes that an error), and every build records
|
|
155
|
+
its clang, platform-tools and host in `<name>.build.json`.
|
|
146
156
|
|
|
147
157
|
```sh
|
|
148
158
|
npx @typesol/cli init my-app --name counter # typesol.json, programs/counter.ts, tests/counter.test.ts, tsconfig
|
|
149
159
|
cd my-app && npm install
|
|
150
160
|
npm test # builds the program and runs it in LiteSVM, an in-process Solana runtime
|
|
151
|
-
npx typesol build
|
|
161
|
+
npx --no-install typesol build # target/counter/{counter.so, counter.json (IDL), counter.client.ts, counter.build.json}
|
|
152
162
|
```
|
|
153
163
|
|
|
154
|
-
`npx typesol doctor` checks all of this (Node.js, platform-tools, Solana CLI, keypair, RPC) and prints the command
|
|
155
|
-
that fixes anything missing.
|
|
164
|
+
`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
|
|
165
|
+
that fixes anything missing. Inside a project, `npx --no-install typesol …` (or `npm run build`, `npm run deploy`) runs the
|
|
166
|
+
project's own copy; outside one, use `npx @typesol/cli …`. Plain `npx typesol` is not TypeSOL: `typesol` is not the npm
|
|
167
|
+
package's name, so where the project's copy is not installed npx would fetch whatever package has that name.
|
|
168
|
+
|
|
169
|
+
To deploy, on devnet:
|
|
156
170
|
|
|
157
171
|
```sh
|
|
158
172
|
solana-keygen new # once, if you have no keypair (~/.config/solana/id.json)
|
|
159
173
|
solana airdrop 2 --url devnet # test SOL for the rent (rate-limited: https://faucet.solana.com also works)
|
|
160
|
-
npx typesol deploy --url devnet
|
|
174
|
+
npx --no-install typesol deploy --url devnet
|
|
161
175
|
```
|
|
162
176
|
|
|
163
177
|
or on a local validator: `solana-test-validator` in another terminal, `solana airdrop 5 --url localhost`, then
|
|
164
|
-
`npx typesol deploy --url localhost`. `deploy` checks the RPC and the payer's balance before sending anything.
|
|
178
|
+
`npx --no-install typesol deploy --url localhost`. `deploy` checks the RPC and the payer's balance before sending anything.
|
|
165
179
|
|
|
166
180
|
`--template vault` or `--template escrow` starts from a SOL vault or an SPL token escrow instead of the counter, each
|
|
167
181
|
with a passing LiteSVM test.
|
|
@@ -268,16 +282,16 @@ toolchain and records them with every result:
|
|
|
268
282
|
<!-- bench:table -->
|
|
269
283
|
| Instruction | TypeSOL | Pinocchio 0.10 | Native Rust | Anchor 1.0.2 |
|
|
270
284
|
| --- | ---: | ---: | ---: | ---: |
|
|
271
|
-
| counter.initialize | **1,
|
|
285
|
+
| counter.initialize | **1,856** | 3,186 | 4,601 | 6,573 |
|
|
272
286
|
| counter.increment | **110** | 113 | 857 | 2,323 |
|
|
273
|
-
| vault.open | **1,
|
|
287
|
+
| vault.open | **1,875** | 3,185 | 4,613 | 6,627 |
|
|
274
288
|
| vault.deposit | **1,314** | 1,377 | 2,832 | 4,355 |
|
|
275
289
|
| vault.withdraw | **315** | 370 | 1,176 | 3,628 |
|
|
276
290
|
| vault.shut | **161** | 167 | 950 | 2,024 |
|
|
277
|
-
| escrow.make | **3,
|
|
291
|
+
| escrow.make | **3,595** | 6,179 | 9,240 | 13,304 |
|
|
278
292
|
| escrow.take | **4,019** | 4,051 | 8,500 | 14,365 |
|
|
279
293
|
| escrow.refund | **2,696** | 2,769 | 5,695 | 8,449 |
|
|
280
|
-
| binary, counter / vault / escrow | 11.1 / 14.1 / 21.
|
|
294
|
+
| binary, counter / vault / escrow | 11.1 / 14.1 / 21.5 KB | 19.6 / 22.9 / 29.4 KB | 27.9 / 35.0 / 46.5 KB | 145.2 / 158.9 / 190.7 KB |
|
|
281
295
|
<!-- /bench:table -->
|
|
282
296
|
|
|
283
297
|
`initialize`, `open` and `make` include the PDA bump search. TypeSOL hashes PDA candidates with the sha256 and
|
package/SECURITY.md
CHANGED
|
@@ -4,11 +4,38 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
6
6
|
|
|
7
|
-
- The compiler, runtime and tooling have been through internal security reviews
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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.
|
|
13
|
+
**TypeSOL has not been audited by an independent firm.** Do not put significant value behind programs built with it
|
|
14
|
+
until an external audit of the compiler and runtime is published, and audit your own programs as you would any
|
|
15
|
+
Solana program.
|
|
16
|
+
- The tests cover binaries built with the toolchain a release declares as tested (Agave 3.1.10, platform-tools v1.52
|
|
17
|
+
for this one). `typesol build` warns about another one, `--toolchain-strict` refuses it, and each build records its
|
|
18
|
+
toolchain in `<name>.build.json`: keep that file with every deployment.
|
|
19
|
+
- From 0.43.0 on, `releases/<version>.json` records the published npm tarball (its shasum, integrity and every file's
|
|
20
|
+
sha256), packed from a clean export of the release tag; `node scripts/release-check.ts <version> --verify --registry`
|
|
21
|
+
compares it with the registry.
|
|
22
|
+
- Only the latest 0.x release receives security fixes, as fix releases (below).
|
|
23
|
+
|
|
24
|
+
## Fix releases
|
|
25
|
+
|
|
26
|
+
From 0.44.0 on, a release that only fixes soundness or security defects is published as a patch of the latest minor
|
|
27
|
+
release (0.44.0 → 0.44.1), so a team can take the fix without taking new features:
|
|
28
|
+
|
|
29
|
+
- it adds no language surface (nothing new in `lib/typesol.d.ts`, no construct accepted that was refused) and changes
|
|
30
|
+
no account layout, IDL or error code beyond what the fix itself needs;
|
|
31
|
+
- a program it refuses or builds to another binary is one the defect touches, and the CHANGELOG says which;
|
|
32
|
+
- its release notes carry the binary diff against the previous release (the previous release's sources built by both
|
|
33
|
+
packages, `binary-diff.txt`; see [docs/testing.md](docs/testing.md#reproducing-a-release)), so a team can see whether
|
|
34
|
+
their program's binary changes.
|
|
35
|
+
|
|
36
|
+
Fixes go to the latest minor only; older minors are not maintained. A fix that needs a language or layout change
|
|
37
|
+
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
|
+
changes (new compile errors, `deploy` refusing to run without a cluster).
|
|
12
39
|
- What a compiled program can rely on is specified in [docs/security-model.md](docs/security-model.md); the package
|
|
13
40
|
for an external audit is [docs/audit.md](docs/audit.md).
|
|
14
41
|
|
package/dist/ai.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The rules every TypeSOL program follows that a model trained on ordinary TypeScript gets wrong first. */
|
|
2
|
-
export declare const AGENT_RULES = "## Writing TypeSOL\n\nTypeSOL compiles a subset of TypeScript to a Solana program (native SBF) with an Anchor-compatible IDL. Programs live\nin `programs/`, tests in `tests/`; `typesol.json` lists the programs.\n\n- Exported functions are instructions; their parameters are the accounts (`Signer`, `Account<T>`, `Mut<T>`,\n `Init<T>`, token accounts, programs) and then the arguments. Account data types are exported interfaces.\n- Integers are bigint: `u8` \u2026 `u128`, `i8` \u2026 `i128` (write `1n`, never `1`; take `u64`, never `number`).\n Arithmetic is checked: an overflow fails the instruction. There is no floating point.\n- Import everything from `\"typesol\"`: types, and functions such as `require`, `log`, `min`, `max`,\n `fixedArray`, `emit`, `invoke`.\n- Fail with `require(condition, MyError.Name)` (an exported string enum of messages) or `require(condition, \"message\")`.\n There is no `throw`, `try`, `async`, `class`, `console` or `Math`.\n- An account the instruction changes is `Mut<T>`; one it creates is `Init<T>` (`acct.create(payer, seeds)`).\n- Lists: `FixedArray<T, N>`, `FixedVec<T, N>`, `Vec<T>`; read with `.get(i)` and write with `.set(i, v)`\n (`i` a bigint), not `xs[i]`. `map`, `filter`, `find`, `some`, `reduce` work on them.\n- Strings are `FixedString<N>` in account data; `Option<T>` (`T | null`) for optional values.\n\n## Checking your work\n\n- `npx typesol check` (or `--json`) type-checks every program and lists what TypeSOL refuses, each error with a\n `hint` that says what to write instead. Fix those first; they are faster than a build.\n- `npm test` builds the programs and runs `tests/` in LiteSVM (an in-process Solana runtime). `npx typesol build`\n writes `target/<name>/`: the `.so`, the IDL and a typed client.\n- The MCP server (`npx typesol mcp`, configured in `.mcp.json` and `.cursor/mcp.json`) gives the same check,\n the IDL and the docs as tools.\n- The language reference: `node_modules/typesol/docs/language.md
|
|
2
|
+
export declare const AGENT_RULES = "## Writing TypeSOL\n\nTypeSOL compiles a subset of TypeScript to a Solana program (native SBF) with an Anchor-compatible IDL. Programs live\nin `programs/`, tests in `tests/`; `typesol.json` lists the programs.\n\n- Exported functions are instructions; their parameters are the accounts (`Signer`, `Account<T>`, `Mut<T>`,\n `Init<T>`, token accounts, programs) and then the arguments. Account data types are exported interfaces.\n- Integers are bigint: `u8` \u2026 `u128`, `i8` \u2026 `i128` (write `1n`, never `1`; take `u64`, never `number`).\n Arithmetic is checked: an overflow fails the instruction. There is no floating point.\n- Import everything from `\"typesol\"`: types, and functions such as `require`, `log`, `min`, `max`,\n `fixedArray`, `emit`, `invoke`.\n- Fail with `require(condition, MyError.Name)` (an exported string enum of messages) or `require(condition, \"message\")`.\n There is no `throw`, `try`, `async`, `class`, `console` or `Math`.\n- An account the instruction changes is `Mut<T>`; one it creates is `Init<T>` (`acct.create(payer, seeds)`).\n- Lists: `FixedArray<T, N>`, `FixedVec<T, N>`, `Vec<T>`; read with `.get(i)` and write with `.set(i, v)`\n (`i` a bigint), not `xs[i]`. `map`, `filter`, `find`, `some`, `reduce` work on them.\n- Strings are `FixedString<N>` in account data; `Option<T>` (`T | null`) for optional values.\n\n## Checking your work\n\n- `npx --no-install typesol check` (or `--json`) type-checks every program and lists what TypeSOL refuses, each error with a\n `hint` that says what to write instead. Fix those first; they are faster than a build.\n- `npm test` builds the programs and runs `tests/` in LiteSVM (an in-process Solana runtime). `npx --no-install typesol build`\n writes `target/<name>/`: the `.so`, the IDL and a typed client.\n- The MCP server (`npx --no-install typesol mcp`, configured in `.mcp.json` and `.cursor/mcp.json`) gives the same check,\n the IDL and the docs as tools.\n- The language reference: `node_modules/typesol/docs/language.md` (after `npm install`), or https://typesol.com/llms-full.txt.\n";
|
|
3
3
|
/** AGENTS.md for a new project (Codex, Cursor, Zed, and other agents that read it). */
|
|
4
4
|
export declare function agentsMd(name: string): string;
|
|
5
5
|
/** Claude Code reads CLAUDE.md, which imports AGENTS.md so the rules are kept in one place. */
|
package/dist/ai.js
CHANGED
|
@@ -21,13 +21,13 @@ in \`programs/\`, tests in \`tests/\`; \`typesol.json\` lists the programs.
|
|
|
21
21
|
|
|
22
22
|
## Checking your work
|
|
23
23
|
|
|
24
|
-
- \`npx typesol check\` (or \`--json\`) type-checks every program and lists what TypeSOL refuses, each error with a
|
|
24
|
+
- \`npx --no-install typesol check\` (or \`--json\`) type-checks every program and lists what TypeSOL refuses, each error with a
|
|
25
25
|
\`hint\` that says what to write instead. Fix those first; they are faster than a build.
|
|
26
|
-
- \`npm test\` builds the programs and runs \`tests/\` in LiteSVM (an in-process Solana runtime). \`npx typesol build\`
|
|
26
|
+
- \`npm test\` builds the programs and runs \`tests/\` in LiteSVM (an in-process Solana runtime). \`npx --no-install typesol build\`
|
|
27
27
|
writes \`target/<name>/\`: the \`.so\`, the IDL and a typed client.
|
|
28
|
-
- The MCP server (\`npx typesol mcp\`, configured in \`.mcp.json\` and \`.cursor/mcp.json\`) gives the same check,
|
|
28
|
+
- The MCP server (\`npx --no-install typesol mcp\`, configured in \`.mcp.json\` and \`.cursor/mcp.json\`) gives the same check,
|
|
29
29
|
the IDL and the docs as tools.
|
|
30
|
-
- The language reference: \`node_modules/typesol/docs/language.md
|
|
30
|
+
- The language reference: \`node_modules/typesol/docs/language.md\` (after \`npm install\`), or https://typesol.com/llms-full.txt.
|
|
31
31
|
`;
|
|
32
32
|
/** AGENTS.md for a new project (Codex, Cursor, Zed, and other agents that read it). */
|
|
33
33
|
export function agentsMd(name) {
|
|
@@ -40,4 +40,4 @@ export function cursorRule() {
|
|
|
40
40
|
return `---\ndescription: TypeSOL, a TypeScript subset compiled to Solana programs\nglobs: programs/**/*.ts, tests/**/*.ts\nalwaysApply: true\n---\n\n${AGENT_RULES}`;
|
|
41
41
|
}
|
|
42
42
|
/** The MCP server configuration Claude Code (.mcp.json) and Cursor (.cursor/mcp.json) read. */
|
|
43
|
-
export const MCP_JSON = JSON.stringify({ mcpServers: { typesol: { command: "npx", args: ["typesol", "mcp"] } } }, null, 2) + "\n";
|
|
43
|
+
export const MCP_JSON = JSON.stringify({ mcpServers: { typesol: { command: "npx", args: ["--no-install", "typesol", "mcp"] } } }, null, 2) + "\n";
|