@canton-network/core-test-token
v1.2.1
Published
daml codegen js for test-token package
Keywords
Readme
@canton-network/core-test-token
TypeScript wrapper package for the Test Token DAML codegen.
Requirements
This package requires a localnet instance that relies on Splice v0.6.12 or higher. Please ensure you have the latest localnet fetched.
Exports
From src/index.ts:
TestTokenV1: shortcut toSplice.Testing.Tokens.TestTokenV1packageId: re-export from@daml.js/test-token-v1commands: command builders for Test Token templates and choices
Build
From the repo root:
pnpm --filter @canton-network/core-test-token buildThe build produces:
- ESM:
dist/index.js - CJS:
dist/index.cjs - Browser ESM:
dist/index.browser.js - Types:
dist/index.d.ts
Regenerating DAML Codegen Inputs
This package depends on generated DAML JS artifacts under
damljs/test-token-v1.
To refresh those artifacts, run:
pnpm script:generate:test-tokenThen rebuild this package.
Usage
import {
TestTokenV1,
packageId,
commands,
} from '@canton-network/core-test-token'
const template = TestTokenV1
console.log(packageId)
// Build a create command for TokenRules
const createRules = commands.create.rules({ admin: 'Alice::1220...' })
// Build an exercise command for TokenTransferOffer.Accept
const acceptTransfer = commands.exercise.transferOffer.accept({
contractId: '00a1b2c3d4...',
choiceArgument: {},
})Command Helpers
The commands export provides typed helpers that return
WrappedCommand<'CreateCommand'> and WrappedCommand<'ExerciseCommand'>.
Available builders:
commands.create.transferOffercommands.create.allocationcommands.create.rulescommands.exercise.transferOffer.acceptcommands.exercise.transferOffer.rejectcommands.exercise.transferOffer.withdrawcommands.exercise.transferOffer.updatecommands.exercise.allocation.executeTransfercommands.exercise.allocation.cancelcommands.exercise.allocation.withdrawcommands.exercise.rules.transfer.transfercommands.exercise.rules.transfer.publicFetchcommands.exercise.rules.allocation.allocatecommands.exercise.rules.allocation.publicFetch
Example:
import { commands } from '@canton-network/core-test-token'
const createAllocation = commands.create.allocation({
allocation: {
// Fill with your AllocationSpecification payload
},
})
const executeTransfer = commands.exercise.allocation.executeTransfer({
contractId: '00f00d...',
choiceArgument: {
// Fill with Allocation_ExecuteTransfer choice argument
},
})License
Apache-2.0
