@typesol/cli 0.48.0 → 0.50.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 +556 -1
- package/NOTICE +17 -1
- package/README.md +122 -43
- package/SECURITY.md +6 -0
- package/dist/compiler/analyze.d.ts +2 -0
- package/dist/compiler/analyze.js +7 -1
- package/dist/compiler/emit/base.d.ts +7 -4
- package/dist/compiler/emit/base.js +17 -5
- package/dist/compiler/emit/borsh.js +8 -8
- package/dist/compiler/emit/calls.d.ts +6 -0
- package/dist/compiler/emit/calls.js +110 -11
- package/dist/compiler/emit/cpi-core.js +3 -3
- package/dist/compiler/emit/cpi.js +2 -2
- package/dist/compiler/emit/expressions.d.ts +1 -0
- package/dist/compiler/emit/expressions.js +15 -1
- package/dist/compiler/emit/function.js +12 -8
- package/dist/compiler/emit/program.js +10 -4
- package/dist/compiler/emit/rbtree.js +1 -1
- package/dist/compiler/emit/shared.d.ts +12 -2
- package/dist/compiler/emit/shared.js +26 -6
- package/dist/compiler/emit/statements.d.ts +8 -1
- package/dist/compiler/emit/statements.js +53 -5
- package/dist/compiler/emit/storage.js +20 -13
- package/dist/compiler/emit/views.js +1 -1
- package/dist/compiler/hints.js +3 -0
- package/dist/compiler/index.d.ts +15 -1
- package/dist/compiler/index.js +50 -9
- package/dist/keys.d.ts +12 -1
- package/dist/keys.js +57 -7
- package/dist/workspace.d.ts +8 -0
- package/dist/workspace.js +90 -15
- package/docker/deps/0.49.0.lock.json +1206 -0
- package/docker/deps/0.50.0.lock.json +1206 -0
- package/docs/architecture.md +3 -3
- package/docs/audit.md +33 -16
- package/docs/case-study-escrow.md +7 -5
- package/docs/case-study-jito-mev.md +14 -14
- package/docs/case-study-marginfi.md +142 -129
- package/docs/case-study-multisig.md +18 -5
- package/docs/case-study-raydium-amm.md +2 -1
- package/docs/case-study-raydium-clmm.md +44 -28
- package/docs/case-study-raydium-cp-swap.md +18 -18
- package/docs/case-study-spl-stake-pool.md +4 -3
- package/docs/cli.md +4 -3
- package/docs/language-accounts.md +21 -16
- package/docs/language-basics.md +4 -1
- package/docs/language-builtins.md +6 -2
- package/docs/language-cpi.md +34 -0
- package/docs/language-errors-events.md +1 -1
- package/docs/language-native.md +73 -7
- package/docs/language-statements.md +5 -3
- package/docs/language-types.md +13 -3
- package/docs/language.md +2 -2
- package/docs/mainnet.md +1 -1
- package/docs/runtime.md +25 -1
- package/docs/security-model.md +12 -4
- package/docs/stability.md +10 -4
- package/docs/testing.md +22 -6
- package/docs/troubleshooting.md +1 -1
- package/lib/typesol.d.ts +43 -3
- package/llms-full.txt +190 -51
- package/llms.txt +2 -1
- package/package.json +3 -3
- package/releases/0.48.0.json +847 -0
- package/releases/0.49.0.json +857 -0
- package/runtime/typesol_builtins.c +47 -2
- package/runtime/typesol_rt.h +131 -4
package/NOTICE
CHANGED
|
@@ -83,12 +83,28 @@ Third-party material in this repository only (not in the published package)
|
|
|
83
83
|
- showcase/mainnet/meteora-dbc/: a TypeSOL port of Meteora's Dynamic Bonding Curve (MeteoraAg/dynamic-bonding-curve,
|
|
84
84
|
release 0.2.2, commit 91e696e), with its tests showcase/test/meteora-dbc*.ts and the mainnet accounts of two of its
|
|
85
85
|
pools, the seven DAMM v2 migration configs, the six DAMM v1 migration configs and the wrapped SOL dynamic vault those
|
|
86
|
-
tests read (showcase/test/fixtures/meteora-dbc/; DAMM v2 is under the Meteora
|
|
86
|
+
tests read (showcase/test/fixtures/meteora-dbc/; DAMM v2 is under the Meteora Non-commercial Licence too, the licences
|
|
87
87
|
of DAMM v1 and the dynamic vault are not established). It is not under this repository's MIT
|
|
88
88
|
licence: it is subject to Meteora's Non-commercial Licence, whose text is showcase/mainnet/meteora-dbc/LICENSE.md.
|
|
89
89
|
Required Notice: All underlying software code is subject to the licence set out at https://github.com/MeteoraAg/dynamic-bonding-curve
|
|
90
90
|
The program's mainnet binary is not kept here either, nor are those of DAMM v2, the locker, DAMM v1 and the dynamic
|
|
91
91
|
vault its migrations call:
|
|
92
92
|
scripts/fetch-programs.sh downloads them (test/programs/SOURCES.md).
|
|
93
|
+
- showcase/mainnet/percolator/: a TypeSOL port of Percolator v12.20, the program aeyakovenko/percolator-prog
|
|
94
|
+
(commit 06f86fb) with its risk engine aeyakovenko/percolator (commit 3f55f87), Copyright Anatoly Yakovenko,
|
|
95
|
+
Apache-2.0 (the licence text is test/programs/LICENSE-Apache-2.0.txt), with its tests showcase/test/percolator*.ts.
|
|
96
|
+
Changes: rewritten in TypeSOL. The original's own warning stands for the port: an educational research project, not
|
|
97
|
+
audited, not for use with real funds. Its mainnet binary is not kept here: scripts/fetch-programs.sh downloads it
|
|
98
|
+
(test/programs/SOURCES.md). showcase/mainnet/percolator/matcher/ is a TypeSOL port of the matcher TradeCpi calls,
|
|
99
|
+
aeyakovenko/percolator-match (commit 199b139), Copyright Anatoly Yakovenko, Apache-2.0, kept as a test fixture.
|
|
100
|
+
- showcase/mainnet/percolator-v16/: a TypeSOL port of Percolator v16, all 50 instructions, the program
|
|
101
|
+
aeyakovenko/percolator-prog (commit 7b11091) with its risk engine aeyakovenko/percolator (commit 5e3af07), Copyright
|
|
102
|
+
Anatoly Yakovenko, Apache-2.0 (the licence text is test/programs/LICENSE-Apache-2.0.txt), with its tests
|
|
103
|
+
showcase/test/percolator-v16*.ts, whose layout table (percolator-v16-layout.ts) transcribes the original's account
|
|
104
|
+
structs. Changes: rewritten in TypeSOL. The original's own warning stands for the port: an educational research
|
|
105
|
+
project, not audited, not for use with real funds. No v16 build is deployed to compare with:
|
|
106
|
+
scripts/percolator-v16-reference/ builds the reference binary from those commits, and the matchers its tests load
|
|
107
|
+
(aeyakovenko/percolator-match commit 60aac3a and two test matchers of percolator-prog, Apache-2.0), in Docker; none
|
|
108
|
+
of the binaries is kept here (test/programs/SOURCES.md).
|
|
93
109
|
- showcase/program-examples/: ports of solana-developers/program-examples (MIT, Copyright Solana Foundation; the
|
|
94
110
|
licence text is in showcase/program-examples/README.md).
|
package/README.md
CHANGED
|
@@ -32,17 +32,22 @@ clients read TypeSOL programs unchanged.
|
|
|
32
32
|
- Every arithmetic operation is checked.
|
|
33
33
|
- Account owner, discriminator, signer, writability and aliasing checks are generated from your parameter types.
|
|
34
34
|
- Constraints follow Anchor's rules and use Anchor's error codes.
|
|
35
|
-
- **Small and fast.** In the
|
|
36
|
-
about 10× smaller, and fewer compute units than native Rust and hand-tuned Pinocchio on every
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
- **Small and fast.** In the counter, vault and escrow benchmarks below, TypeSOL uses 5–32% of Anchor's compute units,
|
|
36
|
+
with binaries about 10× smaller, and fewer compute units than native Rust and hand-tuned Pinocchio on every
|
|
37
|
+
instruction. On 17 official example programs it uses fewer than Anchor and native Rust on every instruction, and
|
|
38
|
+
more than their Pinocchio versions on 13 of the 26 ([Numbers](#numbers)). On mainnet the results differ by
|
|
39
|
+
instruction; see [the mainnet table](#on-mainnet).
|
|
40
|
+
- **Checked against mainnet.** Nine ports of deployed programs (eleven programs: Jito MEV's row is three), among them
|
|
41
|
+
Marginfi v2, Phoenix v1 and SPL Stake Pool, run beside the original binaries: the same outcomes, events, return data
|
|
42
|
+
and account bytes on thousands of transactions, and the same error codes and log lines but for the exceptions each
|
|
43
|
+
case study lists, for fewer compute units ([the ports](#ported-and-checked-against-mainnet-binaries)).
|
|
41
44
|
- **Verifiable.** `typesol verify` reads a deployed program from the cluster and checks it, and the IDL published on
|
|
42
|
-
chain, against its source. Every release records
|
|
43
|
-
|
|
45
|
+
chain, against its source. Every release records its npm tarball in `releases/<version>.json` ([releases/](releases)),
|
|
46
|
+
and the hashes of every program it builds in its GitHub Release's `typesol-<version>-manifest.json`
|
|
47
|
+
([docs/testing.md](docs/testing.md#reproducing-a-release)).
|
|
44
48
|
The same source, TypeSOL version and toolchain build to the same bytes on macOS arm64, Linux arm64 and Linux x86_64
|
|
45
|
-
(measured: all 76 programs
|
|
49
|
+
(measured with 0.45.0: all 76 programs then in the sources for SBPF v0, 14 of them for v1 and v2; programs added
|
|
50
|
+
since, the Meteora DBC and Percolator ports among them, were not in that measurement; Linux arm64 with the platform-tools
|
|
46
51
|
`linux-aarch64` package set up as in [Requirements](#requirements), since there is no Agave CLI for it;
|
|
47
52
|
[docs/stability.md](docs/stability.md#what-builds-the-same-bytes-where)).
|
|
48
53
|
`typesol build --docker` builds in a pinned linux/amd64 container that anyone can rebuild from the Dockerfile, and
|
|
@@ -65,34 +70,68 @@ Node.js and the Solana toolchain are in place ([Quick start](#quick-start), [Req
|
|
|
65
70
|
## Ported and checked against mainnet binaries
|
|
66
71
|
|
|
67
72
|
Each port is the whole program, written in TypeSOL from the original's source. Its tests send every transaction to
|
|
68
|
-
the port and to the binary deployed on mainnet, both in LiteSVM, and require the same outcome,
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
the port and to the binary deployed on mainnet, both in LiteSVM, and require the same outcome, events, return data and
|
|
74
|
+
bytes in every account the transaction names, and the same error code and log lines, with the exceptions each case
|
|
75
|
+
study lists. Of those, the kinds that recur:
|
|
76
|
+
|
|
77
|
+
- **Error-message text.** The Anchor ports log their errors in TypeSOL's words, with Anchor's codes; Jito's, Raydium
|
|
78
|
+
CLMM's and the multisig's also leave out Anchor's `Instruction: …` lines.
|
|
79
|
+
- **Panics.** Where the original panics, Marginfi, Raydium CLMM, Raydium CP-Swap and Jito MEV fail with a numbered
|
|
80
|
+
error, and Marginfi also answers a few runtime errors that carry no code (`AccountBorrowFailed`, `BorshIoError`)
|
|
81
|
+
with numbered ones; the tests require that both fail.
|
|
82
|
+
- **Informational logs.** Marginfi writes only the original's `WARN` lines, of about 160 `msg!` lines.
|
|
83
|
+
- **Raydium CLMM's reward mints**, kept in the order added, so `OperationState`'s bytes differ when two or more are
|
|
84
|
+
listed.
|
|
85
|
+
- **Compute.** A Percolator keeper crank that exceeds the compute budget in the original completes in the port.
|
|
86
|
+
|
|
87
|
+
Phoenix v1, Raydium AMM v4, SPL Stake Pool and Percolator match every log line of the compared transactions, panics
|
|
88
|
+
included, except the runtime's compute-unit lines. The port must also use fewer compute units on every transaction that succeeds. A case study for
|
|
89
|
+
each (for Percolator, the port's README) says what was compared and what was not.
|
|
71
90
|
|
|
72
91
|
| Program | Kind | Instructions | Transactions compared |
|
|
73
92
|
| --- | --- | ---: | ---: |
|
|
74
|
-
| [Marginfi v2](docs/case-study-marginfi.md) | Anchor, lending | 124 | 2,
|
|
93
|
+
| [Marginfi v2](docs/case-study-marginfi.md) | Anchor, lending | 124 | 2,321 |
|
|
75
94
|
| [Phoenix v1](docs/case-study-phoenix.md) | native, limit order book | 28 | 3,575 |
|
|
76
95
|
| [SPL Stake Pool](docs/case-study-spl-stake-pool.md) | native, liquid staking | 27 | 2,107 |
|
|
77
|
-
| [Raydium CLMM](docs/case-study-raydium-clmm.md) | Anchor, concentrated liquidity | 37 |
|
|
96
|
+
| [Raydium CLMM](docs/case-study-raydium-clmm.md) | Anchor, concentrated liquidity | 37 | 308 |
|
|
78
97
|
| [Raydium CP-Swap](docs/case-study-raydium-cp-swap.md) | Anchor, constant product | 21 | 136 |
|
|
79
|
-
| [Raydium AMM v4](docs/case-study-raydium-amm.md) | native, constant product | all |
|
|
98
|
+
| [Raydium AMM v4](docs/case-study-raydium-amm.md) | native, constant product | all | 144 (60 random steps) |
|
|
80
99
|
| [Jito MEV](docs/case-study-jito-mev.md) | Anchor, three programs | 24 | 150 |
|
|
81
|
-
| [
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
| [Percolator v12.20](showcase/mainnet/percolator) | native, perpetuals risk engine | 27 | 139,185 (132,031 random or mutated: 3,711 in random walks on fixed seeds, 128,320 from the mutation fuzzers) |
|
|
101
|
+
| [Percolator v16 at commit 7b110913 (engine 5e3af07)](showcase/mainnet/percolator-v16) | native, multi-asset perpetuals risk engine; compared with a binary built here from the author's pinned source, not a deployed program | 50 | 70,975 |
|
|
102
|
+
| [coral-xyz/multisig](docs/case-study-multisig.md) | Anchor | all | 55 |
|
|
103
|
+
|
|
104
|
+
No Percolator v16 build is deployed, so its row is the one port above not compared with a mainnet binary: its
|
|
105
|
+
reference is the Rust build of the pinned commits (reproducible, its recipe matching the author's recorded hash at an
|
|
106
|
+
older commit). Not compared there: a deployed program, matchers other than the three the author's tests load and one
|
|
107
|
+
of the tests' own, and a few paths no instruction sequence reached (its README lists them); where the reference runs
|
|
108
|
+
out of compute units the port is compared with the reference run under a raised budget. The author's own suite ran on
|
|
109
|
+
both binaries, with every transaction compared (2,324,990 of 2,324,991 identical, the other a force-close that exceeds
|
|
110
|
+
the reference's compute budget); none of the 2,127,486 identical successes costs the port more (port 67,489,438,873
|
|
111
|
+
units, reference 128,297,605,017). A first run, on an earlier binary of the port, had found
|
|
112
|
+
282 such successes at the author's largest market shapes (ResolveMarket, CloseSlab, InitMarket); the cause was fixed
|
|
113
|
+
and the full run repeated (its README has the figures).
|
|
114
|
+
|
|
115
|
+
A further port is held to a narrower comparison and is not counted above:
|
|
84
116
|
[Meteora Dynamic Bonding Curve 0.2.2](showcase/mainnet/meteora-dbc) (Anchor, launchpad, all 35 instructions, with its
|
|
85
|
-
migrations into DAMM v1 and DAMM v2). Outcomes, error codes, account bytes,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
migrations into DAMM v1 and DAMM v2). Outcomes, error codes, account bytes, inner instructions (its events are
|
|
118
|
+
self-CPIs) and return data are compared as for the ports above, with the exceptions its README lists; of the log only
|
|
119
|
+
the events' `Program data:` lines are compared, not the rest of its text, and compute units are not compared. The
|
|
120
|
+
port, its tests (`showcase/test/meteora-dbc*.ts`) and their fixtures (`showcase/test/fixtures/meteora-dbc/`) are under
|
|
121
|
+
Meteora's Non-commercial Licence, not this repository's (see [NOTICE](NOTICE)).
|
|
122
|
+
|
|
123
|
+
Each count is what a default test run compares, with the fetch-only binaries present (`pnpm fetch:programs`); the
|
|
124
|
+
Percolator v16 count needs its reference binaries built as well (`scripts/percolator-v16-reference/build.sh` and
|
|
125
|
+
`probe.sh`, Docker), as CI's `percolator-v16` job does, and is the sum of the `percolator-v16 compared: …` line each of
|
|
126
|
+
its test files prints (without the binaries those files skip and print 0). Random
|
|
127
|
+
walks, with fixed or printed seeds, run on top of the other ports' counts ([docs/testing.md](docs/testing.md)); the
|
|
128
|
+
multisig port has none. The
|
|
90
129
|
sources are in [`showcase/mainnet`](showcase/mainnet), and where each original binary comes from is recorded in
|
|
91
130
|
[test/programs/SOURCES.md](test/programs/SOURCES.md).
|
|
92
131
|
|
|
93
132
|
## At a glance
|
|
94
133
|
|
|
95
|
-
**`counter.ts`**: a complete program, 23 lines. (`typesol init` writes it with one more instruction, a read-only
|
|
134
|
+
**`counter.ts`**: a complete program, 23 non-blank lines. (`typesol init` writes it with one more instruction, a read-only
|
|
96
135
|
`assertAtLeast`.)
|
|
97
136
|
|
|
98
137
|
```ts
|
|
@@ -126,7 +165,7 @@ export function increment(authority: Signer, counter: Mut<Counter>, by: u64): vo
|
|
|
126
165
|
```
|
|
127
166
|
|
|
128
167
|
<details>
|
|
129
|
-
<summary><b>The same program in Anchor</b>: 44 lines of Rust</summary>
|
|
168
|
+
<summary><b>The same program in Anchor</b>: 44 non-blank lines of Rust</summary>
|
|
130
169
|
|
|
131
170
|
```rust
|
|
132
171
|
#[program]
|
|
@@ -264,9 +303,9 @@ the same.
|
|
|
264
303
|
`typesol port` starts from your program's IDL; [docs/case-study-escrow.md](docs/case-study-escrow.md) follows one
|
|
265
304
|
program through the port.
|
|
266
305
|
- Real programs checked against their mainnet binaries: [Showcase](https://github.com/typesol-lang/typesol#showcase-ports-checked-against-mainnet), with a
|
|
267
|
-
case study each (Marginfi v2 in full: all 124 instructions,
|
|
268
|
-
order book, the same on 3,575 transactions down to its event bytes
|
|
269
|
-
lines).
|
|
306
|
+
case study each (Marginfi v2 in full: all 124 instructions, 2,321 transactions with the same outcomes, events and
|
|
307
|
+
account bytes; Phoenix v1, a native order book, the same on 3,575 transactions down to its event bytes and log lines;
|
|
308
|
+
Raydium AMM v4, a native program, down to its log lines).
|
|
270
309
|
- To mainnet (wallet, cost, deploy, IDL, verification): [docs/mainnet.md](docs/mainnet.md).
|
|
271
310
|
- With an AI coding agent: [docs/ai.md](docs/ai.md) (agent rules, [llms.txt](https://typesol.com/llms.txt), the MCP server).
|
|
272
311
|
|
|
@@ -287,7 +326,7 @@ counter.ts ─▶ tsc typecheck ─▶ subset check ─▶ C + typesol_rt.h ─
|
|
|
287
326
|
`--sbpf`).
|
|
288
327
|
|
|
289
328
|
Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts:25)`, or
|
|
290
|
-
`TypeSOL: arithmetic overflow (vault.ts:
|
|
329
|
+
`TypeSOL: arithmetic overflow (vault.ts:44)`.
|
|
291
330
|
|
|
292
331
|
## What you can write
|
|
293
332
|
|
|
@@ -367,14 +406,36 @@ CPI account records only for the accounts a call lists. It uses fewer compute un
|
|
|
367
406
|
instruction here, while also refusing duplicate writable accounts as Anchor does. Fewer compute
|
|
368
407
|
units are not a safety claim. The differential tests also run the escrow against its Anchor twin ([docs/testing.md](docs/testing.md)).
|
|
369
408
|
|
|
409
|
+
These three programs' Pinocchio versions were written for this comparison.
|
|
410
|
+
|
|
411
|
+
<!-- bench:official -->
|
|
412
|
+
On the official examples, 17 programs of solana-developers/program-examples@de09019 that this project did not write (26 instructions, `official.ts` in the benchmarks repository), TypeSOL uses fewer compute units than Anchor on 26 of 26 instructions and than native Rust on 26 of 26, and more than Pinocchio on 13 of 26.
|
|
413
|
+
<!-- /bench:official -->
|
|
414
|
+
|
|
415
|
+
Those Pinocchio versions often do less: favorites, close-account and
|
|
416
|
+
program-derived-addresses take the PDA bump from the client instead of searching for it on chain, and pda-rent-payer
|
|
417
|
+
checks the client's bump instead of finding the canonical one; program-derived-addresses' increment checks neither the
|
|
418
|
+
address nor the owner of the account it writes; transfer-sol checks neither that the recipient is a System account nor
|
|
419
|
+
that the paying account of `transfer_sol_with_program` belongs to the program. The notes for each program, and every
|
|
420
|
+
figure, are in the benchmarks' `results.json` (`official`).
|
|
421
|
+
|
|
370
422
|
### On mainnet
|
|
371
423
|
|
|
372
424
|
The official escrow ([tokens/escrow](https://github.com/solana-developers/program-examples/tree/de090195e4de698e150572c4f886c333323a64a5/tokens/escrow)),
|
|
373
425
|
deployed to Solana mainnet-beta in all four versions and called with the same mints, amounts and accounts, one
|
|
374
426
|
instruction per transaction. The TypeSOL program was upgraded in place to 0.25.0 on 2026-10-29; the others are as first
|
|
375
427
|
deployed on 2026-10-27. Each figure is the compute units of that transaction, linked to Solscan; the lowest per row is
|
|
376
|
-
in bold. The
|
|
377
|
-
|
|
428
|
+
in bold. The TypeSOL program was checked against its source with `typesol verify` (it is the 0.25.0 build, not the
|
|
429
|
+
current release) and its IDL is published on chain with `typesol idl publish`; the Pinocchio, native Rust and Anchor
|
|
430
|
+
programs are the benchmarks' builds, and this record does not check them byte for byte against those builds.
|
|
431
|
+
|
|
432
|
+
These four programs are a benchmark record, not a service: the maintainers' own keys made every offer and took or
|
|
433
|
+
refunded each one in the runs recorded, so no offer is open and they hold no one's tokens. The TypeSOL one predates
|
|
434
|
+
the defects fixed in 0.44.0 and 0.44.1 (see [Status](#status)); its source,
|
|
435
|
+
[`showcase/program-examples/tokens/escrow.ts`](showcase/program-examples/tokens/escrow.ts) (the same at 0.25.0, then
|
|
436
|
+
`test/ports/tokens/escrow.ts`), uses none of the constructs those defects need: no helper functions, closures,
|
|
437
|
+
`Dup<…>` or loaded accounts, seed lists written in place at each call, token wrapper arguments that are plain reads,
|
|
438
|
+
and no `transferFee` or `updateExtraAccountMetas`.
|
|
378
439
|
|
|
379
440
|
| Transaction | TypeSOL | Pinocchio | Native Rust | Anchor |
|
|
380
441
|
| --- | ---: | ---: | ---: | ---: |
|
|
@@ -385,26 +446,33 @@ program's IDL is published on chain with `typesol idl publish`.
|
|
|
385
446
|
| escrow program's own part, 4 transactions | **28,118** | 36,956 | 93,273 | 102,926 |
|
|
386
447
|
| program | [65ybkcg6…](https://solscan.io/account/65ybkcg6mQa9t5EuHtirRdvf2qAu12qRiK6wYBbGk16P) | [FrQwq3iU…](https://solscan.io/account/FrQwq3iUa8ZkWEne1y27webXTAyLgH4Hj6t986t6VS2G) | [5pnmi1Md…](https://solscan.io/account/5pnmi1MdxzXKmgX7ooRSE212rzZK8rb7nNpRTSMqP8V1) | [EG7M3sLL…](https://solscan.io/account/EG7M3sLLwB7MhmtzwYsaxbhZaFDbshL9hmVK79bQVyVq) |
|
|
387
448
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
449
|
+
In make_offer the Associated Token Account program creates the vault: 13,480 to 22,480 CU of the make_offers above
|
|
450
|
+
(13,585 to 22,585 with the token transfer after it). That is most of the TypeSOL and Pinocchio make_offers (67–77%)
|
|
451
|
+
and about a third to a half of the native Rust and Anchor ones (35–46%), whose own part is larger (15,543 to 29,043
|
|
452
|
+
CU). The ATA program searches for the vault address's bump itself at 1,500 CU a try, and every offer has its own
|
|
453
|
+
vault, so that part depends on the offer (13,510 CU for both of Anchor's, 13,480 and 22,480 for TypeSOL's); programs
|
|
454
|
+
that check the vault's address re-derive it, so take_offer and refund_offer can vary with it too. The escrow
|
|
455
|
+
program's own part is steadier: TypeSOL's make_offer spent 6,620 CU of its own on both offers. The Pinocchio version takes the offer PDA's bump from the client instead of
|
|
393
456
|
searching for it. Mainnet figures differ from the LiteSVM means above. Every run, including the one before the
|
|
394
457
|
upgrade, is in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) (`results/`).
|
|
395
458
|
|
|
396
459
|
## How it is tested
|
|
397
460
|
|
|
398
|
-
- **Execution tests.**
|
|
399
|
-
|
|
400
|
-
-
|
|
461
|
+
- **Execution tests.** Programs that use each language feature are compiled and run in LiteSVM (`test/language/`,
|
|
462
|
+
`test/examples/`, `test/integrations/`, `test/security/`), and every complete example of the language guide must
|
|
463
|
+
compile (`test/language/docs-examples.test.ts`).
|
|
464
|
+
- **Diagnostics tests.** Refused constructs are tested with the message they get (`test/language/diagnostics.test.ts`,
|
|
465
|
+
and every row of the guide's "What is refused" table).
|
|
466
|
+
- **Golden tests.** The generated C of the counter and the generated clients of two programs are compared with golden
|
|
467
|
+
output (`test/golden/`), and CI rebuilds 14 programs on Linux x86_64 to the bytes the reference container gives
|
|
468
|
+
(`test/golden/binaries.json`).
|
|
401
469
|
- **Randomized tests** against independent oracles:
|
|
402
470
|
- Arithmetic at every integer width is checked against BigInt.
|
|
403
471
|
- Stateful vault, escrow and ledger runs are checked against a TypeScript model.
|
|
404
472
|
- Differential runs send the same transactions to TypeSOL and to the Anchor twins and compare outcomes, account
|
|
405
473
|
contents and balances.
|
|
406
|
-
- **Ports against mainnet binaries.** The
|
|
407
|
-
transaction, and random walks over them compare every step.
|
|
474
|
+
- **Ports against mainnet binaries.** The nine ports above run beside the deployed originals, transaction by
|
|
475
|
+
transaction, and random walks over eight of them (all but multisig), and over Meteora DBC, compare every step.
|
|
408
476
|
- **Localnet smoke test.** A script deploys every example to a local validator and drives it end to end; it is run
|
|
409
477
|
by hand, not in CI.
|
|
410
478
|
|
|
@@ -417,7 +485,7 @@ Details are in [docs/testing.md](docs/testing.md).
|
|
|
417
485
|
| [`counter.ts`](examples/counter.ts) | PDA init, authority check |
|
|
418
486
|
| [`vault.ts`](examples/vault.ts) | System CPI, direct lamport moves, rent floor, close |
|
|
419
487
|
| [`escrow.ts`](examples/escrow.ts) | SPL Token CPIs signed by a PDA, atomic swap, refund |
|
|
420
|
-
| [`minter.ts`](examples/minter.ts) | capped issuer over SPL Token and Token-2022 |
|
|
488
|
+
| [`minter.ts`](examples/minter.ts) | capped issuer over SPL Token and Token-2022, set up by the mint's authority |
|
|
421
489
|
| [`ledgerbook.ts`](examples/ledgerbook.ts) | enums, Options, a Vec that grows and shrinks its account |
|
|
422
490
|
| [`airdrop.ts`](examples/airdrop.ts) | remaining accounts, batch payouts, `loadAccountMut` |
|
|
423
491
|
| [`relay.ts`](examples/relay.ts), [`caller.ts`](examples/caller.ts) | generic `invoke`, PDA-signed transfers, return data |
|
|
@@ -443,6 +511,8 @@ Case studies: [Marginfi v2](docs/case-study-marginfi.md), [Phoenix v1](docs/case
|
|
|
443
511
|
| [`spl-stake-pool/`](showcase/mainnet/spl-stake-pool) | SPL Stake Pool in full, all 27 instructions, a native program and the one behind most liquid staking tokens: pools of stake across up to 20,000 validators, SOL and stake deposits and withdrawals, rebalancing over epochs, fees and authorities, token metadata |
|
|
444
512
|
| [`raydium-amm/`](showcase/mainnet/raydium-amm) | Raydium AMM v4, the original constant-product AMM and a native (non-Anchor) program, in full: pool creation, deposits and withdrawals, the v1 and v2 swaps, P&L and administration, down to its log records and panics |
|
|
445
513
|
| [`meteora-dbc/`](showcase/mainnet/meteora-dbc) | Meteora Dynamic Bonding Curve 0.2.2 in full, all 35 instructions: configs, pool creation on SPL Token and Token-2022 (transfer fees and hooks), the three swap modes, fee schedulers and the rate limiter, fee claims, the locker, and the migrations into DAMM v1 and DAMM v2. Under Meteora's Non-commercial Licence (its own `LICENSE.md`); log text and compute units are not compared |
|
|
514
|
+
| [`percolator/`](showcase/mainnet/percolator) | Percolator v12.20, Anatoly Yakovenko's perpetuals risk engine and its native program, in full, all 27 instructions, against the immutable mainnet build: one 1.5 MB slab of 4,096 accounts, U256 and U512 arithmetic, trades through matcher programs, funding, liquidation, the keeper crank with pro-rata loss socialisation and side resets, resolution and teardown. The author's own suite gives the same outcome on every test under both binaries (660 passed). Upstream is educational and not audited |
|
|
515
|
+
| [`percolator-v16/`](showcase/mainnet/percolator-v16) | Percolator v16 at commit 7b110913 (engine 5e3af07), Anatoly Yakovenko's multi-asset perpetuals risk engine and its native program, all 50 instructions: portfolios of up to 14 legs, trades direct, batched and through matcher programs, the crank with liquidation, bankrupt closes, Recovery and resolution, insurance and backing buckets with source liens, terminal close-out. Compared with a binary built from the author's pinned source (not a deployed program). Upstream is educational and not audited |
|
|
446
516
|
| [`multisig.ts`](showcase/mainnet/multisig/multisig.ts) | coral-xyz/multisig: stored instructions run with `invokeInstruction`, a PDA signing, Anchor's Borsh accounts |
|
|
447
517
|
|
|
448
518
|
## Status
|
|
@@ -454,6 +524,12 @@ change.
|
|
|
454
524
|
The two latest, of 0.43.0 and 0.44.0 in November 2026, found defects that made a program that compiled behave
|
|
455
525
|
differently from its source; each is fixed with a test, and [docs/audit.md](docs/audit.md) lists them, what the
|
|
456
526
|
reviews covered and what they did not. Programs built before 0.44.1 should be rebuilt.
|
|
527
|
+
- 0.45.0 to 0.50.0 have had no security review. They add, among others,
|
|
528
|
+
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
529
|
+
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
530
|
+
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
531
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), and `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
532
|
+
copied and zeroed by the memory syscalls (0.50.0).
|
|
457
533
|
- From 0.44.0 on, a release that only fixes defects is a patch with no new language surface and a binary diff in its
|
|
458
534
|
notes ([SECURITY.md](SECURITY.md#fix-releases)), and the npm tarball is the one packed from the tag and recorded
|
|
459
535
|
in [releases/](releases).
|
|
@@ -502,6 +578,9 @@ built-in, a constraint or an error code. Then read [CONTRIBUTING.md](CONTRIBUTIN
|
|
|
502
578
|
|
|
503
579
|
## License
|
|
504
580
|
|
|
505
|
-
[MIT](LICENSE)
|
|
581
|
+
[MIT](LICENSE), except the Meteora Dynamic Bonding Curve port: `showcase/mainnet/meteora-dbc/`, its tests
|
|
582
|
+
`showcase/test/meteora-dbc*.ts` and their fixtures `showcase/test/fixtures/meteora-dbc/` are subject to the Meteora
|
|
583
|
+
Non-commercial Licence ([its text](showcase/mainnet/meteora-dbc/LICENSE.md), [NOTICE](NOTICE)), and none of them is in
|
|
584
|
+
the npm package. The runtime and `typesol/testing` include code ported from MIT and Apache-2.0 projects, and the tests
|
|
506
585
|
use third-party program binaries and data that are not in the npm package: see [NOTICE](NOTICE) and
|
|
507
586
|
[test/programs/SOURCES.md](test/programs/SOURCES.md).
|
package/SECURITY.md
CHANGED
|
@@ -8,6 +8,12 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
|
|
|
8
8
|
0.44.0 on 2026-11-11, found defects in the compiler (wrong token-wrapper instruction data, and a reference that could
|
|
9
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
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
|
+
0.45.0 to 0.50.0 have had no security review. They add, among others,
|
|
12
|
+
`runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
|
|
13
|
+
`EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
|
|
14
|
+
`PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
|
|
15
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), and `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
16
|
+
copied and zeroed by the memory syscalls (0.50.0).
|
|
11
17
|
**Rebuild and redeploy programs built before 0.44.1**;
|
|
12
18
|
[docs/security-model.md](docs/security-model.md#status) gives the status, its sections on each review say how to
|
|
13
19
|
tell whether a program was exposed, and [docs/audit.md](docs/audit.md#earlier-reviews) what each review did and did
|
|
@@ -22,6 +22,8 @@ export interface Analysis {
|
|
|
22
22
|
sourceFile: ts.SourceFile;
|
|
23
23
|
/** Every TypeSOL file of the program, entry last. */
|
|
24
24
|
files: string[];
|
|
25
|
+
/** Each of those files' text as the compiler parsed it (a build checks the bytes it records against it). */
|
|
26
|
+
texts: Map<string, string>;
|
|
25
27
|
/** Local identifier -> `typesol` export name, for imports. */
|
|
26
28
|
imports: Map<string, string>;
|
|
27
29
|
reporter: Reporter;
|
package/dist/compiler/analyze.js
CHANGED
|
@@ -1049,6 +1049,7 @@ export function analyze(entry, files) {
|
|
|
1049
1049
|
},
|
|
1050
1050
|
sourceFile,
|
|
1051
1051
|
files: programFiles(program, entryPath).map((f) => f.fileName),
|
|
1052
|
+
texts: new Map(programFiles(program, entryPath).map((f) => [f.fileName, f.text])),
|
|
1052
1053
|
imports: entryImports,
|
|
1053
1054
|
reporter,
|
|
1054
1055
|
checker,
|
|
@@ -1084,7 +1085,8 @@ const CONST_OPS = new Set([
|
|
|
1084
1085
|
* declared before it (in this file or an imported one). JS's bigint results (division truncates, `%` keeps the
|
|
1085
1086
|
* dividend's sign, `>>` rounds down, as Rust's integers do). With `width` (a typed constant, `const X: u64 = …`), every
|
|
1086
1087
|
* step must fit in that type, as Rust computes a typed const; without one the result is a literal, checked where it is
|
|
1087
|
-
* used. Division by zero, a
|
|
1088
|
+
* used. Division by zero, a typed constant's signed minimum divided by or reduced modulo -1, a negative exponent or
|
|
1089
|
+
* shift, and a value past 256 bits are compile errors.
|
|
1088
1090
|
*/
|
|
1089
1091
|
function foldConstant(e, constants, reporter, width) {
|
|
1090
1092
|
const fit = (v, at) => {
|
|
@@ -1136,6 +1138,10 @@ function foldConstant(e, constants, reporter, width) {
|
|
|
1136
1138
|
case ts.SyntaxKind.PercentToken:
|
|
1137
1139
|
if (r === 0n)
|
|
1138
1140
|
reporter.fail(b, `${b.getText()} divides by zero`);
|
|
1141
|
+
// A signed type's minimum by -1: its quotient does not fit, and its remainder fails with it, as at run time
|
|
1142
|
+
// (5100) and in Rust (`i8::MIN % -1` overflows), though JS's bigint gives 0.
|
|
1143
|
+
if (width && INT_INFO[width].signed && l === INT_INFO[width].min && r === -1n)
|
|
1144
|
+
reporter.fail(b, `${b.getText()} overflows ${width}: ${width}'s minimum divided by -1 does not fit, and its remainder fails with it`);
|
|
1139
1145
|
return fit(b.operatorToken.kind === ts.SyntaxKind.SlashToken ? l / r : l % r, b);
|
|
1140
1146
|
case ts.SyntaxKind.AsteriskAsteriskToken:
|
|
1141
1147
|
if (r < 0n)
|
|
@@ -134,11 +134,14 @@ export declare abstract class EmitterBase {
|
|
|
134
134
|
*/
|
|
135
135
|
protected nativeAccountWrites(): boolean;
|
|
136
136
|
/**
|
|
137
|
-
* `const PANIC_STYLE = "solana-1.14"`: a Rust panic logs what
|
|
138
|
-
*
|
|
139
|
-
*
|
|
137
|
+
* `const PANIC_STYLE = "solana-1.14"` / `"solana-1.18"`: a Rust panic logs what that solana-program's panic handler
|
|
138
|
+
* logs and then aborts, so the runtime reports "SBF program panicked". rustc before 1.73 (solana-program 1.14 to
|
|
139
|
+
* 1.17) formats a panic as `panicked at '<message>', <file>:<line>:<col>`; from 1.73 (solana-program 1.18's toolchain)
|
|
140
|
+
* as `panicked at <file>:<line>:<col>:\n<message>`, one log line holding the newline. `"pinocchio"`: pinocchio's
|
|
141
|
+
* `default_panic_handler!` hook logs the location's file alone, then "** PANICKED **", and std aborts. By default it
|
|
142
|
+
* logs the message and calls sol_panic_ with the location.
|
|
140
143
|
*/
|
|
141
|
-
protected panicStyle(): "solana-1.14" | undefined;
|
|
144
|
+
protected panicStyle(): "solana-1.14" | "solana-1.18" | "pinocchio" | undefined;
|
|
142
145
|
/** The C statements of a Rust panic with `message` (undefined: nothing logged) at `location` ("file:line:col"). */
|
|
143
146
|
protected panicC(message: string | undefined, location: string): string[];
|
|
144
147
|
/** `file.ts:line:column` of a node (1-based, as Rust reports a location). */
|
|
@@ -419,17 +419,29 @@ export class EmitterBase {
|
|
|
419
419
|
return this.model.constants.get("NATIVE_ACCOUNT_WRITES")?.value === true;
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
422
|
-
* `const PANIC_STYLE = "solana-1.14"`: a Rust panic logs what
|
|
423
|
-
*
|
|
424
|
-
*
|
|
422
|
+
* `const PANIC_STYLE = "solana-1.14"` / `"solana-1.18"`: a Rust panic logs what that solana-program's panic handler
|
|
423
|
+
* logs and then aborts, so the runtime reports "SBF program panicked". rustc before 1.73 (solana-program 1.14 to
|
|
424
|
+
* 1.17) formats a panic as `panicked at '<message>', <file>:<line>:<col>`; from 1.73 (solana-program 1.18's toolchain)
|
|
425
|
+
* as `panicked at <file>:<line>:<col>:\n<message>`, one log line holding the newline. `"pinocchio"`: pinocchio's
|
|
426
|
+
* `default_panic_handler!` hook logs the location's file alone, then "** PANICKED **", and std aborts. By default it
|
|
427
|
+
* logs the message and calls sol_panic_ with the location.
|
|
425
428
|
*/
|
|
426
429
|
panicStyle() {
|
|
427
|
-
|
|
430
|
+
const v = this.model.constants.get("PANIC_STYLE")?.value;
|
|
431
|
+
return v === "solana-1.14" || v === "solana-1.18" || v === "pinocchio" ? v : undefined;
|
|
428
432
|
}
|
|
429
433
|
/** The C statements of a Rust panic with `message` (undefined: nothing logged) at `location` ("file:line:col"). */
|
|
430
434
|
panicC(message, location) {
|
|
431
|
-
|
|
435
|
+
const style = this.panicStyle();
|
|
436
|
+
if (style === "solana-1.14")
|
|
432
437
|
return [`sol_log(${cString(`panicked at '${message}', ${location}`)});`, `abort();`, `__builtin_unreachable();`];
|
|
438
|
+
if (style === "solana-1.18")
|
|
439
|
+
return [`sol_log(${cString(`panicked at ${location}:\n${message}`)});`, `abort();`, `__builtin_unreachable();`];
|
|
440
|
+
if (style === "pinocchio") {
|
|
441
|
+
// `location.file()` verbatim: the location without its ":line" / ":line:column" (a bare file is kept whole).
|
|
442
|
+
const file = location.replace(/:\d+(?::\d+)?$/, "");
|
|
443
|
+
return [`ts_panic_file(${cString(file)}, ${Buffer.byteLength(file)});`];
|
|
444
|
+
}
|
|
433
445
|
const m = /^(.*?):(\d+)(?::(\d+))?$/.exec(location);
|
|
434
446
|
const [file, line, col] = m ? [m[1], m[2], m[3] ?? "0"] : [location, "0", "0"];
|
|
435
447
|
return [
|
|
@@ -250,7 +250,7 @@ function codec(s, model, o) {
|
|
|
250
250
|
const n = fixedBytes(f.type, model);
|
|
251
251
|
return [
|
|
252
252
|
need(String(n), after(i), pad),
|
|
253
|
-
`${pad}
|
|
253
|
+
`${pad}TS_MEMCPY(&${lv}.${f.name}, src + at, ${n});`,
|
|
254
254
|
`${pad}at += ${n};`,
|
|
255
255
|
...validate(f.type, `${lv}.${f.name}`, pad),
|
|
256
256
|
];
|
|
@@ -279,7 +279,7 @@ function codec(s, model, o) {
|
|
|
279
279
|
`${pad}${lv}.some = ${tag};`,
|
|
280
280
|
`${pad}if (${tag}) {`,
|
|
281
281
|
need(String(n), rest, `${pad} `),
|
|
282
|
-
`${pad}
|
|
282
|
+
`${pad} TS_MEMCPY(&${lv}.v, src + at, ${n});`,
|
|
283
283
|
`${pad} at += ${n};`,
|
|
284
284
|
...validate(t.inner, `${lv}.v`, `${pad} `),
|
|
285
285
|
`${pad}}`,
|
|
@@ -315,7 +315,7 @@ function codec(s, model, o) {
|
|
|
315
315
|
continue;
|
|
316
316
|
}
|
|
317
317
|
const n = fixedBytes(f.type, model);
|
|
318
|
-
lines.push(need(String(n), rest, `${pad} `), `${pad}
|
|
318
|
+
lines.push(need(String(n), rest, `${pad} `), `${pad} TS_MEMCPY(&${flv}, src + at, ${n});`, `${pad} at += ${n};`, ...validate(f.type, flv, `${pad} `));
|
|
319
319
|
}
|
|
320
320
|
lines.push(`${pad} break;`, `${pad}}`);
|
|
321
321
|
});
|
|
@@ -367,7 +367,7 @@ function codec(s, model, o) {
|
|
|
367
367
|
return sub.fields.flatMap((f, i) => {
|
|
368
368
|
if (borshIdentical(f.type, model)) {
|
|
369
369
|
const n = fixedBytes(f.type, model);
|
|
370
|
-
return [room(String(n), after(i), pad), `${pad}
|
|
370
|
+
return [room(String(n), after(i), pad), `${pad}TS_MEMCPY(dst + at, &${lv}.${f.name}, ${n});`, `${pad}at += ${n};`];
|
|
371
371
|
}
|
|
372
372
|
return packVar(f.type, `${lv}.${f.name}`, after(i), pad);
|
|
373
373
|
});
|
|
@@ -386,7 +386,7 @@ function codec(s, model, o) {
|
|
|
386
386
|
room(`(uint64_t)(${lv}.some ? ${1 + n} : 1)`, rest, pad),
|
|
387
387
|
`${pad}dst[at++] = ${lv}.some ? 1 : 0;`,
|
|
388
388
|
`${pad}if (${lv}.some) {`,
|
|
389
|
-
`${pad}
|
|
389
|
+
`${pad} TS_MEMCPY(dst + at, &${lv}.v, ${n});`,
|
|
390
390
|
`${pad} at += ${n};`,
|
|
391
391
|
`${pad}}`,
|
|
392
392
|
];
|
|
@@ -413,7 +413,7 @@ function codec(s, model, o) {
|
|
|
413
413
|
continue;
|
|
414
414
|
}
|
|
415
415
|
const n = fixedBytes(f.type, model);
|
|
416
|
-
lines.push(room(String(n), rest, `${pad} `), `${pad}
|
|
416
|
+
lines.push(room(String(n), rest, `${pad} `), `${pad} TS_MEMCPY(dst + at, &${flv}, ${n});`, `${pad} at += ${n};`);
|
|
417
417
|
}
|
|
418
418
|
lines.push(`${pad} break;`, `${pad}}`);
|
|
419
419
|
});
|
|
@@ -434,11 +434,11 @@ function codec(s, model, o) {
|
|
|
434
434
|
let bytes = 0;
|
|
435
435
|
while (j < s.fields.length && borshIdentical(s.fields[j].type, model))
|
|
436
436
|
bytes += fixedBytes(s.fields[j++].type, model);
|
|
437
|
-
unpackLines.push(`
|
|
437
|
+
unpackLines.push(` TS_MEMCPY(&out->${f.name}, src + at, ${bytes});`, ` at += ${bytes};`);
|
|
438
438
|
for (const g of s.fields.slice(i, j))
|
|
439
439
|
unpackLines.push(...validate(g.type, `out->${g.name}`, " "));
|
|
440
440
|
// A pack can be short of room only after a String / Vec / Option grew; the start always fits (cap >= MIN).
|
|
441
|
-
packLines.push(...(i > 0 ? [room(String(bytes), minAfter[j - 1], " ")] : []), `
|
|
441
|
+
packLines.push(...(i > 0 ? [room(String(bytes), minAfter[j - 1], " ")] : []), ` TS_MEMCPY(dst + at, &in->${f.name}, ${bytes});`, ` at += ${bytes};`);
|
|
442
442
|
i = j;
|
|
443
443
|
continue;
|
|
444
444
|
}
|
|
@@ -3,6 +3,12 @@ import { type AccountParam, type ErrorDef, type FieldType, type Helper, type Str
|
|
|
3
3
|
import { type Value, type Ref, type CpiAcct, type CpiProgram, type Closure } from "./shared.js";
|
|
4
4
|
import { ExpressionEmitter } from "./expressions.js";
|
|
5
5
|
export declare abstract class CallEmitter extends ExpressionEmitter {
|
|
6
|
+
/**
|
|
7
|
+
* Closing an account of this program (`close`, `CloseTo<…>`): TS_CLOSE with the smallest size the account was
|
|
8
|
+
* checked to hold when it loaded (its discriminator and the struct's empty size, or a @layout borsh struct's smallest
|
|
9
|
+
* Borsh form). From TS_ZERO_RUN_MIN bytes on its data is zeroed by the memset syscall; below, by stores as before.
|
|
10
|
+
*/
|
|
11
|
+
protected closeCall(a: AccountParam, dest: string): string;
|
|
6
12
|
protected call(node: ts.CallExpression, topLevel: boolean): Value | undefined;
|
|
7
13
|
/** "unsupported call" naming the callee, with the TypeSOL form of common JavaScript calls. */
|
|
8
14
|
private unsupportedCall;
|