@typesol/cli 0.46.0 → 0.48.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 +164 -0
- package/NOTICE +10 -0
- package/README.md +9 -3
- package/dist/compiler/emit/base.d.ts +6 -0
- package/dist/compiler/emit/base.js +8 -0
- package/dist/compiler/emit/calls.js +18 -0
- package/dist/compiler/emit/cpi.js +3 -1
- package/dist/compiler/emit/function.js +7 -2
- package/dist/compiler/emit/program.js +5 -0
- package/dist/compiler/emit/statements.d.ts +29 -2
- package/dist/compiler/emit/statements.js +149 -6
- package/dist/compiler/emit/token.js +18 -1
- package/dist/compiler/toolchain.js +1 -0
- package/dist/idl-coder.d.ts +129 -0
- package/dist/idl-coder.js +567 -0
- package/dist/testing.d.ts +56 -8
- package/dist/testing.js +115 -34
- package/dist/workspace.js +0 -1
- package/docker/deps/0.47.0.lock.json +1206 -0
- package/docker/deps/0.48.0.lock.json +1206 -0
- package/docs/audit.md +6 -6
- package/docs/language-basics.md +2 -1
- package/docs/language-builtins.md +3 -1
- package/docs/language-chain.md +13 -1
- package/docs/language-cpi.md +26 -0
- package/docs/language-errors-events.md +15 -0
- package/docs/language-statements.md +1 -0
- package/docs/test-your-program.md +45 -4
- package/lib/typesol.d.ts +27 -0
- package/llms-full.txt +107 -10
- package/package.json +1 -5
- package/releases/0.46.0.json +817 -0
- package/releases/0.47.0.json +837 -0
- package/runtime/typesol_rt.h +274 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export type IdlTypeSpec = string | {
|
|
2
|
+
option: IdlTypeSpec;
|
|
3
|
+
} | {
|
|
4
|
+
coption: IdlTypeSpec;
|
|
5
|
+
} | {
|
|
6
|
+
vec: IdlTypeSpec;
|
|
7
|
+
} | {
|
|
8
|
+
array: [IdlTypeSpec, number | {
|
|
9
|
+
generic: string;
|
|
10
|
+
}];
|
|
11
|
+
} | {
|
|
12
|
+
defined: {
|
|
13
|
+
name: string;
|
|
14
|
+
generics?: IdlGenericArg[];
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
generic: string;
|
|
18
|
+
};
|
|
19
|
+
export type IdlGenericArg = {
|
|
20
|
+
kind: "type";
|
|
21
|
+
type: IdlTypeSpec;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "const";
|
|
24
|
+
value: string;
|
|
25
|
+
};
|
|
26
|
+
export type IdlFieldsSpec = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: IdlTypeSpec;
|
|
29
|
+
}[] | IdlTypeSpec[];
|
|
30
|
+
export interface IdlTypeDefSpec {
|
|
31
|
+
name: string;
|
|
32
|
+
generics?: ({
|
|
33
|
+
kind: "type";
|
|
34
|
+
name: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "const";
|
|
37
|
+
name: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
})[];
|
|
40
|
+
type: {
|
|
41
|
+
kind: "struct";
|
|
42
|
+
fields?: IdlFieldsSpec;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "enum";
|
|
45
|
+
variants: {
|
|
46
|
+
name: string;
|
|
47
|
+
fields?: IdlFieldsSpec;
|
|
48
|
+
}[];
|
|
49
|
+
} | {
|
|
50
|
+
kind: "type";
|
|
51
|
+
alias: IdlTypeSpec;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** The parts of an IDL the coder reads. */
|
|
55
|
+
export interface CoderIdl {
|
|
56
|
+
instructions: readonly {
|
|
57
|
+
name: string;
|
|
58
|
+
discriminator: readonly number[];
|
|
59
|
+
args: readonly {
|
|
60
|
+
name: string;
|
|
61
|
+
type: unknown;
|
|
62
|
+
}[];
|
|
63
|
+
}[];
|
|
64
|
+
accounts?: readonly {
|
|
65
|
+
name: string;
|
|
66
|
+
discriminator: readonly number[];
|
|
67
|
+
}[];
|
|
68
|
+
events?: readonly {
|
|
69
|
+
name: string;
|
|
70
|
+
discriminator: readonly number[];
|
|
71
|
+
}[];
|
|
72
|
+
types?: readonly unknown[];
|
|
73
|
+
}
|
|
74
|
+
export interface IdlCoderOptions {
|
|
75
|
+
/** A missing field or argument that is not an Option, or a key that names none, is an error (default false). */
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export declare class IdlCoder {
|
|
79
|
+
private readonly types;
|
|
80
|
+
private readonly instructions;
|
|
81
|
+
private readonly accountDefs;
|
|
82
|
+
private readonly eventDefs;
|
|
83
|
+
private readonly strict;
|
|
84
|
+
private readonly enc;
|
|
85
|
+
private readonly dec;
|
|
86
|
+
constructor(idl: CoderIdl, options?: IdlCoderOptions);
|
|
87
|
+
private resolve;
|
|
88
|
+
private arrayLen;
|
|
89
|
+
/** A defined type and the environment its fields are read in. */
|
|
90
|
+
private definition;
|
|
91
|
+
/** Throws for a shape the coder cannot read, naming it. A type may only contain itself inside an option or vec. */
|
|
92
|
+
private check;
|
|
93
|
+
/** The type's size when every value of it has the same size (as Anchor's layouts give a span), else undefined. */
|
|
94
|
+
private fixedSize;
|
|
95
|
+
private bigint;
|
|
96
|
+
private pubkey;
|
|
97
|
+
private write;
|
|
98
|
+
private items;
|
|
99
|
+
/**
|
|
100
|
+
* A struct's fields in order. A field left undefined is written as zeros when its size is fixed (what Anchor's coder
|
|
101
|
+
* does); a variable-size one cannot be, and throws. Strict: a missing field that is not an Option, and a key that
|
|
102
|
+
* names no field, throw.
|
|
103
|
+
*/
|
|
104
|
+
private fields;
|
|
105
|
+
/** Instruction data: the IDL's discriminator, then the arguments. */
|
|
106
|
+
encodeInstruction(name: string, args: Record<string, unknown>): Buffer;
|
|
107
|
+
/** Account data: the discriminator, then the account's fields. */
|
|
108
|
+
encodeAccount(name: string, value: unknown): Buffer;
|
|
109
|
+
/** A defined type's bytes. */
|
|
110
|
+
encodeType(name: string, value: unknown): Buffer;
|
|
111
|
+
private need;
|
|
112
|
+
/** The value of `type` at `at`, and the offset after it. */
|
|
113
|
+
private read;
|
|
114
|
+
private readFields;
|
|
115
|
+
/** An account's fields, after checking its discriminator. Bytes after the fields are ignored. */
|
|
116
|
+
decodeAccount(name: string, data: Uint8Array): Record<string, unknown>;
|
|
117
|
+
/** A defined type read from the start of `data`. Bytes after it are ignored. */
|
|
118
|
+
decodeType(name: string, data: Uint8Array): unknown;
|
|
119
|
+
/**
|
|
120
|
+
* An event's name and fields from its bytes (the discriminator, then the fields), as Anchor's `coder.events.decode`
|
|
121
|
+
* gives them from the same bytes in base64; null when the bytes start with none of the IDL's event discriminators.
|
|
122
|
+
*/
|
|
123
|
+
decodeEvent(data: Uint8Array): {
|
|
124
|
+
name: string;
|
|
125
|
+
data: Record<string, unknown>;
|
|
126
|
+
} | null;
|
|
127
|
+
/** An instruction's arguments read back from its data (after checking the discriminator). */
|
|
128
|
+
decodeInstruction(name: string, data: Uint8Array): Record<string, unknown>;
|
|
129
|
+
}
|