@typesol/cli 0.39.0 → 0.41.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 +74 -0
- package/README.md +29 -23
- package/dist/ai.d.ts +10 -0
- package/dist/ai.js +43 -0
- package/dist/cli.js +52 -4
- package/dist/compiler/analyze.js +13 -7
- package/dist/compiler/diagnostics.d.ts +2 -0
- package/dist/compiler/emit/base.d.ts +2 -1
- package/dist/compiler/emit/calls.d.ts +5 -0
- package/dist/compiler/emit/calls.js +173 -5
- package/dist/compiler/emit/expressions.d.ts +6 -0
- package/dist/compiler/emit/expressions.js +95 -2
- package/dist/compiler/emit/program.js +12 -0
- package/dist/compiler/emit/shared.d.ts +10 -0
- package/dist/compiler/emit/statements.d.ts +20 -1
- package/dist/compiler/emit/statements.js +177 -7
- package/dist/compiler/hints.d.ts +5 -0
- package/dist/compiler/hints.js +88 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/index.js +6 -1
- package/dist/tools/mcp.d.ts +11 -0
- package/dist/tools/mcp.js +208 -0
- package/dist/workspace.js +8 -0
- package/docs/ai.md +52 -0
- package/docs/audit.md +16 -14
- package/docs/case-study-marginfi.md +2 -2
- package/docs/case-study-raydium-amm.md +80 -0
- package/docs/case-study-raydium-cp-swap.md +77 -41
- package/docs/language.md +27 -7
- package/docs/stability.md +56 -0
- package/docs/testing.md +6 -5
- package/docs/troubleshooting.md +6 -0
- package/lib/typesol.d.ts +73 -2
- package/llms-full.txt +1195 -0
- package/llms.txt +30 -0
- package/package.json +4 -2
- package/runtime/typesol_rt.h +47 -0
- package/ts-plugin/index.js +24 -1
package/lib/typesol.d.ts
CHANGED
|
@@ -184,6 +184,14 @@ export declare function remainingAccounts(): RemainingAccounts;
|
|
|
184
184
|
*/
|
|
185
185
|
export declare function loadAccount<T>(account: RemainingAccount | AccountInfo): Account<T>;
|
|
186
186
|
export declare function loadAccountMut<T>(account: RemainingAccount | AccountInfo): Mut<T>;
|
|
187
|
+
/**
|
|
188
|
+
* A native (non-Anchor) program's own account as a fixed-layout struct, as a `#[repr(C)]` type's `load_checked` /
|
|
189
|
+
* `load_mut_checked` reads it: owned by this program (3007) and at least as large as the struct (3003). There is no
|
|
190
|
+
* discriminator: the fields start at byte 0. `loadRawMut` also requires the account to be writable and not loaded
|
|
191
|
+
* mutably twice in the instruction (2040). Bind it with const: `const amm = loadRawMut<AmmInfo>(ammInfo)`.
|
|
192
|
+
*/
|
|
193
|
+
export declare function loadRaw<T>(account: RemainingAccount | AccountInfo): Account<T>;
|
|
194
|
+
export declare function loadRawMut<T>(account: RemainingAccount | AccountInfo): Mut<T>;
|
|
187
195
|
|
|
188
196
|
/** 32 bytes of hash output (sha256 / keccak256, Merkle roots). Compare with `===`. */
|
|
189
197
|
export interface Hash {
|
|
@@ -553,6 +561,17 @@ export declare function masterEditionAddress(mint: Pubkey): Pubkey;
|
|
|
553
561
|
*/
|
|
554
562
|
export declare function bigEndian(value: bigint): Seed;
|
|
555
563
|
export declare function findProgramAddress(seeds: Seed[], program: Pubkey): Pubkey;
|
|
564
|
+
/**
|
|
565
|
+
* `Pubkey::create_program_address(seeds, program)`: the address of these seeds with the bump given as the last seed,
|
|
566
|
+
* or null when they give no program address (a point on the curve, or too many / too long seeds).
|
|
567
|
+
*/
|
|
568
|
+
export declare function createProgramAddress(seeds: Seed[], program: Pubkey): Pubkey | null;
|
|
569
|
+
/**
|
|
570
|
+
* Log `prefix` followed by the base64 (standard, padded) of a struct value's bytes, as a native program's
|
|
571
|
+
* `msg!("ray_log: {}", base64(bincode(log)))` does. The struct holds integers, Pubkeys and fixed arrays of them only,
|
|
572
|
+
* so its bytes are its serialized form.
|
|
573
|
+
*/
|
|
574
|
+
export declare function logBase64(prefix: string, value: object): void;
|
|
556
575
|
/** The bump of that canonical program address (`Pubkey::find_program_address(seeds, program).1`), to sign with it. */
|
|
557
576
|
export declare function findProgramAddressBump(seeds: Seed[], program: Pubkey): u8;
|
|
558
577
|
/** This program's address (`crate::ID`). */
|
|
@@ -1993,7 +2012,48 @@ export declare enum AnchorError {
|
|
|
1993
2012
|
* as computed at run time (`require(r.err === 0n, r.err)`, a helper returning its error as a value, as Rust's `?` passes
|
|
1994
2013
|
* one on); a zero code fails with 5100.
|
|
1995
2014
|
*/
|
|
1996
|
-
export declare function require(condition: boolean, error: string | AnchorError | u32): asserts condition;
|
|
2015
|
+
export declare function require(condition: boolean, error: string | AnchorError | ProgramError | u32): asserts condition;
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* Solana's built-in program errors (`solana_program::program_error::ProgramError`, no custom code): a native program's
|
|
2019
|
+
* `Err(ProgramError::InvalidInstructionData)`. `require(condition, ProgramError.InvalidInstructionData)` fails the same
|
|
2020
|
+
* way (the runtime reports the built-in error, not a custom one). Not listed in the IDL's errors.
|
|
2021
|
+
*/
|
|
2022
|
+
export declare enum ProgramError {
|
|
2023
|
+
InvalidArgument = 2,
|
|
2024
|
+
InvalidInstructionData = 3,
|
|
2025
|
+
InvalidAccountData = 4,
|
|
2026
|
+
AccountDataTooSmall = 5,
|
|
2027
|
+
InsufficientFunds = 6,
|
|
2028
|
+
IncorrectProgramId = 7,
|
|
2029
|
+
MissingRequiredSignature = 8,
|
|
2030
|
+
AccountAlreadyInitialized = 9,
|
|
2031
|
+
UninitializedAccount = 10,
|
|
2032
|
+
NotEnoughAccountKeys = 11,
|
|
2033
|
+
AccountBorrowFailed = 12,
|
|
2034
|
+
MaxSeedLengthExceeded = 13,
|
|
2035
|
+
InvalidSeeds = 14,
|
|
2036
|
+
BorshIoError = 15,
|
|
2037
|
+
AccountNotRentExempt = 16,
|
|
2038
|
+
UnsupportedSysvar = 17,
|
|
2039
|
+
IllegalOwner = 18,
|
|
2040
|
+
MaxAccountsDataAllocationsExceeded = 19,
|
|
2041
|
+
InvalidRealloc = 20,
|
|
2042
|
+
MaxInstructionTraceLengthExceeded = 21,
|
|
2043
|
+
BuiltinProgramsMustConsumeComputeUnits = 22,
|
|
2044
|
+
InvalidAccountOwner = 23,
|
|
2045
|
+
ArithmeticOverflow = 24,
|
|
2046
|
+
Immutable = 25,
|
|
2047
|
+
IncorrectAuthority = 26,
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* Stop the program as a Rust `panic!` / `unwrap()` on `None` / `unreachable!()` does: the message is logged and the
|
|
2052
|
+
* instruction fails with ProgramFailedToComplete (no error code). For porting native programs whose failures panic:
|
|
2053
|
+
* `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.
|
|
2055
|
+
*/
|
|
2056
|
+
export declare function panic(message?: string, location?: string): never;
|
|
1997
2057
|
/**
|
|
1998
2058
|
* Anchor's `constraint = condition @ error` on `account`. Written at the start of an instruction's body (before any
|
|
1999
2059
|
* other statement), it runs with that account's checks, after its has_one and before its owner check, so a transaction
|
|
@@ -2007,7 +2067,18 @@ export declare function constraint(account: AccountMeta | RemainingAccount | nul
|
|
|
2007
2067
|
* `data.get(i)`, or pass it on to `invokeInstruction`. A `/** @fallback *\/` instruction (Anchor's fallback: no
|
|
2008
2068
|
* parameters, run when no instruction matches) reads its input this way, and its accounts with remainingAccounts().
|
|
2009
2069
|
*/
|
|
2010
|
-
export declare function instructionData():
|
|
2070
|
+
export declare function instructionData(): InstructionBytes;
|
|
2071
|
+
|
|
2072
|
+
/** The instruction data, read in place: its bytes, and little-endian values at a byte offset. */
|
|
2073
|
+
export interface InstructionBytes extends IndexedList<u8> {
|
|
2074
|
+
/** The little-endian value at `offset`; reading past the end fails the instruction (5104). */
|
|
2075
|
+
readU8(offset: u64): u8;
|
|
2076
|
+
readU16(offset: u64): u16;
|
|
2077
|
+
readU32(offset: u64): u32;
|
|
2078
|
+
readU64(offset: u64): u64;
|
|
2079
|
+
readU128(offset: u64): u128;
|
|
2080
|
+
readPubkey(offset: u64): Pubkey;
|
|
2081
|
+
}
|
|
2011
2082
|
|
|
2012
2083
|
/** Write a string, integer or pubkey to the program log. */
|
|
2013
2084
|
export declare function log(value: string | bigint | Pubkey | Hash): void;
|