Skip to content

Create separate SynchronizerId type, mirroring PartyId - #2339

Closed
ayushsingh82 wants to merge 2 commits into
canton-network:mainfrom
ayushsingh82:ayush/synchronizer-id-type-522
Closed

Create separate SynchronizerId type, mirroring PartyId#2339
ayushsingh82 wants to merge 2 commits into
canton-network:mainfrom
ayushsingh82:ayush/synchronizer-id-type-522

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Summary

  • synchronizerId is passed around as a bare string in several places even where a sibling partyId parameter already uses the PartyId type from core-types.
  • Added a SynchronizerId zod schema/type in core/types/src/index.ts, following the exact same pattern as PartyId (schema + z.infer type + example constant).
  • Applied it at the sites that already sit right next to a PartyId-typed value:
    • SDKContext.defaultSynchronizerId (sdk/wallet-sdk/src/wallet/init/types/context.ts)
    • CreatePartyOptions.synchronizerId (sdk/wallet-sdk/src/wallet/namespace/party/external/types.ts)
    • SignedPartyCreationService.allocate()'s synchronizerId param (.../party/external/signed.ts, which already imports PartyId)
    • MergeDelegationNamespace.setup()'s synchronizerId param (.../token/utxos/mergeDelegation.ts, same file already imports PartyId)

I deliberately left the ~200 other bare synchronizerId: string occurrences elsewhere in the repo as-is — the large majority are in auto-generated OpenAPI/AsyncAPI/protobuf client code (core/ledger-client-types/src/generated-clients/**, core/ledger-proto/src/_proto/**) that would just get overwritten on the next codegen run. This mirrors how PartyId itself isn't retrofitted everywhere either (grep -rn "partyId: string" still finds ~27 files outside the generated clients).

Note: like PartyId, SynchronizerId isn't a branded type (z.infer of a z.string() schema resolves structurally to string), so this is a type-level-only, zero-runtime-behavior change everywhere it's applied.

Fixes #522

Test plan

  • Added unit tests for the SynchronizerId schema (valid id, missing :: separator, too-short) in core/types/src/index.test.ts — 14/14 passing in that suite.
  • npx vitest run --project node src/wallet/namespace/party/party.test.ts (wallet-sdk) — 18/18 passing.
  • eslint and prettier --check clean on all 6 changed files.
  • tsc --noEmit clean on every touched file (pre-existing unrelated module-resolution errors elsewhere in wallet-sdk come from other packages needing a full monorepo build, not from this change).

synchronizerId was passed around as a bare string in several places
even where a sibling partyId parameter already used the PartyId type
from core-types. Added a SynchronizerId zod schema/type following the
same pattern as PartyId, and applied it at the sites that already sit
next to a PartyId-typed value: SDKContext.defaultSynchronizerId,
CreatePartyOptions, SignedPartyCreationService.allocate(), and
MergeDelegationNamespace.setup().

Left the ~200 other bare `synchronizerId: string` occurrences as-is --
most are auto-generated OpenAPI/AsyncAPI/protobuf client code that
would be overwritten by codegen anyway, consistent with how PartyId
itself isn't applied everywhere either.

Fixes canton-network#522

Signed-off-by: ayushsingh82 <ayushsinghmi711@gmail.com>
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@alexmatson-da whenever you have a chance, would appreciate a look at this one.

@mjuchli-da mjuchli-da left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor correction needed

Comment thread core/types/src/index.ts Outdated

export type PartyId = z.infer<typeof PartyId>

export const SYNCHRONIZER_ID_EXAMPLE = 'sync::122012312312312312123'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example should not be part of the types library and only be used in tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjuchli-da Done — moved SYNCHRONIZER_ID_EXAMPLE out of the types library and into index.test.ts as a local test-only constant. Pushed in efd2d19.

Address review feedback: the example constant shouldn't be exported
from core/types since it's only used in tests.

Signed-off-by: ayushsingh82 <ayushsinghmi711@gmail.com>
@mjuchli-da mjuchli-da closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create separate type SynchronizerId

2 participants