@distrohelena/canton-typescript-sdk 0.1.35 → 0.1.37
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/README.md +159 -51
- package/dist/cjs/core/types/requests/{submit-command-request.js → submit-commands-request.js} +10 -6
- package/dist/cjs/index.js +10 -8
- package/dist/cjs/query/canonical/in-memory-query-evaluator.js +291 -0
- package/dist/cjs/query/canonical/public-identity.js +41 -0
- package/dist/cjs/query/canonical/query-ast.js +2 -0
- package/dist/cjs/query/canonical/query-dataset.js +351 -0
- package/dist/cjs/query/canonical/query-normalizer.js +655 -0
- package/dist/cjs/query/canonical/query-schema.js +86 -0
- package/dist/cjs/query/canton-manager.js +14 -5
- package/dist/cjs/query/errors/query-snapshot-incomplete-error.js +19 -0
- package/dist/cjs/query/grpc/grpc-contract-cache.js +484 -0
- package/dist/cjs/query/grpc/grpc-package-relation-reader.js +218 -0
- package/dist/cjs/query/grpc/grpc-query-client.js +249 -0
- package/dist/cjs/query/grpc/grpc-query-snapshot-reader.js +238 -0
- package/dist/cjs/query/grpc/grpc-query-value-mapper.js +204 -0
- package/dist/cjs/query/grpc/grpc-relation-mapper.js +794 -0
- package/dist/cjs/query/pqs/pqs-query-client.js +151 -582
- package/dist/cjs/query/pqs/pqs-relational-sql-compiler.js +138 -95
- package/dist/cjs/query/pqs/pqs-result-shape.js +28 -0
- package/dist/cjs/query/pqs/pqs-schema-profile.js +49 -48
- package/dist/cjs/query/pqs/pqs-sql-compiler.js +343 -289
- package/dist/cjs/query/pqs/pqs-sql-syntax.js +10 -0
- package/dist/cjs/services/command/command-service-client.js +16 -3
- package/dist/cjs/services/commands/command-payload-builder.js +1 -1
- package/dist/cjs/services/commands/command-submission-pipeline.js +21 -6
- package/dist/cjs/services/state/state-service-client.js +56 -0
- package/dist/cjs/testing/runtime/declarative-action-executor.js +3 -3
- package/dist/cjs/transports/grpc/grpc-transport.js +2 -2
- package/dist/cjs/transports/grpc/mappers/commands-mapper.js +6 -6
- package/dist/cjs/transports/grpc/mappers/interactive-command-mapper.js +1 -1
- package/dist/cjs/transports/json/json-transport.js +1 -1
- package/dist/cjs/transports/json/mappers/commands-mapper.js +3 -3
- package/dist/core/transports/transport.interface.d.ts +4 -4
- package/dist/core/types/prepared-command-submission.d.ts +3 -3
- package/dist/core/types/requests/{submit-command-request.d.ts → submit-commands-request.d.ts} +8 -4
- package/dist/core/types/requests/{submit-command-request.js → submit-commands-request.js} +8 -4
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/query/canonical/in-memory-query-evaluator.d.ts +22 -0
- package/dist/query/canonical/in-memory-query-evaluator.js +287 -0
- package/dist/query/canonical/public-identity.d.ts +14 -0
- package/dist/query/canonical/public-identity.js +35 -0
- package/dist/query/canonical/query-ast.d.ts +104 -0
- package/dist/query/canonical/query-ast.js +1 -0
- package/dist/query/canonical/query-dataset.d.ts +63 -0
- package/dist/query/canonical/query-dataset.js +343 -0
- package/dist/query/canonical/query-normalizer.d.ts +10 -0
- package/dist/query/canonical/query-normalizer.js +646 -0
- package/dist/query/canonical/query-schema.d.ts +25 -0
- package/dist/query/canonical/query-schema.js +83 -0
- package/dist/query/canton-manager.js +14 -5
- package/dist/query/errors/query-snapshot-incomplete-error.d.ts +14 -0
- package/dist/query/errors/query-snapshot-incomplete-error.js +15 -0
- package/dist/query/grpc/grpc-contract-cache.d.ts +27 -0
- package/dist/query/grpc/grpc-contract-cache.js +479 -0
- package/dist/query/grpc/grpc-package-relation-reader.d.ts +43 -0
- package/dist/query/grpc/grpc-package-relation-reader.js +213 -0
- package/dist/query/grpc/grpc-query-client.d.ts +42 -0
- package/dist/query/grpc/grpc-query-client.js +245 -0
- package/dist/query/grpc/grpc-query-snapshot-reader.d.ts +33 -0
- package/dist/query/grpc/grpc-query-snapshot-reader.js +233 -0
- package/dist/query/grpc/grpc-query-value-mapper.d.ts +15 -0
- package/dist/query/grpc/grpc-query-value-mapper.js +195 -0
- package/dist/query/grpc/grpc-relation-mapper.d.ts +67 -0
- package/dist/query/grpc/grpc-relation-mapper.js +789 -0
- package/dist/query/pqs/pqs-query-client.d.ts +10 -20
- package/dist/query/pqs/pqs-query-client.js +154 -585
- package/dist/query/pqs/pqs-relational-sql-compiler.d.ts +9 -17
- package/dist/query/pqs/pqs-relational-sql-compiler.js +136 -95
- package/dist/query/pqs/pqs-result-shape.d.ts +25 -0
- package/dist/query/pqs/pqs-result-shape.js +25 -0
- package/dist/query/pqs/pqs-schema-profile.js +49 -48
- package/dist/query/pqs/pqs-sql-compiler.d.ts +18 -3
- package/dist/query/pqs/pqs-sql-compiler.js +337 -288
- package/dist/query/pqs/pqs-sql-syntax.d.ts +2 -0
- package/dist/query/pqs/pqs-sql-syntax.js +6 -0
- package/dist/query/query-client.d.ts +15 -0
- package/dist/services/command/command-service-client.d.ts +9 -4
- package/dist/services/command/command-service-client.js +16 -3
- package/dist/services/command-submission/command-submission-service-client.d.ts +2 -2
- package/dist/services/commands/command-payload-builder.d.ts +2 -2
- package/dist/services/commands/command-payload-builder.js +1 -1
- package/dist/services/commands/command-submission-pipeline.d.ts +5 -4
- package/dist/services/commands/command-submission-pipeline.js +21 -6
- package/dist/services/state/state-service-client.d.ts +4 -0
- package/dist/services/state/state-service-client.js +56 -0
- package/dist/testing/runtime/declarative-action-executor.js +3 -3
- package/dist/transports/grpc/grpc-transport.d.ts +4 -4
- package/dist/transports/grpc/grpc-transport.js +3 -3
- package/dist/transports/grpc/mappers/commands-mapper.d.ts +3 -3
- package/dist/transports/grpc/mappers/commands-mapper.js +4 -4
- package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +3 -3
- package/dist/transports/grpc/mappers/interactive-command-mapper.js +1 -1
- package/dist/transports/json/json-transport.d.ts +2 -2
- package/dist/transports/json/json-transport.js +2 -2
- package/dist/transports/json/mappers/commands-mapper.d.ts +2 -2
- package/dist/transports/json/mappers/commands-mapper.js +2 -2
- package/package.json +8 -3
- package/dist/cjs/query/grpc/grpc-contract-query-client.js +0 -178
- package/dist/query/grpc/grpc-contract-query-client.d.ts +0 -33
- package/dist/query/grpc/grpc-contract-query-client.js +0 -174
|
@@ -8,6 +8,19 @@ export interface FindManyArgs<TWhere, TSelect, TOrderBy, TInclude = never> {
|
|
|
8
8
|
readonly take?: number;
|
|
9
9
|
readonly include?: TInclude;
|
|
10
10
|
}
|
|
11
|
+
export interface ContractCacheArgs {
|
|
12
|
+
readonly parties?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export type ContractCacheResult = {
|
|
15
|
+
readonly source: QuerySource.grpc;
|
|
16
|
+
readonly cached: true;
|
|
17
|
+
readonly activeAtOffset: string;
|
|
18
|
+
readonly contractCount: number;
|
|
19
|
+
readonly expiresAt: Date;
|
|
20
|
+
} | {
|
|
21
|
+
readonly source: QuerySource.pqs;
|
|
22
|
+
readonly cached: false;
|
|
23
|
+
};
|
|
11
24
|
export interface QueryDelegate<TRow, TWhere, TSelect, TOrderBy, TUnique, TInclude = never, TGroupBy = never, TGroupRow = never> {
|
|
12
25
|
findMany<TArgs extends FindManyArgs<TWhere, TSelect, TOrderBy, TInclude>>(args?: TArgs): Promise<readonly (TRow & JsonProjectionResult<TArgs>)[]>;
|
|
13
26
|
findUnique<TArgs extends {
|
|
@@ -36,6 +49,8 @@ export type QueryCollectionDelegate<TRow, TWhere, TSelect, TOrderBy, TInclude =
|
|
|
36
49
|
export interface QueryClient {
|
|
37
50
|
readonly source: QuerySource;
|
|
38
51
|
$queryRaw<TRow>(sql: string, values?: readonly unknown[]): Promise<readonly TRow[]>;
|
|
52
|
+
cacheContracts(args?: ContractCacheArgs): Promise<ContractCacheResult>;
|
|
53
|
+
invalidateContractsCache(args?: ContractCacheArgs): Promise<void>;
|
|
39
54
|
readonly contracts: {
|
|
40
55
|
findMany<TArgs extends ContractFindManyArgs>(args?: TArgs): Promise<readonly (ContractResult & JsonProjectionResult<TArgs>)[]>;
|
|
41
56
|
findUnique<TArgs extends ContractFindUniqueArgs>(args: TArgs): Promise<(ContractResult & JsonProjectionResult<TArgs>) | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandSigners, ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
2
2
|
import { RequestOptions } from "../../core/types/request-options.js";
|
|
3
3
|
import { ITransport } from "../../core/transports/transport.interface.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
5
5
|
import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
|
|
6
6
|
import { SubmitCommandTransactionResponse } from "../../core/types/responses/submit-command-transaction-response.js";
|
|
7
7
|
import { PreparedCommandSubmission } from "../../core/types/prepared-command-submission.js";
|
|
@@ -9,9 +9,14 @@ import { SignCommandResult } from "../../core/signing/sign-command-result.js";
|
|
|
9
9
|
export declare class CommandServiceClient {
|
|
10
10
|
private readonly pipeline;
|
|
11
11
|
constructor(transport: ITransport, signer?: ICommandSigner | CommandSigners);
|
|
12
|
-
submitAndWaitForTransactionAsync(request:
|
|
12
|
+
submitAndWaitForTransactionAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandTransactionResponse>;
|
|
13
13
|
/** Submits a command and waits for the result. Supported on JSON and gRPC. */
|
|
14
|
-
submitAndWaitAsync(request:
|
|
15
|
-
|
|
14
|
+
submitAndWaitAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Submits through the connected participant without external command signing.
|
|
17
|
+
* A configured command signer is deliberately ignored for this call.
|
|
18
|
+
*/
|
|
19
|
+
submitParticipantLocalAndWaitAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
20
|
+
prepareAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
|
|
16
21
|
executeAndWaitAsync(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
17
22
|
}
|
|
@@ -7,11 +7,24 @@ export class CommandServiceClient {
|
|
|
7
7
|
signer,
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
submitAndWaitForTransactionAsync(request, options) {
|
|
10
|
+
submitAndWaitForTransactionAsync(request, options) {
|
|
11
|
+
return this.pipeline.submitForTransactionAsync(request, options);
|
|
12
|
+
}
|
|
11
13
|
/** Submits a command and waits for the result. Supported on JSON and gRPC. */
|
|
12
14
|
submitAndWaitAsync(request, options) {
|
|
13
15
|
return this.pipeline.submitAsync(request, options);
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Submits through the connected participant without external command signing.
|
|
19
|
+
* A configured command signer is deliberately ignored for this call.
|
|
20
|
+
*/
|
|
21
|
+
submitParticipantLocalAndWaitAsync(request, options) {
|
|
22
|
+
return this.pipeline.submitParticipantLocalAsync(request, options);
|
|
23
|
+
}
|
|
24
|
+
prepareAsync(request, options) {
|
|
25
|
+
return this.pipeline.prepareAsync(request, options);
|
|
26
|
+
}
|
|
27
|
+
executeAndWaitAsync(prepared, signatures, options) {
|
|
28
|
+
return this.pipeline.executeAsync(prepared, signatures, options);
|
|
29
|
+
}
|
|
17
30
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ITransport } from "../../core/transports/transport.interface.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
3
3
|
import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
|
|
4
4
|
export declare class CommandSubmissionServiceClient {
|
|
5
5
|
private readonly transport;
|
|
6
6
|
constructor(transport: ITransport);
|
|
7
7
|
/** Submits a command without waiting. Placeholder until explicitly implemented. */
|
|
8
|
-
submitAsync(_request:
|
|
8
|
+
submitAsync(_request: SubmitCommandsRequest): Promise<SubmitCommandResponse>;
|
|
9
9
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function buildCanonicalCommandPayload(request:
|
|
1
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
2
|
+
export declare function buildCanonicalCommandPayload(request: SubmitCommandsRequest): Uint8Array;
|
|
@@ -7,7 +7,7 @@ export function buildCanonicalCommandPayload(request) {
|
|
|
7
7
|
applicationId: request.applicationId,
|
|
8
8
|
actAs: request.actAs,
|
|
9
9
|
readAs: request.readAs,
|
|
10
|
-
|
|
10
|
+
commands: request.commands.map(mapCanonicalCommand),
|
|
11
11
|
}));
|
|
12
12
|
}
|
|
13
13
|
function mapCanonicalCommand(command) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandSigners, ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
2
2
|
import { ITransport } from "../../core/transports/transport.interface.js";
|
|
3
3
|
import { RequestOptions } from "../../core/types/request-options.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
5
5
|
import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
|
|
6
6
|
import { SubmitCommandTransactionResponse } from "../../core/types/responses/submit-command-transaction-response.js";
|
|
7
7
|
import { PreparedCommandSubmission } from "../../core/types/prepared-command-submission.js";
|
|
@@ -12,8 +12,9 @@ export declare class CommandSubmissionPipeline {
|
|
|
12
12
|
transport: ITransport;
|
|
13
13
|
signer?: ICommandSigner | CommandSigners;
|
|
14
14
|
});
|
|
15
|
-
submitAsync(request:
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
submitAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
16
|
+
submitParticipantLocalAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
17
|
+
submitForTransactionAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<SubmitCommandTransactionResponse>;
|
|
18
|
+
prepareAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
|
|
18
19
|
executeAsync(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
19
20
|
}
|
|
@@ -12,10 +12,25 @@ export class CommandSubmissionPipeline {
|
|
|
12
12
|
}
|
|
13
13
|
return this.dependencies.transport.submitCommandAsync(request, this.dependencies.signer, options);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
submitParticipantLocalAsync(request, options) {
|
|
16
|
+
return this.dependencies.transport.submitCommandAsync(request, undefined, options);
|
|
17
|
+
}
|
|
18
|
+
submitForTransactionAsync(request, options) {
|
|
19
|
+
if (!this.dependencies.transport.submitCommandForTransactionAsync) {
|
|
20
|
+
throw new NotSupportedError("transaction-returning command submission is not supported by the selected transport");
|
|
21
|
+
}
|
|
22
|
+
return this.dependencies.transport.submitCommandForTransactionAsync(request, options);
|
|
23
|
+
}
|
|
24
|
+
prepareAsync(request, options) {
|
|
25
|
+
if (!this.dependencies.transport.prepareCommandAsync) {
|
|
26
|
+
throw new NotSupportedError("interactive command preparation is not supported by the selected transport");
|
|
27
|
+
}
|
|
28
|
+
return this.dependencies.transport.prepareCommandAsync(request, options);
|
|
29
|
+
}
|
|
30
|
+
executeAsync(prepared, signatures, options) {
|
|
31
|
+
if (!this.dependencies.transport.executePreparedCommandAndWaitAsync) {
|
|
32
|
+
throw new NotSupportedError("interactive command execution is not supported by the selected transport");
|
|
33
|
+
}
|
|
34
|
+
return this.dependencies.transport.executePreparedCommandAndWaitAsync(prepared, signatures, options);
|
|
35
|
+
}
|
|
21
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITransport } from "../../core/transports/transport.interface.js";
|
|
2
|
+
import { ActiveContractsTraversalOptions } from "../../core/types/active-contracts-traversal-options.js";
|
|
2
3
|
import { RequestOptions } from "../../core/types/request-options.js";
|
|
3
4
|
import { GetActiveContractsRequest } from "../../core/types/requests/get-active-contracts-request.js";
|
|
4
5
|
import type { GetActiveContractsPageRequest, GetActiveContractsPageResponse, GetConnectedSynchronizersRequest, GetConnectedSynchronizersResponse, GetLedgerEndRequest, GetLedgerEndResponse, GetLatestPrunedOffsetsRequest, GetLatestPrunedOffsetsResponse } from "../../transports/grpc/generated/canton/com/daml/ledger/api/v2/state_service.js";
|
|
@@ -8,6 +9,8 @@ export declare class StateServiceClient {
|
|
|
8
9
|
constructor(transport: ITransport);
|
|
9
10
|
/** Reads a page of active contracts. Supported on gRPC; JSON rejects it. */
|
|
10
11
|
getActiveContractsPageAsync(request: GetActiveContractsPageRequest, options?: RequestOptions): Promise<GetActiveContractsPageResponse>;
|
|
12
|
+
/** Reads active-contract pages lazily. Supported on gRPC; JSON rejects it. */
|
|
13
|
+
getActiveContractsPagesAsync(request: GetActiveContractsPageRequest, options: ActiveContractsTraversalOptions): AsyncIterable<GetActiveContractsPageResponse>;
|
|
11
14
|
/** Reads active contracts as a stream. JSON-backed; gRPC currently rejects it. */
|
|
12
15
|
getActiveContractsAsync(request: GetActiveContractsRequest, observer: ContractObserver, options?: RequestOptions): Promise<void>;
|
|
13
16
|
/** Reads connected synchronizers. Supported on gRPC; JSON rejects it. */
|
|
@@ -16,4 +19,5 @@ export declare class StateServiceClient {
|
|
|
16
19
|
getLedgerEndAsync(request: GetLedgerEndRequest, options?: RequestOptions): Promise<GetLedgerEndResponse>;
|
|
17
20
|
/** Reads the latest participant pruning offsets. Supported on gRPC; JSON rejects it. */
|
|
18
21
|
getLatestPrunedOffsetsAsync(request: GetLatestPrunedOffsetsRequest, options?: RequestOptions): Promise<GetLatestPrunedOffsetsResponse>;
|
|
22
|
+
private getActiveContractsPagesLazy;
|
|
19
23
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ActiveContractsTraversalError } from "../../core/errors/active-contracts-traversal-error.js";
|
|
2
|
+
import { ValidationError } from "../../core/errors/validation-error.js";
|
|
1
3
|
export class StateServiceClient {
|
|
2
4
|
transport;
|
|
3
5
|
constructor(transport) {
|
|
@@ -8,6 +10,10 @@ export class StateServiceClient {
|
|
|
8
10
|
getActiveContractsPageAsync(request, options) {
|
|
9
11
|
return this.transport.getActiveContractsPageAsync(request, options);
|
|
10
12
|
}
|
|
13
|
+
/** Reads active-contract pages lazily. Supported on gRPC; JSON rejects it. */
|
|
14
|
+
getActiveContractsPagesAsync(request, options) {
|
|
15
|
+
return this.getActiveContractsPagesLazy(request, options);
|
|
16
|
+
}
|
|
11
17
|
/** Reads active contracts as a stream. JSON-backed; gRPC currently rejects it. */
|
|
12
18
|
getActiveContractsAsync(request, observer, options) {
|
|
13
19
|
return this.transport.getActiveContractsAsync(request, observer, options);
|
|
@@ -24,4 +30,54 @@ export class StateServiceClient {
|
|
|
24
30
|
getLatestPrunedOffsetsAsync(request, options) {
|
|
25
31
|
return this.transport.getLatestPrunedOffsetsAsync(request, options);
|
|
26
32
|
}
|
|
33
|
+
async *getActiveContractsPagesLazy(request, options) {
|
|
34
|
+
if (request.pageToken && request.pageToken.length > 0) {
|
|
35
|
+
throw new ValidationError("active contracts traversal must not start with a page token");
|
|
36
|
+
}
|
|
37
|
+
let pageRequest = request;
|
|
38
|
+
let pagesRead = 0;
|
|
39
|
+
let contractsRead = 0;
|
|
40
|
+
let activeAtOffset;
|
|
41
|
+
const observedPageTokens = new Set();
|
|
42
|
+
while (true) {
|
|
43
|
+
if (pagesRead >= options.maxPages) {
|
|
44
|
+
throw new ActiveContractsTraversalError("max-pages-exceeded", "active contracts traversal exceeded maxPages");
|
|
45
|
+
}
|
|
46
|
+
const response = await this.transport.getActiveContractsPageAsync(pageRequest, options.deadline.createRequestOptions());
|
|
47
|
+
pagesRead += 1;
|
|
48
|
+
if (typeof response.activeAtOffset !== "string" ||
|
|
49
|
+
response.activeAtOffset.trim().length === 0) {
|
|
50
|
+
throw new ActiveContractsTraversalError("missing-active-at-offset", "active contracts response is missing activeAtOffset");
|
|
51
|
+
}
|
|
52
|
+
else if (activeAtOffset === undefined) {
|
|
53
|
+
if (request.activeAtOffset !== undefined &&
|
|
54
|
+
request.activeAtOffset !== response.activeAtOffset) {
|
|
55
|
+
throw new ActiveContractsTraversalError("active-at-offset-mismatch", "active contracts response activeAtOffset does not match the request");
|
|
56
|
+
}
|
|
57
|
+
activeAtOffset = response.activeAtOffset;
|
|
58
|
+
}
|
|
59
|
+
else if (activeAtOffset !== response.activeAtOffset) {
|
|
60
|
+
throw new ActiveContractsTraversalError("active-at-offset-mismatch", "active contracts response activeAtOffset changed during traversal");
|
|
61
|
+
}
|
|
62
|
+
contractsRead += response.activeContracts.length;
|
|
63
|
+
if (contractsRead > options.maxContracts) {
|
|
64
|
+
throw new ActiveContractsTraversalError("max-contracts-exceeded", "active contracts traversal exceeded maxContracts");
|
|
65
|
+
}
|
|
66
|
+
yield response;
|
|
67
|
+
if (!response.nextPageToken || response.nextPageToken.length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const pageTokenKey = Array.from(response.nextPageToken).join(",");
|
|
71
|
+
if (observedPageTokens.has(pageTokenKey)) {
|
|
72
|
+
throw new ActiveContractsTraversalError("repeated-page-token", "active contracts traversal received a repeated page token");
|
|
73
|
+
}
|
|
74
|
+
observedPageTokens.add(pageTokenKey);
|
|
75
|
+
pageRequest = {
|
|
76
|
+
activeAtOffset,
|
|
77
|
+
eventFormat: request.eventFormat,
|
|
78
|
+
maxPageSize: request.maxPageSize,
|
|
79
|
+
pageToken: response.nextPageToken,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
27
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CreateCommand } from "../../core/types/commands/create-command.js";
|
|
2
2
|
import { ExerciseCommand } from "../../core/types/commands/exercise-command.js";
|
|
3
3
|
import { DamlRecord } from "../../core/types/daml-values.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
5
5
|
import { TestingConfigurationError } from "../errors/testing-configuration-error.js";
|
|
6
6
|
import { toCampaignMetricOutcome, } from "./canton-test-runtime.js";
|
|
7
7
|
/**
|
|
@@ -18,11 +18,11 @@ export async function executeDeclarativeActionAsync(init) {
|
|
|
18
18
|
templateId: init.action.templateId,
|
|
19
19
|
createArguments: new DamlRecord({ ...init.action.payload }),
|
|
20
20
|
});
|
|
21
|
-
return toCampaignMetricOutcome(await init.runtime.submitAndWaitAsync(init.action.actor, new
|
|
21
|
+
return toCampaignMetricOutcome(await init.runtime.submitAndWaitAsync(init.action.actor, new SubmitCommandsRequest({
|
|
22
22
|
applicationId: init.applicationId,
|
|
23
23
|
actAs: route.actAs,
|
|
24
24
|
readAs: route.readAs,
|
|
25
|
-
command,
|
|
25
|
+
commands: [command],
|
|
26
26
|
})));
|
|
27
27
|
}
|
|
28
28
|
async function createExerciseCommandAsync(action, resolveContractIdAsync) {
|
|
@@ -6,7 +6,7 @@ import { ListKnownPartiesRequest } from "../../core/types/requests/list-known-pa
|
|
|
6
6
|
import { ListPartyToParticipantRequest } from "../../core/types/requests/list-party-to-participant-request.js";
|
|
7
7
|
import { ListUserRightsRequest } from "../../core/types/requests/list-user-rights-request.js";
|
|
8
8
|
import { ListUsersRequest } from "../../core/types/requests/list-users-request.js";
|
|
9
|
-
import {
|
|
9
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
10
10
|
import { CommandSigners, ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
11
11
|
import { SignCommandResult } from "../../core/signing/sign-command-result.js";
|
|
12
12
|
import { PreparedCommandSubmission } from "../../core/types/prepared-command-submission.js";
|
|
@@ -151,9 +151,9 @@ export declare class GrpcTransport implements ITransport {
|
|
|
151
151
|
getUpdateByHashAsync(request: GetUpdateByHashRequest, options?: RequestOptions): Promise<ProtobufGetUpdateResponse>;
|
|
152
152
|
getUpdatesPageAsync(request: GetUpdatesPageRequest, options?: RequestOptions): Promise<ProtobufGetUpdatesPageResponse>;
|
|
153
153
|
getCompletionsAsync(request: GetCompletionsRequest, options?: RequestOptions): AsyncIterable<ProtobufCompletionStreamResponse>;
|
|
154
|
-
submitCommandAsync(request:
|
|
155
|
-
submitCommandForTransactionAsync(request:
|
|
156
|
-
prepareCommandAsync(request:
|
|
154
|
+
submitCommandAsync(request: SubmitCommandsRequest, signer?: ICommandSigner | CommandSigners, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
155
|
+
submitCommandForTransactionAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<import("../../core/types/responses/submit-command-transaction-response.js").SubmitCommandTransactionResponse>;
|
|
156
|
+
prepareCommandAsync(request: SubmitCommandsRequest, options?: RequestOptions): Promise<PreparedCommandSubmission>;
|
|
157
157
|
executePreparedCommandAndWaitAsync(prepared: PreparedCommandSubmission, signatures: Readonly<Record<string, SignCommandResult>>, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
158
158
|
private throwIfDisposed;
|
|
159
159
|
private throwPartyTopologyReadCompatibilityError;
|
|
@@ -7,7 +7,7 @@ import { ListKnownPartiesResponse as SdkListKnownPartiesResponse } from "../../c
|
|
|
7
7
|
import { NotSupportedError } from "../../core/errors/not-supported-error.js";
|
|
8
8
|
import { TransportError } from "../../core/errors/transport-error.js";
|
|
9
9
|
import { createGrpcOperations, } from "./grpc-channel-factory.js";
|
|
10
|
-
import { mapGrpcSubmitCommand,
|
|
10
|
+
import { mapGrpcSubmitCommand, mapGrpcSubmitCommandsForTransactionRequest, mapGrpcSubmitCommandTransaction, mapGrpcSubmitCommandsRequest, } from "./mappers/commands-mapper.js";
|
|
11
11
|
import { mapGrpcExecuteSubmissionAndWaitRequest, mapGrpcInteractiveSubmitCommand, mapGrpcPrepareSubmissionRequest, } from "./mappers/interactive-command-mapper.js";
|
|
12
12
|
import { mapGrpcCreateParty, mapGrpcCreatePartyRequest, mapGrpcListParties, mapGrpcListPartiesRequest } from "./mappers/parties-mapper.js";
|
|
13
13
|
import { mapGrpcListPartyToParticipantRequest, mapGrpcListPartyToParticipantResponse, } from "./mappers/topology-manager-read-mapper.js";
|
|
@@ -487,7 +487,7 @@ export class GrpcTransport {
|
|
|
487
487
|
async submitCommandAsync(request, signer, options) {
|
|
488
488
|
this.throwIfDisposed();
|
|
489
489
|
if (!signer) {
|
|
490
|
-
const payload = await this.operations.submitCommandAsync(
|
|
490
|
+
const payload = await this.operations.submitCommandAsync(mapGrpcSubmitCommandsRequest(request), options);
|
|
491
491
|
return mapGrpcSubmitCommand(payload);
|
|
492
492
|
}
|
|
493
493
|
else if (request.actAs.length !== 1 && !("signAsync" in signer)) {
|
|
@@ -529,7 +529,7 @@ export class GrpcTransport {
|
|
|
529
529
|
if (!this.operations.submitCommandForTransactionAsync) {
|
|
530
530
|
throw new NotSupportedError("transaction-returning command submission is not available on this transport");
|
|
531
531
|
}
|
|
532
|
-
return mapGrpcSubmitCommandTransaction(await this.operations.submitCommandForTransactionAsync(
|
|
532
|
+
return mapGrpcSubmitCommandTransaction(await this.operations.submitCommandForTransactionAsync(mapGrpcSubmitCommandsForTransactionRequest(request), options));
|
|
533
533
|
}
|
|
534
534
|
async prepareCommandAsync(request, options) {
|
|
535
535
|
if (!this.operations.prepareSubmissionAsync) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { CreateCommand } from "../../../core/types/commands/create-command.js";
|
|
2
2
|
import { DamlRecord } from "../../../core/types/daml-values.js";
|
|
3
3
|
import { LedgerCommand } from "../../../core/types/commands/ledger-command.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SubmitCommandsRequest } from "../../../core/types/requests/submit-commands-request.js";
|
|
5
5
|
import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
|
|
6
6
|
import { SubmitCommandTransactionResponse } from "../../../core/types/responses/submit-command-transaction-response.js";
|
|
7
7
|
import { Command } from "../generated/canton/com/daml/ledger/api/v2/commands.js";
|
|
8
8
|
import { SubmitAndWaitRequest, SubmitAndWaitResponse, SubmitAndWaitForTransactionRequest, SubmitAndWaitForTransactionResponse } from "../generated/canton/com/daml/ledger/api/v2/command_service.js";
|
|
9
9
|
import { Record as GrpcRecord, Value } from "../generated/canton/com/daml/ledger/api/v2/value.js";
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
10
|
+
export declare function mapGrpcSubmitCommandsRequest(request: SubmitCommandsRequest): SubmitAndWaitRequest;
|
|
11
|
+
export declare function mapGrpcSubmitCommandsForTransactionRequest(request: SubmitCommandsRequest): SubmitAndWaitForTransactionRequest;
|
|
12
12
|
export declare function mapGrpcSubmitCommandTransaction(payload: SubmitAndWaitForTransactionResponse): SubmitCommandTransactionResponse;
|
|
13
13
|
export declare function mapGrpcSubmitCommand(payload: {
|
|
14
14
|
commandId?: string;
|
|
@@ -11,13 +11,13 @@ import { ExerciseCommand } from "../../../core/types/commands/exercise-command.j
|
|
|
11
11
|
import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
|
|
12
12
|
import { SubmitCommandTransactionResponse } from "../../../core/types/responses/submit-command-transaction-response.js";
|
|
13
13
|
import { mapGrpcDeduplicationPeriod } from "./command-deduplication-mapper.js";
|
|
14
|
-
export function
|
|
14
|
+
export function mapGrpcSubmitCommandsRequest(request) {
|
|
15
15
|
return {
|
|
16
16
|
commands: {
|
|
17
17
|
workflowId: "",
|
|
18
18
|
userId: request.userId ?? "",
|
|
19
19
|
commandId: request.commandId ?? randomUUID(),
|
|
20
|
-
commands:
|
|
20
|
+
commands: request.commands.map(mapGrpcLedgerCommand),
|
|
21
21
|
deduplicationPeriod: mapGrpcDeduplicationPeriod(request.deduplicationPeriod, { allowParticipantBegin: true }),
|
|
22
22
|
actAs: [...request.actAs],
|
|
23
23
|
readAs: [...request.readAs],
|
|
@@ -29,8 +29,8 @@ export function mapGrpcSubmitCommandRequest(request) {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export function
|
|
33
|
-
return { commands:
|
|
32
|
+
export function mapGrpcSubmitCommandsForTransactionRequest(request) {
|
|
33
|
+
return { commands: mapGrpcSubmitCommandsRequest(request).commands };
|
|
34
34
|
}
|
|
35
35
|
export function mapGrpcSubmitCommandTransaction(payload) {
|
|
36
36
|
const transaction = payload.transaction;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SignCommandResult } from "../../../core/signing/sign-command-result.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SubmitCommandsRequest } from "../../../core/types/requests/submit-commands-request.js";
|
|
3
3
|
import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
|
|
4
4
|
import { Signature } from "../generated/canton/com/daml/ledger/api/v2/crypto.js";
|
|
5
5
|
import { ExecuteSubmissionAndWaitRequest, ExecuteSubmissionAndWaitResponse, HashingSchemeVersion, PrepareSubmissionRequest, PreparedTransaction } from "../generated/canton/com/daml/ledger/api/v2/interactive/interactive_submission_service.js";
|
|
6
|
-
export declare function mapGrpcPrepareSubmissionRequest(request:
|
|
6
|
+
export declare function mapGrpcPrepareSubmissionRequest(request: SubmitCommandsRequest, commandId: string): PrepareSubmissionRequest;
|
|
7
7
|
export declare function mapGrpcExecuteSubmissionAndWaitRequest(init: {
|
|
8
|
-
request:
|
|
8
|
+
request: SubmitCommandsRequest;
|
|
9
9
|
preparedTransaction: PreparedTransaction;
|
|
10
10
|
hashingSchemeVersion: HashingSchemeVersion;
|
|
11
11
|
submissionId: string;
|
|
@@ -10,7 +10,7 @@ export function mapGrpcPrepareSubmissionRequest(request, commandId) {
|
|
|
10
10
|
return {
|
|
11
11
|
userId: request.userId ?? "",
|
|
12
12
|
commandId,
|
|
13
|
-
commands:
|
|
13
|
+
commands: request.commands.map(mapGrpcLedgerCommand),
|
|
14
14
|
actAs: [...request.actAs],
|
|
15
15
|
readAs: [...request.readAs],
|
|
16
16
|
disclosedContracts: request.disclosedContracts.map(value => ({ 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 } })),
|
|
@@ -5,7 +5,7 @@ import { ListKnownPartiesRequest } from "../../core/types/requests/list-known-pa
|
|
|
5
5
|
import { ListPartyToParticipantRequest } from "../../core/types/requests/list-party-to-participant-request.js";
|
|
6
6
|
import { ListUserRightsRequest } from "../../core/types/requests/list-user-rights-request.js";
|
|
7
7
|
import { ListUsersRequest } from "../../core/types/requests/list-users-request.js";
|
|
8
|
-
import {
|
|
8
|
+
import { SubmitCommandsRequest } from "../../core/types/requests/submit-commands-request.js";
|
|
9
9
|
import { AllocatePartyResponse } from "../../core/types/responses/allocate-party-response.js";
|
|
10
10
|
import { GetUserResponse } from "../../core/types/responses/get-user-response.js";
|
|
11
11
|
import { ListPartyToParticipantResponse } from "../../core/types/responses/list-party-to-participant-response.js";
|
|
@@ -150,6 +150,6 @@ export declare class JsonTransport implements ITransport {
|
|
|
150
150
|
getUpdateByHashAsync(_request: GetUpdateByHashRequest, _options?: RequestOptions): Promise<GetUpdateResponse>;
|
|
151
151
|
getUpdatesPageAsync(_request: GetUpdatesPageRequest, _options?: RequestOptions): Promise<GetUpdatesPageResponse>;
|
|
152
152
|
getCompletionsAsync(_request: GetCompletionsRequest, _options?: RequestOptions): AsyncIterable<CompletionStreamResponse>;
|
|
153
|
-
submitCommandAsync(request:
|
|
153
|
+
submitCommandAsync(request: SubmitCommandsRequest, signer?: ICommandSigner, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
154
154
|
private throwIfDisposed;
|
|
155
155
|
}
|
|
@@ -3,7 +3,7 @@ import { ListKnownPartiesResponse } from "../../core/types/responses/list-known-
|
|
|
3
3
|
import { NotSupportedError } from "../../core/errors/not-supported-error.js";
|
|
4
4
|
import { GetLedgerApiVersionResponse } from "../grpc/generated/canton/com/daml/ledger/api/v2/version_service.js";
|
|
5
5
|
import { ObjectDisposedError } from "../../core/errors/object-disposed-error.js";
|
|
6
|
-
import { mapJsonSubmitCommand,
|
|
6
|
+
import { mapJsonSubmitCommand, mapJsonSubmitCommandsRequest, } from "./mappers/commands-mapper.js";
|
|
7
7
|
import { UploadDarFileResponse } from "../grpc/generated/canton/com/daml/ledger/api/v2/admin/package_management_service.js";
|
|
8
8
|
import { mapJsonAllocatePartyRequest, mapJsonCreateParty, mapJsonListParties, } from "./mappers/parties-mapper.js";
|
|
9
9
|
import { mapJsonTransactionEvents } from "./mappers/events-mapper.js";
|
|
@@ -451,7 +451,7 @@ export class JsonTransport {
|
|
|
451
451
|
if (signer) {
|
|
452
452
|
throw new NotSupportedError("command signing is not supported by json transport");
|
|
453
453
|
}
|
|
454
|
-
const payload = await this.httpClient.postAsync("/v2/commands/submit-and-wait",
|
|
454
|
+
const payload = await this.httpClient.postAsync("/v2/commands/submit-and-wait", mapJsonSubmitCommandsRequest(request), options);
|
|
455
455
|
return mapJsonSubmitCommand(payload);
|
|
456
456
|
}
|
|
457
457
|
throwIfDisposed() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SubmitCommandsRequest } from "../../../core/types/requests/submit-commands-request.js";
|
|
2
2
|
import { SubmitCommandResponse } from "../../../core/types/responses/submit-command-response.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function mapJsonSubmitCommandsRequest(request: SubmitCommandsRequest): {
|
|
4
4
|
commandId: string;
|
|
5
5
|
actAs: readonly string[];
|
|
6
6
|
readAs: readonly string[];
|
|
@@ -9,7 +9,7 @@ import { DamlRecord } from "../../../core/types/daml-values.js";
|
|
|
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
|
-
export function
|
|
12
|
+
export function mapJsonSubmitCommandsRequest(request) {
|
|
13
13
|
if (request.deduplicationPeriod !== undefined) {
|
|
14
14
|
throw new TransportError("command deduplication periods are not supported by the JSON transport");
|
|
15
15
|
}
|
|
@@ -17,7 +17,7 @@ export function mapJsonSubmitCommandRequest(request) {
|
|
|
17
17
|
commandId: request.commandId ?? randomUUID(),
|
|
18
18
|
actAs: request.actAs,
|
|
19
19
|
readAs: request.readAs,
|
|
20
|
-
commands:
|
|
20
|
+
commands: request.commands.map(mapJsonCommand),
|
|
21
21
|
applicationId: request.applicationId || undefined,
|
|
22
22
|
};
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distrohelena/canton-typescript-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -98,6 +98,11 @@
|
|
|
98
98
|
"example:workflow:retry": "npm run build && node --loader ts-node/esm examples/91-idempotent-command-retry.ts",
|
|
99
99
|
"example:workflow:resume": "npm run build && node --loader ts-node/esm examples/92-resume-update-stream.ts",
|
|
100
100
|
"example:workflow:stale-contract": "npm run build && node --loader ts-node/esm examples/93-archive-and-stale-contract.ts",
|
|
101
|
+
"example:workflow:command-completion": "npm run build && node --loader ts-node/esm examples/94-command-completion-correlation.ts",
|
|
102
|
+
"example:workflow:contract-lifecycle-audit": "npm run build && node --loader ts-node/esm examples/95-contract-lifecycle-audit.ts",
|
|
103
|
+
"example:workflow:update-lookup-reconciliation": "npm run build && node --loader ts-node/esm examples/96-update-lookup-reconciliation.ts",
|
|
104
|
+
"example:workflow:pruning-preflight": "npm run build && node --loader ts-node/esm examples/97-pruning-preflight.ts",
|
|
105
|
+
"example:workflow:participant-local": "npm run build && node --loader ts-node/esm examples/98-participant-local-command-submission.ts",
|
|
101
106
|
"lint": "eslint . --max-warnings=0",
|
|
102
107
|
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
103
108
|
"start:local-ledger": "bash node/start-local.sh",
|
|
@@ -108,9 +113,9 @@
|
|
|
108
113
|
"test:stop-local-script": "bash node/test-stop-local.sh",
|
|
109
114
|
"test:participant-358-sidecar-script": "bash node/test-participant-358-sidecar.sh",
|
|
110
115
|
"test:participant-358-sidecar-smoke": "bash node/test-participant-358-sidecar-smoke.sh",
|
|
111
|
-
"test": "vitest run --maxWorkers=1 --testTimeout=15000",
|
|
116
|
+
"test": "vitest run --exclude 'tests/live/**' --maxWorkers=1 --testTimeout=15000",
|
|
112
117
|
"test:property": "vitest run tests/property --maxWorkers=1 --testTimeout=15000",
|
|
113
|
-
"test:live": "vitest run tests/live --maxWorkers=1 --testTimeout=15000",
|
|
118
|
+
"test:live": "vitest run --dir tests/live --maxWorkers=1 --testTimeout=15000",
|
|
114
119
|
"test:live:fuzz": "vitest run tests/live/specs/live-stateful-fuzzing.test.ts --maxWorkers=1 --testTimeout=300000",
|
|
115
120
|
"test:unit": "vitest run tests/unit",
|
|
116
121
|
"verify:pack": "node ./scripts/verify-npm-pack.mjs"
|