-
Notifications
You must be signed in to change notification settings - Fork 53
feat(example-test-token-v1-registry): enable passing synchronizerId for allocation & transfer #2251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, it, expect, afterEach } from 'vitest' | ||
| import { assignSynchronizerIds, synchronizerId } from './synchronizer' | ||
|
|
||
| describe('synchronizer', () => { | ||
| afterEach(() => { | ||
| Object.assign(synchronizerId, { | ||
| transferInstruction: '', | ||
| allocationInstruction: '', | ||
| }) | ||
| }) | ||
| it('should be set to empty strings by default', () => { | ||
| expect(synchronizerId).toStrictEqual({ | ||
| transferInstruction: '', | ||
| allocationInstruction: '', | ||
| }) | ||
| }) | ||
| it('should properly assign syncrhonizers', () => { | ||
| const expectedResult = { | ||
| transferInstruction: 'transfer-sync-id', | ||
| allocationInstruction: 'allocation-sync-id', | ||
| } | ||
|
|
||
| assignSynchronizerIds(expectedResult) | ||
|
|
||
| expect(synchronizerId).toStrictEqual(expectedResult) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| export const synchronizerId = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Example problematic scenario: I would at least clear it in |
||
| transferInstruction: '', | ||
| allocationInstruction: '', | ||
| } | ||
|
|
||
| export const assignSynchronizerIds = (sync: typeof synchronizerId) => { | ||
| Object.assign(synchronizerId, sync) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
syncFactoryis undefined, because none of factories matchedsynchronizerId.allocationInstruction, but fetchedFactories has at least one item, then we returnfetchedFactories[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.