@typesol/cli 0.40.0 → 0.42.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 (57) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +9 -5
  3. package/dist/ai.d.ts +10 -0
  4. package/dist/ai.js +43 -0
  5. package/dist/cli.js +15 -1
  6. package/dist/compiler/analyze.js +44 -3
  7. package/dist/compiler/diagnostics.d.ts +2 -0
  8. package/dist/compiler/emit/base.d.ts +40 -7
  9. package/dist/compiler/emit/base.js +33 -0
  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 +102 -2
  13. package/dist/compiler/emit/calls.js +671 -50
  14. package/dist/compiler/emit/cpi-core.d.ts +9 -3
  15. package/dist/compiler/emit/cpi-core.js +12 -7
  16. package/dist/compiler/emit/cpi.js +8 -14
  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 +51 -2
  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 +7 -2
  24. package/dist/compiler/emit/shared.d.ts +35 -1
  25. package/dist/compiler/emit/shared.js +9 -1
  26. package/dist/compiler/emit/statements.d.ts +31 -0
  27. package/dist/compiler/emit/statements.js +272 -14
  28. package/dist/compiler/emit/storage.d.ts +27 -1
  29. package/dist/compiler/emit/storage.js +124 -11
  30. package/dist/compiler/emit/token.d.ts +11 -8
  31. package/dist/compiler/emit/token.js +233 -104
  32. package/dist/compiler/hints.js +6 -0
  33. package/dist/compiler/model.d.ts +20 -1
  34. package/dist/compiler/model.js +5 -0
  35. package/dist/testing-stake.d.ts +216 -0
  36. package/dist/testing-stake.js +526 -0
  37. package/dist/testing.d.ts +1 -0
  38. package/dist/testing.js +1 -0
  39. package/dist/tools/mcp.d.ts +11 -0
  40. package/dist/tools/mcp.js +208 -0
  41. package/dist/workspace.js +8 -0
  42. package/docs/ai.md +52 -0
  43. package/docs/architecture.md +1 -1
  44. package/docs/audit.md +16 -14
  45. package/docs/case-study-raydium-cp-swap.md +77 -41
  46. package/docs/case-study-spl-stake-pool.md +122 -0
  47. package/docs/errors.md +1 -1
  48. package/docs/language.md +107 -14
  49. package/docs/security-model.md +4 -0
  50. package/docs/stability.md +69 -0
  51. package/docs/test-your-program.md +47 -0
  52. package/docs/testing.md +19 -0
  53. package/lib/typesol.d.ts +241 -40
  54. package/llms-full.txt +1352 -0
  55. package/llms.txt +30 -0
  56. package/package.json +4 -2
  57. package/runtime/typesol_rt.h +69 -0
package/lib/typesol.d.ts CHANGED
@@ -119,6 +119,11 @@ export interface Vec<T> extends ListMethods<T> {
119
119
  * back: 3004, as under Anchor).
120
120
  */
121
121
  push(value: T, payer?: Mut<Signer>): void;
122
+ /**
123
+ * A FixedVec's bulk append (declared here so a Vec still passes where a FixedVec is expected): a Vec in account data
124
+ * grows one `push` at a time, so calling it on a Vec is a compile error.
125
+ */
126
+ pushAll(items: IndexedList<T>): void;
122
127
  /** Remove and return the last element, shrinking the account. */
123
128
  pop(): T;
124
129
  /** Remove every element, shrinking the account. */
@@ -137,11 +142,53 @@ export interface FixedVec<T, N extends number> extends ListMethods<T> {
137
142
  get(index: bigint): T;
138
143
  set(index: bigint, value: T): void;
139
144
  push(value: T): void;
145
+ /**
146
+ * Append every element of `items` in one copy (a memcpy, not a loop of pushes): another FixedVec, a Vec or FixedArray
147
+ * of the same elements, a Vec argument, or the instruction data or a slice of it (`out.pushAll(data.slice(a, b))`).
148
+ * More than the room left fails (5104) and appends nothing.
149
+ */
150
+ pushAll(items: IndexedList<T>): void;
140
151
  pop(): T;
141
152
  clear(): void;
142
153
  [Symbol.iterator](): Iterator<T>;
143
154
  readonly __capacity?: N;
144
155
  }
156
+ /**
157
+ * A native program's zero-copy list over the rest of an account (SPL's `big_vec::BigVec`, the stake pool's validator
158
+ * list): a u32 length, then the elements back to back, in an account allocated up front. Only the last field of a
159
+ * struct read with `loadRaw` / `loadRawMut`; its room is the account's (`capacity`), and it is never resized. Loading
160
+ * checks that the stored length fits in the account (ProgramError::AccountDataTooSmall). Elements are read and
161
+ * written in place (structs by reference).
162
+ */
163
+ export interface BigVec<T> extends ListMethods<T> {
164
+ readonly length: u64;
165
+ /** How many elements fit: (the account's size - the struct's fixed fields - 4) / size(T). */
166
+ readonly capacity: u64;
167
+ get(index: bigint): T;
168
+ set(index: bigint, value: T): void;
169
+ /** Append after the last element (BigVec::push); no room left fails with ProgramError::AccountDataTooSmall. */
170
+ push(value: T): void;
171
+ /**
172
+ * Keep the elements `fn` holds for, in order, moved down in place in one pass (BigVec::retain); the bytes past the new
173
+ * end keep what they held.
174
+ */
175
+ retain(fn: (x: T) => boolean): void;
176
+ /**
177
+ * Elements `start` to `end - 1` in place (BigVec::deserialize_mut_slice(start, end - start)), for `for … of`, the
178
+ * list methods, `get`, `set` and `.length` right where it is written. Unlike JS's slice it does not clamp: `end`
179
+ * past the length or before `start` fails with ProgramError::AccountDataTooSmall. `end` defaults to the length.
180
+ */
181
+ slice(start: bigint, end?: bigint): BigVecSlice<T>;
182
+ [Symbol.iterator](): Iterator<T>;
183
+ }
184
+ /** Some elements of a BigVec, in place: `bigVec.slice(start, end)`. */
185
+ export interface BigVecSlice<T> extends ListMethods<T> {
186
+ readonly length: u64;
187
+ get(index: bigint): T;
188
+ set(index: bigint, value: T): void;
189
+ [Symbol.iterator](): Iterator<T>;
190
+ }
191
+
145
192
  /** A FixedVec value holding these elements (`acct.owners = fixedVec([a, b])`, `{ owners: fixedVec([]) }`). */
146
193
  export declare function fixedVec<T>(items: T[]): FixedVec<T, never>;
147
194
 
@@ -173,6 +220,23 @@ export interface RemainingSlice extends Iterable<CpiAccount> {
173
220
  }
174
221
  export declare function remainingAccounts(): RemainingAccounts;
175
222
 
223
+ /**
224
+ * A remaining account (or an AccountInfo parameter) as a typed program: `const stake = programAt<StakeProgram>(rest.get(12n))`,
225
+ * then `stake.split(…)`, `token.mintTo(…)`, `system.transfer(…)` as on a declared program parameter, and passed to
226
+ * helpers that take that program type. Its key is checked once, here (ProgramError.IncorrectProgramId otherwise;
227
+ * TokenInterface: either token program). The typed methods take remaining accounts as well as declared ones: the
228
+ * compiler checks declared parameters (writable, signer), the called program and the runtime check remaining accounts.
229
+ */
230
+ export declare function programAt<
231
+ P extends StakeProgram | SystemProgram | TokenProgram | Token2022Program | TokenInterface | AssociatedTokenProgram | MemoProgram,
232
+ >(account: RemainingAccount | AccountInfo): P;
233
+ /**
234
+ * A remaining account (or an AccountInfo parameter) as a sysvar read in place: `sysvarAt<StakeHistorySysvar>(acct)`,
235
+ * bound to a const, then `.count`, `.latestEpoch`, `.effective(epoch)` …. Its key is checked once, here (ProgramError.InvalidArgument
236
+ * otherwise, as solana_program's `Sysvar::from_account_info`).
237
+ */
238
+ export declare function sysvarAt<S extends StakeHistorySysvar>(account: RemainingAccount | AccountInfo): S;
239
+
176
240
  /**
177
241
  * Read a struct of this program from a remaining account or an `AccountInfo` parameter (Anchor's
178
242
  * `AccountLoader::try_from` on an `UncheckedAccount`): owner, discriminator and size are checked.
@@ -192,6 +256,20 @@ export declare function loadAccountMut<T>(account: RemainingAccount | AccountInf
192
256
  */
193
257
  export declare function loadRaw<T>(account: RemainingAccount | AccountInfo): Account<T>;
194
258
  export declare function loadRawMut<T>(account: RemainingAccount | AccountInfo): Mut<T>;
259
+ /**
260
+ * A native program's Borsh account, as Rust's `try_from_slice_unchecked::<T>(&data)` reads it: the data from byte 0
261
+ * decoded into a local `T` (a copy; write it back with `storeBorsh`). No owner check and no discriminator; bytes after
262
+ * the value are ignored. Data too short for it, an Option tag or a boolean other than 0/1, or an enum tag out of range
263
+ * fail with `ProgramError.BorshIoError`. Bind it with const: `const pool = loadBorsh<StakePool>(stakePool)`.
264
+ */
265
+ export declare function loadBorsh<T>(account: RemainingAccount | AccountInfo): T;
266
+ /**
267
+ * Write `value` into the account's data from byte 0 as Borsh, as Rust's `value.serialize(&mut *data)` does: only the
268
+ * encoded bytes are written (an Option that became None leaves the old bytes after it as they were); an account too
269
+ * small for the encoding fails with `ProgramError.BorshIoError`. The account must be writable (`Mut<AccountInfo>`, or a
270
+ * remaining account checked at run time).
271
+ */
272
+ export declare function storeBorsh<T>(account: RemainingAccount | Mut<AccountInfo>, value: T): void;
195
273
 
196
274
  /** 32 bytes of hash output (sha256 / keccak256, Merkle roots). Compare with `===`. */
197
275
  export interface Hash {
@@ -344,48 +422,113 @@ export interface MemoProgram extends AccountMeta {
344
422
  memo(text: string, signers?: AccountMeta[], signerSeeds?: Seed[] | SignerSeeds): void;
345
423
  }
346
424
 
425
+ /** An account whose slot in a Stake CPI names another address: what `named(account, address)` gives. */
426
+ export interface NamedAccount {
427
+ readonly __named_account: void;
428
+ }
429
+ /**
430
+ * A Stake CPI's sysvar or stake config argument as solana_program's stake instruction builders write it: the
431
+ * instruction's account list names `address` (`SysvarC1ock…`), and `account` (the slot's account, whatever its key) is
432
+ * the account handed to the runtime, as Rust's `invoke_signed(&ix, &[stake, clock_info, …])` hands it. The runtime finds
433
+ * each named address among the CPI's accounts only: a slot holding another account fails the call with MissingAccount
434
+ * (Instruction references an unknown account), as the original does, even when the sysvar is elsewhere in the
435
+ * transaction. Only valid as such an argument.
436
+ */
437
+ export declare function named(account: AccountMeta, address: Pubkey): NamedAccount;
438
+
347
439
  /**
348
440
  * The native Stake program (`Stake1111…`). Its address is checked. The sysvar and config accounts it reads are
349
441
  * passed in, as anchor-spl's stake module does (`SysvarRent…`, `SysvarC1ock…`, `SysvarStakeHistory…`,
350
- * `StakeConfig…`). Each authority signs: a wallet, or a PDA of this program with `signerSeeds`.
442
+ * `StakeConfig…`), or as `named(account, address)` (a native port: the address in the instruction, the slot's account
443
+ * passed). Each authority signs: a wallet, or a PDA of this program with `signerSeeds`. The instructions and
444
+ * their accounts are solana-stake-interface's (`StakeInstruction`, bincode with a u32 tag). Every account may also be
445
+ * a remaining account (then the Stake program and the runtime check that it is writable and signed where it must).
351
446
  */
352
447
  export interface StakeProgram extends AccountMeta {
353
448
  readonly __stake_program: void;
354
- /** Initialize a stake account (created with 200 bytes, owned by the Stake program), with no lockup. */
355
- initialize(stake: AccountMeta, rentSysvar: AccountMeta, staker: Pubkey, withdrawer: Pubkey): void;
449
+ /**
450
+ * Initialize a stake account (created with 200 bytes, owned by the Stake program), with no lockup or with `lockup`:
451
+ * no withdrawal before `unixTimestamp` and `epoch` unless `custodian` signs.
452
+ */
453
+ initialize(
454
+ stake: AccountMeta,
455
+ rentSysvar: AccountMeta | NamedAccount,
456
+ staker: Pubkey,
457
+ withdrawer: Pubkey,
458
+ lockup?: { unixTimestamp: i64; epoch: u64; custodian: Pubkey },
459
+ ): void;
356
460
  /** Hand the staker or the withdrawer authority to `newAuthority`. */
357
461
  authorize(
358
462
  stake: AccountMeta,
359
- clockSysvar: AccountMeta,
463
+ clockSysvar: AccountMeta | NamedAccount,
464
+ authority: AccountMeta,
465
+ newAuthority: Pubkey,
466
+ which: "staker" | "withdrawer",
467
+ signerSeeds?: Seed[] | SignerSeeds,
468
+ ): void;
469
+ /** The same, with the lockup custodian signing (to change the withdrawer while a lockup is in force). */
470
+ authorize(
471
+ stake: AccountMeta,
472
+ clockSysvar: AccountMeta | NamedAccount,
360
473
  authority: AccountMeta,
361
474
  newAuthority: Pubkey,
362
475
  which: "staker" | "withdrawer",
476
+ custodian: AccountMeta,
363
477
  signerSeeds?: Seed[] | SignerSeeds,
364
478
  ): void;
365
479
  delegate(
366
480
  stake: AccountMeta,
367
481
  vote: AccountMeta,
368
- clockSysvar: AccountMeta,
369
- stakeHistorySysvar: AccountMeta,
370
- stakeConfig: AccountMeta,
482
+ clockSysvar: AccountMeta | NamedAccount,
483
+ stakeHistorySysvar: AccountMeta | NamedAccount,
484
+ stakeConfig: AccountMeta | NamedAccount,
371
485
  staker: AccountMeta,
372
486
  signerSeeds?: Seed[] | SignerSeeds,
373
487
  ): void;
374
- deactivate(stake: AccountMeta, clockSysvar: AccountMeta, staker: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
488
+ /** Move `lamports` (and their share of the stake) into `splitStake`: 200 bytes, owned by the Stake program, uninitialized. */
489
+ split(stake: AccountMeta, splitStake: AccountMeta, staker: AccountMeta, lamports: u64, signerSeeds?: Seed[] | SignerSeeds): void;
490
+ deactivate(stake: AccountMeta, clockSysvar: AccountMeta | NamedAccount, staker: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
491
+ withdraw(
492
+ stake: AccountMeta,
493
+ to: AccountMeta,
494
+ clockSysvar: AccountMeta | NamedAccount,
495
+ stakeHistorySysvar: AccountMeta | NamedAccount,
496
+ withdrawer: AccountMeta,
497
+ lamports: u64,
498
+ signerSeeds?: Seed[] | SignerSeeds,
499
+ ): void;
500
+ /** The same, with the lockup custodian signing (to withdraw while a lockup is in force). */
375
501
  withdraw(
376
502
  stake: AccountMeta,
377
503
  to: AccountMeta,
378
- clockSysvar: AccountMeta,
379
- stakeHistorySysvar: AccountMeta,
504
+ clockSysvar: AccountMeta | NamedAccount,
505
+ stakeHistorySysvar: AccountMeta | NamedAccount,
380
506
  withdrawer: AccountMeta,
381
507
  lamports: u64,
508
+ custodian: AccountMeta,
509
+ signerSeeds?: Seed[] | SignerSeeds,
510
+ ): void;
511
+ /** Merge `source` into `destination` (same authorities and lockup, compatible states); `source` is drained. */
512
+ merge(
513
+ destination: AccountMeta,
514
+ source: AccountMeta,
515
+ clockSysvar: AccountMeta | NamedAccount,
516
+ stakeHistorySysvar: AccountMeta | NamedAccount,
517
+ staker: AccountMeta,
382
518
  signerSeeds?: Seed[] | SignerSeeds,
383
519
  ): void;
520
+ /**
521
+ * The cluster's minimum delegation in lamports: a GetMinimumDelegation CPI and the u64 the Stake program returns
522
+ * (solana_program's `stake::tools::get_minimum_delegation`, failing as it does: InvalidInstructionData without
523
+ * return data or with another size, IncorrectProgramId when another program returned it).
524
+ */
525
+ getMinimumDelegation(): u64;
384
526
  }
385
527
 
386
528
  /**
387
529
  * The StakeHistory sysvar (`SysvarStakeHistory…`), read as an account: the cluster's stake per recent epoch (up to
388
- * 512, newest first), as the Stake program uses it for warmup and cooldown. The address is checked.
530
+ * 512, newest first), as the Stake program uses it for warmup and cooldown. The address is checked. A remaining
531
+ * account becomes one with `sysvarAt<StakeHistorySysvar>(acct)`.
389
532
  */
390
533
  export interface StakeHistorySysvar extends AccountMeta {
391
534
  readonly __stake_history: void;
@@ -418,21 +561,21 @@ export interface SlotHashesSysvar extends AccountMeta {
418
561
  export interface AssociatedTokenProgram extends AccountMeta {
419
562
  readonly __ata_program: void;
420
563
  create(
421
- payer: Mut<Signer>,
564
+ payer: Mut<Signer> | RemainingAccount,
422
565
  ata: AccountMeta,
423
566
  owner: AccountMeta,
424
567
  mint: AccountMeta,
425
- systemProgram: SystemProgram,
426
- tokenProgram: TokenProgram | Token2022Program | TokenInterface,
568
+ systemProgram: SystemProgram | RemainingAccount,
569
+ tokenProgram: TokenProgram | Token2022Program | TokenInterface | RemainingAccount,
427
570
  ): void;
428
571
  /** Like create, but succeeds if the account already exists. */
429
572
  createIdempotent(
430
- payer: Mut<Signer>,
573
+ payer: Mut<Signer> | RemainingAccount,
431
574
  ata: AccountMeta,
432
575
  owner: AccountMeta,
433
576
  mint: AccountMeta,
434
- systemProgram: SystemProgram,
435
- tokenProgram: TokenProgram | Token2022Program | TokenInterface,
577
+ systemProgram: SystemProgram | RemainingAccount,
578
+ tokenProgram: TokenProgram | Token2022Program | TokenInterface | RemainingAccount,
436
579
  ): void;
437
580
  }
438
581
  /** The associated token account address of `owner` for `mint` under `tokenProgram`. */
@@ -1552,6 +1695,28 @@ export declare function firstNormalEpoch(): u64;
1552
1695
  export declare function firstNormalSlot(): u64;
1553
1696
  /** The LastRestartSlot sysvar: the last slot the cluster restarted at (0 if never). */
1554
1697
  export declare function lastRestartSlot(): u64;
1698
+ /** The EpochRewards sysvar, as `epochRewards()` reads it: read-only; keep it in a local (`const er = epochRewards()`). */
1699
+ export interface EpochRewards {
1700
+ /** The block height the rewards distribution started at in the current epoch. */
1701
+ readonly distributionStartingBlockHeight: u64;
1702
+ /** How many partitions the distribution has (seeds the partition hasher). */
1703
+ readonly numPartitions: u64;
1704
+ /** The parent blockhash of the epoch's first block (seeds the partition hasher). */
1705
+ readonly parentBlockhash: Hash;
1706
+ /** Sum of delegated stake × credits observed over all delegations. */
1707
+ readonly totalPoints: u128;
1708
+ /** The rewards calculated for the epoch, in lamports. */
1709
+ readonly totalRewards: u64;
1710
+ /** The rewards distributed so far, in lamports. */
1711
+ readonly distributedRewards: u64;
1712
+ /** Whether the rewards period (calculation and distribution) is active: stake accounts are being credited. */
1713
+ readonly active: boolean;
1714
+ }
1715
+ /**
1716
+ * The EpochRewards sysvar through the `sol_get_epoch_rewards_sysvar` syscall, Rust's `EpochRewards::get()` (no account
1717
+ * needed). Native programs refuse stake operations while `epochRewards().active`.
1718
+ */
1719
+ export declare function epochRewards(): EpochRewards;
1555
1720
  export type CloseTo<A, Destination extends string> = A & { readonly __closeTo?: Destination };
1556
1721
 
1557
1722
  /** A program-owned account that this instruction creates as a PDA. */
@@ -1660,47 +1825,61 @@ export interface SystemProgram extends AccountMeta {
1660
1825
  * Create `account` with `space` bytes owned by `owner`, funded by `payer`. The new account signs: a
1661
1826
  * `Mut<Signer>` keypair, or a PDA of this program when you pass its `signerSeeds` (with the bump).
1662
1827
  */
1663
- createAccount(payer: Mut<Signer>, account: AccountMeta, lamports: u64, space: u64, owner: Pubkey, signerSeeds?: Seed[] | SignerSeeds): void;
1828
+ createAccount(
1829
+ payer: Mut<Signer> | RemainingAccount,
1830
+ account: AccountMeta,
1831
+ lamports: u64,
1832
+ space: u64,
1833
+ owner: Pubkey,
1834
+ signerSeeds?: Seed[] | SignerSeeds,
1835
+ ): void;
1664
1836
  /**
1665
1837
  * Anchor's `init` with `seeds`, `space` and `owner = …` on an `UncheckedAccount`: `account` must be the PDA of this
1666
1838
  * program for `seeds` (no bump; 2006 otherwise); it is created with `space` bytes owned by `owner`, or, when someone
1667
1839
  * already funded the address, topped up to rent, allocated and assigned. Returns the bump. Among the creates a body
1668
1840
  * starts with, it runs before the other accounts' constraints, as Anchor's `init` does.
1669
1841
  */
1670
- createPda(payer: Mut<Signer>, account: Mut<AccountInfo>, space: u64, owner: Pubkey, seeds: Seed[]): u8;
1842
+ createPda(payer: Mut<Signer> | RemainingAccount, account: Mut<AccountInfo> | RemainingAccount, space: u64, owner: Pubkey, seeds: Seed[]): u8;
1671
1843
  /** System Allocate: give `account` `space` bytes of data. It signs: a keypair, or a PDA of this program with `signerSeeds`. */
1672
1844
  allocate(account: AccountMeta, space: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1673
1845
  /** System Assign: make `owner` the account's owner. It signs: a keypair, or a PDA of this program with `signerSeeds`. */
1674
1846
  assign(account: AccountMeta, owner: Pubkey, signerSeeds?: Seed[] | SignerSeeds): void;
1675
1847
  }
1676
1848
 
1849
+ /**
1850
+ * A token account or mint argument of a token CPI: a `TokenAccount` / `Mint` parameter (checked on entry), an
1851
+ * `AccountInfo` parameter, or a remaining account (the token program checks those).
1852
+ */
1853
+ type TokenAccountArg = TokenAccount | AccountInfo | RemainingAccount;
1854
+ type MintArg = Mint | AccountInfo | RemainingAccount;
1855
+
1677
1856
  /**
1678
1857
  * Token program operations. Pass `signerSeeds` (including the bump) when `authority` is a PDA of this program.
1679
1858
  * Prefer transferChecked: Token-2022 mints with extensions (transfer fees, hooks) require it.
1680
1859
  */
1681
1860
  interface TokenOps {
1682
- transfer(from: TokenAccount, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1683
- transferChecked(from: TokenAccount, mint: Mint, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1861
+ transfer(from: TokenAccountArg, to: TokenAccountArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1862
+ transferChecked(from: TokenAccountArg, mint: MintArg, to: TokenAccountArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1684
1863
  /** `mint`: a Mut<Mint>, or a mint this instruction created and initialized (Mut<Signer> / Mut<AccountInfo>). */
1685
1864
  /** `to`: a Mut<TokenAccount>, or a Mut<AccountInfo> token account this instruction created (e.g. with `ata.create`). */
1686
- mintTo(mint: Mint | AccountMeta, to: TokenAccount | AccountInfo, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1687
- burn(from: TokenAccount, mint: Mint, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1865
+ mintTo(mint: MintArg | AccountMeta, to: TokenAccountArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1866
+ burn(from: TokenAccountArg, mint: MintArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1688
1867
  /** Close a token account (empty), or under Token-2022 a mint with no supply left (its MintCloseAuthority signs). */
1689
- closeAccount(account: TokenAccount | Mint, destination: AccountMeta, authority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1868
+ closeAccount(account: TokenAccountArg | MintArg, destination: AccountMeta, authority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1690
1869
  /** Let `delegate` move up to `amount` from `source`. */
1691
- approve(source: TokenAccount, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1692
- revoke(source: TokenAccount, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1870
+ approve(source: TokenAccountArg, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1871
+ revoke(source: TokenAccountArg, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1693
1872
  /** The checked forms read the decimals from `mint`; Token-2022 mints with some extensions require them. */
1694
- approveChecked(source: TokenAccount, mint: Mint, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1695
- mintToChecked(mint: Mint, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1696
- burnChecked(from: TokenAccount, mint: Mint, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1873
+ approveChecked(source: TokenAccountArg, mint: MintArg, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1874
+ mintToChecked(mint: MintArg, to: TokenAccountArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1875
+ burnChecked(from: TokenAccountArg, mint: MintArg, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1697
1876
  /** Change or remove (null) an authority of a mint or token account: `AuthorityType.MintTokens`, …. */
1698
1877
  setAuthority(target: AccountMeta, currentAuthority: AccountMeta, authorityType: u8, newAuthority: Pubkey | null, signerSeeds?: Seed[] | SignerSeeds): void;
1699
1878
  /** `account`: a Mut<TokenAccount>, or (freezeAccount) a Mut<AccountInfo> token account this instruction created. */
1700
- freezeAccount(account: TokenAccount | AccountInfo, mint: AccountMeta, freezeAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1701
- thawAccount(account: TokenAccount, mint: AccountMeta, freezeAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1879
+ freezeAccount(account: TokenAccountArg, mint: AccountMeta, freezeAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1880
+ thawAccount(account: TokenAccountArg, mint: AccountMeta, freezeAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1702
1881
  /** Update a wrapped-SOL account's amount after lamports were sent to it. */
1703
- syncNative(account: TokenAccount): void;
1882
+ syncNative(account: TokenAccountArg): void;
1704
1883
  /** Initialize a mint created with systemProgram.createAccount (InitializeMint2: no rent sysvar needed). */
1705
1884
  initializeMint2(mint: AccountMeta, decimals: u8, mintAuthority: Pubkey, freezeAuthority: Pubkey | null): void;
1706
1885
  /** Initialize a token account created with systemProgram.createAccount (InitializeAccount3). */
@@ -1781,9 +1960,9 @@ interface Token2022Ops {
1781
1960
  updateInterestRate(mint: AccountMeta, rateAuthority: AccountMeta, rate: i16, signerSeeds?: Seed[] | SignerSeeds): void;
1782
1961
  /** TransferFee TransferCheckedWithFee: `fee` must be the fee Token-2022 computes for `amount`; decimals are the mint's. */
1783
1962
  transferCheckedWithFee(
1784
- from: TokenAccount,
1785
- mint: Mint,
1786
- to: TokenAccount,
1963
+ from: TokenAccountArg,
1964
+ mint: MintArg,
1965
+ to: TokenAccountArg,
1787
1966
  authority: AccountMeta,
1788
1967
  amount: u64,
1789
1968
  fee: u64,
@@ -1792,7 +1971,7 @@ interface Token2022Ops {
1792
1971
  /** TransferFee HarvestWithheldTokensToMint: move withheld fees from the given token accounts (passed on writable as they were passed) to the mint. */
1793
1972
  harvestWithheldTokensToMint(mint: AccountMeta, sources: RemainingAccounts | RemainingSlice): void;
1794
1973
  /** TransferFee WithdrawWithheldTokensFromMint: the fees held by the mint to `destination`. */
1795
- withdrawWithheldTokensFromMint(mint: AccountMeta, destination: TokenAccount, withdrawAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1974
+ withdrawWithheldTokensFromMint(mint: AccountMeta, destination: TokenAccountArg, withdrawAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1796
1975
  /** TransferFee SetTransferFee: takes effect two epochs later. */
1797
1976
  setTransferFee(mint: AccountMeta, configAuthority: AccountMeta, basisPoints: u16, maximumFee: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1798
1977
 
@@ -2051,9 +2230,17 @@ export declare enum ProgramError {
2051
2230
  * Stop the program as a Rust `panic!` / `unwrap()` on `None` / `unreachable!()` does: the message is logged and the
2052
2231
  * instruction fails with ProgramFailedToComplete (no error code). For porting native programs whose failures panic:
2053
2232
  * `location` ("program/src/instruction.rs:482:17") is the place the runtime reports, as the original's panic gives it;
2054
- * by default this source line.
2233
+ * by default this source line. A `null` message logs nothing, for a program whose panic handler writes no line of its
2234
+ * own: `panic(null, "src/lib.rs:105:19")` leaves only the runtime's "SBF program Panicked in src/lib.rs at 105:19".
2235
+ */
2236
+ export declare function panic(message?: string | null, location?: string): never;
2237
+ /**
2238
+ * Stop the program as Rust's `abort` does on SBF (the allocator's out-of-memory error, `std::process::abort`): the
2239
+ * runtime's `abort` syscall, which fails the instruction with ProgramFailedToComplete and logs "SBF program panicked"
2240
+ * (no location, nothing else). Log the original's own line first where it writes one:
2241
+ * `log("Error: memory allocation failed, out of memory"); abort();`.
2055
2242
  */
2056
- export declare function panic(message?: string, location?: string): never;
2243
+ export declare function abort(): never;
2057
2244
  /**
2058
2245
  * Anchor's `constraint = condition @ error` on `account`. Written at the start of an instruction's body (before any
2059
2246
  * other statement), it runs with that account's checks, after its has_one and before its owner check, so a transaction
@@ -2069,8 +2256,22 @@ export declare function constraint(account: AccountMeta | RemainingAccount | nul
2069
2256
  */
2070
2257
  export declare function instructionData(): InstructionBytes;
2071
2258
 
2072
- /** The instruction data, read in place: its bytes, and little-endian values at a byte offset. */
2073
- export interface InstructionBytes extends IndexedList<u8> {
2259
+ /**
2260
+ * The instruction data, read in place: its bytes, and little-endian values at a byte offset. A list of u8 like any other
2261
+ * (`for (const b of data)`, `map` / `filter` / `reduce` / `some` …), read-only; a helper takes it (or a slice) as an
2262
+ * `InstructionBytes` parameter.
2263
+ */
2264
+ export interface InstructionBytes extends IndexedList<u8>, ListMethods<u8> {
2265
+ readonly length: u64;
2266
+ /** The byte at `index` (5104 past the end). */
2267
+ get(index: bigint): u8;
2268
+ /**
2269
+ * Bytes `start` to `end - 1` in place, a view with the same methods (nothing is copied). Unlike JS's slice it does
2270
+ * not clamp: `end` past the length or before `start` fails the instruction (5104). `end` defaults to the length.
2271
+ * Copy one into a local list with `out.pushAll(data.slice(a, b))`.
2272
+ */
2273
+ slice(start: bigint, end?: bigint): InstructionBytes;
2274
+ [Symbol.iterator](): Iterator<u8>;
2074
2275
  /** The little-endian value at `offset`; reading past the end fails the instruction (5104). */
2075
2276
  readU8(offset: u64): u8;
2076
2277
  readU16(offset: u64): u16;