@layerzerolabs/common-canton 1.2.85 → 1.2.86
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/{4S3STHD2.js → 5R6WVDPV.js} +3 -3
- package/dist/{4S3STHD2.js.map → 5R6WVDPV.js.map} +1 -1
- package/dist/{K6KCXLMQ.js → LHA6QVMC.js} +22 -9
- package/dist/LHA6QVMC.js.map +1 -0
- package/dist/{C7YYEPNV.js → THWUUI4S.js} +26 -4
- package/dist/THWUUI4S.js.map +1 -0
- package/dist/address.d.ts +11 -0
- package/dist/address.d.ts.map +1 -1
- package/dist/address.js +1 -1
- package/dist/browser.js +1 -1
- package/dist/client/grpc.d.ts +4 -2
- package/dist/client/grpc.d.ts.map +1 -1
- package/dist/client/grpc.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/topology/types.d.ts +10 -0
- package/dist/client/topology/types.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/provider.js +2 -2
- package/package.json +10 -10
- package/dist/C7YYEPNV.js.map +0 -1
- package/dist/K6KCXLMQ.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CantonClient } from './XZSSPQAG.js';
|
|
2
2
|
import { Configuration } from './XVX7EVTW.js';
|
|
3
|
-
import { CantonGrpcClient } from './
|
|
3
|
+
import { CantonGrpcClient } from './LHA6QVMC.js';
|
|
4
4
|
import { LocalTokenProvider } from './YF7P4UQM.js';
|
|
5
5
|
import { ClientCredentialsTokenProvider } from './V2H2WXKE.js';
|
|
6
6
|
import { __name } from './VUOMXK5T.js';
|
|
@@ -99,5 +99,5 @@ function createTokenProvider(params, isLocal) {
|
|
|
99
99
|
__name(createTokenProvider, "createTokenProvider");
|
|
100
100
|
|
|
101
101
|
export { createCantonChainProvider, parseCantonChainUri };
|
|
102
|
-
//# sourceMappingURL=
|
|
103
|
-
//# sourceMappingURL=
|
|
102
|
+
//# sourceMappingURL=5R6WVDPV.js.map
|
|
103
|
+
//# sourceMappingURL=5R6WVDPV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","actAsParam","actAs","split","map","party","trim","filter","length","walletUrl","tokenUrl","undefined","clientId","clientSecret","process","env","CANTON_CLIENT_SECRET","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","insecureTransport","LocalTokenProvider","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AA6DO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,WAAA,CAAA;AAC1C,EAAA,IAAI,CAACF,YAAAA,EAAc;AACf,IAAA,MAAM,IAAIG,MAAM,kEAAA,CAAA;AACpB,EAAA;AAEA,EAAA,MAAMC,MAAAA,GAASN,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,SAAA,CAAA,IAAc,mBAAA;AAClD,EAAA,MAAMG,UAAAA,GAAaP,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,QAAA,CAAA;AACxC,EAAA,MAAMI,QACFD,UAAAA,EACME,KAAAA,CAAM,GAAA,CAAA,CACPC,GAAAA,CAAI,CAACC,KAAAA,KAAUA,KAAAA,CAAMC,MAAI,CAAA,CACzBC,OAAO,CAACF,KAAAA,KAAUA,MAAMG,MAAAA,GAAS,CAAA,KAAM,EAAA;AAChD,EAAA,MAAMC,SAAAA,GAAYf,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,YAAA,CAAA;AACvC,EAAA,IAAI,CAACW,SAAAA,EAAW;AACZ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AAIA,OAAAA,EAAS;AACT,IAAA,OAAO,IAAIe,kBAAAA,CAAmB;AAC1BzC,MAAAA,MAAAA,EAAQ2B,MAAAA,CAAO3B,MAAAA;AACfE,MAAAA,KAAAA,EAAOyB,MAAAA,CAAOzB,KAAAA;MACdwC,KAAAA,EAAO;KACX,CAAA;AACJ,EAAA;AAGA,EAAA,IAAI,CAACf,OAAOH,MAAAA,EAAQ;AAChB,IAAA,MAAM,IAAIzB,MACN,kHAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAI4C,8BAAAA,CAA+BhB,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"4S3STHD2.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */\n actAs: string[];\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n *\n * When `client-secret` is omitted from the URI, `CANTON_CLIENT_SECRET` is read from the\n * environment.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const actAsParam = url.searchParams.get('act-as');\n const actAs =\n actAsParam\n ?.split(',')\n .map((party) => party.trim())\n .filter((party) => party.length > 0) ?? [];\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n // Prefer URI param; fall back to env so secrets are not committed in provider configs.\n const clientSecret =\n url.searchParams.get('client-secret') ??\n // eslint-disable-next-line turbo/no-undeclared-env-vars -- runtime OAuth secret, not a turbo task input\n process.env.CANTON_CLIENT_SECRET ??\n undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'act-as',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n actAs,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs)\n * over an unencrypted admin channel, allowed for a loopback admin host only.\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters, over a TLS admin channel.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId, {\n walletUrl: params.walletUrl,\n tokenProvider,\n });\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n insecureTransport: isLocal,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: params.actAs,\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret in URI or CANTON_CLIENT_SECRET)',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","actAsParam","actAs","split","map","party","trim","filter","length","walletUrl","tokenUrl","undefined","clientId","clientSecret","process","env","CANTON_CLIENT_SECRET","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","insecureTransport","LocalTokenProvider","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AA6DO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,WAAA,CAAA;AAC1C,EAAA,IAAI,CAACF,YAAAA,EAAc;AACf,IAAA,MAAM,IAAIG,MAAM,kEAAA,CAAA;AACpB,EAAA;AAEA,EAAA,MAAMC,MAAAA,GAASN,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,SAAA,CAAA,IAAc,mBAAA;AAClD,EAAA,MAAMG,UAAAA,GAAaP,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,QAAA,CAAA;AACxC,EAAA,MAAMI,QACFD,UAAAA,EACME,KAAAA,CAAM,GAAA,CAAA,CACPC,GAAAA,CAAI,CAACC,KAAAA,KAAUA,KAAAA,CAAMC,MAAI,CAAA,CACzB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AA,aAAAA;AACAnB,IAAAA,SAAAA,EAAWkB,MAAAA,CAAOlB;AACtB,GAAA;AACJ;AA/BgBgB,MAAAA,CAAAA,yBAAAA,EAAAA,2BAAAA,CAAAA;AAiChB,SAASI,mBAAAA,CAAoBF,QAA8BD,OAAAA,EAAgB;AACvE,EAAA,IAAIA,OAAAA,EAAS;AACT,IAAA,OAAO,IAAIe,kBAAAA,CAAmB;AAC1BzC,MAAAA,MAAAA,EAAQ2B,MAAAA,CAAO3B,MAAAA;AACfE,MAAAA,KAAAA,EAAOyB,MAAAA,CAAOzB,KAAAA;MACdwC,KAAAA,EAAO;KACX,CAAA;AACJ,EAAA;AAGA,EAAA,IAAI,CAACf,OAAOH,MAAAA,EAAQ;AAChB,IAAA,MAAM,IAAIzB,MACN,kHAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAI4C,8BAAAA,CAA+BhB,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"5R6WVDPV.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */\n actAs: string[];\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n *\n * When `client-secret` is omitted from the URI, `CANTON_CLIENT_SECRET` is read from the\n * environment.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const actAsParam = url.searchParams.get('act-as');\n const actAs =\n actAsParam\n ?.split(',')\n .map((party) => party.trim())\n .filter((party) => party.length > 0) ?? [];\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n // Prefer URI param; fall back to env so secrets are not committed in provider configs.\n const clientSecret =\n url.searchParams.get('client-secret') ??\n // eslint-disable-next-line turbo/no-undeclared-env-vars -- runtime OAuth secret, not a turbo task input\n process.env.CANTON_CLIENT_SECRET ??\n undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'act-as',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n actAs,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs)\n * over an unencrypted admin channel, allowed for a loopback admin host only.\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters, over a TLS admin channel.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId, {\n walletUrl: params.walletUrl,\n tokenProvider,\n });\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n insecureTransport: isLocal,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: params.actAs,\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret in URI or CANTON_CLIENT_SECRET)',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
|
|
@@ -129,7 +129,10 @@ var CantonGrpcClient = class {
|
|
|
129
129
|
{
|
|
130
130
|
namespace: item.namespace,
|
|
131
131
|
targetKeyFingerprint: computePublicKeyFingerprint(publicKey),
|
|
132
|
-
|
|
132
|
+
targetPublicKeyDer: publicKey,
|
|
133
|
+
// `is_root_delegation` is deprecated: current nodes report the scope in
|
|
134
|
+
// `restriction` and leave the bool false, so accept either.
|
|
135
|
+
isRootDelegation: item.isRootDelegation || item.restriction.oneofKind === "canSignAllMappings",
|
|
133
136
|
serial: result.context?.serial ?? 0
|
|
134
137
|
}
|
|
135
138
|
];
|
|
@@ -142,12 +145,13 @@ var CantonGrpcClient = class {
|
|
|
142
145
|
* pass the `1220…` suffix as `namespaceFingerprint`.
|
|
143
146
|
*
|
|
144
147
|
* @param namespaceFingerprint - Decentralized namespace fingerprint to filter on.
|
|
148
|
+
* @param proposals - If `true`, query pending proposals instead of authorized mappings.
|
|
145
149
|
* @returns All matching DND mappings, or an empty array if none exist.
|
|
146
150
|
*/
|
|
147
|
-
async getDecentralizedNamespaceDefinition(namespaceFingerprint) {
|
|
151
|
+
async getDecentralizedNamespaceDefinition(namespaceFingerprint, proposals = false) {
|
|
148
152
|
const synchronizerId = await this.#getSynchronizerId();
|
|
149
153
|
const { response } = await this.#topologyRead.listDecentralizedNamespaceDefinition(ListDecentralizedNamespaceDefinitionRequest.create({
|
|
150
|
-
baseQuery: headStateBaseQuery(synchronizerId),
|
|
154
|
+
baseQuery: headStateBaseQuery(synchronizerId, proposals),
|
|
151
155
|
filterNamespace: namespaceFingerprint
|
|
152
156
|
}), {
|
|
153
157
|
meta: await this.#getMeta()
|
|
@@ -164,7 +168,11 @@ var CantonGrpcClient = class {
|
|
|
164
168
|
owners: [
|
|
165
169
|
...item.owners
|
|
166
170
|
],
|
|
167
|
-
serial: result.context?.serial ?? 0
|
|
171
|
+
serial: result.context?.serial ?? 0,
|
|
172
|
+
transactionHash: result.context?.transactionHash?.length ? Buffer.from(result.context.transactionHash).toString("hex") : void 0,
|
|
173
|
+
signedByFingerprints: result.context ? [
|
|
174
|
+
...result.context.signedByFingerprints
|
|
175
|
+
] : void 0
|
|
168
176
|
}
|
|
169
177
|
];
|
|
170
178
|
});
|
|
@@ -175,12 +183,13 @@ var CantonGrpcClient = class {
|
|
|
175
183
|
* Queries topology head state on the synchronizer.
|
|
176
184
|
*
|
|
177
185
|
* @param partyId - Full party identifier (e.g. `hint::1220…`).
|
|
186
|
+
* @param proposals - List pending proposals instead of the effective state.
|
|
178
187
|
* @returns All matching PTK mappings, or an empty array if none exist.
|
|
179
188
|
*/
|
|
180
|
-
async getPartyToKeyMapping(partyId) {
|
|
189
|
+
async getPartyToKeyMapping(partyId, proposals = false) {
|
|
181
190
|
const synchronizerId = await this.#getSynchronizerId();
|
|
182
191
|
const { response } = await this.#topologyRead.listPartyToKeyMapping(ListPartyToKeyMappingRequest.create({
|
|
183
|
-
baseQuery: headStateBaseQuery(synchronizerId),
|
|
192
|
+
baseQuery: headStateBaseQuery(synchronizerId, proposals),
|
|
184
193
|
filterParty: partyId
|
|
185
194
|
}), {
|
|
186
195
|
meta: await this.#getMeta()
|
|
@@ -195,7 +204,11 @@ var CantonGrpcClient = class {
|
|
|
195
204
|
party: item.party,
|
|
196
205
|
threshold: item.threshold,
|
|
197
206
|
signingKeyFingerprints: item.signingKeys.map((key) => computePublicKeyFingerprint(key.publicKey)),
|
|
198
|
-
serial: result.context?.serial ?? 0
|
|
207
|
+
serial: result.context?.serial ?? 0,
|
|
208
|
+
transactionHash: result.context?.transactionHash?.length ? Buffer.from(result.context.transactionHash).toString("hex") : void 0,
|
|
209
|
+
signedByFingerprints: result.context ? [
|
|
210
|
+
...result.context.signedByFingerprints
|
|
211
|
+
] : void 0
|
|
199
212
|
}
|
|
200
213
|
];
|
|
201
214
|
});
|
|
@@ -368,5 +381,5 @@ var CantonGrpcClient = class {
|
|
|
368
381
|
};
|
|
369
382
|
|
|
370
383
|
export { CantonGrpcClient };
|
|
371
|
-
//# sourceMappingURL=
|
|
372
|
-
//# sourceMappingURL=
|
|
384
|
+
//# sourceMappingURL=LHA6QVMC.js.map
|
|
385
|
+
//# sourceMappingURL=LHA6QVMC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client/grpc.ts"],"names":["TOPOLOGY_TRANSACTION_NOT_FOUND","DEFAULT_GRPC_CLIENT_OPTIONS","CantonGrpcClient","opts","tokenProvider","synchronizerId","GrpcTransport","host","channelCredentials","buildChannelCredentials","insecureTransport","clientOptions","grpcClientOptions","TopologyManagerReadServiceClient","TopologyManagerWriteServiceClient","SynchronizerConnectivityServiceClient","token","getToken","Authorization","response","listConnectedSynchronizers","meta","synchronizer","connectedSynchronizers","CantonProtocolError","mapping","serial","generateTransactions","GenerateTransactionsRequest","create","proposals","GenerateTransactionsRequest_Proposal","operation","Enums_TopologyChangeOp","ADD_REPLACE","store","synchronizerStore","generated","generatedTransactions","getNamespaceDelegation","namespaceFingerprint","listNamespaceDelegation","ListNamespaceDelegationRequest","baseQuery","headStateBaseQuery","filterNamespace","filterTargetKeyFingerprint","results","flatMap","result","item","publicKey","targetKey","namespace","targetKeyFingerprint","computePublicKeyFingerprint","targetPublicKeyDer","isRootDelegation","restriction","oneofKind","context","getDecentralizedNamespaceDefinition","listDecentralizedNamespaceDefinition","ListDecentralizedNamespaceDefinitionRequest","decentralizedNamespace","threshold","owners","transactionHash","length","Buffer","from","toString","undefined","signedByFingerprints","getPartyToKeyMapping","partyId","listPartyToKeyMapping","ListPartyToKeyMappingRequest","filterParty","party","signingKeyFingerprints","signingKeys","map","key","getPartyToParticipantMapping","listPartyToParticipant","ListPartyToParticipantRequest","filterParticipant","participants","participant","participantUid","permission","createNamespaceDelegationTx","params","buildNamespaceDelegationMapping","publicKeyDer","createDecentralizedNamespaceDefinitionTx","computeDecentralizedNamespace","buildDecentralizedNamespaceDefinitionMapping","updateDecentralizedNamespaceDefinitionTx","createPartyToKeyTx","buildPartyToKeyMapping","signingPublicKeyDers","createPartyToParticipantTx","buildPartyToParticipantMapping","participantIds","submitTopologyTransactions","transactions","CantonError","addTransactions","AddTransactionsRequest","authorizeTopologyTransaction","transactionHashHex","options","retries","retryDelayMs","attempt","authorize","AuthorizeRequest","type","mustFullyAuthorize","err","msg","Error","message","String","includes","Promise","resolve","setTimeout","close"],"mappings":";;;;;;;;;AAiDA,IAAMA,8BAAAA,GAAiC,gCAAA;AAGvC,IAAMC,2BAAAA,GAA8B;AAChC,EAAA,iCAAA,EAAmC,MAAM,IAAA,GAAO,IAAA;AAChD,EAAA,8BAAA,EAAgC,MAAM,IAAA,GAAO;AACjD,CAAA;AAWO,IAAMC,mBAAN,MAAMA;EAlEb;;;AAmEa,EAAA,UAAA;AACA,EAAA,aAAA;AACA,EAAA,cAAA;AACA,EAAA,aAAA;AACA,EAAA,cAAA;AACT,EAAA,eAAA;;;;AAKA,EAAA,WAAA,CAAYC,IAAAA,EAA+B;AACvC,IAAA,IAAA,CAAK,iBAAiBA,IAAAA,CAAKC,aAAAA;AAC3B,IAAA,IAAA,CAAK,kBAAkBD,IAAAA,CAAKE,cAAAA;AAC5B,IAAA,IAAA,CAAK,UAAA,GAAa,IAAIC,aAAAA,CAAc;AAChCC,MAAAA,IAAAA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AAAA,CAAAA;AAExD,QAAA,IAAIC,GAAAA,CAAII,QAAAA,CAAS9H,8BAAAA,CAAAA,IAAmCoH,UAAUF,OAAAA,EAAS;AACnE,UAAA,MAAM,IAAIa,OAAAA,CAAc,CAACC,YAAYC,UAAAA,CAAWD,OAAAA,EAASb,YAAAA,CAAAA,CAAAA;AACzD,UAAA;AACJ,QAAA;AACA,QAAA,MAAMM,GAAAA;AACV,MAAA;AACJ,IAAA;AACJ,EAAA;;EAGAS,KAAAA,GAAc;AACV,IAAA,IAAA,CAAK,WAAWA,KAAAA,EAAK;AACzB,EAAA;AACJ","file":"LHA6QVMC.js","sourcesContent":["import {\n AddTransactionsRequest,\n AuthorizeRequest,\n Enums_TopologyChangeOp,\n GenerateTransactionsRequest,\n GenerateTransactionsRequest_Proposal,\n ListDecentralizedNamespaceDefinitionRequest,\n ListNamespaceDelegationRequest,\n ListPartyToKeyMappingRequest,\n ListPartyToParticipantRequest,\n type SignedTopologyTransaction,\n TopologyManagerReadServiceClient,\n TopologyManagerWriteServiceClient,\n type TopologyMapping,\n} from '@canton-network/core-ledger-proto';\nimport { GrpcTransport } from '@protobuf-ts/grpc-transport';\n\nimport type { TokenProvider } from '../auth/token-provider';\nimport { CantonError, CantonProtocolError } from '../errors';\nimport {\n buildDecentralizedNamespaceDefinitionMapping,\n buildNamespaceDelegationMapping,\n buildPartyToKeyMapping,\n buildPartyToParticipantMapping,\n} from './topology/mappings';\nimport { SynchronizerConnectivityServiceClient } from './topology/synchronizer-connectivity';\nimport type {\n CantonGrpcClientOptions,\n CreateDecentralizedNamespaceDefinitionTxParams,\n CreateNamespaceDelegationTxParams,\n CreatePartyToKeyMappingTxParams,\n CreatePartyToParticipantMappingTxParams,\n DecentralizedNamespaceDefinitionState,\n GeneratedTopologyTransaction,\n NamespaceDelegationState,\n PartyToKeyMappingState,\n PartyToParticipantMappingState,\n UpdateDecentralizedNamespaceDefinitionTxParams,\n} from './topology/types';\nimport {\n buildChannelCredentials,\n computeDecentralizedNamespace,\n headStateBaseQuery,\n synchronizerStore,\n} from './topology/utils';\nimport { computePublicKeyFingerprint } from './utils';\n\n// Canton error id for a topology transaction the store has not seen yet. gRPC errors carry it only\n// in the message, so it is matched there.\nconst TOPOLOGY_TRANSACTION_NOT_FOUND = 'TOPOLOGY_TRANSACTION_NOT_FOUND';\n\n/** Default gRPC client options: 128 MiB message-size limits for large admin responses. */\nconst DEFAULT_GRPC_CLIENT_OPTIONS = {\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n} as const;\n\n/**\n * gRPC client for the Canton participant admin Topology Manager API.\n *\n * Exposes read queries for topology mappings and write helpers that call\n * `GenerateTransactions` to produce unsigned topology transactions and\n * `AddTransactions` to submit signed ones.\n *\n * A fresh Bearer token is attached to each RPC via {@link TokenProvider}.\n */\nexport class CantonGrpcClient {\n readonly #transport: GrpcTransport;\n readonly #topologyRead: TopologyManagerReadServiceClient;\n readonly #topologyWrite: TopologyManagerWriteServiceClient;\n readonly #connectivity: SynchronizerConnectivityServiceClient;\n readonly #tokenProvider: TokenProvider;\n #synchronizerId?: string;\n\n /**\n * @param opts - Admin API host, auth, optional synchronizer id, and transport security.\n */\n constructor(opts: CantonGrpcClientOptions) {\n this.#tokenProvider = opts.tokenProvider;\n this.#synchronizerId = opts.synchronizerId;\n this.#transport = new GrpcTransport({\n host: opts.host,\n channelCredentials: buildChannelCredentials(opts.host, opts.insecureTransport),\n clientOptions: opts.grpcClientOptions ?? DEFAULT_GRPC_CLIENT_OPTIONS,\n });\n this.#topologyRead = new TopologyManagerReadServiceClient(this.#transport);\n this.#topologyWrite = new TopologyManagerWriteServiceClient(this.#transport);\n this.#connectivity = new SynchronizerConnectivityServiceClient(this.#transport);\n }\n\n /** Returns per-RPC gRPC metadata with a fresh Bearer token. */\n async #getMeta(): Promise<Record<string, string>> {\n const token = await this.#tokenProvider.getToken();\n return { Authorization: `Bearer ${token}` };\n }\n\n /**\n * Returns the client synchronizer id, discovering it on first use when omitted at construction.\n *\n * @throws {CantonProtocolError} If the participant exposes no synchronizer store.\n */\n async #getSynchronizerId(): Promise<string> {\n if (this.#synchronizerId) {\n return this.#synchronizerId;\n }\n this.#synchronizerId = await this.#discoverSynchronizerId();\n return this.#synchronizerId;\n }\n\n /**\n * Resolves the logical id of the first synchronizer the participant is connected to.\n *\n * @throws {CantonProtocolError} If the participant is not connected to any synchronizer.\n */\n async #discoverSynchronizerId(): Promise<string> {\n const { response } = await this.#connectivity.listConnectedSynchronizers(\n {},\n { meta: await this.#getMeta() },\n );\n for (const synchronizer of response.connectedSynchronizers) {\n if (synchronizer.synchronizerId) {\n return synchronizer.synchronizerId;\n }\n }\n throw new CantonProtocolError('Participant is not connected to any synchronizer');\n }\n\n /**\n * Calls `GenerateTransactions` for a single ADD_REPLACE mapping.\n *\n * @param synchronizerId - Synchronizer store to target.\n * @param mapping - Topology mapping to encode into the transaction.\n * @param serial - Topology serial (`0` lets Canton auto-determine).\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n * @throws {CantonProtocolError} If the RPC returns no generated transaction.\n */\n async #generateTopologyTransaction(\n synchronizerId: string,\n mapping: TopologyMapping,\n serial: number,\n ): Promise<GeneratedTopologyTransaction> {\n const { response } = await this.#topologyWrite.generateTransactions(\n GenerateTransactionsRequest.create({\n proposals: [\n GenerateTransactionsRequest_Proposal.create({\n operation: Enums_TopologyChangeOp.ADD_REPLACE,\n serial,\n mapping,\n store: synchronizerStore(synchronizerId),\n }),\n ],\n }),\n { meta: await this.#getMeta() },\n );\n\n const generated = response.generatedTransactions[0];\n\n if (!generated) {\n throw new CantonProtocolError('GenerateTransactions returned no topology transaction');\n }\n\n return generated;\n }\n\n /**\n * Lists Namespace Delegation (NSD) mappings for a namespace.\n *\n * Queries topology head state on the synchronizer. Returns every result from\n * the list RPC.\n *\n * @param namespaceFingerprint - Namespace to filter on (for root NSD, the owner key fingerprint).\n * @returns All matching NSD mappings, or an empty array if none exist.\n */\n async getNamespaceDelegation(\n namespaceFingerprint: string,\n ): Promise<NamespaceDelegationState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listNamespaceDelegation(\n ListNamespaceDelegationRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId),\n filterNamespace: namespaceFingerprint,\n // Empty string = no target-key filter; return all delegations for this namespace.\n filterTargetKeyFingerprint: '',\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n const publicKey = item?.targetKey?.publicKey;\n if (!item || !publicKey) {\n return [];\n }\n return [\n {\n namespace: item.namespace,\n targetKeyFingerprint: computePublicKeyFingerprint(publicKey),\n targetPublicKeyDer: publicKey,\n // `is_root_delegation` is deprecated: current nodes report the scope in\n // `restriction` and leave the bool false, so accept either.\n isRootDelegation:\n item.isRootDelegation ||\n item.restriction.oneofKind === 'canSignAllMappings',\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Lists Decentralized Namespace Definition (DND) mappings for a namespace.\n *\n * Queries topology head state on the synchronizer. For a party id `hint::1220…`,\n * pass the `1220…` suffix as `namespaceFingerprint`.\n *\n * @param namespaceFingerprint - Decentralized namespace fingerprint to filter on.\n * @param proposals - If `true`, query pending proposals instead of authorized mappings.\n * @returns All matching DND mappings, or an empty array if none exist.\n */\n async getDecentralizedNamespaceDefinition(\n namespaceFingerprint: string,\n proposals = false,\n ): Promise<DecentralizedNamespaceDefinitionState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listDecentralizedNamespaceDefinition(\n ListDecentralizedNamespaceDefinitionRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId, proposals),\n filterNamespace: namespaceFingerprint,\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n namespace: item.decentralizedNamespace,\n threshold: item.threshold,\n owners: [...item.owners],\n serial: result.context?.serial ?? 0,\n transactionHash: result.context?.transactionHash?.length\n ? Buffer.from(result.context.transactionHash).toString('hex')\n : undefined,\n signedByFingerprints: result.context\n ? [...result.context.signedByFingerprints]\n : undefined,\n },\n ];\n });\n }\n\n /**\n * Lists Party-to-Key (PTK) mappings for a party.\n *\n * Queries topology head state on the synchronizer.\n *\n * @param partyId - Full party identifier (e.g. `hint::1220…`).\n * @param proposals - List pending proposals instead of the effective state.\n * @returns All matching PTK mappings, or an empty array if none exist.\n */\n async getPartyToKeyMapping(\n partyId: string,\n proposals = false,\n ): Promise<PartyToKeyMappingState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listPartyToKeyMapping(\n ListPartyToKeyMappingRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId, proposals),\n filterParty: partyId,\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n party: item.party,\n threshold: item.threshold,\n signingKeyFingerprints: item.signingKeys.map((key) =>\n computePublicKeyFingerprint(key.publicKey),\n ),\n serial: result.context?.serial ?? 0,\n transactionHash: result.context?.transactionHash?.length\n ? Buffer.from(result.context.transactionHash).toString('hex')\n : undefined,\n signedByFingerprints: result.context\n ? [...result.context.signedByFingerprints]\n : undefined,\n },\n ];\n });\n }\n\n /**\n * Lists Party-to-Participant (PTP) mappings for a party.\n *\n * Queries topology head state on the synchronizer.\n *\n * @param partyId - Full party identifier (e.g. `hint::1220…`).\n * @param proposals - If `true`, query pending proposals instead of authorized mappings.\n * @returns All matching PTP mappings, or an empty array if none exist.\n */\n async getPartyToParticipantMapping(\n partyId: string,\n proposals = false,\n ): Promise<PartyToParticipantMappingState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listPartyToParticipant(\n ListPartyToParticipantRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId, proposals),\n filterParty: partyId,\n // Empty string = no participant filter; return all hosting mappings for this party.\n filterParticipant: '',\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n party: item.party,\n threshold: item.threshold,\n participants: item.participants.map((participant) => ({\n participantUid: participant.participantUid,\n permission: participant.permission,\n })),\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Builds an unsigned Namespace Delegation (NSD) topology transaction.\n *\n * Calls `GenerateTransactions` with an ADD_REPLACE mapping. The returned\n * `transactionHash` must be signed by the namespace key.\n *\n * @param params - Owner public key and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createNamespaceDelegationTx(\n params: CreateNamespaceDelegationTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildNamespaceDelegationMapping(params.publicKeyDer);\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Decentralized Namespace Definition (DND) topology transaction.\n *\n * The decentralized namespace id is derived from `params.owners`. All owners\n * must sign the transaction hash.\n *\n * @param params - Owner fingerprints, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createDecentralizedNamespaceDefinitionTx(\n params: CreateDecentralizedNamespaceDefinitionTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const decentralizedNamespace = computeDecentralizedNamespace(params.owners);\n const mapping = buildDecentralizedNamespaceDefinitionMapping(\n decentralizedNamespace,\n params.threshold,\n params.owners,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n async updateDecentralizedNamespaceDefinitionTx(\n params: UpdateDecentralizedNamespaceDefinitionTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildDecentralizedNamespaceDefinitionMapping(\n params.namespace,\n params.threshold,\n params.owners,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Party-to-Key (PTK) topology transaction.\n *\n * Decentralized namespace owners must sign the transaction hash.\n *\n * @param params - Party id, signing keys, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createPartyToKeyTx(\n params: CreatePartyToKeyMappingTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildPartyToKeyMapping(\n params.partyId,\n params.signingPublicKeyDers,\n params.threshold,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Party-to-Participant (PTP) topology transaction.\n *\n * Party owners sign the transaction hash. On submit, set `proposal: true` on the\n * signed transaction so the hosting participant can authorize via `Authorize`.\n *\n * @param params - Party id, participant ids, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createPartyToParticipantTx(\n params: CreatePartyToParticipantMappingTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildPartyToParticipantMapping(\n params.partyId,\n params.participantIds,\n params.threshold,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Submits signed topology transactions to the synchronizer store.\n *\n * Multiple transactions are submitted atomically in one `AddTransactions` call.\n * When batching, sign `computeMultiTransactionHash` over all transaction hashes\n * and attach the same `MultiTransactionSignatures` to each entry.\n *\n * Set `proposal: true` on a transaction when the hosting participant must\n * authorize that mapping afterward.\n *\n * @param transactions - One or more signed topology transactions.\n * @throws {CantonError} If `transactions` is empty.\n */\n async submitTopologyTransactions(\n transactions: readonly SignedTopologyTransaction[],\n ): Promise<void> {\n if (transactions.length === 0) {\n throw new CantonError('AddTransactions requires at least one transaction');\n }\n const synchronizerId = await this.#getSynchronizerId();\n await this.#topologyWrite.addTransactions(\n AddTransactionsRequest.create({\n transactions: [...transactions],\n store: synchronizerStore(synchronizerId),\n }),\n { meta: await this.#getMeta() },\n );\n }\n\n /**\n * Authorizes a pending topology proposal by its hash.\n *\n * The participant uses its own local signing keys to add its authorization to\n * the pending proposal identified by `transactionHashHex`. For a PTP where the\n * participant is a required signer, this completes the authorization so the\n * transaction becomes effective on the synchronizer.\n *\n * @param transactionHashHex - Hex-encoded hash of the pending proposal.\n */\n async authorizeTopologyTransaction(\n transactionHashHex: string,\n options: { retries?: number; retryDelayMs?: number } = {},\n ): Promise<void> {\n const { retries = 10, retryDelayMs = 2_000 } = options;\n const synchronizerId = await this.#getSynchronizerId();\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n await this.#topologyWrite.authorize(\n AuthorizeRequest.create({\n type: { oneofKind: 'transactionHash', transactionHash: transactionHashHex },\n mustFullyAuthorize: false,\n store: synchronizerStore(synchronizerId),\n }),\n { meta: await this.#getMeta() },\n );\n return;\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n // addTransactions is async — the proposal may not yet be visible.\n if (msg.includes(TOPOLOGY_TRANSACTION_NOT_FOUND) && attempt < retries) {\n await new Promise<void>((resolve) => setTimeout(resolve, retryDelayMs));\n continue;\n }\n throw err;\n }\n }\n }\n\n /** Closes the underlying gRPC transport. */\n close(): void {\n this.#transport.close();\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './U6EV6YAY.js';
|
|
1
|
+
import { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel, CANTON_DEFERRED_VALUE_PREFIX } from './U6EV6YAY.js';
|
|
2
2
|
import { __name } from './VUOMXK5T.js';
|
|
3
3
|
import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';
|
|
4
4
|
|
|
@@ -33,7 +33,29 @@ var toCantonAddress = /* @__PURE__ */ __name((raw) => {
|
|
|
33
33
|
throw new Error(`Not a Canton-native address: ${raw}`);
|
|
34
34
|
}, "toCantonAddress");
|
|
35
35
|
var isCantonAddress = /* @__PURE__ */ __name((value) => value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) || value.startsWith(CANTON_CID_ADDRESS_PREFIX) || isCantonDeferredSentinel(value) || isCantonGlobalAddress(value), "isCantonAddress");
|
|
36
|
+
var cantonAddressToPartyId = /* @__PURE__ */ __name((address) => {
|
|
37
|
+
const isNonPartyAddress = address.startsWith(CANTON_CID_ADDRESS_PREFIX) || address.startsWith(CANTON_GLOBAL_ADDRESS_PREFIX) || address.startsWith(CANTON_DEFERRED_VALUE_PREFIX);
|
|
38
|
+
if (isNonPartyAddress) {
|
|
39
|
+
throw new Error(`Not a Canton party address: ${address}`);
|
|
40
|
+
}
|
|
41
|
+
let candidate;
|
|
42
|
+
if (address.startsWith(CANTON_PARTY_ADDRESS_PREFIX)) {
|
|
43
|
+
if (!address.endsWith(CANTON_DEFERRED_VALUE_SUFFIX)) {
|
|
44
|
+
throw new Error(`Not a Canton party address: ${address}`);
|
|
45
|
+
}
|
|
46
|
+
candidate = address.slice(CANTON_PARTY_ADDRESS_PREFIX.length, address.length - CANTON_DEFERRED_VALUE_SUFFIX.length);
|
|
47
|
+
} else if (address.startsWith("<<")) {
|
|
48
|
+
throw new Error(`Not a Canton party address: ${address}`);
|
|
49
|
+
} else {
|
|
50
|
+
candidate = address;
|
|
51
|
+
}
|
|
52
|
+
const match = CANTON_PARTY_ID_REGEX.exec(candidate);
|
|
53
|
+
if (!match || !match[1] || match[1].includes("<") || match[1].includes(">")) {
|
|
54
|
+
throw new Error(`Not a Canton party address: ${address}`);
|
|
55
|
+
}
|
|
56
|
+
return `${match[1]}::${match[2]}`;
|
|
57
|
+
}, "cantonAddressToPartyId");
|
|
36
58
|
|
|
37
|
-
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress };
|
|
38
|
-
//# sourceMappingURL=
|
|
39
|
-
//# sourceMappingURL=
|
|
59
|
+
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonAddressToPartyId, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress };
|
|
60
|
+
//# sourceMappingURL=THWUUI4S.js.map
|
|
61
|
+
//# sourceMappingURL=THWUUI4S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/address.ts"],"names":["CANTON_PARTY_ID_REGEX","CANTON_CONTRACT_ID_HEX_LENGTH","CANTON_PARTY_ADDRESS_PREFIX","CANTON_CID_ADDRESS_PREFIX","CANTON_GLOBAL_ADDRESS_PREFIX","cantonPartyAddress","hint","fingerprint","CANTON_DEFERRED_VALUE_SUFFIX","cantonCidAddress","contractId","cantonGlobalAddress","address","test","Error","hexZeroPad","toLowerCase","isCantonGlobalAddress","value","cantonDeferredAddress","sentinel","toCantonAddress","raw","isCantonDeferredSentinel","partyMatch","exec","bare","trim0x","length","startsWith","isCantonAddress","cantonAddressToPartyId","isNonPartyAddress","CANTON_DEFERRED_VALUE_PREFIX","candidate","endsWith","slice","match","includes"],"mappings":";;;;AASA,IAAMA,qBAAAA,GAAwB,wBAAA;AAC9B,IAAMC,6BAAAA,GAAgC,GAAA;AAE/B,IAAMC,2BAAAA,GAA8B;AACpC,IAAMC,yBAAAA,GAA4B;AAClC,IAAMC,4BAAAA,GAA+B;AAMrC,IAAMC,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,IAAAA,EAAcC,WAAAA,KAC7C,CAAA,EAAGL,2BAAAA,CAAAA,EAA8BI,IAAAA,CAAAA,EAAAA,EAASC,WAAAA,CAAAA,EAAcC,4BAAAA,CAAAA,CAAAA,E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,QAC5BhB,OAAAA,CAAQgB,MAAAA,GAASpB,6BAA6BoB,MAAM,CAAA;EAE5D,CAAA,MAAA,IAAWhB,OAAAA,CAAQiB,UAAAA,CAAW,IAAA,CAAA,EAAO;AACjC,IAAA,MAAM,IAAIf,KAAAA,CAAM,CAAA,4BAAA,EAA+BF,OAAAA,CAAAA,CAAS,CAAA;EAC5D,CAAA,MAAO;AACHsB,IAAAA,SAAAA,GAAYtB,OAAAA;AAChB,EAAA;AACA,EAAA,MAAMyB,KAAAA,GAAQrC,qBAAAA,CAAsByB,IAAAA,CAAKS,SAAAA,CAAAA;AACzC,EAAA,IAAI,CAACG,KAAAA,IAAS,CAACA,KAAAA,CAAM,CAAA,KAAMA,KAAAA,CAAM,CAAA,CAAA,CAAGC,QAAAA,CAAS,GAAA,CAAA,IAAQD,KAAAA,CAAM,CAAA,CAAA,CAAGC,QAAAA,CAAS,GAAA,CAAA,EAAM;AACzE,IAAA,MAAM,IAAIxB,KAAAA,CAAM,CAAA,4BAAA,EAA+BF,OAAAA,CAAAA,CAAS,CAAA;AAC5D,EAAA;AACA,EAAA,OAAO,GAAGyB,KAAAA,CAAM,CAAA,CAAE,CAAA,EAAA,EAAKA,KAAAA,CAAM,CAAA,CAAE,CAAA,CAAA;AACnC,CAAA,EA3BsC,wBAAA","file":"THWUUI4S.js","sourcesContent":["import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';\nimport type { Branded } from '@layerzerolabs/typescript-utils';\n\nimport {\n CANTON_DEFERRED_VALUE_PREFIX,\n CANTON_DEFERRED_VALUE_SUFFIX,\n isCantonDeferredSentinel,\n} from './deferredValue';\n\nconst CANTON_PARTY_ID_REGEX = /^(.+)::([0-9a-fA-F]+)$/;\nconst CANTON_CONTRACT_ID_HEX_LENGTH = 138; // 69 bytes\n\nexport const CANTON_PARTY_ADDRESS_PREFIX = '<<CANTON_PARTY::';\nexport const CANTON_CID_ADDRESS_PREFIX = '<<CANTON_CID::';\nexport const CANTON_GLOBAL_ADDRESS_PREFIX = '<<CANTON_GLOBAL::';\n\n/** A Canton ledger or VER global address, with an explicit sentinel prefix. */\nexport type CantonAddress = Branded<string, 'CantonAddress'>;\n\n/** Construct a party `CantonAddress` from hint and fingerprint. */\nexport const cantonPartyAddress = (hint: string, fingerprint: string): CantonAddress =>\n `${CANTON_PARTY_ADDRESS_PREFIX}${hint}::${fingerprint}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Construct a contract-ID `CantonAddress` from the raw 69-byte hex contract id. */\nexport const cantonCidAddress = (contractId: string): CantonAddress =>\n `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Explicitly wrap an already-derived VER global address. This does not hash the input. */\nexport const cantonGlobalAddress = (address: string): CantonAddress => {\n if (!/^(?:0x)?[0-9a-fA-F]{1,64}$/.test(address)) {\n throw new Error(`Invalid Canton global bytes32 address: ${address}`);\n }\n return `${CANTON_GLOBAL_ADDRESS_PREFIX}${hexZeroPad(address, 32).toLowerCase()}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n};\n\nexport const isCantonGlobalAddress = (value: string): value is CantonAddress =>\n /^<<CANTON_GLOBAL::0x[0-9a-fA-F]{64}>>$/.test(value);\n\n/** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */\nexport const cantonDeferredAddress = (sentinel: string): CantonAddress => sentinel as CantonAddress;\n\n/** Wrap a raw Canton ledger value (party id, contract id, or deferred sentinel) as `CantonAddress`. */\nexport const toCantonAddress = (raw: string): CantonAddress => {\n if (isCantonDeferredSentinel(raw)) {\n return cantonDeferredAddress(raw);\n }\n const partyMatch = CANTON_PARTY_ID_REGEX.exec(raw);\n if (partyMatch) {\n const [, hint, fingerprint] = partyMatch;\n return cantonPartyAddress(hint!, fingerprint!);\n }\n const bare = trim0x(raw);\n if (bare.length === CANTON_CONTRACT_ID_HEX_LENGTH && bare.startsWith('00')) {\n return cantonCidAddress(bare);\n }\n throw new Error(`Not a Canton-native address: ${raw}`);\n};\n\n/** Returns true if `value` is a valid `CantonAddress` sentinel string. */\nexport const isCantonAddress = (value: string): value is CantonAddress =>\n value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) ||\n value.startsWith(CANTON_CID_ADDRESS_PREFIX) ||\n isCantonDeferredSentinel(value) ||\n isCantonGlobalAddress(value);\n\n/**\n * Convert a Canton party address (`<<CANTON_PARTY::hint::fingerprint>>`) back to its raw party id\n * (`hint::fingerprint`). This is the inverse of {@link cantonPartyAddress} / {@link toCantonAddress}\n * for parties.\n *\n * A raw party id (`hint::fingerprint`, hex fingerprint) is also accepted and returned unchanged.\n *\n * @throws Error for contract-id (`<<CANTON_CID::...>>`), global (`<<CANTON_GLOBAL::...>>`) and deferred\n * (`<<CANTON_DEFERRED:...>>`) addresses, and for any malformed input.\n */\nexport const cantonAddressToPartyId = (address: string): string => {\n const isNonPartyAddress =\n address.startsWith(CANTON_CID_ADDRESS_PREFIX) ||\n address.startsWith(CANTON_GLOBAL_ADDRESS_PREFIX) ||\n address.startsWith(CANTON_DEFERRED_VALUE_PREFIX);\n if (isNonPartyAddress) {\n throw new Error(`Not a Canton party address: ${address}`);\n }\n let candidate: string;\n if (address.startsWith(CANTON_PARTY_ADDRESS_PREFIX)) {\n if (!address.endsWith(CANTON_DEFERRED_VALUE_SUFFIX)) {\n throw new Error(`Not a Canton party address: ${address}`);\n }\n candidate = address.slice(\n CANTON_PARTY_ADDRESS_PREFIX.length,\n address.length - CANTON_DEFERRED_VALUE_SUFFIX.length,\n );\n } else if (address.startsWith('<<')) {\n throw new Error(`Not a Canton party address: ${address}`);\n } else {\n candidate = address;\n }\n const match = CANTON_PARTY_ID_REGEX.exec(candidate);\n if (!match || !match[1] || match[1].includes('<') || match[1].includes('>')) {\n throw new Error(`Not a Canton party address: ${address}`);\n }\n return `${match[1]}::${match[2]}`;\n};\n"]}
|
package/dist/address.d.ts
CHANGED
|
@@ -17,4 +17,15 @@ export declare const cantonDeferredAddress: (sentinel: string) => CantonAddress;
|
|
|
17
17
|
export declare const toCantonAddress: (raw: string) => CantonAddress;
|
|
18
18
|
/** Returns true if `value` is a valid `CantonAddress` sentinel string. */
|
|
19
19
|
export declare const isCantonAddress: (value: string) => value is CantonAddress;
|
|
20
|
+
/**
|
|
21
|
+
* Convert a Canton party address (`<<CANTON_PARTY::hint::fingerprint>>`) back to its raw party id
|
|
22
|
+
* (`hint::fingerprint`). This is the inverse of {@link cantonPartyAddress} / {@link toCantonAddress}
|
|
23
|
+
* for parties.
|
|
24
|
+
*
|
|
25
|
+
* A raw party id (`hint::fingerprint`, hex fingerprint) is also accepted and returned unchanged.
|
|
26
|
+
*
|
|
27
|
+
* @throws Error for contract-id (`<<CANTON_CID::...>>`), global (`<<CANTON_GLOBAL::...>>`) and deferred
|
|
28
|
+
* (`<<CANTON_DEFERRED:...>>`) addresses, and for any malformed input.
|
|
29
|
+
*/
|
|
30
|
+
export declare const cantonAddressToPartyId: (address: string) => string;
|
|
20
31
|
//# sourceMappingURL=address.d.ts.map
|
package/dist/address.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAW/D,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAC9D,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAC1D,eAAO,MAAM,4BAA4B,sBAAsB,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE7D,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,SAAU,MAAM,eAAe,MAAM,KAAG,aACoC,CAAC;AAE5G,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,eAAgB,MAAM,KAAG,aACyC,CAAC;AAEhG,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,YAAa,MAAM,KAAG,aAKrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAAW,MAAM,KAAG,KAAK,IAAI,aACP,CAAC;AAEzD,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,aAA0C,CAAC;AAEpG,uGAAuG;AACvG,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,aAc7C,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,KAAK,IAAI,aAIzB,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,YAAa,MAAM,KAAG,MA2BxD,CAAC"}
|
package/dist/address.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './
|
|
1
|
+
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonAddressToPartyId, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './THWUUI4S.js';
|
|
2
2
|
import './U6EV6YAY.js';
|
|
3
3
|
import './VUOMXK5T.js';
|
|
4
4
|
//# sourceMappingURL=address.js.map
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './
|
|
1
|
+
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonAddressToPartyId, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './THWUUI4S.js';
|
|
2
2
|
export { SECP256K1_SPKI_DER_HEADER, SECP256K1_SPKI_DER_HEADER_HEX, derEncodeSignature, publicKeyToSpkiDer } from './CMDFOA7C.js';
|
|
3
3
|
export { assertHexLength, codePointLength, formatDamlDecimal, intToHex, keccak256Hex, padLeft, showBool, showInt, textToHex, timeToUnixSeconds, toBigInt } from './EZIA6KIP.js';
|
|
4
4
|
export { CANTON_DEFERRED_SENDER, CANTON_DEFERRED_VALUE_PREFIX, CANTON_DEFERRED_VALUE_SUFFIX, cantonActiveContractIdRef, cantonDeferredSenderSchema, cantonDeferredValueSchema, cantonExpectedSignatoriesSchema, cantonRefreshPartyFilterSchema, cantonSenderPartyRef, encodeCantonDeferredValue, isCantonDeferredSender, isCantonDeferredSentinel, isCantonPlaceholder, parseCantonDeferredValue } from './U6EV6YAY.js';
|
package/dist/client/grpc.d.ts
CHANGED
|
@@ -32,18 +32,20 @@ export declare class CantonGrpcClient {
|
|
|
32
32
|
* pass the `1220…` suffix as `namespaceFingerprint`.
|
|
33
33
|
*
|
|
34
34
|
* @param namespaceFingerprint - Decentralized namespace fingerprint to filter on.
|
|
35
|
+
* @param proposals - If `true`, query pending proposals instead of authorized mappings.
|
|
35
36
|
* @returns All matching DND mappings, or an empty array if none exist.
|
|
36
37
|
*/
|
|
37
|
-
getDecentralizedNamespaceDefinition(namespaceFingerprint: string): Promise<DecentralizedNamespaceDefinitionState[]>;
|
|
38
|
+
getDecentralizedNamespaceDefinition(namespaceFingerprint: string, proposals?: boolean): Promise<DecentralizedNamespaceDefinitionState[]>;
|
|
38
39
|
/**
|
|
39
40
|
* Lists Party-to-Key (PTK) mappings for a party.
|
|
40
41
|
*
|
|
41
42
|
* Queries topology head state on the synchronizer.
|
|
42
43
|
*
|
|
43
44
|
* @param partyId - Full party identifier (e.g. `hint::1220…`).
|
|
45
|
+
* @param proposals - List pending proposals instead of the effective state.
|
|
44
46
|
* @returns All matching PTK mappings, or an empty array if none exist.
|
|
45
47
|
*/
|
|
46
|
-
getPartyToKeyMapping(partyId: string): Promise<PartyToKeyMappingState[]>;
|
|
48
|
+
getPartyToKeyMapping(partyId: string, proposals?: boolean): Promise<PartyToKeyMappingState[]>;
|
|
47
49
|
/**
|
|
48
50
|
* Lists Party-to-Participant (PTP) mappings for a party.
|
|
49
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.d.ts","sourceRoot":"","sources":["../../src/client/grpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAUH,KAAK,yBAAyB,EAIjC,MAAM,mCAAmC,CAAC;AAY3C,OAAO,KAAK,EACR,uBAAuB,EACvB,8CAA8C,EAC9C,iCAAiC,EACjC,+BAA+B,EAC/B,uCAAuC,EACvC,qCAAqC,EACrC,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,8BAA8B,EAC9B,8CAA8C,EACjD,MAAM,kBAAkB,CAAC;AAmB1B;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;;IAQzB;;OAEG;IACH,YAAY,IAAI,EAAE,uBAAuB,EAWxC;IA4ED;;;;;;;;OAQG;IACG,sBAAsB,CACxB,oBAAoB,EAAE,MAAM,GAC7B,OAAO,CAAC,wBAAwB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"grpc.d.ts","sourceRoot":"","sources":["../../src/client/grpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAUH,KAAK,yBAAyB,EAIjC,MAAM,mCAAmC,CAAC;AAY3C,OAAO,KAAK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,CAAC,CAQvC;IAED;;;;;;;;;;;;OAYG;IACG,0BAA0B,CAC5B,YAAY,EAAE,SAAS,yBAAyB,EAAE,GACnD,OAAO,CAAC,IAAI,CAAC,CAYf;IAED;;;;;;;;;OASG;IACG,4BAA4B,CAC9B,kBAAkB,EAAE,MAAM,EAC1B,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAO,GAC1D,OAAO,CAAC,IAAI,CAAC,CAwBf;IAED,4CAA4C;IAC5C,KAAK,IAAI,IAAI,CAEZ;CACJ"}
|
package/dist/client/grpc.js
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -285,7 +285,7 @@ export { AMULET_INSTRUMENT_ID, fetchAcceptContext, fetchAmuletContext, fetchAmul
|
|
|
285
285
|
import '../TLQX4ZQW.js';
|
|
286
286
|
import '../ZEK5YBPA.js';
|
|
287
287
|
import '../YMXOSAU4.js';
|
|
288
|
-
export { CantonGrpcClient } from '../
|
|
288
|
+
export { CantonGrpcClient } from '../LHA6QVMC.js';
|
|
289
289
|
import '../RVQWP4JU.js';
|
|
290
290
|
import '../VJ4PVZYL.js';
|
|
291
291
|
export { computeDecentralizedNamespace, computeMultiTransactionHash } from '../K7FRAGGM.js';
|
|
@@ -50,6 +50,8 @@ export type NamespaceDelegationState = {
|
|
|
50
50
|
namespace: string;
|
|
51
51
|
/** Fingerprint of the key receiving delegation authority. */
|
|
52
52
|
targetKeyFingerprint: string;
|
|
53
|
+
/** DER (X.509 SubjectPublicKeyInfo) public key receiving delegation authority. */
|
|
54
|
+
targetPublicKeyDer: Uint8Array;
|
|
53
55
|
/** Whether this is a root (self) namespace delegation. */
|
|
54
56
|
isRootDelegation: boolean;
|
|
55
57
|
/** Topology serial of this mapping revision. */
|
|
@@ -65,6 +67,10 @@ export type DecentralizedNamespaceDefinitionState = {
|
|
|
65
67
|
owners: string[];
|
|
66
68
|
/** Topology serial of this mapping revision. */
|
|
67
69
|
serial: number;
|
|
70
|
+
/** Hex-encoded topology transaction hash of this revision (when returned by the node). */
|
|
71
|
+
transactionHash?: string;
|
|
72
|
+
/** Fingerprints of the keys that have signed this revision (useful for pending proposals). */
|
|
73
|
+
signedByFingerprints?: string[];
|
|
68
74
|
};
|
|
69
75
|
/** Party-to-Key (PTK) mapping as returned by topology list queries. */
|
|
70
76
|
export type PartyToKeyMappingState = {
|
|
@@ -76,6 +82,10 @@ export type PartyToKeyMappingState = {
|
|
|
76
82
|
signingKeyFingerprints: string[];
|
|
77
83
|
/** Topology serial of this mapping revision. */
|
|
78
84
|
serial: number;
|
|
85
|
+
/** Hex-encoded topology transaction hash of this revision (when returned by the node). */
|
|
86
|
+
transactionHash?: string;
|
|
87
|
+
/** Fingerprints of the keys that have signed this revision (useful for pending proposals). */
|
|
88
|
+
signedByFingerprints?: string[];
|
|
79
89
|
};
|
|
80
90
|
/** Party-to-Participant (PTP) mapping as returned by topology list queries. */
|
|
81
91
|
export type PartyToParticipantMappingState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/topology/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,2BAA2B,EAChC,KAAK,iDAAiD,EACzD,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,8GAA8G;AAC9G,MAAM,MAAM,4BAA4B,GAAG,iDAAiD,CAAC;AAE7F,iFAAiF;AACjF,MAAM,MAAM,iCAAiC,GAAG;IAC5C,gHAAgH;IAChH,YAAY,EAAE,UAAU,CAAC;IACzB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,8CAA8C,GAAG;IACzD,kFAAkF;IAClF,MAAM,EAAE,MAAM,EAAE,C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,UAAU,EAAE,2BAA2B,CAAA;KAAE,EAAE,CAAC;IACpF,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAAG;IAClC,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,aAAa,CAAC;CACrC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import './7JX6NIYS.js';
|
|
|
20
20
|
export { buildMultiTransactionSignatures, buildSignedTransaction } from './WKC6X2E3.js';
|
|
21
21
|
import './IIWYAFUO.js';
|
|
22
22
|
export { parseMinFeeValue } from './M3GPMXME.js';
|
|
23
|
-
export { createCantonChainProvider, parseCantonChainUri } from './
|
|
23
|
+
export { createCantonChainProvider, parseCantonChainUri } from './5R6WVDPV.js';
|
|
24
24
|
export { CantonClient } from './XZSSPQAG.js';
|
|
25
25
|
import './YQ7YDN2E.js';
|
|
26
26
|
import './YBJJNRKE.js';
|
|
@@ -305,7 +305,7 @@ export { AMULET_INSTRUMENT_ID, fetchAcceptContext, fetchAmuletContext, fetchAmul
|
|
|
305
305
|
export { assertSafeRegistryUrl, contractIdsFromAnyValue, discloseUtilityCredentials, discoveryUrlsForAppUid, mergeTransferFactoryContexts, partyIdFromRegistryFingerprint } from './TLQX4ZQW.js';
|
|
306
306
|
import './ZEK5YBPA.js';
|
|
307
307
|
export { callbackDisclosure, callbackInterfaceView } from './YMXOSAU4.js';
|
|
308
|
-
export { CantonGrpcClient } from './
|
|
308
|
+
export { CantonGrpcClient } from './LHA6QVMC.js';
|
|
309
309
|
import './RVQWP4JU.js';
|
|
310
310
|
import './VJ4PVZYL.js';
|
|
311
311
|
export { computeDecentralizedNamespace, computeMultiTransactionHash } from './K7FRAGGM.js';
|
|
@@ -316,7 +316,7 @@ import './RSV7WS7X.js';
|
|
|
316
316
|
export { LocalTokenProvider } from './YF7P4UQM.js';
|
|
317
317
|
export { ClientCredentialsTokenProvider } from './V2H2WXKE.js';
|
|
318
318
|
export { parseAmuletAmount, parseAmuletDecimal } from './CXTOAS7N.js';
|
|
319
|
-
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './
|
|
319
|
+
export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonAddressToPartyId, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './THWUUI4S.js';
|
|
320
320
|
export { SECP256K1_SPKI_DER_HEADER, SECP256K1_SPKI_DER_HEADER_HEX, derEncodeSignature, publicKeyToSpkiDer } from './CMDFOA7C.js';
|
|
321
321
|
export { assertHexLength, codePointLength, formatDamlDecimal, intToHex, keccak256Hex, padLeft, showBool, showInt, textToHex, timeToUnixSeconds, toBigInt } from './EZIA6KIP.js';
|
|
322
322
|
export { CantonApiError, CantonError, CantonProtocolError, CantonTransportError, IOAppResolutionError, cantonApiErrorFromResponse, isRetryableCantonError } from './NYEJEKEY.js';
|
package/dist/provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createCantonChainProvider, parseCantonChainUri } from './
|
|
1
|
+
export { createCantonChainProvider, parseCantonChainUri } from './5R6WVDPV.js';
|
|
2
2
|
import './XZSSPQAG.js';
|
|
3
3
|
import './YQ7YDN2E.js';
|
|
4
4
|
import './YBJJNRKE.js';
|
|
@@ -283,7 +283,7 @@ import './7FS5WGDR.js';
|
|
|
283
283
|
import './TLQX4ZQW.js';
|
|
284
284
|
import './ZEK5YBPA.js';
|
|
285
285
|
import './YMXOSAU4.js';
|
|
286
|
-
import './
|
|
286
|
+
import './LHA6QVMC.js';
|
|
287
287
|
import './RVQWP4JU.js';
|
|
288
288
|
import './VJ4PVZYL.js';
|
|
289
289
|
import './K7FRAGGM.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/common-canton",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.86",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Canton VM client and utilities",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@canton-network/core-ledger-proto": "^1.7.0",
|
|
33
33
|
"@daml/types": "3.4.8",
|
|
34
34
|
"@grpc/grpc-js": "^1.14.5",
|
|
35
|
-
"@layerzerolabs/common-chain-model": "1.2.
|
|
36
|
-
"@layerzerolabs/common-encoding-utils": "1.2.
|
|
37
|
-
"@layerzerolabs/common-error-utils": "1.2.
|
|
38
|
-
"@layerzerolabs/typescript-utils": "1.2.
|
|
35
|
+
"@layerzerolabs/common-chain-model": "1.2.86",
|
|
36
|
+
"@layerzerolabs/common-encoding-utils": "1.2.86",
|
|
37
|
+
"@layerzerolabs/common-error-utils": "1.2.86",
|
|
38
|
+
"@layerzerolabs/typescript-utils": "1.2.86",
|
|
39
39
|
"@mojotech/json-type-validation": "^3.1.0",
|
|
40
40
|
"@noble/hashes": "^1.8.0",
|
|
41
41
|
"@noble/secp256k1": "1.7.1",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"zod": "4.3.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@layerzerolabs/eslint-configuration": "^1.2.
|
|
50
|
-
"@layerzerolabs/tsup-configuration": "1.2.
|
|
51
|
-
"@layerzerolabs/typescript-configuration": "1.2.
|
|
52
|
-
"@layerzerolabs/vitest-configuration": "1.2.
|
|
53
|
-
"@layerzerolabs/vm-tooling-canton": "1.2.
|
|
49
|
+
"@layerzerolabs/eslint-configuration": "^1.2.86",
|
|
50
|
+
"@layerzerolabs/tsup-configuration": "1.2.86",
|
|
51
|
+
"@layerzerolabs/typescript-configuration": "1.2.86",
|
|
52
|
+
"@layerzerolabs/vitest-configuration": "1.2.86",
|
|
53
|
+
"@layerzerolabs/vm-tooling-canton": "1.2.86",
|
|
54
54
|
"@vitest/coverage-v8": "4.1.10",
|
|
55
55
|
"eslint": "9.39.1",
|
|
56
56
|
"tsup": "^8.4.0",
|
package/dist/C7YYEPNV.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/address.ts"],"names":["CANTON_PARTY_ID_REGEX","CANTON_CONTRACT_ID_HEX_LENGTH","CANTON_PARTY_ADDRESS_PREFIX","CANTON_CID_ADDRESS_PREFIX","CANTON_GLOBAL_ADDRESS_PREFIX","cantonPartyAddress","hint","fingerprint","CANTON_DEFERRED_VALUE_SUFFIX","cantonCidAddress","contractId","cantonGlobalAddress","address","test","Error","hexZeroPad","toLowerCase","isCantonGlobalAddress","value","cantonDeferredAddress","sentinel","toCantonAddress","raw","isCantonDeferredSentinel","partyMatch","exec","bare","trim0x","length","startsWith","isCantonAddress"],"mappings":";;;;AAKA,IAAMA,qBAAAA,GAAwB,wBAAA;AAC9B,IAAMC,6BAAAA,GAAgC,GAAA;AAE/B,IAAMC,2BAAAA,GAA8B;AACpC,IAAMC,yBAAAA,GAA4B;AAClC,IAAMC,4BAAAA,GAA+B;AAMrC,IAAMC,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,IAAAA,EAAcC,WAAAA,KAC7C,CAAA,EAAGL,2BAAAA,CAAAA,EAA8BI,IAAAA,CAAAA,EAAAA,EAASC,WAAAA,CAAAA,EAAcC,4BAAAA,CAAAA,CAAAA,EAD1B,oBAAA;AAI3B,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AW3B,6BAAAA,IAAiCyB,IAAAA,CAAKG,UAAAA,CAAW,IAAA,CAAA,EAAO;AACxE,IAAA,OAAOpB,iBAAiBiB,IAAAA,CAAAA;AAC5B,EAAA;AACA,EAAA,MAAM,IAAIZ,KAAAA,CAAM,CAAA,6BAAA,EAAgCQ,GAAAA,CAAAA,CAAK,CAAA;AACzD,CAAA,EAd+B,iBAAA;AAiBxB,IAAMQ,kCAAkB,MAAA,CAAA,CAACZ,KAAAA,KAC5BA,KAAAA,CAAMW,UAAAA,CAAW3B,2BAAAA,CAAAA,IACjBgB,KAAAA,CAAMW,UAAAA,CAAW1B,yBAAAA,KACjBoB,wBAAAA,CAAyBL,KAAAA,CAAAA,IACzBD,qBAAAA,CAAsBC,KAAAA,CAAAA,EAJK,iBAAA","file":"C7YYEPNV.js","sourcesContent":["import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';\nimport type { Branded } from '@layerzerolabs/typescript-utils';\n\nimport { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './deferredValue';\n\nconst CANTON_PARTY_ID_REGEX = /^(.+)::([0-9a-fA-F]+)$/;\nconst CANTON_CONTRACT_ID_HEX_LENGTH = 138; // 69 bytes\n\nexport const CANTON_PARTY_ADDRESS_PREFIX = '<<CANTON_PARTY::';\nexport const CANTON_CID_ADDRESS_PREFIX = '<<CANTON_CID::';\nexport const CANTON_GLOBAL_ADDRESS_PREFIX = '<<CANTON_GLOBAL::';\n\n/** A Canton ledger or VER global address, with an explicit sentinel prefix. */\nexport type CantonAddress = Branded<string, 'CantonAddress'>;\n\n/** Construct a party `CantonAddress` from hint and fingerprint. */\nexport const cantonPartyAddress = (hint: string, fingerprint: string): CantonAddress =>\n `${CANTON_PARTY_ADDRESS_PREFIX}${hint}::${fingerprint}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Construct a contract-ID `CantonAddress` from the raw 69-byte hex contract id. */\nexport const cantonCidAddress = (contractId: string): CantonAddress =>\n `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Explicitly wrap an already-derived VER global address. This does not hash the input. */\nexport const cantonGlobalAddress = (address: string): CantonAddress => {\n if (!/^(?:0x)?[0-9a-fA-F]{1,64}$/.test(address)) {\n throw new Error(`Invalid Canton global bytes32 address: ${address}`);\n }\n return `${CANTON_GLOBAL_ADDRESS_PREFIX}${hexZeroPad(address, 32).toLowerCase()}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n};\n\nexport const isCantonGlobalAddress = (value: string): value is CantonAddress =>\n /^<<CANTON_GLOBAL::0x[0-9a-fA-F]{64}>>$/.test(value);\n\n/** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */\nexport const cantonDeferredAddress = (sentinel: string): CantonAddress => sentinel as CantonAddress;\n\n/** Wrap a raw Canton ledger value (party id, contract id, or deferred sentinel) as `CantonAddress`. */\nexport const toCantonAddress = (raw: string): CantonAddress => {\n if (isCantonDeferredSentinel(raw)) {\n return cantonDeferredAddress(raw);\n }\n const partyMatch = CANTON_PARTY_ID_REGEX.exec(raw);\n if (partyMatch) {\n const [, hint, fingerprint] = partyMatch;\n return cantonPartyAddress(hint!, fingerprint!);\n }\n const bare = trim0x(raw);\n if (bare.length === CANTON_CONTRACT_ID_HEX_LENGTH && bare.startsWith('00')) {\n return cantonCidAddress(bare);\n }\n throw new Error(`Not a Canton-native address: ${raw}`);\n};\n\n/** Returns true if `value` is a valid `CantonAddress` sentinel string. */\nexport const isCantonAddress = (value: string): value is CantonAddress =>\n value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) ||\n value.startsWith(CANTON_CID_ADDRESS_PREFIX) ||\n isCantonDeferredSentinel(value) ||\n isCantonGlobalAddress(value);\n"]}
|
package/dist/K6KCXLMQ.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/grpc.ts"],"names":["TOPOLOGY_TRANSACTION_NOT_FOUND","DEFAULT_GRPC_CLIENT_OPTIONS","CantonGrpcClient","opts","tokenProvider","synchronizerId","GrpcTransport","host","channelCredentials","buildChannelCredentials","insecureTransport","clientOptions","grpcClientOptions","TopologyManagerReadServiceClient","TopologyManagerWriteServiceClient","SynchronizerConnectivityServiceClient","token","getToken","Authorization","response","listConnectedSynchronizers","meta","synchronizer","connectedSynchronizers","CantonProtocolError","mapping","serial","generateTransactions","GenerateTransactionsRequest","create","proposals","GenerateTransactionsRequest_Proposal","operation","Enums_TopologyChangeOp","ADD_REPLACE","store","synchronizerStore","generated","generatedTransactions","getNamespaceDelegation","namespaceFingerprint","listNamespaceDelegation","ListNamespaceDelegationRequest","baseQuery","headStateBaseQuery","filterNamespace","filterTargetKeyFingerprint","results","flatMap","result","item","publicKey","targetKey","namespace","targetKeyFingerprint","computePublicKeyFingerprint","isRootDelegation","context","getDecentralizedNamespaceDefinition","listDecentralizedNamespaceDefinition","ListDecentralizedNamespaceDefinitionRequest","decentralizedNamespace","threshold","owners","getPartyToKeyMapping","partyId","listPartyToKeyMapping","ListPartyToKeyMappingRequest","filterParty","party","signingKeyFingerprints","signingKeys","map","key","getPartyToParticipantMapping","listPartyToParticipant","ListPartyToParticipantRequest","filterParticipant","participants","participant","participantUid","permission","createNamespaceDelegationTx","params","buildNamespaceDelegationMapping","publicKeyDer","createDecentralizedNamespaceDefinitionTx","computeDecentralizedNamespace","buildDecentralizedNamespaceDefinitionMapping","updateDecentralizedNamespaceDefinitionTx","createPartyToKeyTx","buildPartyToKeyMapping","signingPublicKeyDers","createPartyToParticipantTx","buildPartyToParticipantMapping","participantIds","submitTopologyTransactions","transactions","length","CantonError","addTransactions","AddTransactionsRequest","authorizeTopologyTransaction","transactionHashHex","options","retries","retryDelayMs","attempt","authorize","AuthorizeRequest","type","oneofKind","transactionHash","mustFullyAuthorize","err","msg","Error","message","String","includes","Promise","resolve","setTimeout","close"],"mappings":";;;;;;;;;AA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,IAAA;AACJ,EAAA;;EAGAS,KAAAA,GAAc;AACV,IAAA,IAAA,CAAK,WAAWA,KAAAA,EAAK;AACzB,EAAA;AACJ","file":"K6KCXLMQ.js","sourcesContent":["import {\n AddTransactionsRequest,\n AuthorizeRequest,\n Enums_TopologyChangeOp,\n GenerateTransactionsRequest,\n GenerateTransactionsRequest_Proposal,\n ListDecentralizedNamespaceDefinitionRequest,\n ListNamespaceDelegationRequest,\n ListPartyToKeyMappingRequest,\n ListPartyToParticipantRequest,\n type SignedTopologyTransaction,\n TopologyManagerReadServiceClient,\n TopologyManagerWriteServiceClient,\n type TopologyMapping,\n} from '@canton-network/core-ledger-proto';\nimport { GrpcTransport } from '@protobuf-ts/grpc-transport';\n\nimport type { TokenProvider } from '../auth/token-provider';\nimport { CantonError, CantonProtocolError } from '../errors';\nimport {\n buildDecentralizedNamespaceDefinitionMapping,\n buildNamespaceDelegationMapping,\n buildPartyToKeyMapping,\n buildPartyToParticipantMapping,\n} from './topology/mappings';\nimport { SynchronizerConnectivityServiceClient } from './topology/synchronizer-connectivity';\nimport type {\n CantonGrpcClientOptions,\n CreateDecentralizedNamespaceDefinitionTxParams,\n CreateNamespaceDelegationTxParams,\n CreatePartyToKeyMappingTxParams,\n CreatePartyToParticipantMappingTxParams,\n DecentralizedNamespaceDefinitionState,\n GeneratedTopologyTransaction,\n NamespaceDelegationState,\n PartyToKeyMappingState,\n PartyToParticipantMappingState,\n UpdateDecentralizedNamespaceDefinitionTxParams,\n} from './topology/types';\nimport {\n buildChannelCredentials,\n computeDecentralizedNamespace,\n headStateBaseQuery,\n synchronizerStore,\n} from './topology/utils';\nimport { computePublicKeyFingerprint } from './utils';\n\n// Canton error id for a topology transaction the store has not seen yet. gRPC errors carry it only\n// in the message, so it is matched there.\nconst TOPOLOGY_TRANSACTION_NOT_FOUND = 'TOPOLOGY_TRANSACTION_NOT_FOUND';\n\n/** Default gRPC client options: 128 MiB message-size limits for large admin responses. */\nconst DEFAULT_GRPC_CLIENT_OPTIONS = {\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n} as const;\n\n/**\n * gRPC client for the Canton participant admin Topology Manager API.\n *\n * Exposes read queries for topology mappings and write helpers that call\n * `GenerateTransactions` to produce unsigned topology transactions and\n * `AddTransactions` to submit signed ones.\n *\n * A fresh Bearer token is attached to each RPC via {@link TokenProvider}.\n */\nexport class CantonGrpcClient {\n readonly #transport: GrpcTransport;\n readonly #topologyRead: TopologyManagerReadServiceClient;\n readonly #topologyWrite: TopologyManagerWriteServiceClient;\n readonly #connectivity: SynchronizerConnectivityServiceClient;\n readonly #tokenProvider: TokenProvider;\n #synchronizerId?: string;\n\n /**\n * @param opts - Admin API host, auth, optional synchronizer id, and transport security.\n */\n constructor(opts: CantonGrpcClientOptions) {\n this.#tokenProvider = opts.tokenProvider;\n this.#synchronizerId = opts.synchronizerId;\n this.#transport = new GrpcTransport({\n host: opts.host,\n channelCredentials: buildChannelCredentials(opts.host, opts.insecureTransport),\n clientOptions: opts.grpcClientOptions ?? DEFAULT_GRPC_CLIENT_OPTIONS,\n });\n this.#topologyRead = new TopologyManagerReadServiceClient(this.#transport);\n this.#topologyWrite = new TopologyManagerWriteServiceClient(this.#transport);\n this.#connectivity = new SynchronizerConnectivityServiceClient(this.#transport);\n }\n\n /** Returns per-RPC gRPC metadata with a fresh Bearer token. */\n async #getMeta(): Promise<Record<string, string>> {\n const token = await this.#tokenProvider.getToken();\n return { Authorization: `Bearer ${token}` };\n }\n\n /**\n * Returns the client synchronizer id, discovering it on first use when omitted at construction.\n *\n * @throws {CantonProtocolError} If the participant exposes no synchronizer store.\n */\n async #getSynchronizerId(): Promise<string> {\n if (this.#synchronizerId) {\n return this.#synchronizerId;\n }\n this.#synchronizerId = await this.#discoverSynchronizerId();\n return this.#synchronizerId;\n }\n\n /**\n * Resolves the logical id of the first synchronizer the participant is connected to.\n *\n * @throws {CantonProtocolError} If the participant is not connected to any synchronizer.\n */\n async #discoverSynchronizerId(): Promise<string> {\n const { response } = await this.#connectivity.listConnectedSynchronizers(\n {},\n { meta: await this.#getMeta() },\n );\n for (const synchronizer of response.connectedSynchronizers) {\n if (synchronizer.synchronizerId) {\n return synchronizer.synchronizerId;\n }\n }\n throw new CantonProtocolError('Participant is not connected to any synchronizer');\n }\n\n /**\n * Calls `GenerateTransactions` for a single ADD_REPLACE mapping.\n *\n * @param synchronizerId - Synchronizer store to target.\n * @param mapping - Topology mapping to encode into the transaction.\n * @param serial - Topology serial (`0` lets Canton auto-determine).\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n * @throws {CantonProtocolError} If the RPC returns no generated transaction.\n */\n async #generateTopologyTransaction(\n synchronizerId: string,\n mapping: TopologyMapping,\n serial: number,\n ): Promise<GeneratedTopologyTransaction> {\n const { response } = await this.#topologyWrite.generateTransactions(\n GenerateTransactionsRequest.create({\n proposals: [\n GenerateTransactionsRequest_Proposal.create({\n operation: Enums_TopologyChangeOp.ADD_REPLACE,\n serial,\n mapping,\n store: synchronizerStore(synchronizerId),\n }),\n ],\n }),\n { meta: await this.#getMeta() },\n );\n\n const generated = response.generatedTransactions[0];\n\n if (!generated) {\n throw new CantonProtocolError('GenerateTransactions returned no topology transaction');\n }\n\n return generated;\n }\n\n /**\n * Lists Namespace Delegation (NSD) mappings for a namespace.\n *\n * Queries topology head state on the synchronizer. Returns every result from\n * the list RPC.\n *\n * @param namespaceFingerprint - Namespace to filter on (for root NSD, the owner key fingerprint).\n * @returns All matching NSD mappings, or an empty array if none exist.\n */\n async getNamespaceDelegation(\n namespaceFingerprint: string,\n ): Promise<NamespaceDelegationState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listNamespaceDelegation(\n ListNamespaceDelegationRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId),\n filterNamespace: namespaceFingerprint,\n // Empty string = no target-key filter; return all delegations for this namespace.\n filterTargetKeyFingerprint: '',\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n const publicKey = item?.targetKey?.publicKey;\n if (!item || !publicKey) {\n return [];\n }\n return [\n {\n namespace: item.namespace,\n targetKeyFingerprint: computePublicKeyFingerprint(publicKey),\n isRootDelegation: item.isRootDelegation,\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Lists Decentralized Namespace Definition (DND) mappings for a namespace.\n *\n * Queries topology head state on the synchronizer. For a party id `hint::1220…`,\n * pass the `1220…` suffix as `namespaceFingerprint`.\n *\n * @param namespaceFingerprint - Decentralized namespace fingerprint to filter on.\n * @returns All matching DND mappings, or an empty array if none exist.\n */\n async getDecentralizedNamespaceDefinition(\n namespaceFingerprint: string,\n ): Promise<DecentralizedNamespaceDefinitionState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listDecentralizedNamespaceDefinition(\n ListDecentralizedNamespaceDefinitionRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId),\n filterNamespace: namespaceFingerprint,\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n namespace: item.decentralizedNamespace,\n threshold: item.threshold,\n owners: [...item.owners],\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Lists Party-to-Key (PTK) mappings for a party.\n *\n * Queries topology head state on the synchronizer.\n *\n * @param partyId - Full party identifier (e.g. `hint::1220…`).\n * @returns All matching PTK mappings, or an empty array if none exist.\n */\n async getPartyToKeyMapping(partyId: string): Promise<PartyToKeyMappingState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listPartyToKeyMapping(\n ListPartyToKeyMappingRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId),\n filterParty: partyId,\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n party: item.party,\n threshold: item.threshold,\n signingKeyFingerprints: item.signingKeys.map((key) =>\n computePublicKeyFingerprint(key.publicKey),\n ),\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Lists Party-to-Participant (PTP) mappings for a party.\n *\n * Queries topology head state on the synchronizer.\n *\n * @param partyId - Full party identifier (e.g. `hint::1220…`).\n * @param proposals - If `true`, query pending proposals instead of authorized mappings.\n * @returns All matching PTP mappings, or an empty array if none exist.\n */\n async getPartyToParticipantMapping(\n partyId: string,\n proposals = false,\n ): Promise<PartyToParticipantMappingState[]> {\n const synchronizerId = await this.#getSynchronizerId();\n const { response } = await this.#topologyRead.listPartyToParticipant(\n ListPartyToParticipantRequest.create({\n baseQuery: headStateBaseQuery(synchronizerId, proposals),\n filterParty: partyId,\n // Empty string = no participant filter; return all hosting mappings for this party.\n filterParticipant: '',\n }),\n { meta: await this.#getMeta() },\n );\n\n return response.results.flatMap((result) => {\n const item = result.item;\n if (!item) {\n return [];\n }\n return [\n {\n party: item.party,\n threshold: item.threshold,\n participants: item.participants.map((participant) => ({\n participantUid: participant.participantUid,\n permission: participant.permission,\n })),\n serial: result.context?.serial ?? 0,\n },\n ];\n });\n }\n\n /**\n * Builds an unsigned Namespace Delegation (NSD) topology transaction.\n *\n * Calls `GenerateTransactions` with an ADD_REPLACE mapping. The returned\n * `transactionHash` must be signed by the namespace key.\n *\n * @param params - Owner public key and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createNamespaceDelegationTx(\n params: CreateNamespaceDelegationTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildNamespaceDelegationMapping(params.publicKeyDer);\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Decentralized Namespace Definition (DND) topology transaction.\n *\n * The decentralized namespace id is derived from `params.owners`. All owners\n * must sign the transaction hash.\n *\n * @param params - Owner fingerprints, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createDecentralizedNamespaceDefinitionTx(\n params: CreateDecentralizedNamespaceDefinitionTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const decentralizedNamespace = computeDecentralizedNamespace(params.owners);\n const mapping = buildDecentralizedNamespaceDefinitionMapping(\n decentralizedNamespace,\n params.threshold,\n params.owners,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n async updateDecentralizedNamespaceDefinitionTx(\n params: UpdateDecentralizedNamespaceDefinitionTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildDecentralizedNamespaceDefinitionMapping(\n params.namespace,\n params.threshold,\n params.owners,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Party-to-Key (PTK) topology transaction.\n *\n * Decentralized namespace owners must sign the transaction hash.\n *\n * @param params - Party id, signing keys, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createPartyToKeyTx(\n params: CreatePartyToKeyMappingTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildPartyToKeyMapping(\n params.partyId,\n params.signingPublicKeyDers,\n params.threshold,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Builds an unsigned Party-to-Participant (PTP) topology transaction.\n *\n * Party owners sign the transaction hash. On submit, set `proposal: true` on the\n * signed transaction so the hosting participant can authorize via `Authorize`.\n *\n * @param params - Party id, participant ids, threshold, and optional serial.\n * @returns Unsigned topology transaction (`serializedTransaction`, `transactionHash`).\n */\n async createPartyToParticipantTx(\n params: CreatePartyToParticipantMappingTxParams,\n ): Promise<GeneratedTopologyTransaction> {\n const synchronizerId = await this.#getSynchronizerId();\n const mapping = buildPartyToParticipantMapping(\n params.partyId,\n params.participantIds,\n params.threshold,\n );\n return this.#generateTopologyTransaction(synchronizerId, mapping, params.serial ?? 0);\n }\n\n /**\n * Submits signed topology transactions to the synchronizer store.\n *\n * Multiple transactions are submitted atomically in one `AddTransactions` call.\n * When batching, sign `computeMultiTransactionHash` over all transaction hashes\n * and attach the same `MultiTransactionSignatures` to each entry.\n *\n * Set `proposal: true` on a transaction when the hosting participant must\n * authorize that mapping afterward.\n *\n * @param transactions - One or more signed topology transactions.\n * @throws {CantonError} If `transactions` is empty.\n */\n async submitTopologyTransactions(\n transactions: readonly SignedTopologyTransaction[],\n ): Promise<void> {\n if (transactions.length === 0) {\n throw new CantonError('AddTransactions requires at least one transaction');\n }\n const synchronizerId = await this.#getSynchronizerId();\n await this.#topologyWrite.addTransactions(\n AddTransactionsRequest.create({\n transactions: [...transactions],\n store: synchronizerStore(synchronizerId),\n }),\n { meta: await this.#getMeta() },\n );\n }\n\n /**\n * Authorizes a pending topology proposal by its hash.\n *\n * The participant uses its own local signing keys to add its authorization to\n * the pending proposal identified by `transactionHashHex`. For a PTP where the\n * participant is a required signer, this completes the authorization so the\n * transaction becomes effective on the synchronizer.\n *\n * @param transactionHashHex - Hex-encoded hash of the pending proposal.\n */\n async authorizeTopologyTransaction(\n transactionHashHex: string,\n options: { retries?: number; retryDelayMs?: number } = {},\n ): Promise<void> {\n const { retries = 10, retryDelayMs = 2_000 } = options;\n const synchronizerId = await this.#getSynchronizerId();\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n await this.#topologyWrite.authorize(\n AuthorizeRequest.create({\n type: { oneofKind: 'transactionHash', transactionHash: transactionHashHex },\n mustFullyAuthorize: false,\n store: synchronizerStore(synchronizerId),\n }),\n { meta: await this.#getMeta() },\n );\n return;\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n // addTransactions is async — the proposal may not yet be visible.\n if (msg.includes(TOPOLOGY_TRANSACTION_NOT_FOUND) && attempt < retries) {\n await new Promise<void>((resolve) => setTimeout(resolve, retryDelayMs));\n continue;\n }\n throw err;\n }\n }\n }\n\n /** Closes the underlying gRPC transport. */\n close(): void {\n this.#transport.close();\n }\n}\n"]}
|