@typesol/cli 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +327 -2
  2. package/README.md +29 -15
  3. package/SECURITY.md +1 -1
  4. package/dist/compiler/analyze.d.ts +6 -11
  5. package/dist/compiler/analyze.js +323 -31
  6. package/dist/compiler/emit/alias.js +3 -2
  7. package/dist/compiler/emit/base.d.ts +5 -0
  8. package/dist/compiler/emit/base.js +2 -0
  9. package/dist/compiler/emit/borsh.js +63 -2
  10. package/dist/compiler/emit/calls.d.ts +9 -1
  11. package/dist/compiler/emit/calls.js +147 -18
  12. package/dist/compiler/emit/cpi-core.js +17 -5
  13. package/dist/compiler/emit/cpi.js +81 -27
  14. package/dist/compiler/emit/create.d.ts +7 -0
  15. package/dist/compiler/emit/create.js +27 -0
  16. package/dist/compiler/emit/expressions.js +7 -4
  17. package/dist/compiler/emit/function.d.ts +7 -0
  18. package/dist/compiler/emit/function.js +164 -29
  19. package/dist/compiler/emit/program.js +15 -2
  20. package/dist/compiler/emit/shared.d.ts +5 -5
  21. package/dist/compiler/emit/shared.js +5 -0
  22. package/dist/compiler/emit/statements.d.ts +8 -0
  23. package/dist/compiler/emit/statements.js +93 -6
  24. package/dist/compiler/emit/storage.d.ts +10 -1
  25. package/dist/compiler/emit/storage.js +50 -11
  26. package/dist/compiler/idl.d.ts +1 -1
  27. package/dist/compiler/idl.js +42 -11
  28. package/dist/compiler/model.d.ts +47 -10
  29. package/dist/compiler/model.js +14 -4
  30. package/dist/testing.js +8 -0
  31. package/dist/tools/clientgen.js +10 -1
  32. package/dist/tools/portgen.d.ts +6 -0
  33. package/dist/tools/portgen.js +68 -17
  34. package/docs/architecture.md +5 -4
  35. package/docs/audit.md +31 -19
  36. package/docs/case-study-escrow.md +5 -5
  37. package/docs/case-study-jito-mev.md +9 -5
  38. package/docs/case-study-marginfi.md +797 -0
  39. package/docs/case-study-multisig.md +3 -3
  40. package/docs/case-study-raydium-clmm.md +44 -33
  41. package/docs/case-study-raydium-cp-swap.md +3 -3
  42. package/docs/cli.md +5 -5
  43. package/docs/client.md +1 -1
  44. package/docs/errors.md +13 -5
  45. package/docs/language.md +38 -25
  46. package/docs/migrate-from-anchor.md +4 -1
  47. package/docs/runtime.md +1 -1
  48. package/docs/security-model.md +2 -1
  49. package/docs/testing.md +33 -1
  50. package/lib/typesol.d.ts +46 -9
  51. package/package.json +9 -7
  52. package/runtime/typesol_rt.h +111 -17
package/CHANGELOG.md CHANGED
@@ -1,11 +1,336 @@
1
1
  # Changelog
2
2
 
3
- TypeSOL follows the organization's [versioning policy](https://github.com/typesol/.github/blob/main/VERSIONING.md)
3
+ TypeSOL follows the organization's [versioning policy](https://github.com/typesol-lang/.github/blob/main/VERSIONING.md)
4
4
  (compiler specifics in CONTRIBUTING.md): until 1.0, a minor version may change the language, the IDL layout or error
5
5
  codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.39.0 — 2026-11-06
10
+
11
+ Marginfi v2 ported in full: all 124 instructions, checked against the mainnet binary on 2,081 transactions with the
12
+ same outcomes, account bytes, events and IDL. The compiler gained what it needed: `Option` struct and `Vec`
13
+ arguments, `f64` fields, hashes as PDA seeds, account resizing and raw writes, `systemProgram.createPda`, and Anchor's
14
+ order and error codes for `init` and zero-copy accounts. The ports moved to `showcase/`. The repository now lives at
15
+ github.com/typesol-lang, and releases are published by hand (no workflow publishes).
16
+
17
+ Upgrading: the IDL writes `Vec<u8>` arguments and account fields as `bytes`, as Anchor does, so an Anchor client
18
+ passes a Buffer for them (the bytes on the wire are unchanged). Accounts created at the start of an instruction now
19
+ run before the other accounts' constraints, and zero-copy accounts are checked in `AccountLoader`'s order, so a
20
+ transaction that breaks several checks can fail with a different error code; programs with such creates or zero-copy
21
+ accounts compile differently (see "Changed" below).
22
+
23
+ - Project: no scheduled or publishing automation in the repository: npm releases are published by hand from a
24
+ maintainer's machine (the release workflow is gone), the macOS suite runs on demand only, and Dependabot no longer
25
+ opens weekly pull requests.
26
+ - Examples: Marginfi's rebalances across Kamino, Drift and JupLend banks, each leg priced at the venue's supply rate
27
+ (klend's curve and reward emissions at the chain's measured slot pace, Drift's curve less its insurance factor,
28
+ JupLend's liquidity-layer rate and Lending rewards), amounts through the venues' exchange rates, deposit room capped
29
+ by the venue's own. Against the binary on mainnet: 2,081 transactions (with the fixes and tests below).
30
+ - Fixed (examples): a classic liquidation by Marginfi's risk admin flags both accounts as the original does, so their
31
+ Exponent PT banks are priced through a vault emergency there too.
32
+ - New: `systemProgram.createPda(payer, account, space, owner, seeds)`, Anchor's `init` with `owner = …` on an
33
+ `UncheckedAccount`: another program's account at this program's PDA, created (or, over an address someone funded
34
+ first, topped up, allocated and assigned) before the instruction's constraints, the PDA recorded in the IDL.
35
+ - Examples: Marginfi's I80F48 magnitudes widen to u256 once (their sum stays in u128) and a float's bit length is
36
+ found by halving, not bit by bit: a classic liquidation takes 7% fewer compute units (130,448 → 121,210 on the
37
+ test's partial liquidation; 38% under the original's).
38
+ - Tests: a `TYPESOL_PROFILE=1` build's VM has no 1.4M compute limit and keeps every log line, so `typesol profile`
39
+ sees a whole Marginfi liquidation (its markers took it past both before).
40
+ - Examples: more of Marginfi's venue paths against the binary: Kamino and Solend deposits and withdrawals of disabled,
41
+ frozen and paused accounts, Kamino's receivership, deleverage, group outflow limit and deleverage day's limit branches
42
+ and its bank's `has_one` accounts, and the risk admin deleveraging an Exponent PT through a vault emergency.
43
+ (`*DepositFailed` / `*WithdrawFailed` guard against a venue that moves other amounts than asked; the venues' own
44
+ programs never do, so they stay untested.)
45
+ - New: an optional account in `invoke`'s list, as it is (`readonly(x)` with `x: A | null`), is left out when it was not
46
+ passed (Rust's `if let Some(..)` pushes).
47
+ - Fixed: a `constraint(acct, …)` that mentions another, optional account runs when that account is missing (it was
48
+ skipped, so `x === null` checks never failed); only `acct` itself being optional and missing skips it. Declared
49
+ constraints (`HasOne` and the like) still run only when the optional accounts they name were passed.
50
+ - Fixed (examples): Marginfi's `drift_withdraw` refuses a withdrawal from a Drift user with admin deposits when the
51
+ reward accounts are missing (6321), as the original does, and passes any combination of the six optional reward
52
+ accounts on to Drift (the port refused all but some).
53
+ - Fixed (examples): Marginfi's `solend_init_obligation` initializes an obligation address someone funded first (Anchor's
54
+ `init` tops the rent up, allocates and assigns), and creates it before all its other checks, as the original does. The
55
+ Solend fuzz holds every transaction to the original's error code; a withdrawal with a debt, where the original fails
56
+ borrowing the bank (AccountBorrowFailed), must fail with the port's error 12.
57
+ - New: `epochStartTimestamp()`, when the current epoch began (the Clock's `epoch_start_timestamp`).
58
+ - Examples: Marginfi's pricing, every oracle setup: staked SOL (a single pool's stake per LST, before and after its
59
+ on-ramp), mSOL (Marinade's rate) and LSTs (an SPL or Sanctum stake pool's), Scope entries, Exponent PTs (linear to
60
+ par, capped by redemption, emergency mode honoured except where the original prices through it), and fixed venue
61
+ prices, each also inside Kamino and JupLend banks where the original has that kind. Setting a fixed venue price
62
+ checks the venue's account. Against the binary on mainnet: 1,936 transactions.
63
+ - Examples: Marginfi's Drift and JupLend banks (`lending_pool_add_bank_drift`, `drift_init_user`, `drift_deposit`,
64
+ `drift_withdraw`, `drift_harvest_reward`, `drift_claim_bad_debt`, `lending_pool_add_bank_juplend`,
65
+ `juplend_init_position`, `juplend_deposit`, `juplend_withdraw`) over Drift v2, Drift's bad-debt Merkle distributor
66
+ and JupLend's lending, liquidity and rewards programs, and their pricing: the feed times the spot market's
67
+ cumulative deposit interest or the Lending's token exchange price. All 124 of Marginfi's instructions are now ported
68
+ (pricing fixed venue banks and venue rebalance legs still stop in the port).
69
+ Against the binary on mainnet: 1,798 transactions, the same IDL for all 124. The venue tests now hold a refused
70
+ transaction to the original's error code, not only to failing.
71
+ - New: `Owner<Account<T>, "…">` is another program's struct account (Anchor's `Account` / `AccountLoader` of a
72
+ `declare_program!` type): loaded with that program as its owner (3007), `HasOne` and fields as for this program's.
73
+ - New: such a struct may have a discriminator of 1 to 8 bytes (`/** @discriminator 0x01 */`, as Anchor's
74
+ `discriminator = &[1]`), its fields starting right after it.
75
+ - Fixed (examples): Marginfi's Solend, Kamino and Drift banks load the venues' accounts as the original's
76
+ `AccountLoader`s do, before any constraint (a foreign account is 3007, not the bank's `has_one` error); setting a
77
+ venue bank's oracle checks its reserve, spot market or Lending again; a Drift scaled balance past u64 is 4102 and a
78
+ Drift deposit limit past I80F48 6004, as in the original. The venue tests now fuzz deposits, withdrawals, borrows,
79
+ repayments and the venues' rates against the original (FUZZ_SEED, FUZZ_STEPS).
80
+ - New: an `Address<AccountInfo, "…">` parameter may be `invoke`'s program (Anchor's `address = ID` on an
81
+ `UncheckedAccount`; the key alone is checked, 2012).
82
+ - Examples: Marginfi's Solend and Kamino banks (`lending_pool_add_bank_solend`, `solend_init_obligation`,
83
+ `solend_deposit`, `solend_withdraw`, `lending_pool_add_bank_kamino`, `kamino_init_obligation`, `kamino_deposit`,
84
+ `kamino_withdraw`, `propagate_kamino_market_emergency`, `kamino_harvest_reward`) over Solend's, klend's and kfarms'
85
+ mainnet programs, and their pricing: the Pyth or Switchboard feed times the reserve's exchange rate in the risk
86
+ engine, the price cache keeping the rate as its multiplier, the circuit breaker watching the multiplied price, a
87
+ Kamino emergency taking the collateral's Initial value. Against the binary on mainnet: 1,601 transactions, the
88
+ same IDL for all 114 ported instructions.
89
+ - New: `Ata<TokenAccount, "@acct.field", "mint">`, the associated token account of a Pubkey stored in a struct
90
+ account; the IDL names the account, as Anchor's does for `acct.load()?.field`.
91
+ - Fixed: an instruction that reads the Clock (`now()`, `currentSlot()`, `currentEpoch()`) in a `constraint(…)` and
92
+ again in its body failed to compile (the Clock cache was declared twice, or after the constraint that used it).
93
+ - Examples: Marginfi's staked SOL (`init_staked_settings`, `edit_staked_settings`, `propagate_staked_settings`,
94
+ `disable_staked_oracles`, `enable_staked_oracle_onramp`, `lending_pool_add_bank_permissionless`,
95
+ `lending_pool_backfill_staked_bank_validator_vote_account`) and `lending_pool_configure_bank_oracle_scope`. Against
96
+ the binary on mainnet: 1,440 transactions, the same IDL for all 104 ported instructions.
97
+ - New: `writeData<T>(account, offset, value)`, a little-endian write into a `Mut<AccountInfo>` of this program
98
+ (bounds-checked); `resizeAccount(account, newSize)`, Rust's `AccountInfo::resize` (the length only, new bytes
99
+ zeroed, no rent moved, at most 10 KiB of growth).
100
+ - `Dup<…>` may name the twin of a close destination (a keeper settling its own record): duplicates share one record,
101
+ so the rent reaches it either way. The closed account itself is still refused as a twin.
102
+ - Examples: Marginfi's rebalance execution (`marginfi_account_start_rebalance`, `end_rebalance`,
103
+ `settle_rebalance_tip`, native banks), account resizing (`lending_pool_resize_group_account`,
104
+ `lending_pool_resize_bank_account`, `resize_global_fee_state`) and the monitor archive
105
+ (`monitor_archive_initialize`, `monitor_archive_upsert_batch`). Against the binary on mainnet: 1,396 transactions,
106
+ the same IDL for all 96 ported instructions.
107
+ - Fixed: an event's fields go out in the order declared, as Anchor's Borsh sends them (a `Vec<T>` field went last,
108
+ after the fixed-size fields as account data stores it), and the IDL lists them so.
109
+ - Examples: Marginfi's rebalance orders, kept: `marginfi_account_place_rebalance_order`, `update_rebalance_order`,
110
+ `close_rebalance_order`, `top_up_rebalance_fee_pool`, `withdraw_rebalance_fee_pool`. Against the binary on mainnet:
111
+ 1,314 transactions, the same IDL for all 88 ported instructions.
112
+ - Examples: Marginfi's order execution, `marginfi_account_start_execute_order` and
113
+ `marginfi_account_end_execute_order` (a sandwich: the executor withdraws and repays in between). Against the binary
114
+ on mainnet: 1,265 transactions, the same IDL for all 83 ported instructions.
115
+ - New: `Option<Vec<T>>` event fields (given `null`, such an argument or a list), and a nested struct written as a
116
+ literal in an event goes out as Borsh (its Options one byte when empty), as Anchor emits Marginfi's
117
+ `SetKeeperCloseFlagsEvent`.
118
+ - New: a `Hash` is a PDA seed (its 32 bytes).
119
+ - Examples: Marginfi's orders, placed and closed: `marginfi_account_place_order`, `marginfi_account_close_order`,
120
+ `marginfi_account_set_keeper_close_flags`, `marginfi_account_keeper_close_order`. Against the binary on mainnet:
121
+ 1,221 transactions, the same IDL for all 81 ported instructions.
122
+ - New: `Option<Vec<T>>` instruction arguments (or `Vec<T> | null`, or of a FixedVec; Anchor's `Option<Vec<u8>>`): a
123
+ tag byte, then the Vec when Some; `x !== null` before reading it as a list or passing it to a helper that takes the
124
+ list.
125
+ - IDL: `Vec<u8>` arguments and account fields are `bytes`, as Anchor writes them (were `{ vec: "u8" }`; the bytes on
126
+ the wire are the same, but an Anchor client now wants a Buffer for them).
127
+ - Examples: Marginfi's bank metadata (`init_bank_metadata`, `write_bank_metadata`, `write_bank_metadata_pre_init`) and
128
+ `lending_pool_clone_bank` (which panics in the mainnet build, as the original does). Against the binary on mainnet:
129
+ 1,170 transactions, the same IDL for all 77 ported instructions.
130
+ - Faster: a struct a function holds itself (a literal, or what a helper returned) passes to a helper that takes
131
+ accounts in place instead of being copied first (only account data can change under a helper); a struct literal
132
+ fills a new `const` directly instead of a temporary; `fixedArray<T, N>(fill)` may be a struct field's value in a
133
+ literal. Programs with struct literals build to different binaries: here raydium-clmm and marginfi (a Marginfi
134
+ withdrawal 2,700 compute units fewer, a health pulse of an empty account 3,400).
135
+ - New: `/** @bytes */` on a FixedArray of integers: the IDL shows each as its bytes (Marginfi's
136
+ `HealthCache.prices: [[u8; 8]; 16]`, written as 16 u64s instead of 128 bytes).
137
+ - Repository: `pnpm test:core` no longer runs the showcase tests too (a path filter of `test` matched
138
+ `showcase/test`); CI's compiler and showcase jobs now split the suite between them.
139
+ - Examples: Marginfi's bank administration, part three: `lending_pool_emissions_deposit` (refusing fee and hook
140
+ mints, as the original does), `lending_pool_init_same_asset_emode_registry` and
141
+ `lending_pool_set_bank_same_asset_emode_eligibility`. Against the binary on mainnet: 1,140 transactions, the same IDL
142
+ for all 73 ported instructions.
143
+ - Examples: Marginfi's bank administration, part two: `lending_pool_configure_bank_gov`,
144
+ `lending_pool_collect_bank_premium_fees`, `super_admin_deposit` and `super_admin_withdraw` (which panic in the
145
+ mainnet build, as the original does). Against the binary on mainnet: 1,084 transactions, the same IDL for all 70
146
+ ported instructions.
147
+ - Examples: Marginfi's bank administration, part one: `lending_pool_configure_bank_emode`, `lending_pool_clone_emode`,
148
+ `lending_pool_configure_bank_premium`, `lending_pool_clear_circuit_breaker`, `lending_pool_backfill_bank_is_t22_flag`
149
+ and `lending_pool_close_bank`. Against the binary on mainnet: 1,061 transactions, the same IDL for all 66 ported
150
+ instructions. 45–96% fewer compute units.
151
+ - New: instruction arguments of type `Option<S>` (or `S | null`) for a fixed-size struct S, as Anchor's
152
+ `Option<WrappedI80F48>`: Borsh (a tag byte, then S when Some), validated on entry like struct arguments (102),
153
+ `{ option: { defined } }` in the IDL, read after `x !== null`. Helpers still take the struct itself.
154
+ - Examples: Marginfi's group and fee state administration: `config_group_fee`, `edit_global_fee_state`,
155
+ `edit_fee_state_premium`, the panic pause (`panic_pause`, `panic_unpause`, `panic_unpause_permissionless`),
156
+ `marginfi_group_set_governance_admin`, `marginfi_group_configure_gov`, `configure_bank_rate_limits`,
157
+ `configure_group_rate_limits`, `update_group_rate_limiter` and `lending_pool_configure_group_premium`. Against the
158
+ binary on mainnet: 1,024 transactions, the same IDL for all 60 ported instructions. 68–97% fewer compute units.
159
+ - Examples: Marginfi's account administration: `marginfi_account_set_freeze`,
160
+ `marginfi_account_update_emissions_destination_account`, `sync_indexer_flags`, `transfer_to_new_account`,
161
+ `transfer_to_new_account_pda` and `admin_close_account`. Against the binary on mainnet: 955 transactions, the same IDL
162
+ for all 48 ported instructions. 38–86% fewer compute units.
163
+ - Examples: Marginfi's flash loans, the start of part 5 of the port: `lending_account_start_flashloan` (the end
164
+ instruction found through the Instructions sysvar) and `lending_account_end_flashloan` (the deferred health check,
165
+ premium rates and the breaker's gate). Against the binary on mainnet: 915 transactions, the same IDL for all 42
166
+ ported instructions; the fuzzer runs flash loans too. 40–52% fewer compute units.
167
+ - Examples: Marginfi decodes its rates' u32 encodings in 64-bit arithmetic (no 128-bit division): accrual 45–73%
168
+ fewer compute units than the original (was 39–73%), 1,000–4,000 fewer on liquidations and bank configuration. The
169
+ receivership and deleverage tests now send the banks in the order the instructions between start and end leave
170
+ them, so their successful cases succeed on every run; the costs in docs/case-study-marginfi.md are re-measured
171
+ (receiverships 30–40% fewer, not 29–45%).
172
+ - Examples: Marginfi's deleverage, which completes part 4 of the port: `start_deleverage` and `end_deleverage` (the
173
+ risk admin's receivership, any account, health may not fall), `configure_deleverage_withdrawal_limit`,
174
+ `update_deleverage_withdrawals`, `lending_pool_force_tokenless_repay_complete` and `purge_deleverage_balance`.
175
+ Against the binary on mainnet: 890 transactions, the same IDL for all 40 ported instructions; the fuzzer
176
+ deleverages too.
177
+ - Examples: Marginfi's receivership liquidation (part 4 of the port): `start_liquidation` and `end_liquidation`, the
178
+ account's health and its banks' prices locked at the start and its health at those prices at the end (the premium
179
+ cap, a close-out under $5, the tag's growing premium, the record's entries, the flat SOL fee), the transaction's
180
+ instructions checked as the original checks them. Against the binary on mainnet: 847 transactions, the same IDL for
181
+ all 34 ported instructions; the fuzzer runs receiverships too. 29–45% fewer compute units on receivership
182
+ transactions.
183
+ - Examples: Marginfi's classic liquidation (part 4 of the port): `lending_account_liquidate`, the liquidatee's
184
+ collateral taken at a discount for its debt, the insurance fund's cut sent from the liability bank's vault, the
185
+ liquidatee's tag after it, the liquidator's health over its own accounts and its premium seeded, a halted bank left
186
+ to the admins, Token-2022. Against the binary on mainnet: 803 transactions, the same IDL for all 32 ported
187
+ instructions; the fuzzer liquidates too. 34–39% fewer compute units on liquidations.
188
+ - Examples: Marginfi's liquidation records and bankruptcy, the start of part 4 of the port:
189
+ `marginfi_account_init_liq_record`, `marginfi_account_tag_liq_record` (a liquidatable account tagged, the health
190
+ cache from the Maintenance pass), `marginfi_account_close_liq_record` and `lending_pool_handle_bankruptcy` (the
191
+ insurance vault first, Token-2022 fees included, the rest socialized, a bank killed when nothing is left). Against
192
+ the binary on mainnet: 736 transactions, the same IDL for all 31 ported instructions; the fuzzer tags and settles
193
+ bankruptcies too. 44–52% fewer compute units on bankruptcies, 45% on a tag.
194
+ - Examples: Marginfi's borrows and health pulses, which completes part 3 of the port: `lending_account_borrow`
195
+ (origination fees, the premium check, rate limits after health) and `lending_account_pulse_health` (three passes
196
+ keeping what each gets to, the indexer flags, the event with the cache). Against the binary on mainnet: 687
197
+ transactions, the same IDL for all 27 ported instructions; the fuzzer borrows and pulses too, and its keys now come
198
+ from its seed, so `FUZZ_SEED` reproduces a run exactly. 41–47% fewer compute units on borrows, 15–64% on pulses.
199
+
200
+ - New: helpers take the remaining accounts as a list. A `RemainingAccounts` parameter (`remainingAccounts()` at the
201
+ call) gives the helper `.length` and `.get(i)` over the same accounts, to read, load or pass on to another helper,
202
+ as a risk engine walks one [bank, oracle] group per position.
203
+ - Examples: Marginfi's withdrawals and risk engine (part 3, docs/case-study-marginfi.md): withdrawals of part or all
204
+ of a deposit, with the account's Initial health over Pyth, Switchboard and fixed prices (oracle errors recorded or
205
+ failing as the original's, e-mode and same-asset e-mode, the isolated tier, the deposit cap's discount), premium
206
+ projection and rate snapshots, the circuit breaker's gate, the liquidation tag, rate limits, receivership,
207
+ deleverage and Token-2022. Against the binary on mainnet: 177 new transactions (595 in all, an account with 16
208
+ positions among them), the same IDL for all
209
+ 25 ported instructions, and the random runs withdraw through the risk engine; 33–84% fewer compute units on the
210
+ withdrawals that succeed. The fuzzer found how the original records an undecodable oracle's error in the health
211
+ cache (0, the variant's index, not 6000).
212
+ - Fixed (Marginfi example): the oracle port below had made I80F48 products cost more (an accrual 26,983 compute units
213
+ instead of 25,296): with three functions multiplying 256-bit values, clang stopped inlining the multiplication.
214
+ The checked and wrapping products now hand everything that cannot overflow to the plain one.
215
+
216
+ - New: helpers take remaining accounts. A `RemainingAccount` parameter (`remainingAccounts().get(i)` at the call)
217
+ gives the helper the account's key, owner, lamports and data length, `readData` at any offset, and `loadAccount` /
218
+ `loadAccountMut` of a struct; a read-only view sees what the instruction already wrote through the same account, and
219
+ a `loadAccountMut` claims the account for the rest of the instruction (a second one fails with 2040).
220
+ - New: `require(condition, code)` with a `u32` code computed at run time fails with that code (a helper that returns
221
+ its error as a value, as Rust's `?` passes one on: `require(r.err === 0n, r.err)`); a zero code fails with 5100.
222
+ - Examples: Marginfi's oracles (part 3 of the port, docs/case-study-marginfi.md): pointing a bank at a Pyth push or
223
+ Switchboard pull feed, fixed prices, and the price cache pulse with the circuit breaker (tiers, escalation, the long
224
+ window, breaking a bank). Against the binary on mainnet: 174 new transactions over Pyth and Switchboard accounts
225
+ written byte for byte, the same IDL for all 24 ported instructions, and the random runs set oracles and pulse prices
226
+ through the breaker; 47–84% fewer compute units on the ones that succeed.
227
+
228
+ - Repository: the ports moved out of `examples/` and `test/` into `showcase/`: `showcase/mainnet/` (Raydium CP-Swap
229
+ and CLMM, Jito's MEV programs, Marginfi, coral-xyz/multisig), `showcase/program-examples/` (was `test/ports/`) and
230
+ `showcase/test/` (their tests, fuzzers, helpers and fixtures). `examples/` keeps the small programs the templates
231
+ come from. CI runs the compiler's tests (`pnpm test:core`) and the showcase (`pnpm test:showcase`) as separate jobs.
232
+ The release manifest and the codegen snapshot read both layouts, so older tags still build.
233
+
234
+ - Faster: `u256` multiplication (and so I80F48 products, `mulDiv`) multiplies only the 32-bit limbs that are not
235
+ zero: two 88-bit values take 9 products instead of 64. A Marginfi I80F48 product went from about 700 to about 380
236
+ compute units, and an interest accrual from 30,292 to 25,296 (against the original's 41,642); across Marginfi's
237
+ successful transactions the port now uses 36–97% fewer compute units than the original (24–97% before). Programs that use
238
+ `u256` or `mulDiv` build to different binaries: here examples/raydium-clmm and marginfi.
239
+ - New: a narrowed `Option` of a struct or fixed array (`args.inner !== null` before it) passes straight to a helper
240
+ that takes the struct or array.
241
+
242
+ - Examples: Marginfi's repayments and fees, which completes part 2 of the port (docs/case-study-marginfi.md):
243
+ repayments in part (the premium settled first) and in full (rounded up, the balance closed), tokenless repayments by
244
+ the risk admin, collecting a bank's fees, and the admin and permissionless withdrawals from its fee and insurance
245
+ vaults. Against the binary on mainnet: 244 transactions (63 new) with the same outcome, account bytes and events, the
246
+ same IDL for all 21 ported instructions, and the random runs repay and move fees too; 24–97% fewer compute units on
247
+ the ones that succeed.
248
+ - Changed: a token account or mint parameter that is an empty system account (never created) fails with
249
+ AccountNotInitialized (3012), as Anchor's `Account` / `InterfaceAccount` checks it, before the owner check (3007).
250
+
251
+ - Examples: Marginfi's accounts and deposits (part 2 of the port, docs/case-study-marginfi.md): opening accounts as
252
+ keypairs and PDAs, deposits (SPL Token, and Token-2022 with the transfer fee added), closing balances and accounts.
253
+ Against the binary on mainnet: the same outcome, account bytes and events on 181 transactions now (66 new), the same
254
+ IDL for all 16 ported instructions, and the random runs cover them; 27–97% fewer compute units on the ones that
255
+ succeed.
256
+ - Faster: Pubkeys and hashes are ordered eight bytes at a time (`a.compare(b)`, the Merkle proof check). A Marginfi
257
+ balance close, which sorts the account's balances, went from 6,610 to 1,865 compute units. Programs that compare
258
+ keys or hashes build to different binaries: here examples/raydium-cp-swap, raydium-clmm, jito-mev's two
259
+ distribution programs and marginfi.
260
+ - New: an Option argument with a default as a seed, `tag ?? 7n`, is recorded in the IDL as Anchor records
261
+ `tag.unwrap_or(7)`, and `typesol client` and `typesol/testing` derive such PDAs. Fix: `typesol client` refused an IDL
262
+ with such a seed (Marginfi's on-chain one).
263
+
264
+ - Examples: Marginfi's group and bank administration (part 2 of the port, docs/case-study-marginfi.md): eleven
265
+ instructions, from the fee state and groups to adding banks (SPL Token and Token-2022, with or without a seed),
266
+ configuring them (operational states, curves, liquidation fees, the circuit breaker, e-mode checks, frozen banks)
267
+ and accruing interest with the group's, insurance and program fees. Checked against the binary on mainnet
268
+ (test/programs/marginfi_v2.so): the same outcome, account bytes and events on 115 transactions, and on random runs
269
+ (`test/verification/fuzz-marginfi.test.ts`); 27–97% fewer compute units on the ones that succeed.
270
+ - Changed: the creates an instruction's body starts with now run before the other accounts' constraints, as Anchor
271
+ creates `init` accounts first. A transaction that breaks both fails with Anchor's code (Marginfi's fuzzer found one:
272
+ adding a bank at a taken address, signed by someone else). Programs that start with a create and have other
273
+ constraints compile differently: here examples/raydium-cp-swap, raydium-clmm, jito-mev's two distribution programs
274
+ and eleven ports under test/ports/tokens; their tests against the mainnet binaries pass as before.
275
+ - Changed: accounts of a zero-copy type (`@serialization bytemuck`) are checked as Anchor's `AccountLoader` checks
276
+ them: the owner first (3007, also for an account never created, where `Account<T>` gives 3012), then a
277
+ discriminator to read (3001, new) and match (3002), then the size (3003). No other program here has such an account,
278
+ so only examples/marginfi compiles differently from this.
279
+ - New: `Address<InstructionsSysvar, "Sysvar1nstructions1111111111111111111111111">` checks the sysvar's address as
280
+ Anchor's `address = …` constraint does (2012, in constraint order) instead of 3008; another address there is a
281
+ compile error.
282
+
283
+ - Repository: a NOTICE for the third-party material the tests use (Apache-2.0 program binaries in test/programs, with
284
+ the licence text, and the Marginfi and Raydium fixtures); a test that every committed binary is the one SOURCES.md
285
+ records (sha256); `scripts/fetch-programs.sh` reports fetched binaries whose hash differs.
286
+ - New: `f64`, a 64-bit float held as its IEEE bits, for event and account fields (`f64FromBits`, `f64Bits`; the IDL
287
+ says `f64`). No float arithmetic.
288
+ - New: `Option<FixedArray<T, N>>` fields (Anchor's `Option<[u16; 3]>`), readable after narrowing with `.get(i)` or
289
+ copied whole into a `FixedArray` field.
290
+ - New: structs holding Options at any depth (Anchor's `BankConfigOpt`, an `Option<InterestRateConfigOpt>` inside it)
291
+ are Borsh where they travel: in instruction arguments, and in `@layout borsh` events and accounts that hold them.
292
+ Their C layout stays fixed; the IDL describes them as Anchor's. Programs without such structs compile as before.
293
+ - `typesol port`: f64 fields, Borsh events for headers holding Options, data-enum `repr`; Marginfi's whole on-chain
294
+ IDL ports with every type and instruction argument as on chain, apart from seven instructions whose arguments are
295
+ an Option of a struct, an array, bytes or a Vec (not supported yet).
296
+ - Fix: a `Vec<FixedArray<T, N>>` argument (Anchor's `Vec<[u8; 32]>` proof) no longer fails in code generation.
297
+ - The repr(C) offset check applies to bytemuck zero-copy types and what they hold, not to repr(C) structs that only
298
+ travel as Borsh.
299
+
300
+ - Releases: each GitHub Release gets a manifest (`scripts/release-manifest.ts`): compiler and toolchain versions, the
301
+ sha256 of every example's and port's binary, IDL and C, the reference binaries and the test corpus. It also gets the
302
+ previous release's sources built by both packages, with their diff, so "the same binaries" can be checked and
303
+ redone by anyone (docs/testing.md). 0.37.0 → 0.38.0, checked by hand: all 67 programs of the 0.37.0 sources build to
304
+ the same binary and IDL.
305
+ - Examples: examples/marginfi begins a port of Marginfi v2 (mrgnlabs/marginfi-v2 @ c5d440f6, Apache-2.0; on mainnet
306
+ as MFv2hWf3… with the same 124 instructions, version 0.1.12 in its on-chain IDL). This first part has no
307
+ instructions yet: its 255 errors (from the on-chain IDL), its I80F48 fixed-point arithmetic and its 12 zero-copy
308
+ accounts with the 32 types they hold. The arithmetic gives the bits the `fixed` crate (1.28.0) gives, checked
309
+ against vectors that crate wrote (test/fixtures/marginfi/i80f48-oracle) and on random values. The accounts read
310
+ mainnet's group, a bank and the fee state as Anchor decodes them, and the IDL describes all 44 types as the
311
+ on-chain IDL does.
312
+ - New: `/** @code 6200 */` on an error enum member gives it that code, the members after it continuing from there
313
+ (Anchor's `Variant = 200`). `require("…")` errors come after the highest code. `typesol port` keeps an IDL's codes
314
+ this way.
315
+ - New: `/** @repr c */` (`packed`, `align N`; `@repr rust` on enums) and `/** @serialization bytemuck */` put an Anchor
316
+ zero-copy type's repr and serialization in the IDL. An unpacked `@repr c` struct must have its fields where C puts
317
+ them; a field that C would pad is a compile error.
318
+ - New: `/** @bytes */` on an integer field shows it in the IDL as `[u8; N]` (an `i128` for Marginfi's
319
+ `WrappedI80F48 { value: [u8; 16] }`); `/** @idlName _pad0 */` names a field in the IDL where the source cannot (a
320
+ leading underscore); a `key_` or `lamports_` field is `key` / `lamports` in the IDL. `typesol port` writes these
321
+ tags from the IDL, so a ported zero-copy account's IDL is the original's.
322
+ - New: a `loadAccountMut` view declared in a loop body ends with its iteration, so a later iteration may load the
323
+ same account again. `loadAccountMut<Dup<T>>` there also lets a remaining account be passed more than once, one view
324
+ at a time (without `Dup<…>` a repeat is still refused, 2040). Raydium CLMM's `swap_router_base_in` uses it: routes
325
+ back through a pool now run as on mainnet (two more transactions in its differential test). Only programs with
326
+ `loadAccountMut` in a loop compile differently (here examples/airdrop.ts and examples/raydium-clmm).
327
+
328
+ - Tests: random transactions against the mainnet binaries. `test/verification/fuzz-jito.test.ts` drives Jito's three
329
+ MEV programs and their ports through random tips, receiver and builder changes, epochs, roots, Merkle claims and
330
+ closes (with injected faults); Raydium CLMM's differential test adds a random run of swaps, positions and liquidity
331
+ changes. Every step must match the original (outcome, account bytes, events, log lines), with a new seed on every
332
+ run, CI's included (`FUZZ_SEED` reproduces one).
333
+
9
334
  ## 0.38.0 — 2026-11-01
10
335
 
11
336
  Raydium CLMM ported in full, and Jito's three MEV programs ported, each checked against its mainnet binary. The
@@ -21,7 +346,7 @@ same binaries as in 0.37.0.
21
346
  bytes and events, 33–84% fewer compute units.
22
347
  - Examples: examples/jito-mev, ports of Jito's three MEV programs (tip payment, tip distribution, priority fee
23
348
  distribution; all 24 instructions), checked against the mainnet binaries (test/programs/jito_*.so) on 150
24
- transactions: the same outcomes, account bytes, events and log lines, with 58–95% fewer compute units. The tip
349
+ transactions: the same outcomes, account bytes, events and log lines, with 58–79% fewer compute units (up to 95% on refused calls). The tip
25
350
  payment port follows the binary on mainnet, which is the program of Jito's #143 (no `claim_tips`). See
26
351
  docs/case-study-jito-mev.md.
27
352
  - New: a `Seeds<…>` bump stored in a struct field of another account, `"@config.bumps.vault"` (Anchor's
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <h3 align="center">Write Solana programs in TypeScript. Ship native SBF.</h3>
6
6
 
7
7
  <p align="center">
8
- <a href="https://github.com/typesol/typesol/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/typesol/typesol/actions/workflows/ci.yml/badge.svg?branch=main"></a>
8
+ <a href="https://github.com/typesol-lang/typesol/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/typesol-lang/typesol/actions/workflows/ci.yml/badge.svg?branch=main"></a>
9
9
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-3178C6"></a>
10
10
  <a href="https://www.npmjs.com/package/@typesol/cli"><img alt="npm version" src="https://img.shields.io/npm/v/@typesol/cli"></a>
11
11
  <img alt="Target: Solana SBF" src="https://img.shields.io/badge/target-Solana%20SBF-14F195">
@@ -180,10 +180,14 @@ checks it against the binary deployed on mainnet (same outcomes and account byte
180
180
  [docs/case-study-raydium-cp-swap.md](docs/case-study-raydium-cp-swap.md) does the same for Raydium CP-Swap's swaps and liquidity
181
181
  (pool creation included: same outcomes, account bytes and events on 70 transactions; 45–79% fewer compute units), and
182
182
  [docs/case-study-raydium-clmm.md](docs/case-study-raydium-clmm.md) for all 37 instructions of Raydium CLMM
183
- (pools, positions, swaps and routes, limit orders, rewards, admin: the same on 300 transactions; 33–84% fewer
183
+ (pools, positions, swaps and routes, limit orders, rewards, admin: the same on 302 transactions; 33–84% fewer
184
184
  compute units), and [docs/case-study-jito-mev.md](docs/case-study-jito-mev.md) for Jito's three MEV programs (tip
185
- payment, tip distribution with Merkle claims, priority fee distribution: the same on 150 transactions; 58–95% fewer
186
- compute units). Tests use `typesol/testing` (accounts by name, plain values; [docs/test-your-program.md](docs/test-your-program.md)). To go to
185
+ payment, tip distribution with Merkle claims, priority fee distribution: the same on 150 transactions; 58–79% fewer
186
+ compute units, up to 95% on refused calls), and [docs/case-study-marginfi.md](docs/case-study-marginfi.md) for
187
+ Marginfi v2 as far as it goes (administration, interest, accounts, deposits, repayments, fees, oracles, the risk
188
+ engine, withdrawals, borrows, health pulses, liquidation records, bankruptcy, classic and receivership liquidation, deleverage, flash loans, account, group, fee state and bank administration, emissions, bank metadata, orders, rebalances, resizing, the monitor archive, staked SOL, Solend, Kamino, Drift and JupLend banks (all 124 instructions), and every oracle setup: the same on
189
+ 2,081 transactions; 16–97% fewer compute
190
+ units, 30–40% on receiverships, 35–39% on liquidations, 17–64% on health pulses). Tests use `typesol/testing` (accounts by name, plain values; [docs/test-your-program.md](docs/test-your-program.md)). To go to
187
191
  mainnet (wallet, cost, deploy, IDL, verification), follow [docs/mainnet.md](docs/mainnet.md).
188
192
 
189
193
  ## How it works
@@ -211,7 +215,7 @@ Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts
211
215
  | --- | --- |
212
216
  | **Accounts** | `Signer`, `Account<T>`, `Mut<T>`, `Init<T>`, `InitIfNeeded<T>` (PDAs or keypair accounts, with Anchor's `space`; mints, token accounts and associated token accounts), `Zeroed<T>` (up to 10 MiB), optional accounts (`A \| null`), token accounts and mints, `SystemAccount`, programs, sysvars, and account groups (Anchor's composite accounts) |
213
217
  | **Constraints** | `HasOne`, `Seeds` (also from account fields and under another program; `pdaBump` like `ctx.bumps`), `CloseTo`, `Ata`, `Address`, `Owner`, `Executable`. They are checked before the body runs and recorded in the IDL, and take your own error as Anchor's `@ ErrorCode.X` does |
214
- | **Data** | `u8`…`u128`, `i8`…`i128`, `boolean`, `Pubkey`, `Hash`, nested structs, `FixedArray`, `FixedString`, `Option`, unit enums, data enums (discriminated unions), `Vec` that resizes its account, `FixedVec` lists anywhere, and Anchor's own byte layout (`@layout borsh`) to take over existing Anchor accounts and to pass, return and emit structs with String / Vec / Option fields as Anchor does |
218
+ | **Data** | `u8`…`u128`, `i8`…`i128`, `u256` (for computation), `f64` (as its bits, in events and accounts), `boolean`, `Pubkey`, `Hash`, nested structs, `FixedArray`, `FixedString`, `Option`, unit enums, data enums (discriminated unions), `Vec` that resizes its account, `FixedVec` lists anywhere, and Anchor's own byte layout (`@layout borsh`) to take over existing Anchor accounts and to pass, return and emit structs with String / Vec / Option fields as Anchor does |
215
219
  | **Control flow** | `if`, `for`, `for … of`, `while`, `switch` (with narrowing on data enums), ternaries, `??`, destructuring, helper functions (returning structs too, arrow functions, closures, function arguments, generics), list callbacks (`some`, `find`, `reduce`, …) across multiple files |
216
220
  | **CPIs** | System, SPL Token, Token-2022 (including extension reads, metadata and token groups), ATA, Memo, Stake, Metaplex Token Metadata, Core, Bubblegum. Generic `invoke` with PDA signing (one or several PDAs per call), return data, and typed bindings generated from any Anchor IDL (`typesol cpi`) |
217
221
  | **Events** | `emit` (log-based) and `emitCpi` (Anchor `emit_cpi!`, through a self-CPI) |
@@ -255,7 +259,7 @@ Subpath exports: `typesol/compiler`, `typesol/workspace`, `typesol/cpi`, `typeso
255
259
  The same counter, vault and escrow programs, written four ways. All four use the same instruction encoding, account
256
260
  layout and checks. They get identical transactions in LiteSVM and must end in identical account state. The table
257
261
  shows mean compute units per call (generated by `scripts/readme-bench.ts` from the benchmark run). The programs,
258
- scenarios and harness are in [typesol/benchmarks](https://github.com/typesol/benchmarks), which pins the compiler and
262
+ scenarios and harness are in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks), which pins the compiler and
259
263
  toolchain and records them with every result:
260
264
 
261
265
  <!-- bench:table -->
@@ -286,7 +290,7 @@ The official escrow ([tokens/escrow](https://github.com/solana-developers/progra
286
290
  deployed to Solana mainnet-beta in all four versions and called with the same mints, amounts and accounts, one
287
291
  instruction per transaction. The TypeSOL program was upgraded in place to 0.25.0 on 2026-10-29; the others are as first
288
292
  deployed on 2026-10-27. Each figure is the compute units of that transaction, linked to Solscan; the lowest per row is
289
- in bold. The deployed programs match these builds byte for byte (`typesol verify` for TypeSOL), and the TypeSOL
293
+ in bold. The deployed programs match their builds byte for byte (`typesol verify` for TypeSOL; that is the 0.25.0 build, not the current release), and the TypeSOL
290
294
  program's IDL is published on chain with `typesol idl publish`.
291
295
 
292
296
  | Transaction | TypeSOL | Pinocchio | Native Rust | Anchor |
@@ -304,7 +308,7 @@ version (13,585 to 22,585 CU of the make_offers above); programs that check the
304
308
  take_offer and refund_offer vary with it too. The escrow program's own part is steadier: TypeSOL's make_offer spent
305
309
  6,620 CU of its own on both offers. The Pinocchio version takes the offer PDA's bump from the client instead of
306
310
  searching for it. Mainnet figures differ from the LiteSVM means above. Every run, including the one before the
307
- upgrade, is in [typesol/benchmarks](https://github.com/typesol/benchmarks) (`results/`).
311
+ upgrade, is in [typesol-lang/benchmarks](https://github.com/typesol-lang/benchmarks) (`results/`).
308
312
 
309
313
  ## How it is tested
310
314
 
@@ -333,15 +337,25 @@ Details are in [docs/testing.md](docs/testing.md).
333
337
  | [`relay.ts`](examples/relay.ts), [`caller.ts`](examples/caller.ts) | generic `invoke`, PDA-signed transfers, return data |
334
338
  | [`profiles.ts`](examples/profiles.ts) | nested structs, FixedString, events |
335
339
  | [`orderbook/`](examples/orderbook) | a three-file, 28 KiB zero-copy limit order book |
336
- | [`raydium-cp-swap/`](examples/raydium-cp-swap) | Raydium CP-Swap's trading core: constant-product swaps, LP deposits and withdrawals, Token-2022 transfer fees, a price oracle |
337
- | [`raydium-clmm/`](examples/raydium-clmm) | Raydium CLMM in full: concentrated-liquidity positions as NFTs, swaps and multi-hop routes across tick arrays, limit orders, rewards, dynamic fees, u256 math |
338
- | [`jito-mev/`](examples/jito-mev) | Jito's tip payment, tip distribution and priority fee distribution: tips paid out per leader, Merkle-proof claims, epochs and expiry |
339
- | [`multisig.ts`](examples/multisig.ts) | coral-xyz/multisig: stored instructions run with `invokeInstruction`, a PDA signing, Anchor's Borsh accounts |
340
+
341
+ ### Showcase: ports checked against mainnet
342
+
343
+ [`showcase/`](showcase) holds programs ported from Anchor and checked against the binaries deployed on mainnet (same
344
+ outcomes, account bytes and events; [`showcase/test`](showcase/test)), and the ports of all 46
345
+ [solana-developers/program-examples](showcase/program-examples/README.md).
346
+
347
+ | | |
348
+ | --- | --- |
349
+ | [`raydium-cp-swap/`](showcase/mainnet/raydium-cp-swap) | Raydium CP-Swap's trading core: constant-product swaps, LP deposits and withdrawals, Token-2022 transfer fees, a price oracle |
350
+ | [`raydium-clmm/`](showcase/mainnet/raydium-clmm) | Raydium CLMM in full: concentrated-liquidity positions as NFTs, swaps and multi-hop routes across tick arrays, limit orders, rewards, dynamic fees, u256 math |
351
+ | [`jito-mev/`](showcase/mainnet/jito-mev) | Jito's tip payment, tip distribution and priority fee distribution: tips paid out per leader, Merkle-proof claims, epochs and expiry |
352
+ | [`marginfi/`](showcase/mainnet/marginfi) | Marginfi v2, in progress: I80F48 fixed-point arithmetic, zero-copy accounts, group and bank administration, interest, accounts, deposits, repayments, fees, Pyth and Switchboard oracles, the circuit breaker, the risk engine, withdrawals, borrows and health pulses, liquidation records, bankruptcy, classic and receivership liquidation, deleverage, flash loans, account, group, fee state and (part of) bank administration, checked against the mainnet binary; the rest of bank administration, orders, staked SOL and the integrations to come |
353
+ | [`multisig.ts`](showcase/mainnet/multisig/multisig.ts) | coral-xyz/multisig: stored instructions run with `invokeInstruction`, a PDA signing, Anchor's Borsh accounts |
340
354
 
341
355
  ## Status
342
356
 
343
357
  **TypeSOL is pre-1.0.** Releases follow the organization's
344
- [versioning policy](https://github.com/typesol/.github/blob/main/VERSIONING.md); [CHANGELOG.md](CHANGELOG.md) lists every
358
+ [versioning policy](https://github.com/typesol-lang/.github/blob/main/VERSIONING.md); [CHANGELOG.md](CHANGELOG.md) lists every
345
359
  change.
346
360
  - The compiler, runtime and tooling have been through internal security reviews and are covered by the tests above.
347
361
  - They have **not been audited by an independent firm**. Do not put significant value behind programs built with
@@ -370,5 +384,5 @@ built-in, a constraint or an error code. Then read [CONTRIBUTING.md](CONTRIBUTIN
370
384
 
371
385
  ## License
372
386
 
373
- [MIT](LICENSE). Third-party program binaries used by the tests are listed with their licenses in
374
- [test/programs/SOURCES.md](test/programs/SOURCES.md).
387
+ [MIT](LICENSE). The tests also use third-party program binaries and data, none of it in the npm package: see
388
+ [NOTICE](NOTICE) and [test/programs/SOURCES.md](test/programs/SOURCES.md).
package/SECURITY.md CHANGED
@@ -15,7 +15,7 @@ TypeSOL generates programs that hold funds. Treat it accordingly.
15
15
  ## Reporting a vulnerability
16
16
 
17
17
  Please report privately, not in a public issue: use the **"Report a vulnerability"** button on
18
- https://github.com/typesol/typesol/security (GitHub private vulnerability reporting). Include a minimal TypeSOL program and the steps that show the problem.
18
+ https://github.com/typesol-lang/typesol/security (GitHub private vulnerability reporting). Include a minimal TypeSOL program and the steps that show the problem.
19
19
  We aim to acknowledge reports within 3 days and to ship a fix or mitigation for confirmed issues as fast as
20
20
  their severity requires, with credit unless you prefer otherwise.
21
21
 
@@ -1,7 +1,9 @@
1
1
  import ts from "typescript";
2
2
  import { Reporter } from "./diagnostics.js";
3
- import { type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
3
+ import { type OptionInner, type DataEnumDef, type EnumDef, type GenericHelper, type Helper, type ProgramModel, type ScalarType, type StructDef, type StructField, type ValueType, isScalar } from "./model.js";
4
4
  export declare const LIB_PATH: string;
5
+ /** Members every account parameter has (`acct.key`, `acct.isSigner`, …): a struct held in an account cannot use them. */
6
+ export declare const ACCOUNT_MEMBERS: Set<string>;
5
7
  /** A struct used as account data: none of its fields may shadow an account member. */
6
8
  export declare function checkAccountMembers(s: StructDef, at: ts.Node, reporter: Reporter): void;
7
9
  /** Why a name cannot be used as a C member, or undefined when it can. */
@@ -40,17 +42,11 @@ export interface TypeScope {
40
42
  structArgs?: Map<string, string>;
41
43
  enums: Map<string, EnumDef>;
42
44
  dataEnums?: Map<string, DataEnumDef>;
43
- options: Map<string, ScalarType | {
44
- kind: "struct";
45
- name: string;
46
- }>;
45
+ options: Map<string, OptionInner>;
47
46
  }
48
47
  export declare function snakeCase(name: string): string;
49
- /**
50
- * An argument's IDL name. Anchor keeps arguments and accounts apart, so an instruction may take an account and an
51
- * argument of one name (`authority`); TypeScript cannot, so the argument is written with a trailing underscore
52
- * (`authority_`) and recorded without it.
53
- */
48
+ /** A struct field's IDL name: snake_case, and an account member's name plus "_" (`key_`) without the "_". */
49
+ export declare function fieldIdlName(name: string): string;
54
50
  export declare function argIdlName(name: string, accountNames: readonly string[]): string;
55
51
  export declare function discriminator(preimage: string): number[];
56
52
  /** Source text by absolute path: an editor's unsaved buffers, read instead of the files on disk. */
@@ -66,7 +62,6 @@ export declare function resolveArgAggregate(node: ts.TypeNode, scope: TypeScope,
66
62
  /** Resolve a type node that names a `typesol` export, returning the export name. */
67
63
  export declare function typesolName(node: ts.TypeNode, imports: Map<string, string>): string | undefined;
68
64
  export declare function resolveScalarType(node: ts.TypeNode, scope: TypeScope): ScalarType | undefined;
69
- /** `Option<T>` or `T | null` with a scalar T. Records the use so a C typedef / IDL type is emitted. */
70
65
  export declare function resolveOptionType(node: ts.TypeNode, scope: TypeScope): (ValueType & {
71
66
  kind: "option";
72
67
  }) | undefined;