@typesol/cli 0.41.0 → 0.43.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 (62) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/README.md +11 -7
  3. package/dist/compiler/analyze.js +484 -13
  4. package/dist/compiler/diagnostics.d.ts +1 -0
  5. package/dist/compiler/diagnostics.js +13 -0
  6. package/dist/compiler/emit/alias.d.ts +44 -0
  7. package/dist/compiler/emit/alias.js +135 -4
  8. package/dist/compiler/emit/base.d.ts +65 -7
  9. package/dist/compiler/emit/base.js +91 -7
  10. package/dist/compiler/emit/borsh.d.ts +7 -0
  11. package/dist/compiler/emit/borsh.js +86 -1
  12. package/dist/compiler/emit/calls.d.ts +169 -2
  13. package/dist/compiler/emit/calls.js +1170 -81
  14. package/dist/compiler/emit/cpi-core.d.ts +28 -5
  15. package/dist/compiler/emit/cpi-core.js +238 -12
  16. package/dist/compiler/emit/cpi.js +16 -16
  17. package/dist/compiler/emit/create.d.ts +3 -3
  18. package/dist/compiler/emit/create.js +33 -25
  19. package/dist/compiler/emit/expressions.js +89 -9
  20. package/dist/compiler/emit/function.js +2 -2
  21. package/dist/compiler/emit/outline.d.ts +24 -0
  22. package/dist/compiler/emit/outline.js +100 -0
  23. package/dist/compiler/emit/program.js +37 -3
  24. package/dist/compiler/emit/rbtree.d.ts +7 -0
  25. package/dist/compiler/emit/rbtree.js +142 -0
  26. package/dist/compiler/emit/shared.d.ts +43 -1
  27. package/dist/compiler/emit/shared.js +18 -2
  28. package/dist/compiler/emit/statements.d.ts +58 -1
  29. package/dist/compiler/emit/statements.js +549 -22
  30. package/dist/compiler/emit/storage.d.ts +48 -1
  31. package/dist/compiler/emit/storage.js +220 -63
  32. package/dist/compiler/emit/token.d.ts +11 -8
  33. package/dist/compiler/emit/token.js +233 -104
  34. package/dist/compiler/emit/views.d.ts +60 -0
  35. package/dist/compiler/emit/views.js +523 -0
  36. package/dist/compiler/hints.js +6 -0
  37. package/dist/compiler/idl.js +2 -1
  38. package/dist/compiler/model.d.ts +84 -4
  39. package/dist/compiler/model.js +19 -0
  40. package/dist/compiler/toolchain.d.ts +15 -0
  41. package/dist/compiler/toolchain.js +146 -11
  42. package/dist/testing-stake.d.ts +216 -0
  43. package/dist/testing-stake.js +526 -0
  44. package/dist/testing.d.ts +1 -0
  45. package/dist/testing.js +1 -0
  46. package/docs/architecture.md +9 -2
  47. package/docs/case-study-phoenix.md +226 -0
  48. package/docs/case-study-spl-stake-pool.md +122 -0
  49. package/docs/errors.md +1 -1
  50. package/docs/language.md +244 -20
  51. package/docs/migrate-from-anchor.md +1 -0
  52. package/docs/runtime.md +1 -1
  53. package/docs/security-model.md +4 -0
  54. package/docs/stability.md +33 -1
  55. package/docs/test-your-program.md +47 -0
  56. package/docs/testing.md +19 -0
  57. package/docs/troubleshooting.md +5 -2
  58. package/lib/typesol.d.ts +462 -44
  59. package/llms-full.txt +338 -26
  60. package/llms.txt +1 -1
  61. package/package.json +2 -2
  62. package/runtime/typesol_rt.h +476 -0
@@ -71,6 +71,89 @@ export function emitBorshCodecs(model) {
71
71
  for (const s of model.structs.values()) {
72
72
  if ((s.layout !== "borsh" && s.wire !== "borsh") || s.size === undefined)
73
73
  continue;
74
+ out.push(...codec(s, model, { unpack: `ts_unpack_${s.name}`, pack: `ts_pack_${s.name}`, deser: DESER, ser: SER, title: "Borsh (Anchor's account layout)" }));
75
+ }
76
+ return out;
77
+ }
78
+ /**
79
+ * C for `ts_bdec_<S>` / `ts_benc_<S>` of the structs `loadBorsh` / `storeBorsh` use (model.borshNative): the same
80
+ * straight-line codec, failing with a bare nonzero return (no log) so that the call site fails with BorshIoError.
81
+ */
82
+ export function emitNativeBorshCodecs(model) {
83
+ const out = [];
84
+ for (const name of model.borshNative) {
85
+ const s = model.structs.get(name);
86
+ out.push(...codec(s, model, {
87
+ unpack: `ts_bdec_${name}`,
88
+ pack: `ts_benc_${name}`,
89
+ deser: "return 1",
90
+ ser: "return 1",
91
+ title: "Borsh (loadBorsh / storeBorsh)",
92
+ utf8: true,
93
+ }));
94
+ }
95
+ return out;
96
+ }
97
+ /**
98
+ * Why `loadBorsh<T>` / `storeBorsh` cannot take a field of this type (their codec has no heap and no views), or
99
+ * undefined when it can.
100
+ */
101
+ function borshNativeUnsupported(t, model) {
102
+ if (borshIdentical(t, model))
103
+ return undefined;
104
+ switch (t.kind) {
105
+ case "fstring":
106
+ return undefined;
107
+ case "vec":
108
+ if (t.heap || t.cap === undefined)
109
+ return "a Vec<T> (it would live on the heap): use FixedVec<T, N>";
110
+ return borshIdentical(t.elem, model) || t.elem.kind === "fstring" ? undefined : "a FixedVec of Options, data enums or lists";
111
+ case "option": {
112
+ const inner = t.inner;
113
+ if (borshIdentical(inner, model))
114
+ return undefined;
115
+ const v = variableStruct(inner, model);
116
+ return v ? borshNativeStructUnsupported(v, model) : "an Option of a list, a string or a data enum";
117
+ }
118
+ case "struct": {
119
+ const v = variableStruct(t, model);
120
+ return v ? borshNativeStructUnsupported(v, model) : `${t.name} is itself @layout borsh: nest a plain struct (it is Borsh inside this one)`;
121
+ }
122
+ case "dataEnum": {
123
+ const e = model.dataEnums.get(t.name);
124
+ for (const v of e.variants)
125
+ for (const f of v.fields)
126
+ if (!borshIdentical(f.type, model))
127
+ return `${e.name} variant ${v.name}'s ${f.name} is not fixed-size (data enum payloads: integers, booleans, Pubkeys, unit enums, FixedArrays and structs of them)`;
128
+ return undefined;
129
+ }
130
+ case "array":
131
+ return "a FixedArray of Options, data enums, strings or lists";
132
+ case "string":
133
+ return "a string (a view of the bytes it was read from): use FixedString<N>";
134
+ default:
135
+ return `a ${t.kind} field`;
136
+ }
137
+ }
138
+ /** Why `loadBorsh<S>` / `storeBorsh` cannot take struct `s`, or undefined when they can. */
139
+ export function borshNativeStructUnsupported(s, model) {
140
+ if (s.size === undefined || s.viewsOnly)
141
+ return `${s.name} has string fields (views of the bytes it was read from): use FixedString<N>`;
142
+ if (s.vec)
143
+ return `${s.name} has a Vec<T> field (it would live on the heap): use FixedVec<T, N>`;
144
+ for (const f of s.fields) {
145
+ const why = borshNativeUnsupported(f.type, model);
146
+ if (why)
147
+ return `${s.name}.${f.name} is ${why}`;
148
+ }
149
+ return undefined;
150
+ }
151
+ /** The decode / encode pair of one struct. */
152
+ function codec(s, model, o) {
153
+ const out = [];
154
+ const DESER = o.deser;
155
+ const SER = o.ser;
156
+ {
74
157
  let k = 0;
75
158
  const tmp = (p) => `${p}${k++}`;
76
159
  // Bools and enum tags inside a Borsh-identical value: invalid ones fail, as Borsh deserialization does.
@@ -114,6 +197,8 @@ export function emitBorshCodecs(model) {
114
197
  `${pad}at += 4;`,
115
198
  `${pad}if (${l} > ${t.cap}) ${DESER};`,
116
199
  need(l, rest, pad),
200
+ // Bytes another program wrote (loadBorsh): checked as UTF-8 as Borsh String deserialization does.
201
+ ...(o.utf8 ? [`${pad}if (!ts_utf8_valid(src + at, ${l})) ${DESER};`] : []),
117
202
  `${pad}${lv}.len = ${l};`,
118
203
  `${pad}ts_memcpy(${lv}.bytes, src + at, ${l});`,
119
204
  `${pad}at += ${l};`,
@@ -356,7 +441,7 @@ export function emitBorshCodecs(model) {
356
441
  i++;
357
442
  }
358
443
  const min = borshMinSize(s, model);
359
- out.push(`/* ${s.name} as Borsh (Anchor's account layout) <-> its fixed-layout struct. */`, `__attribute__((noinline)) static uint64_t ts_unpack_${s.name}(const uint8_t *src, uint64_t len, TSS_${s.name} *out, uint64_t *used) {`, ` if (len < ${min}) ${DESER};`, ` uint64_t at = 0;`, ...unpackLines, ` if (used) *used = at;`, ` return SUCCESS;`, `}`, `__attribute__((noinline)) static uint64_t ts_pack_${s.name}(const TSS_${s.name} *in, uint8_t *dst, uint64_t cap, uint64_t *written) {`, ` if (cap < ${min}) ${SER};`, ` uint64_t at = 0;`, ...packLines, ` if (written) *written = at;`, ` return SUCCESS;`, `}`, "");
444
+ out.push(`/* ${s.name} as ${o.title} <-> its fixed-layout struct. */`, `__attribute__((noinline)) static uint64_t ${o.unpack}(const uint8_t *src, uint64_t len, TSS_${s.name} *out, uint64_t *used) {`, ` if (len < ${min}) ${DESER};`, ` uint64_t at = 0;`, ...unpackLines, ` if (used) *used = at;`, ` return SUCCESS;`, `}`, `__attribute__((noinline)) static uint64_t ${o.pack}(const TSS_${s.name} *in, uint8_t *dst, uint64_t cap, uint64_t *written) {`, ` if (cap < ${min}) ${SER};`, ` uint64_t at = 0;`, ...packLines, ` if (written) *written = at;`, ` return SUCCESS;`, `}`, "");
360
445
  }
361
446
  return out;
362
447
  }
@@ -1,12 +1,24 @@
1
1
  import ts from "typescript";
2
- import { type AccountParam, type ErrorDef, type FieldType, type Helper, type StructDef } from "../model.js";
3
- import { type Value, type Ref, type Closure } from "./shared.js";
2
+ import { type AccountParam, type ErrorDef, type FieldType, type Helper, type StructDef, type ValueType } from "../model.js";
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
6
  protected call(node: ts.CallExpression, topLevel: boolean): Value | undefined;
7
7
  /** "unsupported call" naming the callee, with the TypeSOL form of common JavaScript calls. */
8
8
  private unsupportedCall;
9
9
  protected vecMethod(node: ts.CallExpression, method: string, v: Ref): Value | undefined;
10
+ /**
11
+ * The methods a BigVec adds or changes (SPL's big_vec): `push` into the account's room, `retain`, and the refusals;
12
+ * undefined for the methods it shares with other lists (`set`).
13
+ */
14
+ private bigVecMethod;
15
+ /**
16
+ * BigVec::retain over struct elements, walked with a pointer: the predicate gets each element in place, a kept one
17
+ * costs its predicate and the step. `run` is the first element not yet moved (the run of kept ones since the last
18
+ * removal), `dst` where that run goes; each run moves down once, when the next removal (or the end) is found, and
19
+ * only once something before it was removed. The length is written once, at the end (the moves never reach it).
20
+ */
21
+ private retainStructs;
10
22
  /** sha256(...) / keccak256(...) over strings, Pubkeys, Hashes, integers (LE) and booleans. */
11
23
  protected hashCall(node: ts.CallExpression, fn: "sha256" | "keccak256"): Value;
12
24
  /**
@@ -33,9 +45,73 @@ export declare abstract class CallEmitter extends ExpressionEmitter {
33
45
  * sysvar (ts_ix_* in the runtime). Undefined when the call is something else.
34
46
  */
35
47
  protected instructionsCall(node: ts.CallExpression, callee: ts.PropertyAccessExpression, method: string): Value | undefined;
48
+ /** `fixedArray<T, N>(fill)` written inline (a list method, a map / filter chain or `for … of` over it). */
49
+ protected isInlineArray(node: ts.Expression): boolean;
50
+ /**
51
+ * Whether `node` is a read-only view of a Vec argument or the instruction data, without emitting code: a local or
52
+ * helper parameter holding one, or `.slice(start, end?)` of such a view.
53
+ */
54
+ protected isVecArgView(node: ts.Expression): boolean;
55
+ /**
56
+ * The view `node` names (see isVecArgView) as a `TS_VecArg` C expression. `.slice(start, end)` is elements start..end-1
57
+ * in place (`end` defaults to the length): unlike JS's slice it does not clamp, an `end` past the length or before
58
+ * `start` fails with 5104. Undefined when `node` is not such a view.
59
+ */
60
+ protected vecArgView(node: ts.Expression): {
61
+ c: string;
62
+ type: ValueType & {
63
+ kind: "vecArg";
64
+ };
65
+ } | undefined;
66
+ /**
67
+ * A list's elements as one contiguous run, for a bulk copy or a CPI: a Vec argument, the instruction data or a slice
68
+ * of them; a Vec, FixedVec, BigVec (slice) or FixedArray in account data or a local. Undefined for anything else.
69
+ */
70
+ protected listSpan(e: ts.Expression): {
71
+ items: string;
72
+ count: string;
73
+ elem: FieldType;
74
+ view: boolean;
75
+ } | undefined;
76
+ /** `pushAll(items)`'s source: a list of exactly `elem` (see listSpan). */
77
+ protected bulkSource(e: ts.Expression, elem: FieldType): {
78
+ items: string;
79
+ count: string;
80
+ };
81
+ /**
82
+ * Whether `node` names one account a choice may pick, without emitting code: a remaining account (`rest.get(i)`), a
83
+ * local or `RemainingAccount` helper parameter bound to one, an `AccountInfo` parameter, or a choice between those.
84
+ */
85
+ protected looksLikeAccountHandle(node: ts.Expression): boolean;
86
+ /**
87
+ * `c ? rest.get(5n) : reserve`: one of two accounts, chosen at run time (only the chosen side runs), as a `TsAccount *`
88
+ * usable wherever a remaining account is. Each side is a remaining account, a local or helper parameter bound to one,
89
+ * an `AccountInfo` parameter or another such choice; a `programAt` check is kept when both sides carry the same one.
90
+ */
91
+ protected accountChoice(node: ts.ConditionalExpression): Value;
36
92
  protected handle(node: ts.Expression): string | undefined;
37
93
  /** A declared account parameter or a remaining account, as a `TsAccount *` C expression. */
38
94
  protected anyAccount(node: ts.Expression, what: string): string;
95
+ /**
96
+ * An account argument of a typed CPI: a declared account parameter (`param`, its kind and writability checked by
97
+ * the caller), or a remaining account, a local bound to one, a RemainingAccount helper parameter or a loaded struct
98
+ * (no compile-time checks: the called program and the runtime check them).
99
+ */
100
+ protected cpiAccount(node: ts.Expression, what: string): CpiAcct;
101
+ /** A declared program parameter as the program of a typed CPI. */
102
+ protected programParam(a: AccountParam): CpiProgram;
103
+ /**
104
+ * `programAt<P>(acct)` / `sysvarAt<S>(acct)`: the account (a remaining account or an AccountInfo parameter) checked
105
+ * to be that program or sysvar by its key, once, then usable with P's typed methods. A wrong program fails with
106
+ * ProgramError.IncorrectProgramId and a wrong sysvar with ProgramError.InvalidArgument, as solana_program's checks do.
107
+ */
108
+ protected programAt(node: ts.CallExpression, fn: "programAt" | "sysvarAt"): Value;
109
+ /** A value `programAt` / `sysvarAt` checked (a local bound to one, or the call itself), as the program it is. */
110
+ protected programAtValue(node: ts.Expression): CpiProgram | undefined;
111
+ /** `stake.split(…)` on a programAt value: the same typed methods as on a declared program parameter. */
112
+ protected programAtMethod(node: ts.CallExpression, at: CpiProgram, method: string): Value | undefined;
113
+ /** StakeHistorySysvar's has / effective / activating / deactivating(epoch), on the sysvar account `h`. */
114
+ protected stakeHistoryRead(node: ts.CallExpression, h: string, method: string): Value;
39
115
  /** `readData<T>(account, offset)`: a bounds-checked little-endian read of any account's data. */
40
116
  protected readData(node: ts.CallExpression): Value;
41
117
  /** `writeData<T>(account, offset, value)`: a little-endian store into a writable AccountInfo's data. */
@@ -47,6 +123,58 @@ export declare abstract class CallEmitter extends ExpressionEmitter {
47
123
  * from byte 0, checked as a `#[repr(C)]` type's load_checked does: this program's (3007), large enough (3003).
48
124
  */
49
125
  protected loadRaw(node: ts.CallExpression, mut: boolean): Value;
126
+ /**
127
+ * A native account view's owner check (3007). In a program that makes such views the check goes through ts_owned: the
128
+ * last account found this program's passes with a pointer compare until a CPI or an owner write forgets it.
129
+ */
130
+ protected viewOwnerCheck(h: string): string;
131
+ /** An owner write or a CPI: the owner checks' cache (viewOwnerCheck) is forgotten. */
132
+ protected forgetOwners(): void;
133
+ /**
134
+ * The account a loadRaw-style view reads (its first argument): a remaining account, or an AccountInfo parameter of
135
+ * the instruction (`param`: its position, for the claim). `fn` names the call in messages.
136
+ */
137
+ protected rawAccount(node: ts.CallExpression, fn: string, mut: boolean): {
138
+ h: string;
139
+ param?: number;
140
+ };
141
+ /**
142
+ * A writable view's checks: the account is writable and loaded mutably once in the instruction (2040).
143
+ * NATIVE_ACCOUNT_WRITES: no writability check and no claim. The view writes in place; the runtime refuses the
144
+ * instruction if a read-only account's data changed, and two views of one account share its bytes (the loader
145
+ * gives a duplicate the same record), as two AccountInfos of one account share one buffer in Rust.
146
+ */
147
+ protected claimRawMut(node: ts.CallExpression, h: string, param: number | undefined): void;
148
+ /**
149
+ * `const v = loadBorsh<T>(acct)`: the account's data from byte 0 decoded as Borsh into a local `T` (a copy), as
150
+ * `try_from_slice_unchecked` reads it: no owner check, no discriminator, trailing bytes ignored; bytes that are not
151
+ * a valid `T` (too short, an Option tag or bool not 0/1, an enum tag out of range) fail with BorshIoError.
152
+ */
153
+ protected loadBorsh(node: ts.CallExpression, c: string, declared: StructDef | undefined): StructDef;
154
+ /**
155
+ * `storeBorsh(acct, value)`: `value` encoded as Borsh into the account's data from byte 0, as Rust's
156
+ * `value.serialize(&mut &mut data[..])` writes it: only the encoded bytes (the rest of the account is left as it
157
+ * was), BorshIoError when they do not fit. The account must be writable.
158
+ */
159
+ protected storeBorsh(node: ts.CallExpression): undefined;
160
+ /** The struct loadBorsh / storeBorsh decodes or encodes: from the type argument, else the declared type. */
161
+ private borshNativeStruct;
162
+ /** The account loadBorsh reads or storeBorsh writes (writable: checked at run time, or Mut<AccountInfo>). */
163
+ private borshAccount;
164
+ /**
165
+ * An account `closeRaw` / `assignOwner` writes in place: a remaining account (a helper's RemainingAccount, a ternary
166
+ * between them) or an AccountInfo parameter. Without NATIVE_ACCOUNT_WRITES it is checked as the other writes to
167
+ * accounts the compiler cannot see are: writable (3006; a parameter must be Mut<AccountInfo>), passed once (2040), and
168
+ * for `owned` this program's (3007). With the flag nothing is checked: the runtime judges the result, as it judges a
169
+ * native program's.
170
+ */
171
+ protected inPlaceAccount(node: ts.Expression, what: string, owned: boolean): string;
172
+ /** `TS_FAIL` with a built-in ProgramError (no custom code), logged as `require(…, ProgramError.X)` logs it. */
173
+ protected programErrorFail(name: string, node: ts.Node): string;
174
+ /** A failure with a built-in ProgramError's code: logged with `text`, or nothing under `PROGRAM_ERROR_LOG_PREFIX = null`. */
175
+ protected programFail(code: string, text: string): string;
176
+ /** `const ERROR_LOG_PREFIX = null`: the program's own errors (and codes returned by its helpers) log nothing. */
177
+ protected quietErrors(): boolean;
50
178
  /** `loadAccount<T>(acct)` / `loadAccountMut<T>(acct)`: checked view of a program account. */
51
179
  protected loadAccount(node: ts.CallExpression, mut: boolean): Value;
52
180
  /**
@@ -57,6 +185,12 @@ export declare abstract class CallEmitter extends ExpressionEmitter {
57
185
  protected migrate(node: ts.CallExpression, a: AccountParam, topLevel: boolean): Value | undefined;
58
186
  /** Whether a helper (or one it calls) grows a Vec, which needs the instruction's SystemProgram for rent. */
59
187
  private helperGrows;
188
+ /** Whether a helper's body (or a helper it calls) closes or resizes an account: closeRaw / resizeAccount. */
189
+ private helperResizes;
190
+ /** Whether a helper's body (or a helper it calls) makes a writable tree view, which may change a tree's structure. */
191
+ private helperMakesMutTree;
192
+ /** Whether a helper's body (or a helper it calls) calls one of these built-ins. */
193
+ private helperCalls;
60
194
  /**
61
195
  * A helper given a closure (a function that reads the caller's variables) for a function parameter: a closure only
62
196
  * runs where it is declared, so the helper is expanded here, like a closure, with the closure bound to the
@@ -77,11 +211,44 @@ export declare abstract class CallEmitter extends ExpressionEmitter {
77
211
  protected callHelper(node: ts.CallExpression, h: Helper): Value | undefined;
78
212
  /** One helper argument: a C argument list fragment (accounts, seeds, references) or a value to settle. */
79
213
  protected helperArg(h: Helper, p: Helper["params"][number], n: ts.Expression): Value | string;
214
+ /**
215
+ * An `Inout<T>` argument: a pointer to the caller's place itself (never a copy), which must be writable. A literal
216
+ * (`f({ … })`, `fixedArray(…)`) is built in a local of its own, as JS passes a fresh object; a ternary must pick
217
+ * between two places (a literal branch would be a copy the helper's writes never reach).
218
+ */
219
+ protected inoutArg(h: Helper, p: Helper["params"][number], n: ts.Expression): string;
220
+ /**
221
+ * The rules of a call with `Inout<T>` arguments, so the helper's pointer is the only way to the place while it runs
222
+ * (Rust's one `&mut` at a time) and stays valid: no other argument may share storage with an Inout one (two places,
223
+ * one inside the other, the same list's elements whatever their indexes, an account and a place in it); a place in
224
+ * a list whose elements can move is refused when the call may move them; a reference into the place read after the
225
+ * call is refused (the helper may replace what it points at). Places whose roots differ but may be the same bytes at
226
+ * run time (two `Dup<…>` accounts, two loadRawMut views under NATIVE_ACCOUNT_WRITES, a helper's account parameters)
227
+ * are compared at run time (2040).
228
+ */
229
+ protected checkInoutCall(node: ts.CallExpression, h: Helper, argNodes: readonly ts.Expression[], passed: (string | undefined)[]): void;
230
+ /**
231
+ * A struct, array or data-enum helper argument written as a literal (`f({ a: 1n, b: { c } })`, `g([1n, 2n])`, or a
232
+ * ternary with a literal branch): built in a local of its own, as `const x: T = { … }; f(x)` would, and passed by
233
+ * pointer (the helper cannot change it, and nothing else sees it). Undefined for anything else.
234
+ */
235
+ protected literalArg(n: ts.Expression, want: FieldType): string | undefined;
80
236
  /**
81
237
  * A struct/array/data-enum helper argument. Helpers that take accounts may change account data, so they get a
82
238
  * copy taken at the call (JS passes the object as it was); other helpers cannot write, so a pointer is enough.
83
239
  */
84
240
  protected snapshotPlace(lv: string, type: FieldType, h: Helper, node?: ts.Expression): string;
241
+ /**
242
+ * A FixedVec or FixedArray of `elem` given for a read-only list parameter: a `TS_VecArg` view of its elements (the
243
+ * length as it is at the call). A list this function holds (a local, a field of a struct it owns) is read in place;
244
+ * one in account data is copied first when the helper takes accounts, as a struct argument is (the helper may write
245
+ * the account). Undefined when `n` is not such a list.
246
+ */
247
+ protected listViewArg(n: ts.Expression, want: ValueType & {
248
+ kind: "vecArg";
249
+ }, h: Helper): string | undefined;
250
+ /** Whether `node` is a list this function holds on its stack (a local list, a field of a struct it owns), not account data. */
251
+ protected callerHoldsList(node: ts.Expression): boolean;
85
252
  /** Whether `node` is (part of) a struct value this function owns: `h`, `h.inner`, `h.list.get(i)`. */
86
253
  protected ownedRoot(node: ts.Expression): boolean;
87
254
  /** `signer([...seeds])` (one PDA signature), or a SignerSeeds parameter passed on. */