@distrohelena/canton-typescript-sdk 0.1.26 → 0.1.28

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.
@@ -189,8 +189,8 @@ class AnalyzedDamlTypeBuilder {
189
189
  try {
190
190
  dataType = this.semanticModel.getDataTypeOrThrow(reference);
191
191
  }
192
- catch (error) {
193
- throw this.unsupported(context, `could not resolve named type '${reference.name}'`);
192
+ catch {
193
+ throw this.unsupported(context, `could not resolve named type '${reference.packageId}:${reference.moduleName}:${reference.name}'`);
194
194
  }
195
195
  if (dataType.definition.kind === "record") {
196
196
  return Object.freeze({
@@ -29,14 +29,14 @@ export class DamlInterfaceGenerator {
29
29
  /** Generates an in-memory project from compiled DAML-LF archive bytes. */
30
30
  async generateFromDalfOrThrowAsync(archiveBytes) {
31
31
  const pkg = this.packageLoader.loadPackageOrThrow(archiveBytes);
32
- const compilation = DamlLfCompilation.createOrThrow(new DamlLfWorkspace([pkg]));
32
+ const compilation = DamlLfCompilation.createForTemplateGeneration(new DamlLfWorkspace([pkg]));
33
33
  return this.projectEmitter.emitProject(this.analyzeOrThrow(compilation));
34
34
  }
35
35
  /** Generates an in-memory project from DAR bytes. */
36
36
  async generateFromDarOrThrowAsync(archiveBytes) {
37
37
  const archive = await this.darArchiveLoader.loadDarOrThrowAsync(archiveBytes);
38
38
  const packages = archive.packageEntries.map((entry) => this.packageLoader.loadPackageOrThrow(entry.bytes));
39
- const compilation = DamlLfCompilation.createOrThrow(new DamlLfWorkspace(packages));
39
+ const compilation = DamlLfCompilation.createForTemplateGeneration(new DamlLfWorkspace(packages));
40
40
  return this.projectEmitter.emitProject(this.analyzeOrThrow(compilation));
41
41
  }
42
42
  }
@@ -18,6 +18,7 @@ export declare class DamlLfCompilation {
18
18
  private readonly valueDefinitionIdentities;
19
19
  private constructor();
20
20
  static createOrThrow(workspace: DamlLfWorkspace): DamlLfCompilation;
21
+ static createForTemplateGeneration(workspace: DamlLfWorkspace): DamlLfCompilation;
21
22
  getModuleSymbolOrThrow(reference: ModuleReference): ModuleSymbol;
22
23
  getTypeSymbolOrThrow(reference: TypeConReference): TypeSymbol;
23
24
  createSemanticModel(): DamlLfSemanticModel;
@@ -25,6 +25,11 @@ export class DamlLfCompilation {
25
25
  compilation.validateReferencesOrThrow();
26
26
  return compilation;
27
27
  }
28
+ static createForTemplateGeneration(workspace) {
29
+ const compilation = new DamlLfCompilation(workspace);
30
+ compilation.buildIndexes();
31
+ return compilation;
32
+ }
28
33
  getModuleSymbolOrThrow(reference) {
29
34
  const symbol = this.moduleSymbols.get(DamlLfCompilation.createModuleKey(reference.packageId, reference.moduleName));
30
35
  if (symbol === undefined) {
@@ -31,7 +31,7 @@ export class Lf2ModelMapper {
31
31
  if (rawType?.sum.oneofKind === "tapp") {
32
32
  const lhs = Lf2ModelMapper.mapType(currentPackageId, rawPackage, rawType.sum.tapp.lhs);
33
33
  const numericScale = lhs.builtinType === DamlLfBuiltinType.numeric
34
- ? Lf2ModelMapper.readNumericScale(rawType.sum.tapp.rhs)
34
+ ? Lf2ModelMapper.readNumericScale(rawPackage, rawType.sum.tapp.rhs)
35
35
  : undefined;
36
36
  return new DamlLfType({
37
37
  builtinType: lhs.builtinType,
@@ -63,7 +63,7 @@ export class Lf2ModelMapper {
63
63
  else if (rawType?.sum.oneofKind === "builtin") {
64
64
  const builtinType = Lf2ModelMapper.mapBuiltinType(rawType.sum.builtin.builtin);
65
65
  const numericScale = builtinType === DamlLfBuiltinType.numeric
66
- ? Lf2ModelMapper.readNumericScale(rawType.sum.builtin.args[0])
66
+ ? Lf2ModelMapper.readNumericScale(rawPackage, rawType.sum.builtin.args[0])
67
67
  : undefined;
68
68
  return new DamlLfType({
69
69
  builtinType,
@@ -111,7 +111,11 @@ export class Lf2ModelMapper {
111
111
  return DamlLfBuiltinType.unknown;
112
112
  }
113
113
  }
114
- static readNumericScale(rawType) {
114
+ static readNumericScale(rawPackage, rawType) {
115
+ if (rawType?.sum.oneofKind === "internedType"
116
+ && rawType.sum.internedType >= 0) {
117
+ return Lf2ModelMapper.readNumericScale(rawPackage, rawPackage.internedTypes[rawType.sum.internedType]);
118
+ }
115
119
  if (rawType?.sum.oneofKind !== "nat") {
116
120
  return undefined;
117
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distrohelena/canton-typescript-sdk",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",