Skip to content

feat(example-test-token-v1-registry): enable passing synchronizerId for allocation & transfer - #2251

Open
mateuszpiatkowski-da wants to merge 2 commits into
mateuszpiatkowski-da/core-otc-tradefrom
mateuszpiatkowski-da/adjust-example-test-token-v1-registry
Open

feat(example-test-token-v1-registry): enable passing synchronizerId for allocation & transfer#2251
mateuszpiatkowski-da wants to merge 2 commits into
mateuszpiatkowski-da/core-otc-tradefrom
mateuszpiatkowski-da/adjust-example-test-token-v1-registry

Conversation

@mateuszpiatkowski-da

Copy link
Copy Markdown
Contributor

Signed-off-by: Mateusz Piątkowski mateusz.piatkowski@digitalasset.com


Stack created with GitHub Stacks CLIGive Feedback 💬

@mateuszpiatkowski-da
mateuszpiatkowski-da requested a review from a team as a code owner August 7, 2026 14:05
@mateuszpiatkowski-da
mateuszpiatkowski-da force-pushed the mateuszpiatkowski-da/adjust-example-test-token-v1-registry branch from 8eb11f4 to 6b6c43f Compare August 7, 2026 14:40
@mateuszpiatkowski-da mateuszpiatkowski-da self-assigned this Aug 7, 2026
@mateuszpiatkowski-da
mateuszpiatkowski-da force-pushed the mateuszpiatkowski-da/adjust-example-test-token-v1-registry branch from 6b6c43f to 9644cbe Compare August 10, 2026 09:54
@mateuszpiatkowski-da
mateuszpiatkowski-da force-pushed the mateuszpiatkowski-da/adjust-example-test-token-v1-registry branch 2 times, most recently from 8e04537 to f777673 Compare August 10, 2026 13:01
…d for allocation & transfer instructions

Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
@mateuszpiatkowski-da
mateuszpiatkowski-da force-pushed the mateuszpiatkowski-da/adjust-example-test-token-v1-registry branch from f777673 to 6391241 Compare August 10, 2026 15:13
@mateuszpiatkowski-da mateuszpiatkowski-da changed the title feat(example-test-token-v1-registry): enable passing in synchronizerId for allocation & transfer instructions feat(example-test-token-v1-registry): enable passing synchronizerId for allocation & transfer Aug 10, 2026
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
(factory) =>
factory.synchronizerId === synchronizerId.allocationInstruction
)
if (syncFactory) {

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.

If syncFactory is undefined, because none of factories matched synchronizerId.allocationInstruction, but fetchedFactories has at least one item, then we return fetchedFactories[0].

I think a better flow in "multi-sync mode" would be to skip returning fetchedFactories[0] if no factory matches sync id, and go straight to "...and create one otherwise" part.

let server: Server

await initOperatorParty()
export const startRegistry = async (

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.

Nothing but tests calls startRegistry. Is that intentional in scope of that branch?

})

it("shouldn't do anything", async () => {
const { stopRegistry } = await import('.')

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.

Now that importing index doesn't trigger any action, and start/stop has to be manually called, maybe it would be less confusing to have one static import at the beginning of the file?

// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

export const synchronizerId = {

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'm suspicious of that approach to have a shared module level object with sync ids that is mutated after calling startRegistry if options?.synchronizerIds is provided, while stopRegistry doesn't reset it to empty state.

Example problematic scenario:
-startRegistry with options?.synchronizerIds -> synchronizerId modified, getAllocationFactory would check this syncs id
-stopRegistry
-startRegistry without options?.synchronizerIds -> synchronizerId from previous startRegistry still present, getAllocationFactory would check sync ids from previous startRegistry.

I would at least clear it in stopRegistry.
Or you could consider a different approach where syncIds live only inside registry instance, instead of a common module level object. Seems safer and easier to modify, i.e. if you wanted an option to have multiple instances of registry at the same time for some reason. But this is far-fetched scenario which I don't know we will ever need, so for me it's only important that you assure uninteded synchronizer ids don't appear when we didn't want them, so cleanup in stopRegistry probably would suffice.

* @customize The registry shouldn't be responsible for vetting daml files. We're doing this for development purposes only. Feel free to remove this when constructing your own token.
*/
if (process.env.NODE_ENV === 'development') await TestToken.utils.vetDar(sdk)
await initOperatorParty(options?.operator)

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.

Not sure if it's a problem, but if you startRegistry, stopRegistry and startRegistry again, it will try to allocate same party twice.

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