@distrohelena/canton-typescript-sdk 0.1.25 → 0.1.26
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/dist/daml-interface/analysis/analyzed-daml-type.d.ts +0 -1
- package/dist/daml-interface/analysis/daml-interface-analyzer.js +1 -1
- package/dist/daml-interface/emission/named-type-emitter.js +2 -6
- package/dist/daml-interface/emission/support-file-emitter.js +1 -1
- package/dist/daml-interface/emission/template-binding-emitter.js +10 -8
- package/dist/daml-interface/emission/type-script-name-resolver.js +2 -2
- package/dist/daml-interface/runtime/daml-template.d.ts +1 -1
- package/dist/daml-interface/runtime/daml-template.js +1 -1
- package/dist/daml-interface/runtime/daml-type-descriptor.d.ts +1 -1
- package/dist/daml-lf/daml-lf-compilation.js +7 -0
- package/package.json +1 -1
|
@@ -128,9 +128,9 @@ class AnalyzedDamlTypeBuilder {
|
|
|
128
128
|
numericScale: type.numericScale,
|
|
129
129
|
});
|
|
130
130
|
case DamlLfBuiltinType.contractId:
|
|
131
|
+
this.assertArgumentCountOrThrow(type, 1, context);
|
|
131
132
|
return Object.freeze({
|
|
132
133
|
kind: "contractId",
|
|
133
|
-
contract: this.buildUnaryArgumentOrThrow(type, context),
|
|
134
134
|
});
|
|
135
135
|
case DamlLfBuiltinType.optional:
|
|
136
136
|
return Object.freeze({
|
|
@@ -139,9 +139,7 @@ export class NamedTypeEmitter {
|
|
|
139
139
|
case "namedReference":
|
|
140
140
|
yield type;
|
|
141
141
|
return;
|
|
142
|
-
case "contractId":
|
|
143
|
-
yield* this.getNamedReferences(type.contract);
|
|
144
|
-
return;
|
|
142
|
+
case "contractId": return;
|
|
145
143
|
case "optional":
|
|
146
144
|
case "list":
|
|
147
145
|
yield* this.getNamedReferences(type.element);
|
|
@@ -405,9 +403,7 @@ export class NamedTypeEmitter {
|
|
|
405
403
|
}
|
|
406
404
|
return;
|
|
407
405
|
}
|
|
408
|
-
case "contractId":
|
|
409
|
-
yield* this.getRuntimePrimitiveTypes(type.contract);
|
|
410
|
-
return;
|
|
406
|
+
case "contractId": return;
|
|
411
407
|
case "optional":
|
|
412
408
|
case "list":
|
|
413
409
|
yield* this.getRuntimePrimitiveTypes(type.element);
|
|
@@ -186,7 +186,7 @@ export class SupportFileEmitter {
|
|
|
186
186
|
case "primitive":
|
|
187
187
|
return `{ kind: "primitive", primitive: ${JSON.stringify(type.builtinType)}${type.numericScale === undefined ? "" : `, numericScale: ${type.numericScale}`} }`;
|
|
188
188
|
case "contractId":
|
|
189
|
-
return
|
|
189
|
+
return '{ kind: "contractId" }';
|
|
190
190
|
case "optional":
|
|
191
191
|
return `{ kind: "optional", element: ${this.emitDescriptor(type.element)} }`;
|
|
192
192
|
case "list":
|
|
@@ -195,7 +195,7 @@ export class TemplateBindingEmitter {
|
|
|
195
195
|
case "primitive":
|
|
196
196
|
return `{ kind: "primitive", primitive: ${JSON.stringify(type.builtinType)}${type.numericScale === undefined ? "" : `, numericScale: ${type.numericScale}`} }`;
|
|
197
197
|
case "contractId":
|
|
198
|
-
return
|
|
198
|
+
return '{ kind: "contractId" }';
|
|
199
199
|
case "optional":
|
|
200
200
|
return `{ kind: "optional", element: ${this.emitDescriptor(type.element)} }`;
|
|
201
201
|
case "list":
|
|
@@ -255,13 +255,17 @@ export class TemplateBindingEmitter {
|
|
|
255
255
|
if ("kind" in type) {
|
|
256
256
|
return type;
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
else if (type.builtinType === DamlLfBuiltinType.contractId) {
|
|
259
|
+
if (type.typeArguments.length !== 1) {
|
|
260
|
+
throw new Error("DAML ContractId requires exactly one type argument");
|
|
261
|
+
}
|
|
262
|
+
return { kind: "contractId" };
|
|
263
|
+
}
|
|
264
|
+
else if (type.typeConReference !== undefined) {
|
|
260
265
|
return { kind: "namedReference", identity: type.typeConReference };
|
|
261
266
|
}
|
|
267
|
+
const arguments_ = type.typeArguments.map((argument) => this.normalizeType(argument));
|
|
262
268
|
switch (type.builtinType) {
|
|
263
|
-
case DamlLfBuiltinType.contractId:
|
|
264
|
-
return { kind: "contractId", contract: arguments_[0] ?? { kind: "primitive", builtinType: DamlLfBuiltinType.text } };
|
|
265
269
|
case DamlLfBuiltinType.optional:
|
|
266
270
|
return { kind: "optional", element: arguments_[0] ?? { kind: "primitive", builtinType: DamlLfBuiltinType.text } };
|
|
267
271
|
case DamlLfBuiltinType.list:
|
|
@@ -345,9 +349,7 @@ export class TemplateBindingEmitter {
|
|
|
345
349
|
case "namedReference":
|
|
346
350
|
yield type;
|
|
347
351
|
return;
|
|
348
|
-
case "contractId":
|
|
349
|
-
yield* this.walkNamedReferences(type.contract);
|
|
350
|
-
return;
|
|
352
|
+
case "contractId": return;
|
|
351
353
|
case "optional":
|
|
352
354
|
case "list":
|
|
353
355
|
yield* this.walkNamedReferences(type.element);
|
|
@@ -2,13 +2,13 @@ import { DamlLfBuiltinType } from "../../daml-lf/model/daml-lf-builtin-type.js";
|
|
|
2
2
|
const typeScriptKeywords = new Set([
|
|
3
3
|
"as", "async", "await", "break", "case", "catch", "class", "const", "continue",
|
|
4
4
|
"debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false",
|
|
5
|
-
"finally", "for", "from", "function", "
|
|
5
|
+
"finally", "for", "from", "function", "if", "implements", "import", "in",
|
|
6
6
|
"instanceof", "interface", "let", "new", "null", "of", "package", "private", "protected",
|
|
7
7
|
"public", "return", "set", "static", "super", "switch", "this", "throw", "true", "try",
|
|
8
8
|
"type", "typeof", "undefined", "var", "void", "while", "with", "yield",
|
|
9
9
|
]);
|
|
10
10
|
const damlTemplateMemberNames = new Set([
|
|
11
|
-
"constructor", "
|
|
11
|
+
"constructor", "contractId", "templateId", "create", "decodeCreatedEvent",
|
|
12
12
|
"decodeExercisedEvent",
|
|
13
13
|
]);
|
|
14
14
|
const reservedTypeNames = new Set(["DamlTemplate"]);
|
|
@@ -12,7 +12,7 @@ export type DamlPrimitiveDescriptor = {
|
|
|
12
12
|
};
|
|
13
13
|
export type DamlContractIdDescriptor = {
|
|
14
14
|
readonly kind: "contractId";
|
|
15
|
-
readonly contract
|
|
15
|
+
readonly contract?: DamlTypeDescriptor;
|
|
16
16
|
};
|
|
17
17
|
export type DamlOptionalDescriptor = {
|
|
18
18
|
readonly kind: "optional";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DamlLfResolutionException } from "./errors/daml-lf-resolution.exception.js";
|
|
2
2
|
import { DamlLfSemanticException } from "./errors/daml-lf-semantic.exception.js";
|
|
3
|
+
import { DamlLfBuiltinType } from "./model/daml-lf-builtin-type.js";
|
|
3
4
|
import { DamlLfDataType } from "./model/daml-lf-data-type.js";
|
|
4
5
|
import { DamlLfTemplate } from "./model/daml-lf-template.js";
|
|
5
6
|
import { DamlLfValueDefinition } from "./model/daml-lf-value-definition.js";
|
|
@@ -122,6 +123,12 @@ export class DamlLfCompilation {
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
validateTypeOrThrow(type) {
|
|
126
|
+
if (type.builtinType === DamlLfBuiltinType.contractId) {
|
|
127
|
+
if (type.typeArguments.length !== 1) {
|
|
128
|
+
throw new DamlLfSemanticException("builtin 'contractId' requires 1 type argument");
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
125
132
|
for (const typeArgument of type.typeArguments) {
|
|
126
133
|
this.validateTypeOrThrow(typeArgument);
|
|
127
134
|
}
|