-
Notifications
You must be signed in to change notification settings - Fork 53
feat(core-splice-codegen,example-test-token-v1-registry): create new core package, move test token #2249
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
Open
Open
feat(core-splice-codegen,example-test-token-v1-registry): create new core package, move test token #2249
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8924594
feat(core-splice-codegen,example-test-token-v1-registry): create new …
mateuszpiatkowski-da be2dc81
docs(core-splice-codegen): update readme
mateuszpiatkowski-da ca1b285
fix(core-splice-codegen): remove build warnings
mateuszpiatkowski-da ef601eb
fix(splice-codegen): fix build
mateuszpiatkowski-da 59be9f0
test(example-test-token-v1-registry): update tests
mateuszpiatkowski-da File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # @canton-network/core-splice-codegen | ||
|
|
||
| Typed wrappers around generated DAML JS packages used by Splice examples and SDK integrations. | ||
|
|
||
| This package currently exposes two modules: | ||
|
|
||
| - `TestToken` (from `@daml.js/test-token-v1`) | ||
| - `OTCTrade` (from `@daml.js/otc-trade`) | ||
|
|
||
| ## Installation | ||
|
|
||
| ```sh | ||
| yarn add @canton-network/core-splice-codegen | ||
| ``` | ||
|
|
||
| ## Exports | ||
|
|
||
| Top-level exports (from `src/index.ts`): | ||
|
|
||
| - `TestToken` | ||
| - `OTCTrade` | ||
|
|
||
| Each module has the same shape: | ||
|
|
||
| - `DAR`: typed template references, package ID, and selected type exports | ||
| - `commands`: typed create/exercise command builders | ||
| - `utils`: helper utilities (currently `vetDar`) | ||
|
|
||
| ## Build | ||
|
|
||
| From repository root: | ||
|
|
||
| ```sh | ||
| yarn workspace @canton-network/core-splice-codegen build | ||
| ``` | ||
|
|
||
| Build outputs: | ||
|
|
||
| - ESM: `dist/index.js` | ||
| - CJS: `dist/index.cjs` | ||
| - Browser ESM: `dist/index.browser.js` | ||
| - Types: `dist/index.d.ts` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```ts | ||
| import { TestToken, OTCTrade } from '@canton-network/core-splice-codegen' | ||
|
|
||
| // Template references | ||
| console.log(TestToken.DAR.TestTokenV1.TokenRules.templateId) | ||
| console.log(OTCTrade.DAR.TradingApp.OTCTradeProposal.templateId) | ||
|
|
||
| // Typed create command | ||
| const createRules = TestToken.commands.create.rules({ | ||
| admin: 'Alice::1220...', | ||
| }) | ||
|
|
||
| // Typed exercise command | ||
| const settleTrade = OTCTrade.commands.exercise.otcTrade.settle({ | ||
| contractId: '00abc...', | ||
| choiceArgument: { | ||
| allocationsWithContext: {}, | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| ## TestToken Module | ||
|
|
||
| `TestToken.DAR` includes: | ||
|
|
||
| - `packageId` | ||
| - `TestTokenV1` | ||
| - `TestTokenID` | ||
| - Types: `Token`, `TokenAllocation`, `TokenRules`, `TokenTransferOffer` | ||
|
|
||
| `TestToken.commands.create`: | ||
|
|
||
| - `transferOffer` | ||
| - `allocation` | ||
| - `rules` | ||
| - `token` | ||
|
|
||
| `TestToken.commands.exercise.transferOffer`: | ||
|
|
||
| - `accept` | ||
| - `reject` | ||
| - `withdraw` | ||
| - `update` | ||
|
|
||
| `TestToken.commands.exercise.allocation`: | ||
|
|
||
| - `executeTransfer` | ||
| - `cancel` | ||
| - `withdraw` | ||
|
|
||
| `TestToken.commands.exercise.rules.transfer`: | ||
|
|
||
| - `transfer` | ||
| - `publicFetch` | ||
|
|
||
| `TestToken.commands.exercise.rules.allocation`: | ||
|
|
||
| - `allocate` | ||
| - `publicFetch` | ||
|
|
||
| `TestToken.utils`: | ||
|
|
||
| - `vetDar(sdk, synchronizerId?)` | ||
|
|
||
| ## OTCTrade Module | ||
|
|
||
| `OTCTrade.DAR` includes: | ||
|
|
||
| - `packageId` | ||
| - `TradingApp` | ||
| - Types: `OTCTrade`, `OTCTradeProposal` | ||
|
|
||
| `OTCTrade.commands.create`: | ||
|
|
||
| - `otcTrade` | ||
| - `otcTradeProposal` | ||
|
|
||
| `OTCTrade.commands.exercise.otcTrade`: | ||
|
|
||
| - `settle` | ||
| - `cancel` | ||
|
|
||
| `OTCTrade.commands.exercise.otcTradeProposal`: | ||
|
|
||
| - `accept` | ||
| - `reject` | ||
| - `initiateSettlement` | ||
|
|
||
| `OTCTrade.utils`: | ||
|
|
||
| - `vetDar(sdk, synchronizerId?)` | ||
|
|
||
| ## DAR Vetting Utility | ||
|
|
||
| Both modules expose `utils.vetDar`, which loads a local DAR file and uploads it through the SDK: | ||
|
|
||
| ```ts | ||
| import { TestToken } from '@canton-network/core-splice-codegen' | ||
|
|
||
| await TestToken.utils.vetDar(sdk) | ||
| await TestToken.utils.vetDar(sdk, 'global-synchronizer-id') | ||
| ``` | ||
|
|
||
| Notes: | ||
|
|
||
| - `vetDar` expects local DAR files to exist under `.localnet/dars/`. | ||
| - If those files are absent, DAR upload will fail at runtime. | ||
|
|
||
| ## Relationship To Token Standard | ||
|
|
||
| `TestToken` command helpers are wired to choice names from `@canton-network/core-token-standard`: | ||
|
|
||
| - transfer-instruction choices | ||
| - allocation choices | ||
| - transfer/allocation factory choices | ||
|
|
||
| This keeps command generation aligned with Token Standard API semantics while staying strongly typed against DAML templates. | ||
|
|
||
| ## License | ||
|
|
||
| Apache-2.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would go through this readme and check which sections actually provide value to reader. For example here the same info can be derived by quick look at index. You could either add some descriptions what is TestToken and what is OTCTrade, or just omit it. Build outputs section also provides exactly the same info that dedicated property in package.json - I would skip that.