Skip to content

feat: multi sync example#1622

Open
Viktor-Kalashnykov-da wants to merge 11 commits into
mainfrom
wiktor/multisync-example
Open

feat: multi sync example#1622
Viktor-Kalashnykov-da wants to merge 11 commits into
mainfrom
wiktor/multisync-example

Conversation

@Viktor-Kalashnykov-da
Copy link
Copy Markdown

Multi-Synchronizer DvP Example & SDK Enhancements
Summary
Adds a new end-to-end example script (15-multi-sync-trade) demonstrating a Delivery vs Payment (DvP) trade across multiple synchronizers, along with the SDK and infrastructure changes required to support it.

New Example Script
docs/wallet-integration-guide/examples/scripts/15-multi-sync-trade.ts (~920 lines)

Implements the multi-synchronizer DvP workflow from the "Example: token using private synchronizer" design, showcasing how assets on different synchronizers (global vs. private) can be traded atomically.

Participants:

Canton Coin app (Global Synchronizer) — Amulet instrument
Token app (Private Synchronizer) — Token instrument
Alice — holds Amulet, receives Token
Bob — holds Token, receives Amulet
Trading app — orchestrates the OTC trade
Flow:

SDK initialization & synchronizer discovery (global + private)
DAR upload for the trading app
Party onboarding (Alice, Bob, Trading App)
Amulet minting for Alice & token setup
Trading app creates an OTC Trade → Allocation requests emitted
Alice allocates Amulet on the global synchronizer
Bob allocates Token on the private synchronizer
Pre-settlement: reassign Bob's allocation (private → global) via unassign/assign
Trading app settles the trade (OTCTrade_Settle)
Post-settlement: reassign Alice's new Token holding (global → private)
Final holdings verification
Note: Several steps are stubbed out (wrapped in comments) because the Token app DAR and private-sync reassignment for external parties are not yet available. The script is structured so these stubs can be replaced with real calls once the platform supports them.

SDK Changes
New Contracts namespace (sdk/wallet-sdk/src/wallet/namespace/contract/)
Provides contract reassignment operations needed for multi-synchronizer workflows:

assignContract(options) — Assigns a contract to a target synchronizer (completes a reassignment started by unassign)
unassignContract(options) — Unassigns a contract from a source synchronizer, initiating a cross-synchronizer move
Both methods call POST /v2/commands/submit-and-wait-for-reassignment with the appropriate AssignCommand / UnassignCommand.

Exposed on the SDK as sdk.contracts.

New State namespace (sdk/wallet-sdk/src/wallet/namespace/state/)
Provides ledger state queries:

connectedSynchronizers(options?) — Returns the list of connected synchronizers for a given party/participant via GET /v2/state/connected-synchronizers
Exposed on the SDK as sdk.ledger.state.

SignedPartyCreation enhancement
Party creation now respects an optional synchronizerId from createPartyOptions, falling back to defaultSynchronizerId. This allows onboarding parties on a specific synchronizer (e.g., the private one).
New type exports
ConnectedSynchronizer, ConnectedSynchronizersOptions
AssignContractOptions, UnassignContractOptions
Contracts class
Localnet Infrastructure
Multi-sync profile support (scripts/src/start-localnet.ts)
Refactored profile selection to be dynamic instead of hard-coded
Default profiles: sv, app-provider, app-user
New --multi-sync flag appends the multi-sync Docker Compose profile
New --profile flag (repeatable) allows fully custom profile selection
Added elapsed-time logging on start/stop
New root-level npm scripts
Script Description
start:localnet:multi-sync Starts localnet with the multi-sync profile enabled
stop:localnet:multi-sync Stops the multi-sync localnet and removes volumes
API Specs
Ledger API 3.4.12 (api-specs/ledger-api/3.4.12/openapi.yaml)
Package vetting endpoints: GET /v2/package-vetting and POST /v2/package-vetting marked as deprecated; replaced by POST /v2/package-vetting/list and POST /v2/package-vetting/update
TAPS support: Added optional tapsMaxPasses field to JsCommandsMeta and submission request schemas for Topology-Aware Package Selection
How to Test

Start localnet with multi-sync profile

yarn start:localnet:multi-sync

Run the new example

cd docs/wallet-integration-guide/examples
yarn run-15

Stop

yarn stop:localnet:multi-sync

@Viktor-Kalashnykov-da Viktor-Kalashnykov-da requested review from a team as code owners April 14, 2026 19:09
@Viktor-Kalashnykov-da Viktor-Kalashnykov-da marked this pull request as draft April 14, 2026 19:09
Comment thread docs/wallet-integration-guide/examples/scripts/multi-sync/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/multi-sync/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync-trade.ts Outdated
Comment thread sdk/wallet-sdk/src/wallet/sdk.ts Fixed
@Viktor-Kalashnykov-da Viktor-Kalashnykov-da changed the title Multi-Sync Example feat(multisync-example): Multi-Sync Example Apr 17, 2026
Comment thread core/token-standard-service/src/token-standard-service.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/utils/synchronizer.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/utils/synchronizer.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/multi-sync/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/multi-sync/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/multi-sync/15-multi-sync-trade.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/utils/synchronizer.ts Outdated
Comment thread scripts/src/start-localnet.ts Outdated
Comment thread sdk/wallet-sdk/src/wallet/namespace/contract/client.ts Outdated
Comment thread sdk/wallet-sdk/src/wallet/namespace/ledger/dar/client.ts Outdated
Comment thread .gitignore Outdated
Copy link
Copy Markdown
Contributor

@jarekr-da jarekr-da left a comment

Choose a reason for hiding this comment

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

I made first round or review.
Generally that is a scenario we want.
I posted questions and problems to recheck / fix.

@Viktor-Kalashnykov-da Viktor-Kalashnykov-da changed the title feat(multisync-example): Multi-Sync Example feat: multi sync example Apr 21, 2026
Comment thread core/wallet-test-utils/src/wallet-gateway.ts Outdated
Comment thread .vscode/settings.json Outdated
Comment thread api-specs/ledger-api/3.4.12/openapi.yaml
Comment thread core/ledger-client/src/ledger-client.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/utils/synchronizer.ts Outdated
Comment thread scripts/localnet/app-synchronizer.sc Outdated
Comment thread canton/multi-sync/app-synchronizer.sc
Comment thread yarn.lock Outdated
Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
… from docs/wallet-integration-guide/examples/package.json

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
Comment thread docs/wallet-integration-guide/examples/scripts/utils/acs-logger.ts
Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/_setup.ts Outdated
…nRules Contract to usage of 2 contracts of the same type but on different synchronizers

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
Signed-off-by: Viktor-Kalashnykov-da <viktor.kalashnykov@digitalasset.com>
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/_trade_ops.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/_trade_ops.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/index.ts Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/README.md Outdated
Comment thread docs/wallet-integration-guide/examples/scripts/15-multi-sync/README.md Outdated
)

// do not run tests from these directory names; full name match
const EXCEPTIONS_DIR_NAMES = ['stress', '13-rewards-for-deposits']
Copy link
Copy Markdown
Contributor

@jarekr-da jarekr-da May 13, 2026

Choose a reason for hiding this comment

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

this change can be reverted - nothing is effectively changed

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.

Sorry, my mistake - this can only be reverted after merge of code I am working (not yet here).

Comment thread sdk/wallet-sdk/src/wallet/common.ts Outdated
Signed-off-by: Viktor-Kalashnykov-da <viktor.kalashnykov@digitalasset.com>
…edBefore and validUntil fields

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
…r in the final step

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
…ntation for example #15

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
…mespace/state/client (and utility type as well)

Signed-off-by: vkalashnykov <viktor.kalashnykov@digitalasset.com>
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.

2 participants