@distrohelena/canton-typescript-sdk 1.0.2 → 1.0.4
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/cjs/grpc/index.js +4 -1
- package/dist/cjs/query/grpc/grpc-contract-cache.js +3 -3
- package/dist/cjs/query/grpc/grpc-query-value-mapper.js +9 -3
- package/dist/cjs/transports/grpc/mappers/topology-response-codec.js +170 -0
- package/dist/grpc/index.d.ts +1 -0
- package/dist/grpc/index.js +1 -0
- package/dist/query/grpc/grpc-contract-cache.js +3 -3
- package/dist/query/grpc/grpc-query-value-mapper.js +9 -3
- package/dist/transports/grpc/mappers/topology-response-codec.d.ts +19 -0
- package/dist/transports/grpc/mappers/topology-response-codec.js +165 -0
- package/package.json +1 -1
package/dist/cjs/grpc/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GrpcTransport = exports.GrpcLedgerClient = void 0;
|
|
3
|
+
exports.ListPartyToParticipantResponseCodec = exports.ListPartyToKeyMappingResponseCodec = exports.GrpcTransport = exports.GrpcLedgerClient = void 0;
|
|
4
4
|
var grpc_ledger_client_js_1 = require("../transports/grpc/grpc-ledger-client.js");
|
|
5
5
|
Object.defineProperty(exports, "GrpcLedgerClient", { enumerable: true, get: function () { return grpc_ledger_client_js_1.GrpcLedgerClient; } });
|
|
6
6
|
var grpc_transport_js_1 = require("../transports/grpc/grpc-transport.js");
|
|
7
7
|
Object.defineProperty(exports, "GrpcTransport", { enumerable: true, get: function () { return grpc_transport_js_1.GrpcTransport; } });
|
|
8
|
+
var topology_response_codec_js_1 = require("../transports/grpc/mappers/topology-response-codec.js");
|
|
9
|
+
Object.defineProperty(exports, "ListPartyToKeyMappingResponseCodec", { enumerable: true, get: function () { return topology_response_codec_js_1.ListPartyToKeyMappingResponseCodec; } });
|
|
10
|
+
Object.defineProperty(exports, "ListPartyToParticipantResponseCodec", { enumerable: true, get: function () { return topology_response_codec_js_1.ListPartyToParticipantResponseCodec; } });
|
|
@@ -240,7 +240,7 @@ class GrpcContractCache {
|
|
|
240
240
|
async writeSnapshotAsync(parties, key, activeAtOffset, contracts, creationMetadata, outcome) {
|
|
241
241
|
const expiresAtEpochMs = effectiveExpiryEpochMs(this.now, this.ttlMs);
|
|
242
242
|
const snapshot = {
|
|
243
|
-
version:
|
|
243
|
+
version: 3,
|
|
244
244
|
endpointScope: this.endpointScope,
|
|
245
245
|
parties,
|
|
246
246
|
activeAtOffset,
|
|
@@ -314,7 +314,7 @@ class GrpcContractCache {
|
|
|
314
314
|
: {}),
|
|
315
315
|
};
|
|
316
316
|
const snapshot = {
|
|
317
|
-
version:
|
|
317
|
+
version: 3,
|
|
318
318
|
endpointScope: this.endpointScope,
|
|
319
319
|
parties,
|
|
320
320
|
activeAtOffset: activeAtOffset,
|
|
@@ -416,7 +416,7 @@ function asCompatibleSnapshot(value, endpointScope, parties, nowEpochMs, ignoreE
|
|
|
416
416
|
const expiresAtEpochMs = candidate.expiresAtEpochMs;
|
|
417
417
|
const contracts = materializeContractRows(candidate.contracts);
|
|
418
418
|
const creationMetadata = materializeCreationMetadata(candidate.creationMetadata, contracts);
|
|
419
|
-
if (version !==
|
|
419
|
+
if (version !== 3
|
|
420
420
|
|| storedEndpointScope !== endpointScope
|
|
421
421
|
|| (rawParties !== undefined && storedParties === undefined)
|
|
422
422
|
|| !sameParties(storedParties, parties)
|
|
@@ -144,16 +144,22 @@ function int64(value, name) {
|
|
|
144
144
|
}
|
|
145
145
|
function timestamp(value) {
|
|
146
146
|
int64(value, "timestamp");
|
|
147
|
-
|
|
147
|
+
const micros = BigInt(value);
|
|
148
|
+
if (micros < -62135596800000000n || micros > 253402300799999999n) {
|
|
148
149
|
throw new validation_error_js_1.ValidationError("gRPC query timestamp is outside the Ledger API range");
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
+
// Daml-LF JSON encoding, as stored by PQS: sub-second part of length 0, 3, or 6.
|
|
152
|
+
const seconds = micros >= 0n || micros % 1000000n === 0n ? micros / 1000000n : micros / 1000000n - 1n;
|
|
153
|
+
const fraction = micros - seconds * 1000000n;
|
|
154
|
+
const base = new Date(Number(seconds) * 1000).toISOString().slice(0, 19);
|
|
155
|
+
const subSecond = fraction === 0n ? "" : fraction % 1000n === 0n ? `.${(fraction / 1000n).toString().padStart(3, "0")}` : `.${fraction.toString().padStart(6, "0")}`;
|
|
156
|
+
return `${base}${subSecond}Z`;
|
|
151
157
|
}
|
|
152
158
|
function date(value) {
|
|
153
159
|
if (!Number.isInteger(value) || value < MIN_DATE_EPOCH_DAY || value > MAX_DATE_EPOCH_DAY) {
|
|
154
160
|
throw new validation_error_js_1.ValidationError("gRPC query date is outside the Ledger API range");
|
|
155
161
|
}
|
|
156
|
-
return value;
|
|
162
|
+
return new Date(value * 86_400_000).toISOString().slice(0, 10);
|
|
157
163
|
}
|
|
158
164
|
function numeric(value) {
|
|
159
165
|
if (!/^[+-]?\d{1,38}(?:\.\d{0,37})?$/.test(value)) {
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListPartyToParticipantResponseCodec = exports.ListPartyToKeyMappingResponseCodec = void 0;
|
|
4
|
+
const participant_permission_js_1 = require("../../../core/types/topology/participant-permission.js");
|
|
5
|
+
const crypto_js_1 = require("../generated/canton/com/digitalasset/canton/crypto/v30/crypto.js");
|
|
6
|
+
const topology_js_1 = require("../generated/canton/com/digitalasset/canton/protocol/v30/topology.js");
|
|
7
|
+
const topology_manager_read_service_js_1 = require("../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js");
|
|
8
|
+
const topology_common_mapper_js_1 = require("./topology-common-mapper.js");
|
|
9
|
+
const topology_manager_read_mapper_js_1 = require("./topology-manager-read-mapper.js");
|
|
10
|
+
/** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
11
|
+
class ListPartyToKeyMappingResponseCodec {
|
|
12
|
+
constructor() { }
|
|
13
|
+
static fromProto(payload) {
|
|
14
|
+
return (0, topology_manager_read_mapper_js_1.mapGrpcListPartyToKeyMappingResponse)(payload);
|
|
15
|
+
}
|
|
16
|
+
static toProto(response) {
|
|
17
|
+
return {
|
|
18
|
+
results: response.results.map((result) => ({
|
|
19
|
+
context: baseResultToProto(result.context),
|
|
20
|
+
item: partyToKeyMappingToProto(result.item),
|
|
21
|
+
})),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static fromBinary(bytes) {
|
|
25
|
+
return ListPartyToKeyMappingResponseCodec.fromProto(topology_manager_read_service_js_1.ListPartyToKeyMappingResponse.fromBinary(bytes));
|
|
26
|
+
}
|
|
27
|
+
static toBinary(response) {
|
|
28
|
+
return topology_manager_read_service_js_1.ListPartyToKeyMappingResponse.toBinary(ListPartyToKeyMappingResponseCodec.toProto(response));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ListPartyToKeyMappingResponseCodec = ListPartyToKeyMappingResponseCodec;
|
|
32
|
+
/** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
33
|
+
class ListPartyToParticipantResponseCodec {
|
|
34
|
+
constructor() { }
|
|
35
|
+
static fromProto(payload) {
|
|
36
|
+
return (0, topology_manager_read_mapper_js_1.mapGrpcListPartyToParticipantResponse)(payload);
|
|
37
|
+
}
|
|
38
|
+
static toProto(response) {
|
|
39
|
+
return {
|
|
40
|
+
results: response.results.map((result) => ({
|
|
41
|
+
context: baseResultToProto(result.context),
|
|
42
|
+
item: partyToParticipantToProto(result.item),
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static fromBinary(bytes) {
|
|
47
|
+
return ListPartyToParticipantResponseCodec.fromProto(topology_manager_read_service_js_1.ListPartyToParticipantResponse.fromBinary(bytes));
|
|
48
|
+
}
|
|
49
|
+
static toBinary(response) {
|
|
50
|
+
return topology_manager_read_service_js_1.ListPartyToParticipantResponse.toBinary(ListPartyToParticipantResponseCodec.toProto(response));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ListPartyToParticipantResponseCodec = ListPartyToParticipantResponseCodec;
|
|
54
|
+
function baseResultToProto(value) {
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
store: (0, topology_common_mapper_js_1.mapGrpcTopologyStoreId)(value.storeId),
|
|
60
|
+
sequenced: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.sequencedAt),
|
|
61
|
+
validFrom: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.validFrom),
|
|
62
|
+
validUntil: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.validUntil),
|
|
63
|
+
operation: (0, topology_common_mapper_js_1.mapGrpcTopologyChangeOp)(value.operation),
|
|
64
|
+
transactionHash: new Uint8Array(value.transactionHash),
|
|
65
|
+
serial: value.serial,
|
|
66
|
+
signedByFingerprints: [...value.signedByFingerprints],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function partyToKeyMappingToProto(value) {
|
|
70
|
+
return {
|
|
71
|
+
party: value.party,
|
|
72
|
+
threshold: value.threshold,
|
|
73
|
+
signingKeys: value.signingKeys.map(signingPublicKeyToProto),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function partyToParticipantToProto(value) {
|
|
77
|
+
return {
|
|
78
|
+
party: value.party,
|
|
79
|
+
threshold: value.threshold,
|
|
80
|
+
participants: value.participants.map(hostingParticipantToProto),
|
|
81
|
+
partySigningKeys: signingKeysWithThresholdToProto(value.partySigningKeys),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function hostingParticipantToProto(value) {
|
|
85
|
+
return {
|
|
86
|
+
participantUid: value.participantUid,
|
|
87
|
+
permission: participantPermissionToProto(value.permission),
|
|
88
|
+
onboarding: value.onboarding === undefined ? undefined : {},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function signingKeysWithThresholdToProto(value) {
|
|
92
|
+
if (value === undefined) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
threshold: value.threshold,
|
|
97
|
+
keys: value.keys.map(signingPublicKeyToProto),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// The wire format carries no fingerprint (reads recompute it) and the deprecated scheme is never emitted.
|
|
101
|
+
function signingPublicKeyToProto(value) {
|
|
102
|
+
return {
|
|
103
|
+
format: cryptoKeyFormatToProto(value.format),
|
|
104
|
+
publicKey: new Uint8Array(value.publicKey),
|
|
105
|
+
scheme: crypto_js_1.SigningKeyScheme.UNSPECIFIED,
|
|
106
|
+
usage: value.usage.map(signingKeyUsageToProto),
|
|
107
|
+
keySpec: signingKeySpecToProto(value.keySpec),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function participantPermissionToProto(value) {
|
|
111
|
+
switch (value) {
|
|
112
|
+
case participant_permission_js_1.ParticipantPermission.submission:
|
|
113
|
+
return topology_js_1.Enums_ParticipantPermission.SUBMISSION;
|
|
114
|
+
case participant_permission_js_1.ParticipantPermission.confirmation:
|
|
115
|
+
return topology_js_1.Enums_ParticipantPermission.CONFIRMATION;
|
|
116
|
+
case participant_permission_js_1.ParticipantPermission.observation:
|
|
117
|
+
return topology_js_1.Enums_ParticipantPermission.OBSERVATION;
|
|
118
|
+
case participant_permission_js_1.ParticipantPermission.unspecified:
|
|
119
|
+
default:
|
|
120
|
+
return topology_js_1.Enums_ParticipantPermission.UNSPECIFIED;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function cryptoKeyFormatToProto(value) {
|
|
124
|
+
switch (value) {
|
|
125
|
+
case "der":
|
|
126
|
+
return crypto_js_1.CryptoKeyFormat.DER;
|
|
127
|
+
case "raw":
|
|
128
|
+
return crypto_js_1.CryptoKeyFormat.RAW;
|
|
129
|
+
case "derX509SubjectPublicKeyInfo":
|
|
130
|
+
return crypto_js_1.CryptoKeyFormat.DER_X509_SUBJECT_PUBLIC_KEY_INFO;
|
|
131
|
+
case "derPkcs8PrivateKeyInfo":
|
|
132
|
+
return crypto_js_1.CryptoKeyFormat.DER_PKCS8_PRIVATE_KEY_INFO;
|
|
133
|
+
case "symbolic":
|
|
134
|
+
return crypto_js_1.CryptoKeyFormat.SYMBOLIC;
|
|
135
|
+
default:
|
|
136
|
+
return crypto_js_1.CryptoKeyFormat.UNSPECIFIED;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function signingKeyUsageToProto(value) {
|
|
140
|
+
switch (value) {
|
|
141
|
+
case "namespace":
|
|
142
|
+
return crypto_js_1.SigningKeyUsage.NAMESPACE;
|
|
143
|
+
case "identityDelegation":
|
|
144
|
+
return crypto_js_1.SigningKeyUsage.IDENTITY_DELEGATION;
|
|
145
|
+
case "sequencerAuthentication":
|
|
146
|
+
return crypto_js_1.SigningKeyUsage.SEQUENCER_AUTHENTICATION;
|
|
147
|
+
case "protocol":
|
|
148
|
+
return crypto_js_1.SigningKeyUsage.PROTOCOL;
|
|
149
|
+
case "proofOfOwnership":
|
|
150
|
+
return crypto_js_1.SigningKeyUsage.PROOF_OF_OWNERSHIP;
|
|
151
|
+
default:
|
|
152
|
+
return crypto_js_1.SigningKeyUsage.UNSPECIFIED;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function signingKeySpecToProto(value) {
|
|
156
|
+
switch (value) {
|
|
157
|
+
case "ecCurve25519":
|
|
158
|
+
return crypto_js_1.SigningKeySpec.EC_CURVE25519;
|
|
159
|
+
case "ecP256":
|
|
160
|
+
return crypto_js_1.SigningKeySpec.EC_P256;
|
|
161
|
+
case "ecP384":
|
|
162
|
+
return crypto_js_1.SigningKeySpec.EC_P384;
|
|
163
|
+
case "ecSecp256k1":
|
|
164
|
+
return crypto_js_1.SigningKeySpec.EC_SECP256K1;
|
|
165
|
+
case "mlDsa65":
|
|
166
|
+
return crypto_js_1.SigningKeySpec.ML_DSA_65;
|
|
167
|
+
default:
|
|
168
|
+
return crypto_js_1.SigningKeySpec.UNSPECIFIED;
|
|
169
|
+
}
|
|
170
|
+
}
|
package/dist/grpc/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { GrpcLedgerClient } from "../transports/grpc/grpc-ledger-client.js";
|
|
2
2
|
export { GrpcTransport } from "../transports/grpc/grpc-transport.js";
|
|
3
|
+
export { ListPartyToKeyMappingResponseCodec, ListPartyToParticipantResponseCodec } from "../transports/grpc/mappers/topology-response-codec.js";
|
package/dist/grpc/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { GrpcLedgerClient } from "../transports/grpc/grpc-ledger-client.js";
|
|
2
2
|
export { GrpcTransport } from "../transports/grpc/grpc-transport.js";
|
|
3
|
+
export { ListPartyToKeyMappingResponseCodec, ListPartyToParticipantResponseCodec } from "../transports/grpc/mappers/topology-response-codec.js";
|
|
@@ -236,7 +236,7 @@ export class GrpcContractCache {
|
|
|
236
236
|
async writeSnapshotAsync(parties, key, activeAtOffset, contracts, creationMetadata, outcome) {
|
|
237
237
|
const expiresAtEpochMs = effectiveExpiryEpochMs(this.now, this.ttlMs);
|
|
238
238
|
const snapshot = {
|
|
239
|
-
version:
|
|
239
|
+
version: 3,
|
|
240
240
|
endpointScope: this.endpointScope,
|
|
241
241
|
parties,
|
|
242
242
|
activeAtOffset,
|
|
@@ -310,7 +310,7 @@ export class GrpcContractCache {
|
|
|
310
310
|
: {}),
|
|
311
311
|
};
|
|
312
312
|
const snapshot = {
|
|
313
|
-
version:
|
|
313
|
+
version: 3,
|
|
314
314
|
endpointScope: this.endpointScope,
|
|
315
315
|
parties,
|
|
316
316
|
activeAtOffset: activeAtOffset,
|
|
@@ -411,7 +411,7 @@ function asCompatibleSnapshot(value, endpointScope, parties, nowEpochMs, ignoreE
|
|
|
411
411
|
const expiresAtEpochMs = candidate.expiresAtEpochMs;
|
|
412
412
|
const contracts = materializeContractRows(candidate.contracts);
|
|
413
413
|
const creationMetadata = materializeCreationMetadata(candidate.creationMetadata, contracts);
|
|
414
|
-
if (version !==
|
|
414
|
+
if (version !== 3
|
|
415
415
|
|| storedEndpointScope !== endpointScope
|
|
416
416
|
|| (rawParties !== undefined && storedParties === undefined)
|
|
417
417
|
|| !sameParties(storedParties, parties)
|
|
@@ -135,16 +135,22 @@ function int64(value, name) {
|
|
|
135
135
|
}
|
|
136
136
|
function timestamp(value) {
|
|
137
137
|
int64(value, "timestamp");
|
|
138
|
-
|
|
138
|
+
const micros = BigInt(value);
|
|
139
|
+
if (micros < -62135596800000000n || micros > 253402300799999999n) {
|
|
139
140
|
throw new ValidationError("gRPC query timestamp is outside the Ledger API range");
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
+
// Daml-LF JSON encoding, as stored by PQS: sub-second part of length 0, 3, or 6.
|
|
143
|
+
const seconds = micros >= 0n || micros % 1000000n === 0n ? micros / 1000000n : micros / 1000000n - 1n;
|
|
144
|
+
const fraction = micros - seconds * 1000000n;
|
|
145
|
+
const base = new Date(Number(seconds) * 1000).toISOString().slice(0, 19);
|
|
146
|
+
const subSecond = fraction === 0n ? "" : fraction % 1000n === 0n ? `.${(fraction / 1000n).toString().padStart(3, "0")}` : `.${fraction.toString().padStart(6, "0")}`;
|
|
147
|
+
return `${base}${subSecond}Z`;
|
|
142
148
|
}
|
|
143
149
|
function date(value) {
|
|
144
150
|
if (!Number.isInteger(value) || value < MIN_DATE_EPOCH_DAY || value > MAX_DATE_EPOCH_DAY) {
|
|
145
151
|
throw new ValidationError("gRPC query date is outside the Ledger API range");
|
|
146
152
|
}
|
|
147
|
-
return value;
|
|
153
|
+
return new Date(value * 86_400_000).toISOString().slice(0, 10);
|
|
148
154
|
}
|
|
149
155
|
function numeric(value) {
|
|
150
156
|
if (!/^[+-]?\d{1,38}(?:\.\d{0,37})?$/.test(value)) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ListPartyToKeyMappingResponse } from "../../../core/types/responses/list-party-to-key-mapping-response.js";
|
|
2
|
+
import { ListPartyToParticipantResponse } from "../../../core/types/responses/list-party-to-participant-response.js";
|
|
3
|
+
import { ListPartyToKeyMappingResponse as GrpcListPartyToKeyMappingResponse, ListPartyToParticipantResponse as GrpcListPartyToParticipantResponse } from "../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js";
|
|
4
|
+
/** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
5
|
+
export declare class ListPartyToKeyMappingResponseCodec {
|
|
6
|
+
private constructor();
|
|
7
|
+
static fromProto(payload: Partial<GrpcListPartyToKeyMappingResponse>): ListPartyToKeyMappingResponse;
|
|
8
|
+
static toProto(response: ListPartyToKeyMappingResponse): GrpcListPartyToKeyMappingResponse;
|
|
9
|
+
static fromBinary(bytes: Uint8Array): ListPartyToKeyMappingResponse;
|
|
10
|
+
static toBinary(response: ListPartyToKeyMappingResponse): Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
/** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
13
|
+
export declare class ListPartyToParticipantResponseCodec {
|
|
14
|
+
private constructor();
|
|
15
|
+
static fromProto(payload: Partial<GrpcListPartyToParticipantResponse>): ListPartyToParticipantResponse;
|
|
16
|
+
static toProto(response: ListPartyToParticipantResponse): GrpcListPartyToParticipantResponse;
|
|
17
|
+
static fromBinary(bytes: Uint8Array): ListPartyToParticipantResponse;
|
|
18
|
+
static toBinary(response: ListPartyToParticipantResponse): Uint8Array;
|
|
19
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ParticipantPermission } from "../../../core/types/topology/participant-permission.js";
|
|
2
|
+
import { CryptoKeyFormat, SigningKeyScheme, SigningKeySpec, SigningKeyUsage, } from "../generated/canton/com/digitalasset/canton/crypto/v30/crypto.js";
|
|
3
|
+
import { Enums_ParticipantPermission, } from "../generated/canton/com/digitalasset/canton/protocol/v30/topology.js";
|
|
4
|
+
import { ListPartyToKeyMappingResponse as GrpcListPartyToKeyMappingResponse, ListPartyToParticipantResponse as GrpcListPartyToParticipantResponse, } from "../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js";
|
|
5
|
+
import { mapGrpcTimestamp, mapGrpcTopologyChangeOp, mapGrpcTopologyStoreId, } from "./topology-common-mapper.js";
|
|
6
|
+
import { mapGrpcListPartyToKeyMappingResponse, mapGrpcListPartyToParticipantResponse, } from "./topology-manager-read-mapper.js";
|
|
7
|
+
/** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
8
|
+
export class ListPartyToKeyMappingResponseCodec {
|
|
9
|
+
constructor() { }
|
|
10
|
+
static fromProto(payload) {
|
|
11
|
+
return mapGrpcListPartyToKeyMappingResponse(payload);
|
|
12
|
+
}
|
|
13
|
+
static toProto(response) {
|
|
14
|
+
return {
|
|
15
|
+
results: response.results.map((result) => ({
|
|
16
|
+
context: baseResultToProto(result.context),
|
|
17
|
+
item: partyToKeyMappingToProto(result.item),
|
|
18
|
+
})),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static fromBinary(bytes) {
|
|
22
|
+
return ListPartyToKeyMappingResponseCodec.fromProto(GrpcListPartyToKeyMappingResponse.fromBinary(bytes));
|
|
23
|
+
}
|
|
24
|
+
static toBinary(response) {
|
|
25
|
+
return GrpcListPartyToKeyMappingResponse.toBinary(ListPartyToKeyMappingResponseCodec.toProto(response));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
|
|
29
|
+
export class ListPartyToParticipantResponseCodec {
|
|
30
|
+
constructor() { }
|
|
31
|
+
static fromProto(payload) {
|
|
32
|
+
return mapGrpcListPartyToParticipantResponse(payload);
|
|
33
|
+
}
|
|
34
|
+
static toProto(response) {
|
|
35
|
+
return {
|
|
36
|
+
results: response.results.map((result) => ({
|
|
37
|
+
context: baseResultToProto(result.context),
|
|
38
|
+
item: partyToParticipantToProto(result.item),
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static fromBinary(bytes) {
|
|
43
|
+
return ListPartyToParticipantResponseCodec.fromProto(GrpcListPartyToParticipantResponse.fromBinary(bytes));
|
|
44
|
+
}
|
|
45
|
+
static toBinary(response) {
|
|
46
|
+
return GrpcListPartyToParticipantResponse.toBinary(ListPartyToParticipantResponseCodec.toProto(response));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function baseResultToProto(value) {
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
store: mapGrpcTopologyStoreId(value.storeId),
|
|
55
|
+
sequenced: mapGrpcTimestamp(value.sequencedAt),
|
|
56
|
+
validFrom: mapGrpcTimestamp(value.validFrom),
|
|
57
|
+
validUntil: mapGrpcTimestamp(value.validUntil),
|
|
58
|
+
operation: mapGrpcTopologyChangeOp(value.operation),
|
|
59
|
+
transactionHash: new Uint8Array(value.transactionHash),
|
|
60
|
+
serial: value.serial,
|
|
61
|
+
signedByFingerprints: [...value.signedByFingerprints],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function partyToKeyMappingToProto(value) {
|
|
65
|
+
return {
|
|
66
|
+
party: value.party,
|
|
67
|
+
threshold: value.threshold,
|
|
68
|
+
signingKeys: value.signingKeys.map(signingPublicKeyToProto),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function partyToParticipantToProto(value) {
|
|
72
|
+
return {
|
|
73
|
+
party: value.party,
|
|
74
|
+
threshold: value.threshold,
|
|
75
|
+
participants: value.participants.map(hostingParticipantToProto),
|
|
76
|
+
partySigningKeys: signingKeysWithThresholdToProto(value.partySigningKeys),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function hostingParticipantToProto(value) {
|
|
80
|
+
return {
|
|
81
|
+
participantUid: value.participantUid,
|
|
82
|
+
permission: participantPermissionToProto(value.permission),
|
|
83
|
+
onboarding: value.onboarding === undefined ? undefined : {},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function signingKeysWithThresholdToProto(value) {
|
|
87
|
+
if (value === undefined) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
threshold: value.threshold,
|
|
92
|
+
keys: value.keys.map(signingPublicKeyToProto),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// The wire format carries no fingerprint (reads recompute it) and the deprecated scheme is never emitted.
|
|
96
|
+
function signingPublicKeyToProto(value) {
|
|
97
|
+
return {
|
|
98
|
+
format: cryptoKeyFormatToProto(value.format),
|
|
99
|
+
publicKey: new Uint8Array(value.publicKey),
|
|
100
|
+
scheme: SigningKeyScheme.UNSPECIFIED,
|
|
101
|
+
usage: value.usage.map(signingKeyUsageToProto),
|
|
102
|
+
keySpec: signingKeySpecToProto(value.keySpec),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function participantPermissionToProto(value) {
|
|
106
|
+
switch (value) {
|
|
107
|
+
case ParticipantPermission.submission:
|
|
108
|
+
return Enums_ParticipantPermission.SUBMISSION;
|
|
109
|
+
case ParticipantPermission.confirmation:
|
|
110
|
+
return Enums_ParticipantPermission.CONFIRMATION;
|
|
111
|
+
case ParticipantPermission.observation:
|
|
112
|
+
return Enums_ParticipantPermission.OBSERVATION;
|
|
113
|
+
case ParticipantPermission.unspecified:
|
|
114
|
+
default:
|
|
115
|
+
return Enums_ParticipantPermission.UNSPECIFIED;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function cryptoKeyFormatToProto(value) {
|
|
119
|
+
switch (value) {
|
|
120
|
+
case "der":
|
|
121
|
+
return CryptoKeyFormat.DER;
|
|
122
|
+
case "raw":
|
|
123
|
+
return CryptoKeyFormat.RAW;
|
|
124
|
+
case "derX509SubjectPublicKeyInfo":
|
|
125
|
+
return CryptoKeyFormat.DER_X509_SUBJECT_PUBLIC_KEY_INFO;
|
|
126
|
+
case "derPkcs8PrivateKeyInfo":
|
|
127
|
+
return CryptoKeyFormat.DER_PKCS8_PRIVATE_KEY_INFO;
|
|
128
|
+
case "symbolic":
|
|
129
|
+
return CryptoKeyFormat.SYMBOLIC;
|
|
130
|
+
default:
|
|
131
|
+
return CryptoKeyFormat.UNSPECIFIED;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function signingKeyUsageToProto(value) {
|
|
135
|
+
switch (value) {
|
|
136
|
+
case "namespace":
|
|
137
|
+
return SigningKeyUsage.NAMESPACE;
|
|
138
|
+
case "identityDelegation":
|
|
139
|
+
return SigningKeyUsage.IDENTITY_DELEGATION;
|
|
140
|
+
case "sequencerAuthentication":
|
|
141
|
+
return SigningKeyUsage.SEQUENCER_AUTHENTICATION;
|
|
142
|
+
case "protocol":
|
|
143
|
+
return SigningKeyUsage.PROTOCOL;
|
|
144
|
+
case "proofOfOwnership":
|
|
145
|
+
return SigningKeyUsage.PROOF_OF_OWNERSHIP;
|
|
146
|
+
default:
|
|
147
|
+
return SigningKeyUsage.UNSPECIFIED;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function signingKeySpecToProto(value) {
|
|
151
|
+
switch (value) {
|
|
152
|
+
case "ecCurve25519":
|
|
153
|
+
return SigningKeySpec.EC_CURVE25519;
|
|
154
|
+
case "ecP256":
|
|
155
|
+
return SigningKeySpec.EC_P256;
|
|
156
|
+
case "ecP384":
|
|
157
|
+
return SigningKeySpec.EC_P384;
|
|
158
|
+
case "ecSecp256k1":
|
|
159
|
+
return SigningKeySpec.EC_SECP256K1;
|
|
160
|
+
case "mlDsa65":
|
|
161
|
+
return SigningKeySpec.ML_DSA_65;
|
|
162
|
+
default:
|
|
163
|
+
return SigningKeySpec.UNSPECIFIED;
|
|
164
|
+
}
|
|
165
|
+
}
|