@distrohelena/canton-typescript-sdk 0.1.6 → 0.1.7
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/signing/command-signer.interface.d.ts +2 -0
- package/dist/core/transports/transport.interface.d.ts +2 -2
- package/dist/core/types/disclosed-contract.d.ts +13 -0
- package/dist/core/types/disclosed-contract.js +15 -0
- package/dist/core/types/requests/submit-command-request.d.ts +5 -0
- package/dist/core/types/requests/submit-command-request.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/command/command-service-client.d.ts +2 -2
- package/dist/services/commands/command-submission-pipeline.d.ts +2 -2
- package/dist/transports/grpc/grpc-transport.d.ts +2 -2
- package/dist/transports/grpc/grpc-transport.js +7 -6
- package/dist/transports/grpc/mappers/commands-mapper.js +5 -2
- package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +4 -1
- package/dist/transports/grpc/mappers/interactive-command-mapper.js +3 -8
- package/package.json +1 -1
|
@@ -3,3 +3,5 @@ import { SignCommandResult } from "./sign-command-result.js";
|
|
|
3
3
|
export interface ICommandSigner {
|
|
4
4
|
signAsync(request: SignCommandRequest): Promise<SignCommandResult>;
|
|
5
5
|
}
|
|
6
|
+
/** One signer for each party that acts in an interactively signed command. */
|
|
7
|
+
export type CommandSigners = Readonly<Record<string, ICommandSigner>>;
|
|
@@ -185,7 +185,7 @@ import { CompletionObserver } from "../../services/command-completion/completion
|
|
|
185
185
|
import { CommitmentChunkObserver } from "../../services/participant-inspection/commitment-chunk-observer.interface.js";
|
|
186
186
|
import { ContractObserver } from "../../services/contracts/contract-observer.interface.js";
|
|
187
187
|
import { TransactionObserver } from "../../services/events/transaction-observer.interface.js";
|
|
188
|
-
import { ICommandSigner } from "../signing/command-signer.interface.js";
|
|
188
|
+
import { CommandSigners, ICommandSigner } from "../signing/command-signer.interface.js";
|
|
189
189
|
import { RequestOptions } from "../types/request-options.js";
|
|
190
190
|
import { SubmitCommandRequest } from "../types/requests/submit-command-request.js";
|
|
191
191
|
export interface ITransport {
|
|
@@ -380,5 +380,5 @@ export interface ITransport {
|
|
|
380
380
|
* Submits a command.
|
|
381
381
|
* Supported on JSON and gRPC. External signing is gRPC-only.
|
|
382
382
|
*/
|
|
383
|
-
submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
383
|
+
submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner | CommandSigners, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
384
384
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateId } from "../../query/model-types.js";
|
|
2
|
+
export declare class DisclosedContract {
|
|
3
|
+
readonly createdEventBlob: Uint8Array;
|
|
4
|
+
readonly templateId?: TemplateId;
|
|
5
|
+
readonly contractId?: string;
|
|
6
|
+
readonly synchronizerId?: string;
|
|
7
|
+
constructor(init: {
|
|
8
|
+
createdEventBlob: Uint8Array;
|
|
9
|
+
templateId?: TemplateId;
|
|
10
|
+
contractId?: string;
|
|
11
|
+
synchronizerId?: string;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValidationError } from "../errors/validation-error.js";
|
|
2
|
+
export class DisclosedContract {
|
|
3
|
+
createdEventBlob;
|
|
4
|
+
templateId;
|
|
5
|
+
contractId;
|
|
6
|
+
synchronizerId;
|
|
7
|
+
constructor(init) {
|
|
8
|
+
if (init.createdEventBlob.length === 0)
|
|
9
|
+
throw new ValidationError("disclosed contracts require a createdEventBlob");
|
|
10
|
+
this.createdEventBlob = init.createdEventBlob;
|
|
11
|
+
this.templateId = init.templateId;
|
|
12
|
+
this.contractId = init.contractId;
|
|
13
|
+
this.synchronizerId = init.synchronizerId;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { LedgerCommand } from "../commands/ledger-command.js";
|
|
2
|
+
import { DisclosedContract } from "../disclosed-contract.js";
|
|
2
3
|
export declare class SubmitCommandRequest {
|
|
3
4
|
readonly applicationId: string;
|
|
4
5
|
readonly userId?: string;
|
|
5
6
|
readonly actAs: readonly string[];
|
|
6
7
|
readonly readAs: readonly string[];
|
|
7
8
|
readonly command: LedgerCommand;
|
|
9
|
+
readonly disclosedContracts: readonly DisclosedContract[];
|
|
10
|
+
readonly synchronizerId?: string;
|
|
8
11
|
constructor(init: {
|
|
9
12
|
applicationId: string;
|
|
10
13
|
userId?: string;
|
|
11
14
|
actAs: readonly string[];
|
|
12
15
|
readAs?: readonly string[];
|
|
13
16
|
command: LedgerCommand;
|
|
17
|
+
disclosedContracts?: readonly DisclosedContract[];
|
|
18
|
+
synchronizerId?: string;
|
|
14
19
|
});
|
|
15
20
|
}
|
|
@@ -5,6 +5,8 @@ export class SubmitCommandRequest {
|
|
|
5
5
|
actAs;
|
|
6
6
|
readAs;
|
|
7
7
|
command;
|
|
8
|
+
disclosedContracts;
|
|
9
|
+
synchronizerId;
|
|
8
10
|
constructor(init) {
|
|
9
11
|
if (init.actAs.length === 0) {
|
|
10
12
|
throw new ValidationError("submit requests require at least one actAs party");
|
|
@@ -14,5 +16,7 @@ export class SubmitCommandRequest {
|
|
|
14
16
|
this.actAs = init.actAs;
|
|
15
17
|
this.readAs = init.readAs ?? [];
|
|
16
18
|
this.command = init.command;
|
|
19
|
+
this.disclosedContracts = init.disclosedContracts ?? [];
|
|
20
|
+
this.synchronizerId = init.synchronizerId;
|
|
17
21
|
}
|
|
18
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -206,6 +206,7 @@ export { AllocateExternalPartyRequest } from "./core/types/requests/allocate-ext
|
|
|
206
206
|
export { CreateExternalPartyRequest, } from "./core/types/requests/create-external-party-request.js";
|
|
207
207
|
export type { ExternalPartySigner, ExternalPartySigningRequest, ExternalPartySigningResult, ExternalPartySigningPayloadKind, } from "./core/types/requests/create-external-party-request.js";
|
|
208
208
|
export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
|
|
209
|
+
export { DisclosedContract } from "./core/types/disclosed-contract.js";
|
|
209
210
|
export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
|
|
210
211
|
export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
|
|
211
212
|
export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
|
package/dist/index.js
CHANGED
|
@@ -193,6 +193,7 @@ export { FinalizeDecentralizedPartyRequest, PreparedDecentralizedParty } from ".
|
|
|
193
193
|
export { AllocateExternalPartyRequest } from "./core/types/requests/allocate-external-party-request.js";
|
|
194
194
|
export { CreateExternalPartyRequest, } from "./core/types/requests/create-external-party-request.js";
|
|
195
195
|
export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
|
|
196
|
+
export { DisclosedContract } from "./core/types/disclosed-contract.js";
|
|
196
197
|
export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
|
|
197
198
|
export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
|
|
198
199
|
export { AssembleSignedTopologyTransactionsRequest } from "./core/types/requests/assemble-signed-topology-transactions-request.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
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
4
|
import { SubmitCommandRequest } from "../../core/types/requests/submit-command-request.js";
|
|
5
5
|
import { SubmitCommandResponse } from "../../core/types/responses/submit-command-response.js";
|
|
6
6
|
export declare class CommandServiceClient {
|
|
7
7
|
private readonly pipeline;
|
|
8
|
-
constructor(transport: ITransport, signer?: ICommandSigner);
|
|
8
|
+
constructor(transport: ITransport, signer?: ICommandSigner | CommandSigners);
|
|
9
9
|
/** Submits a command and waits for the result. Supported on JSON and gRPC. */
|
|
10
10
|
submitAndWaitAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
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
4
|
import { SubmitCommandRequest } from "../../core/types/requests/submit-command-request.js";
|
|
@@ -7,7 +7,7 @@ export declare class CommandSubmissionPipeline {
|
|
|
7
7
|
private readonly dependencies;
|
|
8
8
|
constructor(dependencies: {
|
|
9
9
|
transport: ITransport;
|
|
10
|
-
signer?: ICommandSigner;
|
|
10
|
+
signer?: ICommandSigner | CommandSigners;
|
|
11
11
|
});
|
|
12
12
|
submitAsync(request: SubmitCommandRequest, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
13
13
|
}
|
|
@@ -84,7 +84,7 @@ import { TopologyListPartiesRequest } from "../../core/types/requests/topology-l
|
|
|
84
84
|
import { TopologyListVettedPackagesRequest } from "../../core/types/requests/topology-list-vetted-packages-request.js";
|
|
85
85
|
import { TrafficControlStateRequest } from "../../core/types/requests/traffic-control-state-request.js";
|
|
86
86
|
import { UploadDarFileRequest } from "../../core/types/requests/upload-dar-file-request.js";
|
|
87
|
-
import { ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
87
|
+
import { CommandSigners, ICommandSigner } from "../../core/signing/command-signer.interface.js";
|
|
88
88
|
import { AllocatePartyResponse as SdkAllocatePartyResponse } from "../../core/types/responses/allocate-party-response.js";
|
|
89
89
|
import { AllocateExternalPartyResponse } from "../../core/types/responses/allocate-external-party-response.js";
|
|
90
90
|
import { AddPartyAsyncResponse } from "../../core/types/responses/add-party-async-response.js";
|
|
@@ -275,7 +275,7 @@ export declare class GrpcTransport implements ITransport {
|
|
|
275
275
|
getUpdateByHashAsync(request: GetUpdateByHashRequest, options?: RequestOptions): Promise<GetUpdateByHashResponse>;
|
|
276
276
|
getUpdatesPageAsync(request: GetUpdatesPageRequest, options?: RequestOptions): Promise<GetUpdatesPageResponse>;
|
|
277
277
|
getCompletionsAsync(request: GetCompletionsRequest, observer: CompletionObserver, options?: RequestOptions): Promise<void>;
|
|
278
|
-
submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
278
|
+
submitCommandAsync(request: SubmitCommandRequest, signer?: ICommandSigner | CommandSigners, options?: RequestOptions): Promise<SubmitCommandResponse>;
|
|
279
279
|
private throwIfDisposed;
|
|
280
280
|
private throwPartyTopologyReadCompatibilityError;
|
|
281
281
|
private isProtobufDeserializationFailure;
|
|
@@ -583,7 +583,7 @@ export class GrpcTransport {
|
|
|
583
583
|
const payload = await this.operations.submitCommandAsync(mapGrpcSubmitCommandRequest(request), options);
|
|
584
584
|
return mapGrpcSubmitCommand(payload);
|
|
585
585
|
}
|
|
586
|
-
else if (request.actAs.length !== 1) {
|
|
586
|
+
else if (request.actAs.length !== 1 && !("signAsync" in signer)) {
|
|
587
587
|
throw new ValidationError("interactive gRPC command signing currently requires exactly one actAs party");
|
|
588
588
|
}
|
|
589
589
|
else if (!this.operations.prepareSubmissionAsync) {
|
|
@@ -601,17 +601,18 @@ export class GrpcTransport {
|
|
|
601
601
|
else if (prepared.preparedTransactionHash.length === 0) {
|
|
602
602
|
throw new ValidationError("interactive prepare submission did not return a preparedTransactionHash");
|
|
603
603
|
}
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
604
|
+
const signerResults = await Promise.all(request.actAs.map(async (party) => {
|
|
605
|
+
const partySigner = "signAsync" in signer ? signer : signer[party];
|
|
606
|
+
if (partySigner === undefined)
|
|
607
|
+
throw new ValidationError(`interactive command signing requires a signer for ${party}`);
|
|
608
|
+
return { party, result: await partySigner.signAsync(new SignCommandRequest({ payload: prepared.preparedTransactionHash, party, algorithmHint: "ed25519" })) };
|
|
608
609
|
}));
|
|
609
610
|
const executed = await this.operations.executeSubmissionAndWaitAsync(mapGrpcExecuteSubmissionAndWaitRequest({
|
|
610
611
|
request,
|
|
611
612
|
preparedTransaction: prepared.preparedTransaction,
|
|
612
613
|
hashingSchemeVersion: prepared.hashingSchemeVersion,
|
|
613
614
|
submissionId,
|
|
614
|
-
|
|
615
|
+
signerResults,
|
|
615
616
|
}), options);
|
|
616
617
|
return mapGrpcInteractiveSubmitCommand(executed);
|
|
617
618
|
}
|
|
@@ -20,13 +20,16 @@ export function mapGrpcSubmitCommandRequest(request) {
|
|
|
20
20
|
actAs: [...request.actAs],
|
|
21
21
|
readAs: [...request.readAs],
|
|
22
22
|
submissionId: "",
|
|
23
|
-
disclosedContracts:
|
|
24
|
-
synchronizerId: "",
|
|
23
|
+
disclosedContracts: request.disclosedContracts.map(mapGrpcDisclosedContract),
|
|
24
|
+
synchronizerId: request.synchronizerId ?? "",
|
|
25
25
|
packageIdSelectionPreference: [],
|
|
26
26
|
prefetchContractKeys: [],
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
function mapGrpcDisclosedContract(value) {
|
|
31
|
+
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
|
+
}
|
|
30
33
|
export function mapGrpcSubmitCommand(payload) {
|
|
31
34
|
return new SubmitCommandResponse({
|
|
32
35
|
commandId: "commandId" in payload ? payload.commandId : undefined,
|
|
@@ -9,7 +9,10 @@ export declare function mapGrpcExecuteSubmissionAndWaitRequest(init: {
|
|
|
9
9
|
preparedTransaction: PreparedTransaction;
|
|
10
10
|
hashingSchemeVersion: HashingSchemeVersion;
|
|
11
11
|
submissionId: string;
|
|
12
|
-
|
|
12
|
+
signerResults: readonly {
|
|
13
|
+
readonly party: string;
|
|
14
|
+
readonly result: SignCommandResult;
|
|
15
|
+
}[];
|
|
13
16
|
}): ExecuteSubmissionAndWaitRequest;
|
|
14
17
|
export declare function mapGrpcInteractiveSubmitCommand(payload: ExecuteSubmissionAndWaitResponse): SubmitCommandResponse;
|
|
15
18
|
export declare function mapGrpcSignature(result: SignCommandResult): Signature;
|
|
@@ -9,8 +9,8 @@ export function mapGrpcPrepareSubmissionRequest(request, commandId) {
|
|
|
9
9
|
commands: [mapGrpcLedgerCommand(request.command)],
|
|
10
10
|
actAs: [...request.actAs],
|
|
11
11
|
readAs: [...request.readAs],
|
|
12
|
-
disclosedContracts:
|
|
13
|
-
synchronizerId: "",
|
|
12
|
+
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 } })),
|
|
13
|
+
synchronizerId: request.synchronizerId ?? "",
|
|
14
14
|
packageIdSelectionPreference: [],
|
|
15
15
|
prefetchContractKeys: [],
|
|
16
16
|
verboseHashing: false,
|
|
@@ -20,12 +20,7 @@ export function mapGrpcExecuteSubmissionAndWaitRequest(init) {
|
|
|
20
20
|
return {
|
|
21
21
|
preparedTransaction: init.preparedTransaction,
|
|
22
22
|
partySignatures: {
|
|
23
|
-
signatures: [
|
|
24
|
-
{
|
|
25
|
-
party: init.request.actAs[0] ?? "",
|
|
26
|
-
signatures: [mapGrpcSignature(init.signerResult)],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
23
|
+
signatures: init.signerResults.map(({ party, result }) => ({ party, signatures: [mapGrpcSignature(result)] })),
|
|
29
24
|
},
|
|
30
25
|
deduplicationPeriod: {
|
|
31
26
|
oneofKind: undefined,
|