Skip to content

feat: multi sync example#1622

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

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

Conversation

@Viktor-Kalashnykov-da

@Viktor-Kalashnykov-da Viktor-Kalashnykov-da commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Multi-Synchronizer DvP Example - On ledger API - Part 1

Showcases automatic reassignment of Token from private synchronizer to global one, used on a realistic trade scenario with use of a custom Token.

New test:
https://github.com/canton-network/wallet/pull/1622/changes#diff-37db720ea457076fe6d04f6938d19c44e5dde3d7e1a5815953ff6b83199a1052

Design principles:

  1. !!! We remove handling of synchronizers inside wallet-sdk.
    Client code should be responsible of selecting synchronizerId in multi-sync scenarios.
    If not provided - synchronizer choice is left for canton participant logic.
    Existing tests are updated (refactor(wallet-sdk): remove default synchronizer auto-selection #1740).

  2. We try to show "realistic scenario" - we use multiple parties (Alice, Bob, TokenAdmin, TradingApp) we also
    distribute dars to selected synchronizers (private dars to private). This contributes to relative complexity of the test code

image

source:
https://docs.google.com/presentation/d/1q6LpHi-wC_MO_mzf7wp5D-15j4lNeKjCMW5xmBggaTY

  1. Example works with Token Standard V1
    We have experimented with token standard V2 -> but as V2 is not yet merged to splice use of V2 means even more code

  2. All tests run on multi-sync

This is a first PR in a series
Showcases only on-ledger part - and ensures code works.
There are 2 follow up PRs (wip)

Technical limitations:
In this PR we introduce separate tests for multi-sync (otherwise regular tests are flaky on multi-sync) - that split will be removed in a separate PR (above)

New example script:
docs/wallet-integration-guide/examples/scripts/15-multi-sync-trade.ts

Notes

  1. explicit reassignment
    we experimented with automatic reassignment of contracts - and it basically worked BUT.

It worked as long as Bob is owner of TokenRules contract which seems unrealistic.
We introduced TokenAdmin as additional party that is issuer of Token on app-synchronizer (private one).
But this in fact forces us to use explicit reassignment.

  1. TestToken on global synchronizer. The original intention seemed to be that TestToken dar is only vetted on private synchronizer.
    But since the settlement actually happens on global - TestToken related models must be also on global synchronizer

@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

@jarekr-da jarekr-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.

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
@jarekr-da
jarekr-da force-pushed the wiktor/multisync-example branch from 585d9b4 to 56f38fe Compare July 9, 2026 10:43
Comment on lines +14 to +17
import {
aliceTransferToCharlie,
bobSelfTransferToApp,
} from './_token_transfer.js'
jarekr-da and others added 22 commits July 14, 2026 09:28
Rebase the wiktor/multisync-example branch onto origin/main. The branch's
tangled history (79 commits including 12 main-merges) is collapsed into this
net change set applied on top of current main; the original commits remain on
origin/wiktor/multisync-example and in a local backup tag.

Includes the multi-sync DvP example (run-17), the core-test-token-v1 registry
package and splice-test-token-v1 DAR, and wallet-sdk multi-sync support.

Non-trivial conflict resolutions:
- ledger/dar namespace: origin/main independently introduced DarNamespace in
  dar/index.ts (with dar.test.ts). Folded the branch's extra vet() method into
  it and removed the now-redundant dar/client.ts duplicate.
- examples/package.json: main's existing run-15/run-16 no-validator-url
  examples are preserved unchanged; the new multi-sync example is added as
  run-17 (scripts/17-multi-sync).

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…EADME.md

Co-authored-by: Simon Meier <simon@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…EADME.md

Co-authored-by: Simon Meier <simon@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
@jarekr-da
jarekr-da force-pushed the wiktor/multisync-example branch from ce24575 to 936a150 Compare July 14, 2026 07:33
Signed-off-by: jarekr-da <jaroslaw.ratajski@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.

7 participants