Skip to content

Commit c6b0b10

Browse files
feat: fix build, adjust solution to fit needs, move types in splice-codegen
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
1 parent bc85b2e commit c6b0b10

24 files changed

Lines changed: 140 additions & 206 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ jobs:
516516

517517
- name: Rebuild DAML-dependent packages
518518
run: |
519-
yarn workspace @canton-network/core-test-token build
519+
yarn workspace @canton-network/core-splice-codegen build
520520
521521
- uses: ./.github/actions/check_resources
522522

core/splice-codegen/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @canton-network/core-test-token
1+
# @canton-network/core-splice-codegen
22

33
TypeScript wrapper package for the Test Token DAML codegen.
44

@@ -15,7 +15,7 @@ From [src/index.ts](src/index.ts):
1515
From the repo root:
1616

1717
```sh
18-
yarn workspace @canton-network/core-test-token build
18+
yarn workspace @canton-network/core-splice-codegen build
1919
```
2020

2121
The build produces:
@@ -45,7 +45,7 @@ import {
4545
TestTokenV1,
4646
packageId,
4747
commands,
48-
} from '@canton-network/core-test-token'
48+
} from '@canton-network/core-splice-codegen'
4949

5050
const template = TestTokenV1
5151
console.log(packageId)
@@ -85,7 +85,7 @@ Available builders:
8585
Example:
8686

8787
```ts
88-
import { commands } from '@canton-network/core-test-token'
88+
import { commands } from '@canton-network/core-splice-codegen'
8989

9090
const createAllocation = commands.create.allocation({
9191
allocation: {

core/splice-codegen/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
export { module as TestToken } from './test-token'
55
export { module as OTCTrade } from './otc-trade'
6+
export type * from './test-token/types'
7+
export type * from './otc-trade/types'

core/splice-codegen/src/otc-trade/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { generateCommand } from 'src/common'
5-
import { OTCTrade, OTCTradeProposal, TradingApp } from './dar'
5+
import { TradingApp } from './dar'
6+
import { OTCTrade, OTCTradeProposal } from './types'
67

78
const commands = {
89
create: {

core/splice-codegen/src/otc-trade/dar.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ import { Splice } from '@daml.js/otc-trade'
55

66
export { packageId } from '@daml.js/otc-trade'
77
export const TradingApp = Splice.Testing.Apps.TradingApp
8-
9-
export type {
10-
OTCTrade,
11-
OTCTradeProposal,
12-
} from '@daml.js/otc-trade/Splice/Testing/Apps/TradingApp'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export type {
5+
OTCTrade,
6+
OTCTradeProposal,
7+
} from '@daml.js/otc-trade/Splice/Testing/Apps/TradingApp'

core/splice-codegen/src/test-token/commands.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import {
5-
TestTokenID,
6-
TestTokenV1,
7-
TokenAllocation,
8-
TokenRules,
9-
TokenTransferOffer,
10-
type Token,
11-
} from './dar'
4+
import { TestTokenID, TestTokenV1 } from './dar'
125
import {
136
Allocation,
147
AllocationFactory,
@@ -18,6 +11,7 @@ import {
1811
import { PartyId } from '@canton-network/core-types'
1912
import { WrappedCommand } from '@canton-network/core-ledger-client-types'
2013
import { generateCommand } from 'src/common'
14+
import { Token, TokenAllocation, TokenRules, TokenTransferOffer } from './types'
2115

2216
const commands = {
2317
create: {

core/splice-codegen/src/test-token/dar.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,3 @@ export { packageId } from '@daml.js/test-token-v1'
77
export const TestTokenV1 = Splice.Testing.Tokens.TestTokenV1
88

99
export const TestTokenID = 'TestToken'
10-
11-
export type {
12-
Token,
13-
TokenAllocation,
14-
TokenRules,
15-
TokenTransferOffer,
16-
} from '@daml.js/test-token-v1/Splice/Testing/Tokens/TestTokenV1'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export type {
5+
Token,
6+
TokenAllocation,
7+
TokenRules,
8+
TokenTransferOffer,
9+
} from '@daml.js/test-token-v1/Splice/Testing/Tokens/TestTokenV1'

core/token-standard-service/src/token-standard-service.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import {
1414
AllocationFactory_Allocate,
1515
AllocationSpecification,
1616
Transfer,
17-
transferInstructionRegistryTypes,
18-
allocationInstructionRegistryTypes,
1917
ExtraArgs,
2018
Metadata,
2119
FEATURED_APP_DELEGATE_PROXY_INTERFACE_ID,
2220
Holding,
2321
Beneficiaries,
22+
OffLedger,
2423
} from '@canton-network/core-token-standard'
2524
import {
2625
EventFilterBySetup,
@@ -506,7 +505,7 @@ class AllocationService {
506505
choiceArgs: AllocationFactory_Allocate,
507506
excludeDebugFields: boolean = true
508507
): Promise<
509-
allocationInstructionRegistryTypes['schemas']['FactoryWithChoiceContext']
508+
OffLedger.AllocationInstructionV1.components['schemas']['FactoryWithChoiceContext']
510509
> {
511510
return this.core
512511
.getTokenStandardClient(registryUrl)
@@ -519,7 +518,7 @@ class AllocationService {
519518
async createAllocationInstructionFromContext(
520519
factoryId: string,
521520
choiceArgs: AllocationFactory_Allocate,
522-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
521+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
523522
): Promise<[ExerciseCommand, DisclosedContract[]]> {
524523
choiceArgs.extraArgs.context = {
525524
...choiceContext.choiceContextData,
@@ -542,7 +541,7 @@ class AllocationService {
542541
requestedAt?: string,
543542
prefetchedRegistryChoiceContext?: {
544543
factoryId: string
545-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
544+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
546545
}
547546
): Promise<[ExerciseCommand, DisclosedContract[]]> {
548547
const choiceArgs = await this.buildAllocationFactoryChoiceArgs(
@@ -579,7 +578,7 @@ class AllocationService {
579578
| 'Allocation_ExecuteTransfer'
580579
| 'Allocation_Withdraw'
581580
| 'Allocation_Cancel',
582-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
581+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
583582
): [ExerciseCommand, DisclosedContract[]] {
584583
const exercise: ExerciseCommand = {
585584
templateId,
@@ -614,7 +613,7 @@ class AllocationService {
614613

615614
createExecuteTransferAllocationFromContext(
616615
allocationCid: string,
617-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
616+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
618617
): [ExerciseCommand, DisclosedContract[]] {
619618
return this.buildAllocationExerciseWithContext(
620619
ALLOCATION_INTERFACE_ID,
@@ -627,7 +626,7 @@ class AllocationService {
627626
async createExecuteTransferAllocation(
628627
allocationCid: string,
629628
registryUrl: string,
630-
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
629+
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
631630
): Promise<[ExerciseCommand, DisclosedContract[]]> {
632631
if (prefetchedRegistryChoiceContext) {
633632
return this.createExecuteTransferAllocationFromContext(
@@ -648,7 +647,9 @@ class AllocationService {
648647
async fetchWithdrawAllocationChoiceContext(
649648
allocationCid: string,
650649
registryUrl: string
651-
): Promise<allocationInstructionRegistryTypes['schemas']['ChoiceContext']> {
650+
): Promise<
651+
OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
652+
> {
652653
return this.core.getTokenStandardClient(registryUrl).post(
653654
'/registry/allocations/v1/{allocationId}/choice-contexts/withdraw',
654655
{
@@ -660,7 +661,7 @@ class AllocationService {
660661

661662
createWithdrawAllocationFromContext(
662663
allocationCid: string,
663-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
664+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
664665
): [ExerciseCommand, DisclosedContract[]] {
665666
return this.buildAllocationExerciseWithContext(
666667
ALLOCATION_INTERFACE_ID,
@@ -673,7 +674,7 @@ class AllocationService {
673674
async createWithdrawAllocation(
674675
allocationCid: string,
675676
registryUrl: string,
676-
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
677+
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
677678
): Promise<[ExerciseCommand, DisclosedContract[]]> {
678679
if (prefetchedRegistryChoiceContext) {
679680
return this.createWithdrawAllocationFromContext(
@@ -694,7 +695,9 @@ class AllocationService {
694695
async fetchCancelAllocationChoiceContext(
695696
allocationCid: string,
696697
registryUrl: string
697-
): Promise<allocationInstructionRegistryTypes['schemas']['ChoiceContext']> {
698+
): Promise<
699+
OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
700+
> {
698701
return this.core.getTokenStandardClient(registryUrl).post(
699702
'/registry/allocations/v1/{allocationId}/choice-contexts/cancel',
700703
{
@@ -706,7 +709,7 @@ class AllocationService {
706709

707710
createCancelAllocationFromContext(
708711
allocationCid: string,
709-
choiceContext: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
712+
choiceContext: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
710713
): [ExerciseCommand, DisclosedContract[]] {
711714
return this.buildAllocationExerciseWithContext(
712715
ALLOCATION_INTERFACE_ID,
@@ -719,7 +722,7 @@ class AllocationService {
719722
async createCancelAllocation(
720723
allocationCid: string,
721724
registryUrl: string,
722-
prefetchedRegistryChoiceContext?: allocationInstructionRegistryTypes['schemas']['ChoiceContext']
725+
prefetchedRegistryChoiceContext?: OffLedger.AllocationInstructionV1.components['schemas']['ChoiceContext']
723726
): Promise<[ExerciseCommand, DisclosedContract[]]> {
724727
if (prefetchedRegistryChoiceContext) {
725728
return this.createCancelAllocationFromContext(
@@ -875,7 +878,7 @@ class TransferService {
875878
choiceArgs: CreateTransferChoiceArgs,
876879
excludeDebugFields: boolean = true
877880
): Promise<
878-
transferInstructionRegistryTypes['schemas']['TransferFactoryWithChoiceContext']
881+
OffLedger.TransferInstructionV1.components['schemas']['TransferFactoryWithChoiceContext']
879882
> {
880883
return await this.core
881884
.getTokenStandardClient(registryUrl)
@@ -888,7 +891,7 @@ class TransferService {
888891
async createTransferFromContext(
889892
factoryId: string,
890893
choiceArgs: CreateTransferChoiceArgs,
891-
choiceContext: transferInstructionRegistryTypes['schemas']['ChoiceContext']
894+
choiceContext: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
892895
): Promise<[ExerciseCommand, DisclosedContract[]]> {
893896
this.logger.debug('Creating transfer from pre-fetched context...')
894897
choiceArgs.extraArgs.context = {
@@ -918,7 +921,7 @@ class TransferService {
918921
meta?: Metadata,
919922
prefetchedRegistryChoiceContext?: {
920923
factoryId: string
921-
choiceContext: transferInstructionRegistryTypes['schemas']['ChoiceContext']
924+
choiceContext: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
922925
},
923926
continueUntilCompletion?: boolean
924927
): Promise<[ExerciseCommand, DisclosedContract[]]> {
@@ -1126,7 +1129,7 @@ class TransferService {
11261129
async createAcceptTransferInstruction(
11271130
transferInstructionCid: string,
11281131
registryUrl: string,
1129-
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
1132+
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
11301133
): Promise<[ExerciseCommand, DisclosedContract[]]> {
11311134
if (prefetchedRegistryChoiceContext) {
11321135
return this.createAcceptTransferInstructionFromContext(
@@ -1207,7 +1210,7 @@ class TransferService {
12071210
async createRejectTransferInstruction(
12081211
transferInstructionCid: string,
12091212
registryUrl: string,
1210-
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
1213+
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
12111214
): Promise<[ExerciseCommand, DisclosedContract[]]> {
12121215
if (prefetchedRegistryChoiceContext) {
12131216
return this.createRejectTransferInstructionFromContext(
@@ -1289,7 +1292,7 @@ class TransferService {
12891292
async createWithdrawTransferInstruction(
12901293
transferInstructionCid: string,
12911294
registryUrl: string,
1292-
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
1295+
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
12931296
): Promise<[ExerciseCommand, DisclosedContract[]]> {
12941297
if (prefetchedRegistryChoiceContext) {
12951298
return this.createWithdrawTransferInstructionFromContext(
@@ -1317,7 +1320,7 @@ class TransferService {
13171320
transferInstructionCid: string,
13181321
registryUrl: string,
13191322
instructionChoice: 'Accept' | 'Reject' | 'Withdraw',
1320-
prefetchedRegistryChoiceContext?: transferInstructionRegistryTypes['schemas']['ChoiceContext']
1323+
prefetchedRegistryChoiceContext?: OffLedger.TransferInstructionV1.components['schemas']['ChoiceContext']
13211324
): Promise<[ExerciseCommand, DisclosedContract[]]> {
13221325
switch (instructionChoice) {
13231326
case 'Accept':

0 commit comments

Comments
 (0)