@typesol/cli 0.33.0 → 0.35.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 CHANGED
@@ -6,6 +6,38 @@ codes, and says so here.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.35.0 — 2026-10-30
10
+
11
+ Token Metadata's Burn and the EpochSchedule and LastRestartSlot sysvars. Existing programs compile to the same binaries
12
+ as in 0.34.0.
13
+
14
+ - New: Token Metadata `burnV1` (Burn), for an NFT (with its master edition) or fungible asset held by a wallet or this
15
+ program's PDA.
16
+ - New: the EpochSchedule and LastRestartSlot sysvars: `slotsPerEpoch()`, `epochWarmup()`, `firstNormalEpoch()`,
17
+ `firstNormalSlot()`, `lastRestartSlot()`.
18
+ ## 0.34.0 — 2026-10-30
19
+
20
+ More of anchor-spl and Anchor's tooling: Memo and Stake CPIs, Token Metadata updates, Token-2022 token groups, the
21
+ SlotHashes sysvar, `@fallback`, account groups inside account groups, and `typesol clone` for tests against cluster
22
+ accounts. Existing programs compile to the same binaries as in 0.33.0.
23
+
24
+ - New: account groups inside account groups (Anchor's nested composite accounts): `d.p.vault`, nested in the IDL,
25
+ flattened by the client and `typesol/testing` (`dPVault` / `d_p_vault`).
26
+ - New: Token Metadata `updateMetadataAccountsV2` (Anchor's `update_metadata_accounts_v2`): the whole DataV2 or null,
27
+ a new update authority, primary sale and mutability, signed by the update authority (a PDA with seeds).
28
+ - New: `StakeProgram`: `initialize`, `authorize`, `delegate`, `deactivate`, `withdraw`, with the sysvars passed in as
29
+ anchor-spl does, signed by wallets or this program's PDAs.
30
+ - New: `typesol clone [<address>…]` (Anchor's `[test.validator.clone]`): cluster accounts and programs copied to
31
+ `tests/accounts/` (`"clone"` and `"accounts"` in `typesol.json`), which `testProgram` loads into its LiteSVM;
32
+ `loadClonedAccounts(svm, dir)` for a LiteSVM of your own.
33
+ - New: `/** @fallback */` (Anchor's `fallback`): an instruction without parameters run when no other matches the data,
34
+ short data included, instead of 101; it reads `const data = instructionData()` and `remainingAccounts()`.
35
+ - New: `MemoProgram`: `memoProgram.memo(text, [signers], signerSeeds?)`, SPL Memo v2 signed by wallets or this
36
+ program's PDAs.
37
+ - New: `SlotHashesSysvar`, the SlotHashes sysvar read as an account: `count`, `latestSlot`, `latestHash`.
38
+ - New: the Token Group interface on Token-2022: `initializeTokenGroup`, `initializeGroupMember`, `updateGroupMaxSize`,
39
+ `updateGroupAuthority`.
40
+
9
41
  ## 0.33.0 — 2026-10-30
10
42
 
11
43
  The rest of what large Anchor programs lean on: account groups (composite accounts), your errors on declarative
package/README.md CHANGED
@@ -208,7 +208,7 @@ Runtime failures point back to your source: `Error 6000 Unauthorized (counter.ts
208
208
  | **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 |
209
209
  | **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 |
210
210
  | **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 |
211
- | **CPIs** | System, SPL Token, Token-2022 (including extension reads and metadata), ATA, 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`) |
211
+ | **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`) |
212
212
  | **Events** | `emit` (log-based) and `emitCpi` (Anchor `emit_cpi!`, through a self-CPI) |
213
213
  | **Crypto & oracles** | `sha256`, `keccak256`, Merkle proofs, Ed25519 and secp256k1 signature checks, Pyth pull oracle, Switchboard |
214
214
  | **Interfaces** | custom discriminators (`@discriminator`), so a TypeSOL program can be a Token-2022 transfer hook, with extra accounts (ExtraAccountMetaList) |
@@ -221,6 +221,7 @@ The full reference, with every type, check and built-in, is in [docs/language.md
221
221
  | --- | --- |
222
222
  | `typesol init` | scaffold a project with a program, a LiteSVM test and TypeScript configs |
223
223
  | `typesol new <program>` | add another program and its test to a project |
224
+ | `typesol clone <address…>` | copy mainnet accounts and programs for the tests, loaded by `testProgram` |
224
225
  | `typesol build` | compile every program in `typesol.json`, or a single `.ts` file |
225
226
  | `typesol check` | typecheck and subset-check without compiling (every program of the project, or one file) |
226
227
  | `typesol deploy` | `solana program deploy` with the right program keypair (`--dry-run` prints the commands) |
package/dist/cli.js CHANGED
@@ -313,6 +313,36 @@ const COMMANDS = {
313
313
  return 0;
314
314
  },
315
315
  },
316
+ clone: {
317
+ usage: "typesol clone [<address>…] [--url <rpc>] [--config <solana cli config>] [--out <dir>]",
318
+ help: [
319
+ "Copy accounts and programs from a cluster for the tests (Anchor's [test.validator.clone]): each account to",
320
+ '<address>.json, each program to <address>.so (its ELF), in the project\'s tests/accounts ("accounts" in typesol.json)',
321
+ 'or --out. Without addresses, the project\'s "clone" list. testProgram loads that directory into its LiteSVM.',
322
+ "The RPC is --url, a cluster moniker, or the Solana CLI config.",
323
+ ].join("\n "),
324
+ options: { url: { type: "string" }, config: { type: "string" }, out: { type: "string" } },
325
+ async run(v, args) {
326
+ const ws = findWorkspace(process.cwd());
327
+ const addresses = args.length ? args : (ws?.clone ?? []);
328
+ if (!addresses.length)
329
+ throw new UsageError(`name the accounts to clone, or list them in ${CONFIG} as "clone": ["…"]`);
330
+ for (const a of addresses)
331
+ if (!decodeAddress(a))
332
+ throw new UsageError(`"${a}" is not a base58 Solana address`);
333
+ const dir = path.resolve(v.out ?? ws?.accounts ?? "accounts");
334
+ const rpcUrl = v.url ?? solanaConfig(v.config).url;
335
+ if (!rpcUrl)
336
+ throw new Error("no RPC: pass --url, or set json_rpc_url in the Solana CLI config");
337
+ const kit = await import("@solana/kit");
338
+ const { cloneAccounts } = await import("./tools/clone.js");
339
+ const lines = await cloneAccounts(kit.createSolanaRpc(clusterUrl(rpcUrl)), [...new Set(addresses)], dir);
340
+ for (const l of lines)
341
+ log(` ${l}`);
342
+ log(` ${lines.length} written to ${path.relative(process.cwd(), dir) || "."}`);
343
+ return 0;
344
+ },
345
+ },
316
346
  cpi: {
317
347
  usage: "typesol cpi <idl.json> [--out <file.ts>] [--prefix <name>] [--address <base58>]",
318
348
  help: "Generate TypeSOL helpers that call another program's instructions, from its Anchor IDL (0.30+/1.x or TypeSOL).",
@@ -94,6 +94,9 @@ const TYPE_EXPORTS = new Set([
94
94
  "PythPriceUpdate",
95
95
  "AssociatedTokenProgram",
96
96
  "TokenMetadataProgram",
97
+ "MemoProgram",
98
+ "StakeProgram",
99
+ "SlotHashesSysvar",
97
100
  "SwitchboardFeed",
98
101
  "HasOne",
99
102
  "TokenOf",
@@ -657,6 +660,14 @@ export function analyze(entry, files) {
657
660
  const ix = reporter.guard(() => analyzeInstruction(fn.node, reporter, scopeFor(fn.imports), structs, groups));
658
661
  if (!ix)
659
662
  continue;
663
+ // `/** @fallback */`: Anchor's fallback, run when no instruction matches the data (instead of 101).
664
+ if (ts.getJSDocTags(fn.node).some((t) => t.tagName.text === "fallback")) {
665
+ if (ix.accounts.length || ix.args.length || ix.returns)
666
+ reporter.error(fn.node.name ?? fn.node, "a @fallback takes no parameters and returns nothing: read remainingAccounts() and instructionData()");
667
+ if (instructions.some((o) => o.fallback))
668
+ reporter.error(fn.node.name ?? fn.node, "a program has at most one @fallback");
669
+ ix.fallback = true;
670
+ }
660
671
  instructions.push(ix);
661
672
  for (const a of ix.args)
662
673
  collectStructs(a.type, structs, dataEnums, argStructs);
@@ -1496,6 +1507,9 @@ const ACCOUNT_TYPES = new Set([
1496
1507
  "PythPriceUpdate",
1497
1508
  "AssociatedTokenProgram",
1498
1509
  "TokenMetadataProgram",
1510
+ "MemoProgram",
1511
+ "StakeProgram",
1512
+ "SlotHashesSysvar",
1499
1513
  "SwitchboardFeed",
1500
1514
  "HasOne",
1501
1515
  "TokenOf",
@@ -1576,40 +1590,7 @@ function analyzeInstruction(fn, reporter, scope, structs, groups = new Map()) {
1576
1590
  if (group) {
1577
1591
  if (p.type.typeArguments)
1578
1592
  reporter.fail(p.type, "account groups take no type arguments");
1579
- const members = [];
1580
- for (const m of group.decl.members) {
1581
- if (!ts.isPropertySignature(m) || !m.type || !ts.isIdentifier(m.name))
1582
- reporter.fail(m, "account groups hold plain fields");
1583
- if (m.questionToken)
1584
- reporter.fail(m, `optional accounts are written ${m.name.text}: A | null`);
1585
- if (ts.isTypeReferenceNode(m.type) && ts.isIdentifier(m.type.typeName) && groups.has(m.type.typeName.text))
1586
- reporter.fail(m.type, "account groups do not nest yet: list the inner group's accounts here");
1587
- if (!ACCOUNT_TYPES.has(typesolName(withoutNull(m.type), group.imports) ?? ""))
1588
- reporter.fail(m.type, `${group.decl.name.text} is an account group: every field is an account (pass values as instruction arguments)`);
1589
- const a = accountFrom(m.type, `${p.name.text}__${m.name.text}`, m, group.imports);
1590
- a.group = { param: p.name.text, field: m.name.text, type: group.decl.name.text };
1591
- members.push(a);
1592
- }
1593
- // Constraints in a group name its own fields (as in Anchor's composite accounts), then the instruction's.
1594
- const sibling = (n) => (members.some((x) => x.group.field === n) ? `${p.name.text}__${n}` : n);
1595
- const at = (n) => (n.startsWith("@") ? `@${sibling(n.slice(1).split(".")[0])}${n.slice(1).includes(".") ? n.slice(n.indexOf(".")) : ""}` : n);
1596
- for (const a of members) {
1597
- const c = a.constraints;
1598
- c.hasOne = c.hasOne.map((e) => {
1599
- if (!e.includes("=")) {
1600
- if (sibling(e) !== e)
1601
- (c.hasOneParams ??= new Map()).set(e, sibling(e));
1602
- return e;
1603
- }
1604
- const [f, param] = e.split("=");
1605
- return `${f}=${sibling(param)}`;
1606
- });
1607
- if (c.seeds)
1608
- c.seeds = { ...c.seeds, names: c.seeds.names.map(at), bump: c.seeds.bump && at(c.seeds.bump), program: c.seeds.program && at(c.seeds.program) };
1609
- if (c.closeTo)
1610
- c.closeTo = sibling(c.closeTo);
1611
- if (c.ata)
1612
- c.ata = { owner: sibling(c.ata.owner), mint: sibling(c.ata.mint) };
1593
+ for (const a of expandGroup(group, [p.name.text], new Set())) {
1613
1594
  a.index = accounts.length;
1614
1595
  accounts.push(a);
1615
1596
  }
@@ -1620,6 +1601,60 @@ function analyzeInstruction(fn, reporter, scope, structs, groups = new Map()) {
1620
1601
  accounts.push(a);
1621
1602
  });
1622
1603
  }
1604
+ /**
1605
+ * A group's accounts, in field order, named by their path (`pool__vault`, `pool__fees__vault` for a group inside a
1606
+ * group). Constraints in a group name its own fields first (as in Anchor's composite accounts), then the
1607
+ * instruction's parameters.
1608
+ */
1609
+ function expandGroup(group, path, visiting) {
1610
+ const name = group.decl.name.text;
1611
+ if (visiting.has(name))
1612
+ reporter.fail(group.decl.name, `${name} contains itself`);
1613
+ const prefix = path.join("__");
1614
+ const all = [];
1615
+ const own = [];
1616
+ for (const m of group.decl.members) {
1617
+ if (!ts.isPropertySignature(m) || !m.type || !ts.isIdentifier(m.name))
1618
+ reporter.fail(m, "account groups hold plain fields");
1619
+ if (m.questionToken)
1620
+ reporter.fail(m, `optional accounts are written ${m.name.text}: A | null`);
1621
+ const inner = ts.isTypeReferenceNode(m.type) && ts.isIdentifier(m.type.typeName) ? groups.get(m.type.typeName.text) : undefined;
1622
+ const innerBare = withoutNull(m.type);
1623
+ if (innerBare !== m.type && ts.isTypeReferenceNode(innerBare) && ts.isIdentifier(innerBare.typeName) && groups.has(innerBare.typeName.text))
1624
+ reporter.fail(m.type, "account groups cannot be optional; make the accounts inside it optional (field: A | null)");
1625
+ if (inner) {
1626
+ all.push(...expandGroup(inner, [...path, m.name.text], new Set([...visiting, name])));
1627
+ continue;
1628
+ }
1629
+ if (!ACCOUNT_TYPES.has(typesolName(withoutNull(m.type), group.imports) ?? ""))
1630
+ reporter.fail(m.type, `${name} is an account group: every field is an account (pass values as instruction arguments)`);
1631
+ const a = accountFrom(m.type, `${prefix}__${m.name.text}`, m, group.imports);
1632
+ a.group = { param: prefix, field: m.name.text, type: name, path };
1633
+ own.push(a);
1634
+ all.push(a);
1635
+ }
1636
+ const sibling = (n) => (own.some((x) => x.group.field === n) ? `${prefix}__${n}` : n);
1637
+ const at = (n) => (n.startsWith("@") ? `@${sibling(n.slice(1).split(".")[0])}${n.slice(1).includes(".") ? n.slice(n.indexOf(".")) : ""}` : n);
1638
+ for (const a of own) {
1639
+ const c = a.constraints;
1640
+ c.hasOne = c.hasOne.map((e) => {
1641
+ if (!e.includes("=")) {
1642
+ if (sibling(e) !== e)
1643
+ (c.hasOneParams ??= new Map()).set(e, sibling(e));
1644
+ return e;
1645
+ }
1646
+ const [f, param] = e.split("=");
1647
+ return `${f}=${sibling(param)}`;
1648
+ });
1649
+ if (c.seeds)
1650
+ c.seeds = { ...c.seeds, names: c.seeds.names.map(at), bump: c.seeds.bump && at(c.seeds.bump), program: c.seeds.program && at(c.seeds.program) };
1651
+ if (c.closeTo)
1652
+ c.closeTo = sibling(c.closeTo);
1653
+ if (c.ata)
1654
+ c.ata = { owner: sibling(c.ata.owner), mint: sibling(c.ata.mint) };
1655
+ }
1656
+ return all;
1657
+ }
1623
1658
  /** An account parameter (or a group's field) of type `typeNode`. */
1624
1659
  function accountFrom(typeNode, name, node, imports) {
1625
1660
  // Optional accounts: `Mut<Vault> | null` or `Optional<Mut<Vault>>`.
@@ -1651,8 +1686,8 @@ function analyzeInstruction(fn, reporter, scope, structs, groups = new Map()) {
1651
1686
  }
1652
1687
  // A group parameter's name is taken too: `pool.vault` reads its field, so no other parameter may be `pool`.
1653
1688
  for (const a of accounts)
1654
- if (a.group && [...args, ...accounts].some((o) => o.name === a.group.param))
1655
- reporter.error(a.node, `"${a.group.param}" names both an account group and another parameter`);
1689
+ if (a.group && [...args, ...accounts].some((o) => o.name === a.group.path[0]))
1690
+ reporter.error(a.node, `"${a.group.path[0]}" names both an account group and another parameter`);
1656
1691
  // Constraints refer to other parameters by name: check them now that all are known.
1657
1692
  for (const a of accounts) {
1658
1693
  const c = a.constraints;
@@ -1964,6 +1999,12 @@ function resolveAccountKind(node, reporter, imports, structs) {
1964
1999
  return { kind: "selfProgram" };
1965
2000
  case "AssociatedTokenProgram":
1966
2001
  return { kind: "ataProgram" };
2002
+ case "MemoProgram":
2003
+ return { kind: "memoProgram" };
2004
+ case "StakeProgram":
2005
+ return { kind: "stakeProgram" };
2006
+ case "SlotHashesSysvar":
2007
+ return { kind: "slotHashes" };
1967
2008
  case "TokenMetadataProgram":
1968
2009
  return { kind: "metadataProgram" };
1969
2010
  case "SwitchboardFeed": {
@@ -105,8 +105,12 @@ export declare abstract class EmitterBase {
105
105
  protected withoutBang(node: ts.Expression): ts.PropertyAccessExpression | undefined;
106
106
  /** The account an expression names: a parameter (`vault`) or a field of an account group (`pool.vault`). */
107
107
  protected accountAt(node: ts.Expression): AccountParam | undefined;
108
+ /** `pool.fees.vault` as ["pool", "fees", "vault"] when `pool` is an account group parameter. */
109
+ protected groupPath(node: ts.Expression): string[] | undefined;
108
110
  /** An account group parameter's name. */
109
111
  protected isGroup(name: string): boolean;
112
+ /** `pool` or `pool.fees`: a group (or a group inside one), not an account. */
113
+ protected isGroupValue(node: ts.Expression): boolean;
110
114
  protected accountParam(node: ts.Expression, what: string): AccountParam;
111
115
  protected assertUsable(a: AccountParam, node: ts.Node): void;
112
116
  protected abstract expect(v: Value, want: ValueType | undefined, node: ts.Node): Value;
@@ -132,6 +136,8 @@ export declare abstract class EmitterBase {
132
136
  protected abstract allocateOrAssign(node: ts.CallExpression, system: AccountParam, method: "allocate" | "assign"): undefined;
133
137
  protected abstract tokenOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
134
138
  protected abstract ataOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
139
+ protected abstract memoOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
140
+ protected abstract stakeOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
135
141
  protected abstract metadataOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
136
142
  protected abstract coreOp(node: ts.CallExpression, core: AccountParam, method: string): undefined;
137
143
  protected abstract bubblegumOp(node: ts.CallExpression, bg: AccountParam, method: string): undefined;
@@ -360,14 +360,36 @@ export class EmitterBase {
360
360
  accountAt(node) {
361
361
  if (ts.isIdentifier(node))
362
362
  return this.accounts.get(node.text);
363
- if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && this.isGroup(node.expression.text))
364
- return this.accounts.get(`${node.expression.text}__${node.name.text}`);
365
- return undefined;
363
+ const path = this.groupPath(node);
364
+ return path && path.length > 1 ? this.accounts.get(path.join("__")) : undefined;
365
+ }
366
+ /** `pool.fees.vault` as ["pool", "fees", "vault"] when `pool` is an account group parameter. */
367
+ groupPath(node) {
368
+ const names = [];
369
+ let e = node;
370
+ while (ts.isPropertyAccessExpression(e)) {
371
+ names.unshift(e.name.text);
372
+ e = e.expression;
373
+ }
374
+ if (!ts.isIdentifier(e) || !this.isGroup(e.text))
375
+ return undefined;
376
+ return [e.text, ...names];
366
377
  }
367
378
  /** An account group parameter's name. */
368
379
  isGroup(name) {
369
380
  for (const a of this.accounts.values())
370
- if (a.group?.param === name)
381
+ if (a.group?.path[0] === name)
382
+ return true;
383
+ return false;
384
+ }
385
+ /** `pool` or `pool.fees`: a group (or a group inside one), not an account. */
386
+ isGroupValue(node) {
387
+ const path = ts.isIdentifier(node) ? (this.isGroup(node.text) ? [node.text] : undefined) : this.groupPath(node);
388
+ if (!path)
389
+ return false;
390
+ const prefix = `${path.join("__")}__`;
391
+ for (const a of this.accounts.values())
392
+ if (a.name.startsWith(prefix))
371
393
  return true;
372
394
  return false;
373
395
  }
@@ -377,8 +399,8 @@ export class EmitterBase {
377
399
  return this.accountParam(node.expression, what);
378
400
  const a = this.accountAt(node);
379
401
  if (!a) {
380
- if (ts.isIdentifier(node) && this.isGroup(node.text))
381
- this.fail(node, `${what} must be an account; "${node.text}" is a group of accounts: pass one of its fields (${node.text}.…)`);
402
+ if (this.isGroupValue(node))
403
+ this.fail(node, `${what} must be an account; "${node.getText()}" is a group of accounts: pass one of its fields (${node.getText()}.…)`);
382
404
  if (!ts.isIdentifier(node))
383
405
  this.fail(node, `${what} must be an account parameter`);
384
406
  this.fail(node, `${what} must be an account parameter, "${node.text}" is not one`);
@@ -107,6 +107,21 @@ export class CallEmitter extends ExpressionEmitter {
107
107
  this.line(`TS_TRY(ts_minimum_balance(a_${a.name}->data_len, &${t}));`);
108
108
  return { c: t, type: U64 };
109
109
  }
110
+ case "slotsPerEpoch":
111
+ case "firstNormalEpoch":
112
+ case "firstNormalSlot":
113
+ case "epochWarmup":
114
+ case "lastRestartSlot": {
115
+ if (args.length !== 0)
116
+ this.fail(node, `${builtin}() takes no arguments`);
117
+ const t = this.tmp();
118
+ this.line(`uint64_t ${t};`);
119
+ if (builtin === "lastRestartSlot")
120
+ this.line(`TS_TRY(ts_last_restart_slot(&${t}));`);
121
+ else
122
+ this.line(`TS_TRY(ts_epoch_schedule(${{ slotsPerEpoch: 0, epochWarmup: 2, firstNormalEpoch: 3, firstNormalSlot: 4 }[builtin]}, &${t}));`);
123
+ return builtin === "epochWarmup" ? { c: `(${t} != 0)`, type: BOOL } : { c: t, type: U64 };
124
+ }
110
125
  case "currentSlot":
111
126
  case "currentEpoch":
112
127
  case "now": {
@@ -536,6 +551,8 @@ export class CallEmitter extends ExpressionEmitter {
536
551
  }
537
552
  case "returnData":
538
553
  return this.returnData(node);
554
+ case "instructionData":
555
+ this.fail(node, "bind the data to a local first: const data = instructionData()");
539
556
  case "fixedArray":
540
557
  this.fail(node, "fixedArray<T, N>(fill) is only allowed as a local declaration: const xs = fixedArray<u64, 4>(0n)");
541
558
  case "readonly":
@@ -687,6 +704,10 @@ export class CallEmitter extends ExpressionEmitter {
687
704
  return this.tokenOp(node, target, method);
688
705
  if (target?.kind.kind === "ataProgram")
689
706
  return this.ataOp(node, target, method);
707
+ if (target?.kind.kind === "memoProgram")
708
+ return this.memoOp(node, target, method);
709
+ if (target?.kind.kind === "stakeProgram")
710
+ return this.stakeOp(node, target, method);
690
711
  if (target?.kind.kind === "metadataProgram")
691
712
  return this.metadataOp(node, target, method);
692
713
  // Each Metaplex CPI in its own C block: its data buffer's stack slot is reused by the next one.
@@ -324,6 +324,8 @@ export class ExpressionEmitter extends StorageEmitter {
324
324
  }
325
325
  if (this.accountAt(node))
326
326
  this.fail(node, `"${node.getText()}" is an account; use ${node.getText()}.key for its address`);
327
+ if (this.isGroupValue(node))
328
+ this.fail(node, `"${node.getText()}" is a group of accounts; use one of its fields (${node.getText()}.…)`);
327
329
  if (ts.isIdentifier(node.expression) || this.accountAt(node.expression)) {
328
330
  const a = this.accountAt(node.expression);
329
331
  if (a) {
@@ -371,6 +373,16 @@ export class ExpressionEmitter extends StorageEmitter {
371
373
  if (field === "tokenProgram")
372
374
  return { c: `&${v}->owner`, type: PUBKEY };
373
375
  }
376
+ if (k.kind === "slotHashes") {
377
+ // u64 count, then (u64 slot, 32-byte hash) entries, newest first; the entry check ran at entry.
378
+ if (field === "count")
379
+ return { c: `ts_read_le(${v}->data, 8)`, type: U64 };
380
+ if (field === "latestSlot")
381
+ return { c: `ts_read_le(${v}->data + 8, 8)`, type: U64 };
382
+ if (field === "latestHash")
383
+ return { c: `((const SolPubkey *)(${v}->data + 16))`, type: HASH };
384
+ this.fail(node.name, "SlotHashesSysvar has count, latestSlot and latestHash");
385
+ }
374
386
  if (k.kind === "pyth") {
375
387
  // Raw fields of the update; pythPrice() is the checked read.
376
388
  const m = `${v}->data + pm_${a.name}`;
@@ -76,6 +76,13 @@ export class FunctionEmitter extends StatementEmitter {
76
76
  head.push(` TS_TRY(ts_check_switchboard(${v}, ${k.devnet}));`);
77
77
  if (k.kind === "ataProgram")
78
78
  head.push(` TS_TRY(ts_check_address(${v}, &TS_ATA_PROGRAM_ID));`);
79
+ if (k.kind === "memoProgram")
80
+ head.push(` TS_TRY(ts_check_address(${v}, &TS_MEMO_PROGRAM_ID));`);
81
+ if (k.kind === "stakeProgram")
82
+ head.push(` TS_TRY(ts_check_address(${v}, &TS_STAKE_PROGRAM_ID));`);
83
+ // SlotHashes: the address, and room for its length and one entry (u64 count, then (u64 slot, hash) newest first).
84
+ if (k.kind === "slotHashes")
85
+ head.push(` TS_TRY(ts_check_address(${v}, &TS_SLOT_HASHES_ID));`, ` if (${v}->data_len < 48 || ts_read_le(${v}->data, 8) == 0) TS_FAIL(TS_ERR_SYSVAR, "TypeSOL: SlotHashes has no entries");`);
79
86
  if (k.kind === "metadataProgram")
80
87
  head.push(` TS_TRY(ts_check_address(${v}, &TS_MPL_METADATA_ID));`);
81
88
  if (k.kind === "coreProgram")
@@ -14,6 +14,23 @@ type MplField = {
14
14
  /** Metaplex: Token Metadata, Core (plugins and external plugins) and Bubblegum. */
15
15
  export declare abstract class MetaplexEmitter extends TokenEmitter {
16
16
  protected metadataOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
17
+ /** Metaplex creators `[{ address, verified, share }, …]` (1 to 5, shares adding up to 100): 34 bytes each. */
18
+ protected mplCreators(list0: ts.Expression): {
19
+ buf: string;
20
+ count: string;
21
+ };
22
+ /**
23
+ * updateMetadataAccountsV2(metadata, updateAuthority, data | null, newUpdateAuthority | null, primarySaleHappened |
24
+ * null, isMutable | null, signerSeeds?): Anchor's `update_metadata_accounts_v2`. `data` is the whole new DataV2
25
+ * (`{ name, symbol, uri, sellerFeeBasisPoints, creators?, collection? }`); each null leaves that part as it is.
26
+ */
27
+ protected metadataUpdate(node: ts.CallExpression, program: AccountParam): undefined;
28
+ /**
29
+ * burnV1(authority, metadata, edition | null, mint, token, collectionMetadata | null, systemProgram,
30
+ * instructionsSysvar, tokenProgram, amount, signerSeeds?): Token Metadata's Burn (41, BurnArgs::V1) of a
31
+ * non-fungible (its master edition) or fungible asset held in `token`. The holder signs and gets the rent back.
32
+ */
33
+ protected metadataBurn(node: ts.CallExpression, program: AccountParam): undefined;
17
34
  /** CreateMasterEditionV3 (17) and Verify (52) with VerificationArgs::CollectionV1. */
18
35
  protected metadataCollectionOp(node: ts.CallExpression, program: AccountParam, method: string): undefined;
19
36
  /**