@typesol/cli 0.38.0 → 0.40.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 +373 -2
- package/README.md +43 -26
- package/SECURITY.md +1 -1
- package/dist/cli.js +37 -3
- package/dist/compiler/analyze.d.ts +6 -11
- package/dist/compiler/analyze.js +331 -34
- package/dist/compiler/emit/alias.js +3 -2
- package/dist/compiler/emit/base.d.ts +7 -1
- package/dist/compiler/emit/base.js +2 -0
- package/dist/compiler/emit/borsh.js +63 -2
- package/dist/compiler/emit/calls.d.ts +14 -1
- package/dist/compiler/emit/calls.js +311 -21
- package/dist/compiler/emit/cpi-core.js +17 -5
- package/dist/compiler/emit/cpi.js +81 -27
- package/dist/compiler/emit/create.d.ts +7 -0
- package/dist/compiler/emit/create.js +27 -0
- package/dist/compiler/emit/expressions.d.ts +6 -0
- package/dist/compiler/emit/expressions.js +102 -6
- package/dist/compiler/emit/function.d.ts +7 -0
- package/dist/compiler/emit/function.js +164 -29
- package/dist/compiler/emit/program.js +27 -2
- package/dist/compiler/emit/shared.d.ts +15 -5
- package/dist/compiler/emit/shared.js +5 -0
- package/dist/compiler/emit/statements.d.ts +28 -1
- package/dist/compiler/emit/statements.js +270 -13
- package/dist/compiler/emit/storage.d.ts +10 -1
- package/dist/compiler/emit/storage.js +50 -11
- package/dist/compiler/hints.d.ts +5 -0
- package/dist/compiler/hints.js +88 -0
- package/dist/compiler/idl.d.ts +1 -1
- package/dist/compiler/idl.js +42 -11
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/index.js +6 -1
- package/dist/compiler/model.d.ts +47 -10
- package/dist/compiler/model.js +14 -4
- package/dist/testing.js +8 -0
- package/dist/tools/clientgen.js +10 -1
- package/dist/tools/portgen.d.ts +6 -0
- package/dist/tools/portgen.js +68 -17
- package/docs/architecture.md +5 -4
- package/docs/audit.md +31 -19
- package/docs/case-study-escrow.md +5 -5
- package/docs/case-study-jito-mev.md +9 -5
- package/docs/case-study-marginfi.md +797 -0
- package/docs/case-study-multisig.md +3 -3
- package/docs/case-study-raydium-amm.md +80 -0
- package/docs/case-study-raydium-clmm.md +44 -33
- package/docs/case-study-raydium-cp-swap.md +3 -3
- package/docs/cli.md +5 -5
- package/docs/client.md +1 -1
- package/docs/errors.md +13 -5
- package/docs/language.md +65 -32
- package/docs/migrate-from-anchor.md +4 -1
- package/docs/runtime.md +1 -1
- package/docs/security-model.md +2 -1
- package/docs/testing.md +34 -1
- package/docs/troubleshooting.md +6 -0
- package/lib/typesol.d.ts +118 -10
- package/package.json +9 -7
- package/runtime/typesol_rt.h +158 -17
- package/ts-plugin/index.js +24 -1
|
@@ -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,
|
|
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
|
-
|
|
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;
|