@sig-net/midnight-serde 0.23.0 → 0.24.0-rc.10

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.
@@ -1,48 +0,0 @@
1
- import type { CompactType, CompactUintType, CompactValueOf } from "./types.ts";
2
- /**
3
- * The EXCLUSIVE upper bound of a uint descriptor, whichever form it uses.
4
- *
5
- * @param type - The uint descriptor to read.
6
- * @returns One past the largest value the descriptor admits.
7
- */
8
- export declare function uintBound(type: CompactUintType): bigint;
9
- /**
10
- * Packed byte size of an ALREADY-VALIDATED descriptor. Package-internal: the
11
- * public {@link compactSerializedSize} validates first.
12
- *
13
- * @param type - A descriptor that has already passed validation.
14
- * @returns The packed byte size.
15
- */
16
- export declare function packedSize(type: CompactType): number;
17
- /**
18
- * Packed byte size of a type, before `serialize<T, N>`'s right zero-padding.
19
- *
20
- * @param type - The descriptor to size.
21
- * @returns The packed byte size.
22
- * @throws {Error} If the descriptor is not a well-formed Compact type.
23
- */
24
- export declare function compactSerializedSize(type: CompactType): number;
25
- /**
26
- * Byte-exact twin of `serialize<T, padTo>(value)`. With `padTo` omitted the
27
- * packed value is returned unpadded, matching `serialize<T, packedSize>`.
28
- *
29
- * The value parameter is typed from the descriptor (see `CompactValueOf`), so
30
- * a literal descriptor gets compile-time checking of the value shape, and the
31
- * same shape is enforced again at runtime.
32
- *
33
- * @param type - The descriptor the value conforms to.
34
- * @param value - The value to pack, shaped by the descriptor.
35
- * @param padTo - Total output length; omit to return the value unpadded.
36
- * @returns The packed bytes.
37
- * @throws {Error} If the descriptor or the value fails validation, or `padTo` is
38
- * smaller than the packed size.
39
- */
40
- export declare function compactSerialize<const T extends CompactType>(type: T, value: CompactValueOf<T>, padTo?: number): Uint8Array;
41
- /**
42
- * Display name of a uint descriptor in its own declaration form.
43
- *
44
- * @param type - The uint descriptor to name.
45
- * @returns `Uint<bits>` for the sized form, `Uint<0..bound>` for the bounded one.
46
- */
47
- export declare function uintName(type: CompactUintType): string;
48
- //# sourceMappingURL=serialize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AA+B7F;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAKvD;AAmBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CA2BpD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAG/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAC1D,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EACxB,KAAK,CAAC,EAAE,MAAM,GACb,UAAU,CAeZ;AA0ID;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAKtD"}
package/dist/serialize.js DELETED
@@ -1,292 +0,0 @@
1
- // Byte-exact twin of Compact's builtin `serialize<T, N>` from
2
- // CompactStandardLibrary, pinned against compiled circuits by tests/.
3
- //
4
- // Layout rules (compactc 0.33 / language 0.25):
5
- // - struct fields and tuple elements are packed in declaration order, no
6
- // alignment gaps
7
- // - every value is little-endian at its NATURAL width (see src/types.ts);
8
- // bounded uints and enums are as wide as their largest legal value, which
9
- // makes `Uint<0..1>` and single-variant enums ZERO bytes wide
10
- // - `serialize<T, N>` places the packed value at the START of `Bytes<N>` and
11
- // zero-pads on the right; N below the packed size is a compile error, and
12
- // this module throws on the same condition.
13
- //
14
- // Compact is a strict protocol, so this module is too: every public entry
15
- // point runs the full recursive descriptor validation (src/validate.ts)
16
- // before touching a byte, every value is range- and shape-checked at runtime,
17
- // and every switch has a throwing backstop for anything that slips past the
18
- // type system.
19
- import { FIELD_MODULUS } from "./types.js";
20
- import { assertCompactType, assertUnreachable, isUint8Array } from "./validate.js";
21
- /**
22
- * Byte length of the largest legal value, given the EXCLUSIVE bound. 0 for a bound of 1.
23
- *
24
- * @param bound - Exclusive upper bound of the value range.
25
- * @returns The byte width needed to hold any value below the bound.
26
- */
27
- function widthOfBound(bound) {
28
- let max = bound - 1n;
29
- let width = 0;
30
- while (max > 0n) {
31
- width++;
32
- max >>= 8n;
33
- }
34
- return width;
35
- }
36
- /**
37
- * The sized-form bit width of a uint descriptor, or undefined for the bounded
38
- * form. Own-property read: `'bits' in type` would walk the prototype chain.
39
- *
40
- * @param type - The uint descriptor to inspect.
41
- * @returns The declared bit width, or undefined when the descriptor is bounded.
42
- */
43
- function sizedBits(type) {
44
- return Object.hasOwn(type, "bits") ? type.bits : undefined;
45
- }
46
- /**
47
- * The EXCLUSIVE upper bound of a uint descriptor, whichever form it uses.
48
- *
49
- * @param type - The uint descriptor to read.
50
- * @returns One past the largest value the descriptor admits.
51
- */
52
- export function uintBound(type) {
53
- const bits = sizedBits(type);
54
- return bits !== undefined
55
- ? 1n << BigInt(bits)
56
- : BigInt(type.bound);
57
- }
58
- /**
59
- * Guard for the Number arithmetic below: element counts and widths are
60
- * individually safe integers (validated), but their products and sums can
61
- * still leave the safe range and silently round. Never produce a wrong size.
62
- *
63
- * @param size - The computed packed size to check.
64
- * @param label - Descriptor kind, used in the error message.
65
- * @returns The size unchanged, once proven safe.
66
- * @throws {Error} If the size is not a safe integer.
67
- */
68
- function assertSafeSize(size, label) {
69
- if (!Number.isSafeInteger(size)) {
70
- throw new Error(`${label}: packed size exceeds Number.MAX_SAFE_INTEGER`);
71
- }
72
- return size;
73
- }
74
- /**
75
- * Packed byte size of an ALREADY-VALIDATED descriptor. Package-internal: the
76
- * public {@link compactSerializedSize} validates first.
77
- *
78
- * @param type - A descriptor that has already passed validation.
79
- * @returns The packed byte size.
80
- */
81
- export function packedSize(type) {
82
- switch (type.kind) {
83
- case "boolean":
84
- return 1;
85
- case "uint":
86
- return widthOfBound(uintBound(type));
87
- case "field":
88
- return 32;
89
- case "bytes":
90
- return type.length;
91
- case "enum":
92
- return widthOfBound(BigInt(type.variants));
93
- case "vector":
94
- return assertSafeSize(type.length * packedSize(type.element), "vector");
95
- case "tuple":
96
- return assertSafeSize(type.elements.reduce((sum, e) => sum + packedSize(e), 0), "tuple");
97
- case "struct":
98
- return assertSafeSize(type.fields.reduce((sum, f) => sum + packedSize(f.type), 0), "struct");
99
- default:
100
- return assertUnreachable(type, "packedSize");
101
- }
102
- }
103
- /**
104
- * Packed byte size of a type, before `serialize<T, N>`'s right zero-padding.
105
- *
106
- * @param type - The descriptor to size.
107
- * @returns The packed byte size.
108
- * @throws {Error} If the descriptor is not a well-formed Compact type.
109
- */
110
- export function compactSerializedSize(type) {
111
- assertCompactType(type);
112
- return packedSize(type);
113
- }
114
- /**
115
- * Byte-exact twin of `serialize<T, padTo>(value)`. With `padTo` omitted the
116
- * packed value is returned unpadded, matching `serialize<T, packedSize>`.
117
- *
118
- * The value parameter is typed from the descriptor (see `CompactValueOf`), so
119
- * a literal descriptor gets compile-time checking of the value shape, and the
120
- * same shape is enforced again at runtime.
121
- *
122
- * @param type - The descriptor the value conforms to.
123
- * @param value - The value to pack, shaped by the descriptor.
124
- * @param padTo - Total output length; omit to return the value unpadded.
125
- * @returns The packed bytes.
126
- * @throws {Error} If the descriptor or the value fails validation, or `padTo` is
127
- * smaller than the packed size.
128
- */
129
- export function compactSerialize(type, value, padTo) {
130
- assertCompactType(type);
131
- if (padTo !== undefined && (!Number.isInteger(padTo) || padTo < 0)) {
132
- throw new Error(`padTo must be a non-negative integer, got ${String(padTo)}`);
133
- }
134
- const size = packedSize(type);
135
- const total = padTo ?? size;
136
- if (total < size) {
137
- throw new Error(`padTo ${String(total)} is below the packed size ${String(size)} (a compile error in Compact too)`);
138
- }
139
- const out = new Uint8Array(total);
140
- encodeInto(out, 0, type, value, "value");
141
- return out;
142
- }
143
- /**
144
- * Whether a value is a plain object usable as a struct: not null, not an
145
- * array, not a Uint8Array. Takes `unknown` so each check is load-bearing
146
- * rather than narrowed away by the declared parameter type.
147
- *
148
- * @param value - The candidate struct value.
149
- * @returns Whether the value can carry named fields.
150
- */
151
- function isStructValue(value) {
152
- return (typeof value === "object" && value !== null && !Array.isArray(value) && !isUint8Array(value));
153
- }
154
- function encodeInto(out, offset, type, value, label) {
155
- switch (type.kind) {
156
- case "boolean": {
157
- if (typeof value !== "boolean")
158
- throw new Error(`${label}: expected boolean`);
159
- out[offset] = value ? 1 : 0;
160
- return offset + 1;
161
- }
162
- case "uint": {
163
- if (typeof value !== "bigint")
164
- throw new Error(`${label}: expected bigint`);
165
- const bound = uintBound(type);
166
- const size = widthOfBound(bound);
167
- if (value >= bound) {
168
- throw new Error(`${label}: value ${String(value)} exceeds ${uintName(type)}`);
169
- }
170
- writeUintLE(out, offset, value, size, label);
171
- return offset + size;
172
- }
173
- case "field": {
174
- if (typeof value !== "bigint")
175
- throw new Error(`${label}: expected bigint`);
176
- if (value >= FIELD_MODULUS) {
177
- throw new Error(`${label}: value ${String(value)} is not below the Field modulus`);
178
- }
179
- writeUintLE(out, offset, value, 32, label);
180
- return offset + 32;
181
- }
182
- case "bytes": {
183
- if (!isUint8Array(value))
184
- throw new Error(`${label}: expected Uint8Array`);
185
- if (value.length !== type.length) {
186
- throw new Error(`${label}: expected exactly ${String(type.length)} bytes, got ${String(value.length)}`);
187
- }
188
- out.set(value, offset);
189
- return offset + type.length;
190
- }
191
- case "enum": {
192
- // Matches the generated bindings: enum values are numbers (the index).
193
- if (typeof value !== "number" || !Number.isInteger(value)) {
194
- throw new Error(`${label}: expected an integer number (enum variant index)`);
195
- }
196
- const size = widthOfBound(BigInt(type.variants));
197
- if (value < 0 || value >= type.variants) {
198
- throw new Error(`${label}: variant index ${String(value)} is outside 0..${String(type.variants - 1)}`);
199
- }
200
- writeUintLE(out, offset, BigInt(value), size, label);
201
- return offset + size;
202
- }
203
- case "vector": {
204
- if (!Array.isArray(value))
205
- throw new Error(`${label}: expected array`);
206
- if (value.length !== type.length) {
207
- throw new Error(`${label}: expected exactly ${String(type.length)} elements, got ${String(value.length)}`);
208
- }
209
- let cursor = offset;
210
- value.forEach((element, i) => {
211
- cursor = encodeInto(out, cursor, type.element, element, `${label}[${String(i)}]`);
212
- });
213
- return cursor;
214
- }
215
- case "tuple": {
216
- if (!Array.isArray(value))
217
- throw new Error(`${label}: expected array (tuple)`);
218
- if (value.length !== type.elements.length) {
219
- throw new Error(`${label}: expected exactly ${String(type.elements.length)} elements, got ${String(value.length)}`);
220
- }
221
- let cursor = offset;
222
- for (const [i, element] of type.elements.entries()) {
223
- const item = value[i];
224
- // The length check above proves this, but the index signature does not.
225
- if (item === undefined) {
226
- throw new Error(`${label}[${String(i)}]: missing element`);
227
- }
228
- cursor = encodeInto(out, cursor, element, item, `${label}[${String(i)}]`);
229
- }
230
- return cursor;
231
- }
232
- case "struct": {
233
- if (!isStructValue(value)) {
234
- throw new Error(`${label}: expected an object`);
235
- }
236
- // Reject unknown keys, mirroring the strictness on descriptors: a
237
- // typo'd extra property alongside the correctly-named ones would
238
- // otherwise vanish silently.
239
- const declared = new Set(type.fields.map((f) => f.name));
240
- for (const key of Object.keys(value)) {
241
- if (!declared.has(key)) {
242
- throw new Error(`${label}: unknown field '${key}' (not in the descriptor)`);
243
- }
244
- }
245
- let cursor = offset;
246
- for (const field of type.fields) {
247
- // Own-property lookup: field names like 'toString' or '__proto__'
248
- // are legal Compact identifiers and must not resolve through the
249
- // JS prototype chain.
250
- if (!Object.hasOwn(value, field.name)) {
251
- throw new Error(`${label}: missing field '${field.name}'`);
252
- }
253
- const fieldValue = value[field.name];
254
- // hasOwn above proves the KEY exists; an explicit undefined VALUE is a
255
- // separate case, and neither is serializable.
256
- if (fieldValue === undefined) {
257
- throw new Error(`${label}: missing field '${field.name}'`);
258
- }
259
- cursor = encodeInto(out, cursor, field.type, fieldValue, `${label}.${field.name}`);
260
- }
261
- return cursor;
262
- }
263
- default:
264
- return assertUnreachable(type, label);
265
- }
266
- }
267
- /**
268
- * Display name of a uint descriptor in its own declaration form.
269
- *
270
- * @param type - The uint descriptor to name.
271
- * @returns `Uint<bits>` for the sized form, `Uint<0..bound>` for the bounded one.
272
- */
273
- export function uintName(type) {
274
- const bits = sizedBits(type);
275
- return bits !== undefined
276
- ? `Uint<${String(bits)}>`
277
- : `Uint<0..${String(type.bound)}>`;
278
- }
279
- function writeUintLE(out, offset, value, size, label) {
280
- if (value < 0n) {
281
- throw new Error(`${label}: negative values cannot be Compact-serialized (got ${String(value)})`);
282
- }
283
- if (value >> BigInt(size * 8) !== 0n) {
284
- throw new Error(`${label}: value ${String(value)} does not fit in ${String(size)} bytes`);
285
- }
286
- let v = value;
287
- for (let i = 0; i < size; i++) {
288
- out[offset + i] = Number(v & 0xffn);
289
- v >>= 8n;
290
- }
291
- }
292
- //# sourceMappingURL=serialize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,sEAAsE;AACtE,EAAE;AACF,gDAAgD;AAChD,2EAA2E;AAC3E,qBAAqB;AACrB,4EAA4E;AAC5E,8EAA8E;AAC9E,kEAAkE;AAClE,+EAA+E;AAC/E,8EAA8E;AAC9E,gDAAgD;AAChD,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,8EAA8E;AAC9E,4EAA4E;AAC5E,eAAe;AAGf,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnF;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC;IACrB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAA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,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAqB;IAC5C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG;QACzB,CAAC,CAAC,WAAW,MAAM,CAAE,IAAmC,CAAC,KAAK,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,SAAS,WAAW,CAClB,GAAe,EACf,MAAc,EACd,KAAa,EACb,IAAY,EACZ,KAAa;IAEb,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,uDAAuD,MAAM,CAAC,KAAK,CAAC,GAAG,CAChF,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,MAAM,CAAC,KAAK,CAAC,oBAAoB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACpC,CAAC,KAAK,EAAE,CAAC;IACX,CAAC;AACH,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,134 +0,0 @@
1
- /**
2
- * The BLS12-381 scalar field modulus. A Compact `Field` value must be below
3
- * it. Matches `maxField + 1n` exported by `@midnight-ntwrk/compact-runtime`.
4
- */
5
- export declare const FIELD_MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513n;
6
- /** Maximum `Uint` width accepted by compactc 0.33 (bits). */
7
- export declare const MAX_UINT_BITS = 248;
8
- /**
9
- * Maximum EXCLUSIVE bound of a Compact `Uint<0..n>`: 2^248, i.e. one above
10
- * the language reference's maximum Uint value 256^31 - 1.
11
- */
12
- export declare const MAX_UINT_BOUND: bigint;
13
- /** Compact `Boolean`: 1 byte, 0x00 or 0x01. */
14
- export interface CompactBooleanType {
15
- readonly kind: "boolean";
16
- }
17
- /** Compact `Uint<bits>` (sized): ceil(bits / 8) bytes little-endian, bits 1..248. */
18
- export interface CompactSizedUintType {
19
- readonly kind: "uint";
20
- readonly bits: number;
21
- }
22
- /**
23
- * Compact `Uint<0..bound>` (bounded): values 0 (inclusive) to `bound`
24
- * EXCLUSIVE, per the language reference. Width is the byte length of
25
- * `bound - 1`, so `Uint<0..1000>` is 2 bytes and `Uint<0..1>` is ZERO bytes
26
- * (both circuit-pinned). A number `bound` must be a safe integer; use a
27
- * bigint beyond 2^53.
28
- */
29
- export interface CompactBoundedUintType {
30
- readonly kind: "uint";
31
- readonly bound: number | bigint;
32
- }
33
- /**
34
- * A Compact unsigned integer, in either declaration form. `Uint<w>` is the
35
- * same type as `Uint<0..2^w>`, so `{ bits: w }` and `{ bound: 1n << w }`
36
- * describe identical layouts and ranges.
37
- */
38
- export type CompactUintType = CompactSizedUintType | CompactBoundedUintType;
39
- /** Compact `Field`: 32 bytes little-endian, value below {@link FIELD_MODULUS}. */
40
- export interface CompactFieldType {
41
- readonly kind: "field";
42
- }
43
- /** Compact `Bytes<length>`: raw bytes, copied verbatim. `Bytes<0>` is legal. */
44
- export interface CompactBytesType {
45
- readonly kind: "bytes";
46
- readonly length: number;
47
- }
48
- /**
49
- * A Compact enum: the variant INDEX packed exactly like
50
- * `Uint<0..variants>`, i.e. byte length of `variants - 1` (one byte up to
51
- * 256 variants, ZERO bytes for a single-variant enum; circuit-pinned).
52
- * Values are numbers, matching the generated contract bindings.
53
- */
54
- export interface CompactEnumType {
55
- readonly kind: "enum";
56
- readonly variants: number;
57
- }
58
- /**
59
- * Compact `Vector<length, element>`: elements back to back, no length
60
- * prefix. `Vector<0, T>` is legal and zero bytes wide.
61
- */
62
- export interface CompactVectorType {
63
- readonly kind: "vector";
64
- readonly length: number;
65
- readonly element: CompactType;
66
- }
67
- /**
68
- * A Compact tuple `[T1, ..., Tn]`: elements packed in order, no gaps, no
69
- * prefix, exactly like a struct without field names. `Vector<n, T>` is the
70
- * homogeneous special case. Values are TypeScript arrays/tuples, matching
71
- * the generated contract bindings. The empty tuple `[]` is legal and zero
72
- * bytes wide.
73
- */
74
- export interface CompactTupleType {
75
- readonly kind: "tuple";
76
- readonly elements: readonly CompactType[];
77
- }
78
- /**
79
- * A Compact struct: fields packed in declaration order, no gaps, flattened.
80
- * A struct with no fields is legal and zero bytes wide.
81
- */
82
- export interface CompactStructType {
83
- readonly kind: "struct";
84
- readonly fields: readonly {
85
- readonly name: string;
86
- readonly type: CompactType;
87
- }[];
88
- }
89
- /** Any Compact type descriptor: the union of every supported kind. */
90
- export type CompactType = CompactBooleanType | CompactUintType | CompactFieldType | CompactBytesType | CompactEnumType | CompactVectorType | CompactTupleType | CompactStructType;
91
- /**
92
- * The TypeScript value shapes descriptors map to, matching the generated
93
- * contract bindings: `Boolean` is boolean, `Uint`/`Field` are bigint, an
94
- * enum is a number (the variant index), `Bytes` is Uint8Array, `Vector` and
95
- * tuples are arrays, a struct is a plain object.
96
- */
97
- export type CompactValue = boolean | bigint | number | Uint8Array | CompactValue[] | {
98
- [field: string]: CompactValue;
99
- };
100
- /**
101
- * The precise TypeScript value type of a descriptor. Declare descriptors
102
- * `as const satisfies CompactType` (or as a plain literal) and both
103
- * `compactSerialize` and `compactDeserialize` type their values exactly:
104
- *
105
- * ```ts
106
- * const RESULT = {
107
- * kind: "struct",
108
- * fields: [
109
- * { name: "ok", type: { kind: "boolean" } },
110
- * { name: "amount", type: { kind: "uint", bits: 128 } },
111
- * ],
112
- * } as const satisfies CompactType;
113
- *
114
- * const value = compactDeserialize(RESULT, bytes);
115
- * // ^? { ok: boolean; amount: bigint }
116
- * ```
117
- *
118
- * A descriptor WIDENED to `CompactType` degrades gracefully to
119
- * {@link CompactValue}.
120
- */
121
- /**
122
- * Maps a tuple of descriptors to the tuple of their value types. A separate
123
- * alias with its own type parameter so the mapped type is homomorphic (an
124
- * inline `keyof T['elements']` would map method keys too, not just indices).
125
- */
126
- type CompactTupleValueOf<E extends readonly CompactType[]> = number extends E["length"] ? CompactValue[] : {
127
- -readonly [I in keyof E]: CompactValueOf<E[I]>;
128
- };
129
- /** The TypeScript value type a given Compact descriptor serializes. */
130
- export type CompactValueOf<T extends CompactType> = T extends CompactBooleanType ? boolean : T extends CompactUintType | CompactFieldType ? bigint : T extends CompactEnumType ? number : T extends CompactBytesType ? Uint8Array : T extends CompactVectorType ? CompactValueOf<T["element"]>[] : T extends CompactTupleType ? CompactTupleValueOf<T["elements"]> : T extends CompactStructType ? {
131
- -readonly [F in T["fields"][number] as F["name"]]: CompactValueOf<F["type"]>;
132
- } : never;
133
- export {};
134
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,aAAa,iFAAsE,CAAC;AAEjG,6DAA6D;AAC7D,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAa,CAAC;AAEzC,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,G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AAG,MAAM,GAAG,UAAU,GAAG,YAAY,EAAE,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;GAIG;AACH,KAAK,mBAAmB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACnF,YAAY,EAAE,GACd;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvD,uEAAuE;AACvE,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,kBAAkB,GAC5E,OAAO,GACP,CAAC,SAAS,eAAe,GAAG,gBAAgB,GAC1C,MAAM,GACN,CAAC,SAAS,eAAe,GACvB,MAAM,GACN,CAAC,SAAS,gBAAgB,GACxB,UAAU,GACV,CAAC,SAAS,iBAAiB,GACzB,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAC9B,CAAC,SAAS,gBAAgB,GACxB,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,GAClC,CAAC,SAAS,iBAAiB,GACzB;IACE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAC7E,GACD,KAAK,CAAC"}
package/dist/types.js DELETED
@@ -1,22 +0,0 @@
1
- // Type descriptors for Compact circuit types, the runtime mirror of what a
2
- // contract declares at compile time. A descriptor tree fully determines the
3
- // byte layout of Compact's builtin `serialize<T, N>` / `deserialize<T, N>`
4
- // pair, so off-chain code can produce or consume the exact bytes a circuit
5
- // reads or writes.
6
- //
7
- // Coverage: every serializable Compact type has a descriptor kind. The only
8
- // exclusion is `Opaque<...>`, which compactc itself rejects with
9
- // "Opaque<...> is not a serializable type".
10
- /**
11
- * The BLS12-381 scalar field modulus. A Compact `Field` value must be below
12
- * it. Matches `maxField + 1n` exported by `@midnight-ntwrk/compact-runtime`.
13
- */
14
- export const FIELD_MODULUS = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n;
15
- /** Maximum `Uint` width accepted by compactc 0.33 (bits). */
16
- export const MAX_UINT_BITS = 248;
17
- /**
18
- * Maximum EXCLUSIVE bound of a Compact `Uint<0..n>`: 2^248, i.e. one above
19
- * the language reference's maximum Uint value 256^31 - 1.
20
- */
21
- export const MAX_UINT_BOUND = 1n << 248n;
22
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,mBAAmB;AACnB,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,4CAA4C;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mEAAmE,CAAC;AAEjG,6DAA6D;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,IAAI,IAAI,CAAC"}
@@ -1,39 +0,0 @@
1
- import type { CompactType } from "./types.ts";
2
- /**
3
- * Cross-realm-safe Uint8Array check. `instanceof` fails for buffers created
4
- * in another realm (node:vm context, iframe), which are otherwise perfectly
5
- * valid inputs, so fall back to the brand check.
6
- *
7
- * @param value - The value to test.
8
- * @returns Whether the value is a Uint8Array from any realm.
9
- */
10
- export declare function isUint8Array(value: unknown): value is Uint8Array;
11
- /**
12
- * Assert that `type` is a structurally valid {@link CompactType}, recursively.
13
- * Rejects unknown kinds, unexpected extra keys (typo protection), out-of-range
14
- * widths and lengths, empty or duplicate struct field names, and any
15
- * non-object node. Error messages carry the path to the offending node.
16
- *
17
- * @param type - The candidate descriptor.
18
- * @param label - Path prefix for error messages.
19
- * @throws {Error} If the descriptor is malformed at any depth.
20
- */
21
- export declare function assertCompactType(type: unknown, label?: string): asserts type is CompactType;
22
- /**
23
- * Boolean form of {@link assertCompactType}.
24
- *
25
- * @param type - The candidate descriptor.
26
- * @returns Whether the descriptor is structurally valid.
27
- */
28
- export declare function isCompactType(type: unknown): type is CompactType;
29
- /**
30
- * Exhaustiveness backstop for descriptor switches. Statically `value` is
31
- * `never` (every kind handled); at runtime it still throws on anything that
32
- * slipped past validation instead of falling through to undefined behaviour.
33
- *
34
- * @param value - The descriptor every branch was meant to have handled.
35
- * @param label - Caller name, used in the error message.
36
- * @throws {Error} Always, naming the unhandled kind.
37
- */
38
- export declare function assertUnreachable(value: never, label: string): never;
39
- //# sourceMappingURL=validate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuB9C;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAIhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,SAAS,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAkI5F;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,WAAW,CAOhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAGpE"}