@distrohelena/canton-typescript-sdk 0.1.9 → 0.1.12

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.
@@ -188,6 +188,7 @@ import { TransactionObserver } from "../../services/events/transaction-observer.
188
188
  import { CommandSigners, ICommandSigner } from "../signing/command-signer.interface.js";
189
189
  import { SignCommandResult } from "../signing/sign-command-result.js";
190
190
  import { PreparedCommandSubmission } from "../types/prepared-command-submission.js";
191
+ import { SubmitCommandTransactionResponse } from "../types/responses/submit-command-transaction-response.js";
191
192
  import { RequestOptions } from "../types/request-options.js";
192
193
  import { SubmitCommandRequest } from "../types/requests/submit-command-request.js";
193
194
  export interface ITransport {
@@ -383,6 +384,7 @@ export interface ITransport {
383
384
  * Supported on JSON and gRPC. External signing is gRPC-only.
384
385
  */
385
386
  submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner | CommandSigners, options?: RequestOptions): Promise<SubmitCommandResponse>;
387
+ submitCommandForTransactionAsync?(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandTransactionResponse>;
386
388
  prepareCommandAsync?(request: SubmitCommandRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
387
389
  executePreparedCommandAndWaitAsync?(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
388
390
  }
@@ -0,0 +1,5 @@
1
+ /** Explicit DAML contract-id value, distinguished from ordinary text. */
2
+ export declare class DamlContractId {
3
+ readonly value: string;
4
+ constructor(value: string);
5
+ }
@@ -0,0 +1,11 @@
1
+ import { ValidationError } from "../errors/validation-error.js";
2
+ /** Explicit DAML contract-id value, distinguished from ordinary text. */
3
+ export class DamlContractId {
4
+ value;
5
+ constructor(value) {
6
+ if (value.length === 0) {
7
+ throw new ValidationError("DAML contract ids must not be empty");
8
+ }
9
+ this.value = value;
10
+ }
11
+ }
@@ -0,0 +1,35 @@
1
+ import { TemplateId } from "../../query/model-types.js";
2
+ export declare class DamlUnit {
3
+ }
4
+ export declare class DamlDate {
5
+ readonly daysSinceEpoch: number;
6
+ constructor(daysSinceEpoch: number);
7
+ }
8
+ export declare class DamlTimestamp {
9
+ readonly microsecondsSinceEpoch: string;
10
+ constructor(microsecondsSinceEpoch: string);
11
+ }
12
+ export declare class DamlTextMap {
13
+ readonly entries: readonly (readonly [string, unknown])[];
14
+ constructor(entries: readonly (readonly [string, unknown])[]);
15
+ }
16
+ export declare class DamlGenMap {
17
+ readonly entries: readonly (readonly [unknown, unknown])[];
18
+ constructor(entries: readonly (readonly [unknown, unknown])[]);
19
+ }
20
+ export declare class DamlVariant {
21
+ readonly constructorName: string;
22
+ readonly value: unknown;
23
+ readonly variantId?: TemplateId | undefined;
24
+ constructor(constructorName: string, value: unknown, variantId?: TemplateId | undefined);
25
+ }
26
+ export declare class DamlEnum {
27
+ readonly constructorName: string;
28
+ readonly enumId?: TemplateId | undefined;
29
+ constructor(constructorName: string, enumId?: TemplateId | undefined);
30
+ }
31
+ export declare class DamlRecord {
32
+ readonly fields: Readonly<Record<string, unknown>>;
33
+ readonly recordId?: TemplateId | undefined;
34
+ constructor(fields: Readonly<Record<string, unknown>>, recordId?: TemplateId | undefined);
35
+ }
@@ -0,0 +1,52 @@
1
+ export class DamlUnit {
2
+ }
3
+ export class DamlDate {
4
+ daysSinceEpoch;
5
+ constructor(daysSinceEpoch) {
6
+ this.daysSinceEpoch = daysSinceEpoch;
7
+ }
8
+ }
9
+ export class DamlTimestamp {
10
+ microsecondsSinceEpoch;
11
+ constructor(microsecondsSinceEpoch) {
12
+ this.microsecondsSinceEpoch = microsecondsSinceEpoch;
13
+ }
14
+ }
15
+ export class DamlTextMap {
16
+ entries;
17
+ constructor(entries) {
18
+ this.entries = entries;
19
+ }
20
+ }
21
+ export class DamlGenMap {
22
+ entries;
23
+ constructor(entries) {
24
+ this.entries = entries;
25
+ }
26
+ }
27
+ export class DamlVariant {
28
+ constructorName;
29
+ value;
30
+ variantId;
31
+ constructor(constructorName, value, variantId) {
32
+ this.constructorName = constructorName;
33
+ this.value = value;
34
+ this.variantId = variantId;
35
+ }
36
+ }
37
+ export class DamlEnum {
38
+ constructorName;
39
+ enumId;
40
+ constructor(constructorName, enumId) {
41
+ this.constructorName = constructorName;
42
+ this.enumId = enumId;
43
+ }
44
+ }
45
+ export class DamlRecord {
46
+ fields;
47
+ recordId;
48
+ constructor(fields, recordId) {
49
+ this.fields = fields;
50
+ this.recordId = recordId;
51
+ }
52
+ }
@@ -0,0 +1,7 @@
1
+ /** Result of a gRPC command submission that waited for its transaction. */
2
+ export declare class SubmitCommandTransactionResponse {
3
+ readonly transactionId: string;
4
+ readonly events: readonly unknown[];
5
+ readonly transaction: unknown;
6
+ constructor(transactionId: string, events: readonly unknown[], transaction: unknown);
7
+ }
@@ -0,0 +1,11 @@
1
+ /** Result of a gRPC command submission that waited for its transaction. */
2
+ export class SubmitCommandTransactionResponse {
3
+ transactionId;
4
+ events;
5
+ transaction;
6
+ constructor(transactionId, events, transaction) {
7
+ this.transactionId = transactionId;
8
+ this.events = events;
9
+ this.transaction = transaction;
10
+ }
11
+ }
package/dist/index.d.ts CHANGED
@@ -208,6 +208,9 @@ export type { ExternalPartySigner, ExternalPartySigningRequest, ExternalPartySig
208
208
  export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
209
209
  export { DisclosedContract } from "./core/types/disclosed-contract.js";
210
210
  export { PreparedCommandSubmission } from "./core/types/prepared-command-submission.js";
211
+ export { DamlContractId } from "./core/types/daml-contract-id.js";
212
+ export { DamlUnit, DamlDate, DamlTimestamp, DamlTextMap, DamlGenMap, DamlVariant, DamlEnum, DamlRecord } from "./core/types/daml-values.js";
213
+ export { SubmitCommandTransactionResponse } from "./core/types/responses/submit-command-transaction-response.js";
211
214
  export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
212
215
  export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
213
216
  export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
package/dist/index.js CHANGED
@@ -195,6 +195,9 @@ export { CreateExternalPartyRequest, } from "./core/types/requests/create-extern
195
195
  export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
196
196
  export { DisclosedContract } from "./core/types/disclosed-contract.js";
197
197
  export { PreparedCommandSubmission } from "./core/types/prepared-command-submission.js";
198
+ export { DamlContractId } from "./core/types/daml-contract-id.js";
199
+ export { DamlUnit, DamlDate, DamlTimestamp, DamlTextMap, DamlGenMap, DamlVariant, DamlEnum, DamlRecord } from "./core/types/daml-values.js";
200
+ export { SubmitCommandTransactionResponse } from "./core/types/responses/submit-command-transaction-response.js";
198
201
  export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
199
202
  export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
200
203
  export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
@@ -44,7 +44,7 @@ export class GrpcContractQueryClient {
44
44
  args.where?.contractId?.in !== undefined ||
45
45
  args.where?.contractId?.is !== undefined ||
46
46
  args.where?.contractId?.isNot !== undefined ||
47
- (args.where?.templateId !== undefined && typeof args.where.templateId.equals !== "string")) {
47
+ args.where?.templateId !== undefined) {
48
48
  throw new QueryCapabilityError(QuerySource.grpc, "contracts.findMany");
49
49
  }
50
50
  const findArgs = args;
@@ -57,9 +57,6 @@ export class GrpcContractQueryClient {
57
57
  : row.contractId === args.where.contractId.equals);
58
58
  if (args.where?.payload !== undefined)
59
59
  rows = rows.filter((row) => matchesPayload(row.payload, args.where.payload));
60
- const legacyTemplate = args.where?.templateId;
61
- if (legacyTemplate?.equals !== undefined)
62
- rows = rows.filter((row) => `${row.templateId.packageId}:${row.templateId.moduleName}:${row.templateId.entityName}` === legacyTemplate.equals);
63
60
  return rows;
64
61
  }
65
62
  unsupported(operation) {
@@ -109,9 +109,7 @@ type PayloadValueFilter = {
109
109
  export type PayloadMatch = {
110
110
  readonly [field: string]: PayloadMatch | PayloadValueFilter;
111
111
  };
112
- export type ContractPayloadFilter = ({
113
- readonly path: string;
114
- } & PayloadValueFilter) | {
112
+ export type ContractPayloadFilter = {
115
113
  readonly match: PayloadMatch;
116
114
  };
117
115
  type ContractWhereFields = {
@@ -78,24 +78,13 @@ function compileWhere(where, addValue) {
78
78
  return;
79
79
  } for (const [name, child] of Object.entries(filter))
80
80
  compilePayload([...path, name], child); };
81
- if (payload.match !== undefined) {
82
- compilePayload([], payload.match);
83
- }
84
- else {
85
- const path = payload.path;
86
- if (typeof path !== "string" || path.split(".").some((x) => x.length === 0))
87
- throw new Error("payload path must contain non-empty segments");
88
- compilePayload(path.split("."), payload);
89
- }
81
+ if (payload.match === undefined)
82
+ throw new Error("payload requires match");
83
+ compilePayload([], payload.match);
90
84
  continue;
91
85
  }
92
86
  if (key === "templateId") {
93
87
  const fields = { packageId: "contract_row.creation_package_id", moduleName: "contract_tpe_row.module_name", entityName: "contract_tpe_row.entity_name" };
94
- const legacy = value;
95
- if (typeof legacy.equals === "string") {
96
- parts.push(`(contract_row.creation_package_id || ':' || contract_tpe_row.module_name || ':' || contract_tpe_row.entity_name) = ${addValue(legacy.equals)}`);
97
- continue;
98
- }
99
88
  for (const [name, filter] of Object.entries(value))
100
89
  for (const [op, operand] of Object.entries(filter)) {
101
90
  const sql = { equals: "=", lt: "<", lte: "<=", gt: ">", gte: ">=", like: "like", ilike: "ilike" }[op];
@@ -3,11 +3,13 @@ import { RequestOptions } from "../../core/types/request-options.js";
3
3
  import { ITransport } from "../../core/transports/transport.interface.js";
4
4
  import { SubmitCommandRequest } from "../../core/types/requests/submit-command-request.js";
5
5
  import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
6
+ import { SubmitCommandTransactionResponse } from "../../core/types/responses/submit-command-transaction-response.js";
6
7
  import { PreparedCommandSubmission } from "../../core/types/prepared-command-submission.js";
7
8
  import { SignCommandResult } from "../../core/signing/sign-command-result.js";
8
9
  export declare class CommandServiceClient {
9
10
  private readonly pipeline;
10
11
  constructor(transport: ITransport, signer?: ICommandSigner | CommandSigners);
12
+ submitAndWaitForTransactionAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandTransactionResponse>;
11
13
  /** Submits a command and waits for the result. Supported on JSON and gRPC. */
12
14
  submitAndWaitAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
13
15
  prepareAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
@@ -7,6 +7,7 @@ export class CommandServiceClient {
7
7
  signer,
8
8
  });
9
9
  }
10
+ submitAndWaitForTransactionAsync(request, options) { return this.pipeline.submitForTransactionAsync(request, options); }
10
11
  /** Submits a command and waits for the result. Supported on JSON and gRPC. */
11
12
  submitAndWaitAsync(request, options) {
12
13
  return this.pipeline.submitAsync(request, options);
@@ -3,6 +3,7 @@ import { ITransport } from "../../core/transports/transport.interface.js";
3
3
  import { RequestOptions } from "../../core/types/request-options.js";
4
4
  import { SubmitCommandRequest } from "../../core/types/requests/submit-command-request.js";
5
5
  import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
6
+ import { SubmitCommandTransactionResponse } from "../../core/types/responses/submit-command-transaction-response.js";
6
7
  import { PreparedCommandSubmission } from "../../core/types/prepared-command-submission.js";
7
8
  import { SignCommandResult } from "../../core/signing/sign-command-result.js";
8
9
  export declare class CommandSubmissionPipeline {
@@ -12,6 +13,7 @@ export declare class CommandSubmissionPipeline {
12
13
  signer?: ICommandSigner | CommandSigners;
13
14
  });
14
15
  submitAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
16
+ submitForTransactionAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandTransactionResponse>;
15
17
  prepareAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
16
18
  executeAsync(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
17
19
  }
@@ -12,6 +12,8 @@ export class CommandSubmissionPipeline {
12
12
  }
13
13
  return this.dependencies.transport.submitCommandAsync(request, this.dependencies.signer, options);
14
14
  }
15
+ submitForTransactionAsync(request, options) { if (!this.dependencies.transport.submitCommandForTransactionAsync)
16
+ throw new NotSupportedError("transaction-returning command submission is not supported by the selected transport"); return this.dependencies.transport.submitCommandForTransactionAsync(request, options); }
15
17
  prepareAsync(request, options) { if (!this.dependencies.transport.prepareCommandAsync)
16
18
  throw new NotSupportedError("interactive command preparation is not supported by the selected transport"); return this.dependencies.transport.prepareCommandAsync(request, options); }
17
19
  executeAsync(prepared, signatures, options) { if (!this.dependencies.transport.executePreparedCommandAndWaitAsync)
@@ -125,6 +125,7 @@ export interface GrpcOperations {
125
125
  prepareSubmissionAsync?(request: unknown, options?: RequestOptions): Promise<unknown>;
126
126
  executeSubmissionAndWaitAsync?(request: unknown, options?: RequestOptions): Promise<unknown>;
127
127
  submitCommandAsync(request: unknown, options?: RequestOptions): Promise<unknown>;
128
+ submitCommandForTransactionAsync?(request: unknown, options?: RequestOptions): Promise<unknown>;
128
129
  }
129
130
  export interface GrpcOperationDependencies {
130
131
  versionServiceClient?: Pick<IVersionServiceClient, "getLedgerApiVersion">;
@@ -154,6 +155,6 @@ export interface GrpcOperationDependencies {
154
155
  updateServiceClient?: Pick<IUpdateServiceClient, "getUpdates" | "getUpdateByOffset" | "getUpdateById" | "getUpdateByHash" | "getUpdatesPage">;
155
156
  commandCompletionServiceClient?: Pick<ICommandCompletionServiceClient, "getCompletions">;
156
157
  interactiveSubmissionServiceClient?: Pick<IInteractiveSubmissionServiceClient, "prepareSubmission" | "executeSubmissionAndWait">;
157
- commandServiceClient?: Pick<ICommandServiceClient, "submitAndWait">;
158
+ commandServiceClient?: Pick<ICommandServiceClient, "submitAndWait" | "submitAndWaitForTransaction">;
158
159
  }
159
160
  export declare function createGrpcOperations(options: CantonClientOptions, endpoint: string, grpcChannelSecurity: GrpcChannelSecurity, dependencies?: GrpcOperationDependencies): GrpcOperations;
@@ -463,6 +463,10 @@ export function createGrpcOperations(options, endpoint, grpcChannelSecurity, dep
463
463
  const callOptions = await buildCallOptionsForLedgerSurfaceAsync(options, requestOptions);
464
464
  return await unwrapUnaryResponse(commandServiceClient.submitAndWait(request, callOptions));
465
465
  },
466
+ async submitCommandForTransactionAsync(request, requestOptions) {
467
+ const callOptions = await buildCallOptionsForLedgerSurfaceAsync(options, requestOptions);
468
+ return await unwrapUnaryResponse(commandServiceClient.submitAndWaitForTransaction(request, callOptions));
469
+ },
466
470
  async prepareSubmissionAsync(request, requestOptions) {
467
471
  const callOptions = await buildCallOptionsForLedgerSurfaceAsync(options, requestOptions);
468
472
  return await unwrapUnaryResponse(interactiveSubmissionServiceClient.prepareSubmission(request, callOptions));
@@ -278,6 +278,7 @@ export declare class GrpcTransport implements ITransport {
278
278
  getUpdatesPageAsync(request: GetUpdatesPageRequest, options?: RequestOptions): Promise<GetUpdatesPageResponse>;
279
279
  getCompletionsAsync(request: GetCompletionsRequest, observer: CompletionObserver, options?: RequestOptions): Promise<void>;
280
280
  submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner | CommandSigners, options?: RequestOptions): Promise<SubmitCommandResponse>;
281
+ submitCommandForTransactionAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<import("../../core/types/responses/submit-command-transaction-response.js").SubmitCommandTransactionResponse>;
281
282
  prepareCommandAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
282
283
  executePreparedCommandAndWaitAsync(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
283
284
  private throwIfDisposed;
@@ -11,7 +11,7 @@ import { NotSupportedError } from "../../core/errors/not-supported-error.js";
11
11
  import { TransportError } from "../../core/errors/transport-error.js";
12
12
  import { PackageFormat } from "../../core/types/package-format.js";
13
13
  import { createGrpcOperations, } from "./grpc-channel-factory.js";
14
- import { mapGrpcSubmitCommand, mapGrpcSubmitCommandRequest, } from "./mappers/commands-mapper.js";
14
+ import { mapGrpcSubmitCommand, mapGrpcSubmitCommandForTransactionRequest, mapGrpcSubmitCommandTransaction, mapGrpcSubmitCommandRequest, } from "./mappers/commands-mapper.js";
15
15
  import { mapGrpcExecuteSubmissionAndWaitRequest, mapGrpcInteractiveSubmitCommand, mapGrpcPrepareSubmissionRequest, } from "./mappers/interactive-command-mapper.js";
16
16
  import { mapGrpcGetContract, mapGrpcGetContractRequest, mapGrpcQueryContracts, mapGrpcQueryContractsRequest, } from "./mappers/contracts-mapper.js";
17
17
  import { mapGrpcCompletionStreamResponse, mapGrpcGetCompletionsRequest, } from "./mappers/command-completion-mapper.js";
@@ -617,6 +617,12 @@ export class GrpcTransport {
617
617
  }), options);
618
618
  return mapGrpcInteractiveSubmitCommand(executed);
619
619
  }
620
+ async submitCommandForTransactionAsync(request, options) {
621
+ this.throwIfDisposed();
622
+ if (!this.operations.submitCommandForTransactionAsync)
623
+ throw new NotSupportedError("transaction-returning command submission is not available on this transport");
624
+ return mapGrpcSubmitCommandTransaction(await this.operations.submitCommandForTransactionAsync(mapGrpcSubmitCommandForTransactionRequest(request), options));
625
+ }
620
626
  async prepareCommandAsync(request, options) {
621
627
  if (!this.operations.prepareSubmissionAsync)
622
628
  throw new NotSupportedError("interactive gRPC command signing is not available on this transport");
@@ -2,10 +2,13 @@ import { CreateCommand } from "../../../core/types/commands/create-command.js";
2
2
  import { LedgerCommand } from "../../../core/types/commands/ledger-command.js";
3
3
  import { SubmitCommandRequest } from "../../../core/types/requests/submit-command-request.js";
4
4
  import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
5
+ import { SubmitCommandTransactionResponse } from "../../../core/types/responses/submit-command-transaction-response.js";
5
6
  import { Command } from "../generated/canton/com/daml/ledger/api/v2/commands.js";
6
- import { SubmitAndWaitRequest, SubmitAndWaitResponse } from "../generated/canton/com/daml/ledger/api/v2/command_service.js";
7
+ import { SubmitAndWaitRequest, SubmitAndWaitResponse, SubmitAndWaitForTransactionRequest, SubmitAndWaitForTransactionResponse } from "../generated/canton/com/daml/ledger/api/v2/command_service.js";
7
8
  import { Identifier, Record as GrpcRecord, Value } from "../generated/canton/com/daml/ledger/api/v2/value.js";
8
9
  export declare function mapGrpcSubmitCommandRequest(request: SubmitCommandRequest): SubmitAndWaitRequest;
10
+ export declare function mapGrpcSubmitCommandForTransactionRequest(request: SubmitCommandRequest): SubmitAndWaitForTransactionRequest;
11
+ export declare function mapGrpcSubmitCommandTransaction(payload: SubmitAndWaitForTransactionResponse): SubmitCommandTransactionResponse;
9
12
  export declare function mapGrpcSubmitCommand(payload: {
10
13
  commandId?: string;
11
14
  transactionId?: string;
@@ -4,9 +4,12 @@ import { CreateAndExerciseCommand } from "../../../core/types/commands/create-an
4
4
  import { CreateCommand } from "../../../core/types/commands/create-command.js";
5
5
  import { DamlNumeric } from "../../../core/types/daml-numeric.js";
6
6
  import { DamlParty } from "../../../core/types/daml-party.js";
7
+ import { DamlContractId } from "../../../core/types/daml-contract-id.js";
8
+ import { DamlDate, DamlEnum, DamlGenMap, DamlRecord, DamlTextMap, DamlTimestamp, DamlUnit, DamlVariant } from "../../../core/types/daml-values.js";
7
9
  import { ExerciseByKeyCommand } from "../../../core/types/commands/exercise-by-key-command.js";
8
10
  import { ExerciseCommand } from "../../../core/types/commands/exercise-command.js";
9
11
  import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
12
+ import { SubmitCommandTransactionResponse } from "../../../core/types/responses/submit-command-transaction-response.js";
10
13
  export function mapGrpcSubmitCommandRequest(request) {
11
14
  return {
12
15
  commands: {
@@ -27,6 +30,8 @@ export function mapGrpcSubmitCommandRequest(request) {
27
30
  },
28
31
  };
29
32
  }
33
+ export function mapGrpcSubmitCommandForTransactionRequest(request) { return { commands: mapGrpcSubmitCommandRequest(request).commands }; }
34
+ export function mapGrpcSubmitCommandTransaction(payload) { const transaction = payload.transaction; return new SubmitCommandTransactionResponse(transaction?.updateId ?? "", transaction?.events ?? [], transaction); }
30
35
  function mapGrpcDisclosedContract(value) {
31
36
  return { createdEventBlob: value.createdEventBlob, contractId: value.contractId ?? "", synchronizerId: value.synchronizerId ?? "", templateId: value.templateId === undefined ? undefined : { packageId: value.templateId.packageId, moduleName: value.templateId.moduleName, entityName: value.templateId.entityName } };
32
37
  }
@@ -103,6 +108,23 @@ export function mapRecord(payload) {
103
108
  };
104
109
  }
105
110
  export function mapValue(value) {
111
+ const identifier = (value) => ({ packageId: value.packageId, moduleName: value.moduleName, entityName: value.entityName });
112
+ if (value instanceof DamlUnit)
113
+ return { sum: { oneofKind: "unit", unit: {} } };
114
+ if (value instanceof DamlDate)
115
+ return { sum: { oneofKind: "date", date: value.daysSinceEpoch } };
116
+ if (value instanceof DamlTimestamp)
117
+ return { sum: { oneofKind: "timestamp", timestamp: value.microsecondsSinceEpoch } };
118
+ if (value instanceof DamlTextMap)
119
+ return { sum: { oneofKind: "textMap", textMap: { entries: value.entries.map(([key, item]) => ({ key, value: mapValue(item) })) } } };
120
+ if (value instanceof DamlGenMap)
121
+ return { sum: { oneofKind: "genMap", genMap: { entries: value.entries.map(([key, item]) => ({ key: mapValue(key), value: mapValue(item) })) } } };
122
+ if (value instanceof DamlVariant)
123
+ return { sum: { oneofKind: "variant", variant: { variantId: value.variantId && identifier(value.variantId), constructor: value.constructorName, value: mapValue(value.value) } } };
124
+ if (value instanceof DamlEnum)
125
+ return { sum: { oneofKind: "enum", enum: { enumId: value.enumId && identifier(value.enumId), constructor: value.constructorName } } };
126
+ if (value instanceof DamlRecord)
127
+ return { sum: { oneofKind: "record", record: { recordId: value.recordId && identifier(value.recordId), fields: mapRecord(value.fields).fields } } };
106
128
  if (value === null || value === undefined) {
107
129
  return {
108
130
  sum: {
@@ -119,6 +141,9 @@ export function mapValue(value) {
119
141
  },
120
142
  };
121
143
  }
144
+ else if (value instanceof DamlContractId) {
145
+ return { sum: { oneofKind: "contractId", contractId: value.value } };
146
+ }
122
147
  else if (value instanceof DamlNumeric) {
123
148
  return {
124
149
  sum: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distrohelena/canton-typescript-sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",