@distrohelena/canton-typescript-sdk 0.1.11 → 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.
- package/dist/core/transports/transport.interface.d.ts +2 -0
- package/dist/core/types/responses/submit-command-transaction-response.d.ts +7 -0
- package/dist/core/types/responses/submit-command-transaction-response.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/command/command-service-client.d.ts +2 -0
- package/dist/services/command/command-service-client.js +1 -0
- package/dist/services/commands/command-submission-pipeline.d.ts +2 -0
- package/dist/services/commands/command-submission-pipeline.js +2 -0
- package/dist/transports/grpc/grpc-channel-factory.d.ts +2 -1
- package/dist/transports/grpc/grpc-channel-factory.js +4 -0
- package/dist/transports/grpc/grpc-transport.d.ts +1 -0
- package/dist/transports/grpc/grpc-transport.js +7 -1
- package/dist/transports/grpc/mappers/commands-mapper.d.ts +4 -1
- package/dist/transports/grpc/mappers/commands-mapper.js +3 -0
- package/package.json +1 -1
|
@@ -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,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
|
@@ -210,6 +210,7 @@ export { DisclosedContract } from "./core/types/disclosed-contract.js";
|
|
|
210
210
|
export { PreparedCommandSubmission } from "./core/types/prepared-command-submission.js";
|
|
211
211
|
export { DamlContractId } from "./core/types/daml-contract-id.js";
|
|
212
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";
|
|
213
214
|
export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
|
|
214
215
|
export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
|
|
215
216
|
export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
|
package/dist/index.js
CHANGED
|
@@ -197,6 +197,7 @@ export { DisclosedContract } from "./core/types/disclosed-contract.js";
|
|
|
197
197
|
export { PreparedCommandSubmission } from "./core/types/prepared-command-submission.js";
|
|
198
198
|
export { DamlContractId } from "./core/types/daml-contract-id.js";
|
|
199
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";
|
|
200
201
|
export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
|
|
201
202
|
export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
|
|
202
203
|
export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
|
|
@@ -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;
|
|
@@ -9,6 +9,7 @@ import { DamlDate, DamlEnum, DamlGenMap, DamlRecord, DamlTextMap, DamlTimestamp,
|
|
|
9
9
|
import { ExerciseByKeyCommand } from "../../../core/types/commands/exercise-by-key-command.js";
|
|
10
10
|
import { ExerciseCommand } from "../../../core/types/commands/exercise-command.js";
|
|
11
11
|
import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
|
|
12
|
+
import { SubmitCommandTransactionResponse } from "../../../core/types/responses/submit-command-transaction-response.js";
|
|
12
13
|
export function mapGrpcSubmitCommandRequest(request) {
|
|
13
14
|
return {
|
|
14
15
|
commands: {
|
|
@@ -29,6 +30,8 @@ export function mapGrpcSubmitCommandRequest(request) {
|
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
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); }
|
|
32
35
|
function mapGrpcDisclosedContract(value) {
|
|
33
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 } };
|
|
34
37
|
}
|