@lionden/leo-compiler 0.1.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 (67) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/dist/abi-hash.d.ts +15 -0
  4. package/dist/abi-hash.d.ts.map +1 -0
  5. package/dist/abi-hash.js +75 -0
  6. package/dist/abi-hash.js.map +1 -0
  7. package/dist/abi-parser.d.ts +38 -0
  8. package/dist/abi-parser.d.ts.map +1 -0
  9. package/dist/abi-parser.js +513 -0
  10. package/dist/abi-parser.js.map +1 -0
  11. package/dist/abi-types.d.ts +111 -0
  12. package/dist/abi-types.d.ts.map +1 -0
  13. package/dist/abi-types.js +5 -0
  14. package/dist/abi-types.js.map +1 -0
  15. package/dist/cache.d.ts +27 -0
  16. package/dist/cache.d.ts.map +1 -0
  17. package/dist/cache.js +74 -0
  18. package/dist/cache.js.map +1 -0
  19. package/dist/codegen/codegen-error.d.ts +10 -0
  20. package/dist/codegen/codegen-error.d.ts.map +1 -0
  21. package/dist/codegen/codegen-error.js +14 -0
  22. package/dist/codegen/codegen-error.js.map +1 -0
  23. package/dist/codegen/contract-wrapper.d.ts +6 -0
  24. package/dist/codegen/contract-wrapper.d.ts.map +1 -0
  25. package/dist/codegen/contract-wrapper.js +2482 -0
  26. package/dist/codegen/contract-wrapper.js.map +1 -0
  27. package/dist/codegen/type-mapper.d.ts +46 -0
  28. package/dist/codegen/type-mapper.d.ts.map +1 -0
  29. package/dist/codegen/type-mapper.js +132 -0
  30. package/dist/codegen/type-mapper.js.map +1 -0
  31. package/dist/codegen/typescript-generator.d.ts +65 -0
  32. package/dist/codegen/typescript-generator.d.ts.map +1 -0
  33. package/dist/codegen/typescript-generator.js +2076 -0
  34. package/dist/codegen/typescript-generator.js.map +1 -0
  35. package/dist/compiler.d.ts +43 -0
  36. package/dist/compiler.d.ts.map +1 -0
  37. package/dist/compiler.js +532 -0
  38. package/dist/compiler.js.map +1 -0
  39. package/dist/dependency-resolver.d.ts +33 -0
  40. package/dist/dependency-resolver.d.ts.map +1 -0
  41. package/dist/dependency-resolver.js +142 -0
  42. package/dist/dependency-resolver.js.map +1 -0
  43. package/dist/import-parser.d.ts +17 -0
  44. package/dist/import-parser.d.ts.map +1 -0
  45. package/dist/import-parser.js +46 -0
  46. package/dist/import-parser.js.map +1 -0
  47. package/dist/index.d.ts +15 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +22 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/package-materializer.d.ts +29 -0
  52. package/dist/package-materializer.d.ts.map +1 -0
  53. package/dist/package-materializer.js +160 -0
  54. package/dist/package-materializer.js.map +1 -0
  55. package/dist/source-discovery.d.ts +24 -0
  56. package/dist/source-discovery.d.ts.map +1 -0
  57. package/dist/source-discovery.js +131 -0
  58. package/dist/source-discovery.js.map +1 -0
  59. package/dist/source-scrubber.d.ts +22 -0
  60. package/dist/source-scrubber.d.ts.map +1 -0
  61. package/dist/source-scrubber.js +71 -0
  62. package/dist/source-scrubber.js.map +1 -0
  63. package/dist/types.d.ts +72 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +8 -0
  66. package/dist/types.js.map +1 -0
  67. package/package.json +34 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-wrapper.js","sourceRoot":"","sources":["../../src/codegen/contract-wrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAs6ElD;IACC,wEAAwE;IACxE,oEAAoE;IACpE,sEAAsE;IACtE,uEAAuE;IACvE,uDAAuD;KACtD,OAAO,CAAC,4BAA4B,EAAE,wCAAwC,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { AleoType, PlaintextType, PrimitiveType, RecordRef, StructRef } from "../abi-types.js";
2
+ /**
3
+ * Convert a path (from a StructRef, RecordRef, or declaration) to a
4
+ * collision-free TypeScript identifier.
5
+ *
6
+ * Single segment: `["Foo"]` → `"Foo"` (unchanged).
7
+ * Multi-segment: `["utils", "Vector3"]` → `"Utils_Vector3"`.
8
+ */
9
+ export declare function pathToTsName(path: readonly string[]): string;
10
+ /**
11
+ * Derive the TypeScript name for a StructRef.
12
+ */
13
+ export declare function structRefName(ref: StructRef): string;
14
+ /**
15
+ * Derive the TypeScript name for a RecordRef.
16
+ */
17
+ export declare function recordRefName(ref: RecordRef): string;
18
+ /**
19
+ * Derive a collision-free `${base}Input` identifier for a struct/record input
20
+ * type, given the set of names already reserved in the module. Pure: the result
21
+ * is a deterministic function of `base` and `reserved`.
22
+ *
23
+ * Prefers `${base}Input`; on collision, escalates underscores between the base
24
+ * and the `Input` suffix (`${base}_Input`, `${base}__Input`, …) until free.
25
+ * Since every candidate ends in `Input`, it can only collide with reserved names
26
+ * that also end in `Input` (imported `*Input` types, a user type literally named
27
+ * `FooInput`, or a previously claimed alias).
28
+ */
29
+ export declare function disambiguateInputName(base: string, reserved: ReadonlySet<string>): string;
30
+ /**
31
+ * Map a Leo/Aleo primitive type to its TypeScript representation.
32
+ */
33
+ export declare function primitiveToTs(prim: PrimitiveType): string;
34
+ /**
35
+ * Map a PlaintextType to its TypeScript representation.
36
+ */
37
+ export declare function plaintextToTs(pt: PlaintextType): string;
38
+ /**
39
+ * Map a top-level AleoType to its TypeScript representation.
40
+ */
41
+ export declare function aleoTypeToTs(ty: AleoType): string;
42
+ /**
43
+ * Check if a type uses bigint in TS (needs BigInt serialization).
44
+ */
45
+ export declare function isBigIntType(prim: PrimitiveType): boolean;
46
+ //# sourceMappingURL=type-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-mapper.d.ts","sourceRoot":"","sources":["../../src/codegen/type-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEpG;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAQzF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA4CzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,CASvD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAMzD"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Convert a path (from a StructRef, RecordRef, or declaration) to a
3
+ * collision-free TypeScript identifier.
4
+ *
5
+ * Single segment: `["Foo"]` → `"Foo"` (unchanged).
6
+ * Multi-segment: `["utils", "Vector3"]` → `"Utils_Vector3"`.
7
+ */
8
+ export function pathToTsName(path) {
9
+ if (path.length === 1)
10
+ return path[0];
11
+ return path.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("_");
12
+ }
13
+ /**
14
+ * Derive the TypeScript name for a StructRef.
15
+ */
16
+ export function structRefName(ref) {
17
+ return pathToTsName(ref.path);
18
+ }
19
+ /**
20
+ * Derive the TypeScript name for a RecordRef.
21
+ */
22
+ export function recordRefName(ref) {
23
+ return pathToTsName(ref.path);
24
+ }
25
+ /**
26
+ * Derive a collision-free `${base}Input` identifier for a struct/record input
27
+ * type, given the set of names already reserved in the module. Pure: the result
28
+ * is a deterministic function of `base` and `reserved`.
29
+ *
30
+ * Prefers `${base}Input`; on collision, escalates underscores between the base
31
+ * and the `Input` suffix (`${base}_Input`, `${base}__Input`, …) until free.
32
+ * Since every candidate ends in `Input`, it can only collide with reserved names
33
+ * that also end in `Input` (imported `*Input` types, a user type literally named
34
+ * `FooInput`, or a previously claimed alias).
35
+ */
36
+ export function disambiguateInputName(base, reserved) {
37
+ let candidate = `${base}Input`;
38
+ let underscores = 1;
39
+ while (reserved.has(candidate)) {
40
+ candidate = `${base}${"_".repeat(underscores)}Input`;
41
+ underscores++;
42
+ }
43
+ return candidate;
44
+ }
45
+ /**
46
+ * Map a Leo/Aleo primitive type to its TypeScript representation.
47
+ */
48
+ export function primitiveToTs(prim) {
49
+ if (typeof prim === "string") {
50
+ switch (prim) {
51
+ case "Address":
52
+ return "string";
53
+ case "Boolean":
54
+ return "boolean";
55
+ case "Field":
56
+ return "string";
57
+ case "Group":
58
+ return "string";
59
+ case "Identifier":
60
+ return "string";
61
+ case "Scalar":
62
+ return "string";
63
+ }
64
+ return "unknown";
65
+ }
66
+ if (typeof prim === "object" && prim !== null && "UInt" in prim) {
67
+ switch (prim.UInt) {
68
+ case "U8":
69
+ case "U16":
70
+ case "U32":
71
+ return "number";
72
+ case "U64":
73
+ case "U128":
74
+ return "bigint";
75
+ }
76
+ }
77
+ if (typeof prim === "object" && prim !== null && "Int" in prim) {
78
+ switch (prim.Int) {
79
+ case "I8":
80
+ case "I16":
81
+ case "I32":
82
+ return "number";
83
+ case "I64":
84
+ case "I128":
85
+ return "bigint";
86
+ }
87
+ }
88
+ return "unknown";
89
+ }
90
+ /**
91
+ * Map a PlaintextType to its TypeScript representation.
92
+ */
93
+ export function plaintextToTs(pt) {
94
+ if ("Primitive" in pt)
95
+ return primitiveToTs(pt.Primitive);
96
+ if ("Struct" in pt)
97
+ return structRefName(pt.Struct);
98
+ if ("Array" in pt) {
99
+ const [elemType, _size] = pt.Array;
100
+ return `${plaintextToTs(elemType)}[]`;
101
+ }
102
+ if ("Optional" in pt)
103
+ return `${plaintextToTs(pt.Optional)} | null`;
104
+ return "unknown";
105
+ }
106
+ /**
107
+ * Map a top-level AleoType to its TypeScript representation.
108
+ */
109
+ export function aleoTypeToTs(ty) {
110
+ if (ty === "DynamicRecord")
111
+ return "string";
112
+ if ("Plaintext" in ty)
113
+ return plaintextToTs(ty.Plaintext);
114
+ if ("Record" in ty)
115
+ return recordRefName(ty.Record);
116
+ if ("Future" in ty)
117
+ return "void";
118
+ return "unknown";
119
+ }
120
+ /**
121
+ * Check if a type uses bigint in TS (needs BigInt serialization).
122
+ */
123
+ export function isBigIntType(prim) {
124
+ if (typeof prim === "object") {
125
+ if ("UInt" in prim)
126
+ return prim.UInt === "U64" || prim.UInt === "U128";
127
+ if ("Int" in prim)
128
+ return prim.Int === "I64" || prim.Int === "I128";
129
+ }
130
+ return false;
131
+ }
132
+ //# sourceMappingURL=type-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-mapper.js","sourceRoot":"","sources":["../../src/codegen/type-mapper.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAu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GAAG,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;IACpE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,EAAY;IACvC,IAAI,EAAE,KAAK,eAAe;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,WAAW,IAAI,EAAE;QAAE,OAAO,aAAa,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,QAAQ,IAAI,EAAE;QAAE,OAAO,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,QAAQ,IAAI,EAAE;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;QACvE,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,GAAG,KAAK,KAAK,IAAI,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,65 @@
1
+ import type { ProgramABI } from "../abi-types.js";
2
+ /**
3
+ * Options for `generateBindings`. Currently used to thread per-program
4
+ * dynamic-record helper configuration through to the emitter; plugin-leo
5
+ * filters the global helper map by ownership before passing here.
6
+ */
7
+ export interface GenerateBindingsOptions {
8
+ readonly dynamicRecords?: readonly ResolvedDynamicRecordHelperEmit[];
9
+ }
10
+ /**
11
+ * Resolved helper entry as the emitter consumes it. `sourceProgram` is bound
12
+ * to the owning programId by the time the emitter runs (plugin-leo's routing
13
+ * step). Shape-equivalent to `ResolvedDynamicRecordHelper` from `@lionden/config`
14
+ * but redeclared locally so the codegen layer doesn't depend on the config
15
+ * package.
16
+ */
17
+ export interface ResolvedDynamicRecordHelperEmit {
18
+ readonly helperName: string;
19
+ readonly sourceRecord: string;
20
+ readonly sourceProgram: string;
21
+ readonly schema: Readonly<Record<string, string>>;
22
+ }
23
+ /**
24
+ * Generate TypeScript bindings from a ProgramABI.
25
+ * Produces a single .ts file with:
26
+ * - Struct/record interfaces
27
+ * - Storage variable interface
28
+ * - Serializer/deserializer functions
29
+ * - Typed contract wrapper class
30
+ */
31
+ export declare function generateBindings(abi: ProgramABI, allAbis?: readonly ProgramABI[], options?: GenerateBindingsOptions): string;
32
+ /**
33
+ * Generate the BaseContract file content.
34
+ */
35
+ export declare function generateBaseContract(): string;
36
+ export declare function programIdToClassName(programId: string): string;
37
+ /**
38
+ * Assert that every program id maps to a distinct typechain module file
39
+ * (`${programIdToClassName(id)}.ts`) and that none collides with a reserved
40
+ * emitter file (`BaseContract.ts`).
41
+ *
42
+ * `programIdToClassName` is non-injective — it splits on `[_\-.]` and
43
+ * CamelCases — so e.g. `foo_bar.aleo` and `foo__bar.aleo` both yield `FooBar`,
44
+ * and `base_contract.aleo` yields `BaseContract`. The per-program emit loop
45
+ * writes `${stem}.ts` with no cross-program dedup, so a collision silently
46
+ * overwrites another program's bindings (or the runtime `BaseContract.ts`),
47
+ * leaving the generated module set internally inconsistent.
48
+ *
49
+ * Comparison is case-insensitive: the common dev filesystems (macOS APFS,
50
+ * Windows NTFS) are case-insensitive, so two programs whose class names differ
51
+ * only by case (e.g. `ab.aleo` → `Ab`, `a_b.aleo` → `AB`) would share one
52
+ * file. This guard turns any such collision into a clear build-time
53
+ * `CodegenError` instead.
54
+ */
55
+ export declare function assertTypechainModuleNamesUnique(programIds: readonly string[]): void;
56
+ /**
57
+ * Derive a class name that does not collide with struct/record interface names
58
+ * or the BaseContract imports emitted for this module. The latter also keeps
59
+ * the `create${class}` factory clear of the imported `createRecordOutputMatcher`
60
+ * (e.g. `record_output_matcher.aleo` → `RecordOutputMatcherContract`).
61
+ */
62
+ export declare function resolveContractClassName(abi: ProgramABI, options?: {
63
+ readonly includeLeoValueImport?: boolean;
64
+ }): string;
65
+ //# sourceMappingURL=typescript-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-generator.d.ts","sourceRoot":"","sources":["../../src/codegen/typescript-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAOV,UAAU,EAQX,MAAM,iBAAiB,CAAC;AAWzB;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,+BAA+B,EAAE,CAAC;CACtE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAoBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,UAAU,EACf,OAAO,GAAE,SAAS,UAAU,EAAU,EACtC,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAoGR;AAsJD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAmgED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM9D;AAQD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CA0BpF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GACzD,MAAM,CAYR"}