@daml/types
TypeScript package
@daml/types
TypeScript and JavaScript language bindings for Canton.
TypeScriptUpdated 3.4.9
Package@daml/types
Current release3.5.2
Compared releases7
@daml/types TypeDoc snapshots.
Table of Contents
| Name | Kind | Summary | Introduced | Changed | Deprecated | Removed |
|---|---|---|---|---|---|---|
Choice | Interface | Interface for objects representing Daml choices. | 3.4.8 | - | - | - |
ChoiceFrom | Interface | The origin companion that contained a [[Choice]]. | 3.4.8 | - | - | - |
ContractTypeCompanion | Interface | Companion objects for templates and interfaces, containing their choices. | 3.4.8 | 3.4.9: members added: templateIdWithPackageId | - | - |
FromTemplate | Interface | A mixin for [[InterfaceCompanion]]. This supplies the basis for the methods of [[ToInterface]]. Even interfaces that retroactively implement for no templates implement this, because forward implementations still require this marker to work. | 3.4.8 | - | - | - |
Map | Interface | The counterpart of Daml’s DA.Map.Map K V type.This is an immutable map which compares keys via deep equality. The order of iteration is unspecified; the only guarantee is that the order in keys andvalues match, i.e. m.get(k) is (deep-, value-based) equal to[...m.values()][[...m.keys()].findIndex((l) => _.isEqual(k, l))] | 3.4.8 | - | - | - |
Serializable | Interface | Interface for companion objects of serializable types. Its main purpose is to serialize and deserialize values between raw JSON and typed values. | 3.4.8 | - | - | - |
Template | Interface | Interface for objects representing Daml templates. It is similar to theTemplate type class in Daml. | 3.4.8 | 3.4.9: members added: templateIdWithPackageId | - | - |
ToInterface | Interface | A mixin for [[Template]] that provides the toInterface andunsafeFromInterface contract ID conversion functions.Even templates that directly implement no interfaces implement this, because this also permits conversion with interfaces that supply retroactive implementations to this template. | 3.4.8 | - | - | - |
Unit | Interface | The counterpart of Daml’s () type. | 3.4.8 | - | - | - |
Bool | Type Alias | The counterpart of Daml’s Bool type. | 3.4.8 | - | - | - |
ContractId | Type Alias | The counterpart of Daml’s ContractId T type.We represent ContractIds as strings. Their exact format of these strings depends on the ledgerthe Daml application is running on. The purpose of the intersection with { [ContractIdBrand]: T } is toprevent accidental use of a ContractId<T> when a ContractId<U> isneeded (unless T is a subtype of U). This technique is known as”branding” in the TypeScript community. | 3.4.8 | - | - | - |
Date | Type Alias | The counterpart of Daml’s Date type.We represent Dates as strings with format YYYY-MM-DD. | 3.4.8 | - | - | - |
Decimal | Type Alias | The counterpart of Daml’s Decimal type.In Daml, Decimal’s are the same as Numeric with precision 10. | 3.4.8 | - | - | - |
DisclosedContract | Type Alias | A disclosed contract that can be passed on a command submission. | 3.4.8 | - | - | - |
Int | Type Alias | The counterpart of Daml’s Int type.We represent Ints as string in order to avoid a loss of precision. | 3.4.8 | - | - | - |
Interface | Type Alias | An interface type, for use with contract IDs. | 3.4.8 | - | - | - |
InterfaceCompanion | Type Alias | Interface for objects representing Daml interfaces. | 3.4.8 | - | - | - |
List | Type Alias | The counterpart of Daml’s [T] list type.We represent lists using arrays. | 3.4.8 | - | - | - |
Numeric | Type Alias | The counterpart of Daml’s Numeric type.We represent Numerics as string in order to avoid a loss of precision. The string must matchthe regular expression -?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?. | 3.4.8 | - | - | - |
Optional | Type Alias | The counterpart of Daml’s Optional T type. | 3.4.8 | - | - | - |
Party | Type Alias | The counterpart of Daml’s Party type.We represent Partys as strings matching the regular expression [A-Za-z0-9:_\- ]+. | 3.4.8 | - | - | - |
TemplateOrInterface | Type Alias | - | 3.4.8 | 3.4.9: signature updated; type parameter renamed: I -> Id | - | - |
Text | Type Alias | The counterpart of Daml’s Text type. | 3.4.8 | - | - | - |
TextMap | Type Alias | The counterpart of Daml’s TextMap T type.We represent TextMaps as dictionaries. | 3.4.8 | - | - | - |
Time | Type Alias | The counterpart of Daml’s Time type.We represent Timess as strings with format YYYY-MM-DDThh:mm:ss[.ssssss]Z. | 3.4.8 | - | - | - |
Bool | Variable | Companion object of the [[Bool]] type. | 3.4.8 | - | - | - |
Date | Variable | Companion object of the [[Date]] type. | 3.4.8 | - | - | - |
Decimal | Variable | Companion object of the [[Decimal]] type. | 3.4.8 | - | - | - |
Int | Variable | Companion object of the [[Int]] type. | 3.4.8 | - | - | - |
Party | Variable | Companion object of the [[Party]] type. | 3.4.8 | - | - | - |
Text | Variable | Companion object of the [[Text]] type. | 3.4.8 | - | - | - |
Time | Variable | Companion object of the [[Time]] type. | 3.4.8 | - | - | - |
Unit | Variable | Companion object of the [[Unit]] type. | 3.4.8 | - | - | - |
ContractId | Function | Companion object of the [[ContractId]] type. | 3.4.8 | - | - | - |
emptyMap | Function | - | 3.4.8 | - | - | - |
List | Function | Companion object of the [[List]] type. | 3.4.8 | - | - | - |
Map | Function | Companion function of the [[GenMap]] type. | 3.4.8 | - | - | - |
Numeric | Function | Companion function of the [[Numeric]] type. | 3.4.8 | - | - | - |
Optional | Function | Companion function of the [[Optional]] type. | 3.4.8 | - | - | - |
TextMap | Function | Companion object of the [[TextMap]] type. | 3.4.8 | - | - | - |
Reference
Interfaces
Choice
Interface
- Kind:
Interface - Source:
index.d.ts:113
interface Choice<T extends object = void, C extends void = void, R extends void = void, K extends void = unknown> extends ChoiceFrom<TemplateOrInterface<T, K>>
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | The template type. |
C | - | - | The choice type. |
R | - | - | The choice return type. |
K | - | unknown | The contract key type. |
| Member | Type | Description |
|---|---|---|
choiceName | string | The choice name. |
template | () => TemplateOrInterface | Returns the template to which this choice belongs. |
ChoiceFrom
Interface
- Kind:
Interface - Source:
index.d.ts:140
interface ChoiceFrom<O extends void = void>
| Name | Constraint | Default | Description |
|---|---|---|---|
O | - | - | The type of the template or interface of which this [[Choice]] is a member. |
| Member | Type | Description |
|---|---|---|
template | () => O | Returns the template to which this choice belongs. |
ContractTypeCompanion
InterfaceUpdated 3.4.9
- Kind:
Interface - Source:
index.d.ts:25
interface ContractTypeCompanion<T extends object = void, K extends void = void, I extends string = void>
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | The template payload format or interface view. |
K | - | - | The contract key type. |
I | string | - | The template or interface id. |
| Member | Type | Description |
|---|---|---|
templateId | I | - |
templateIdWithPackageId | string | - |
FromTemplate
Interface
- Kind:
Interface - Source:
index.d.ts:101
interface FromTemplate<If extends void = void, TX extends void = void>
| Name | Constraint | Default | Description |
|---|---|---|---|
If | - | - | The interface type. |
TX | - | - | The intersection of template types this interface retroactively implements, or unknown if there are none. |
| Member | Type | Description |
|---|---|---|
[FromTemplateBrand] | [If, TX] | - |
Map
Interface
- Kind:
Interface - Source:
index.d.ts:340
interface Map<K extends void = void, V extends void = void>
DA.Map.Map K V type.
This is an immutable map which compares keys via deep equality. The order of
iteration is unspecified; the only guarantee is that the order in keys and
values match, i.e. m.get(k) is (deep-, value-based) equal to
[...m.values()][[...m.keys()].findIndex((l) => _.isEqual(k, l))]
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
K | - | - | The type of the map keys. |
V | - | - | The type of the map values. |
| Member | Type | Description |
|---|---|---|
delete | (k: K) => Map<K, V> | - |
entries | () => Iterator<[K, V], undefined, undefined> | - |
entriesArray | () => [K, V][] | - |
forEach | (f: (value: V, key: K, map: Map<K, V>) => T, u?: U) => void | - |
get | (k: K) => undefined | V | - |
has | (k: K) => boolean | - |
keys | () => Iterator<K, undefined, undefined> | - |
set | (k: K, v: V) => Map<K, V> | - |
values | () => Iterator<V, undefined, undefined> | - |
Serializable
Interface
- Kind:
Interface - Source:
index.d.ts:8
interface Serializable<T extends void = void>
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | The template type. |
Template
InterfaceUpdated 3.4.9
- Kind:
Interface - Source:
index.d.ts:50
interface Template<T extends object = void, K extends void = unknown, I extends string = string> extends ContractTypeCompanion<T, K, I>, Serializable<T>
Template type class in Daml.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | The template type. |
K | - | unknown | The contract key type. |
I | string | string | The template id type. |
| Member | Type | Description |
|---|---|---|
Archive | Choice<T, {}, {}, K> & ChoiceFrom<Template<T, K, I>> | - |
templateId | I | - |
templateIdWithPackageId | string | - |
ToInterface
Interface
- Kind:
Interface - Source:
index.d.ts:69
interface ToInterface<T extends object = void, IfU extends void = void>
toInterface and
unsafeFromInterface contract ID conversion functions.
Even templates that directly implement no interfaces implement this, because
this also permits conversion with interfaces that supply retroactive
implementations to this template.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | The template type. |
IfU | - | - | The union of implemented interfaces, or never for templatesthat directly implement no interface. |
| Member | Type | Description |
|---|---|---|
toInterface | void | - |
unsafeFromInterface | void | - |
Unit
Interface
- Kind:
Interface - Source:
index.d.ts:181
interface Unit
() type.
Type Aliases
Bool
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:190
type Bool = boolean
Bool type.
ContractId
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:294
type ContractId<T extends void = void> = string & { [ContractIdBrand]: T }
ContractId T type.
We represent ContractIds as strings. Their exact format of these strings depends on the ledger
the Daml application is running on.
The purpose of the intersection with { [ContractIdBrand]: T } is to
prevent accidental use of a ContractId<T> when a ContractId<U> is
needed (unless T is a subtype of U). This technique is known as
“branding” in the TypeScript community.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | The contract template. |
Date
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:272
type Date = string
Date type.
We represent Dates as strings with format YYYY-MM-DD.
Decimal
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:218
type Decimal = Numeric
Decimal type.
In Daml, Decimal’s are the same as Numeric with precision 10.
DisclosedContract
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:362
type DisclosedContract = { contractId: ContractId<unknown>; createdEventBlob: string; templateId: string }
Int
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:200
type Int = string
Int type.
We represent Ints as string in order to avoid a loss of precision.
Interface
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:81
type Interface<IfId extends void = void> = { readonly [InterfaceBrand]: IfId }
| Name | Constraint | Default | Description |
|---|---|---|---|
IfId | - | - | The interface ID as a constant string. |
InterfaceCompanion
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:87
type InterfaceCompanion<T extends object = void, K extends void = void, I extends string = string> = ContractTypeCompanion<T, K, I>
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | - |
K | - | - | - |
I | string | string | - |
List
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:262
type List<T extends void = void> = T[]
[T] list type.
We represent lists using arrays.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | The type of the list values. |
Numeric
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:211
type Numeric = string
Numeric type.
We represent Numerics as string in order to avoid a loss of precision. The string must match
the regular expression -?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?.
Optional
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:306
type Optional<T extends void = void> = null | OptionalInner<T>
Optional T type.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | The type of the optionally present value. |
Party
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:250
type Party = string
Party type.
We represent Partys as strings matching the regular expression [A-Za-z0-9:_\- ]+.
TemplateOrInterface
Type AliasUpdated 3.4.9
- Kind:
Type Alias - Source:
index.d.ts:88
type TemplateOrInterface<T extends object = void, K extends void = unknown, Id extends string = string> = Template<T, K, Id> | InterfaceCompanion<T, K, Id>
| Name | Constraint | Default | Description |
|---|---|---|---|
T | object | - | - |
K | - | unknown | - |
Id | string | string | - |
Text
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:230
type Text = string
Text type.
TextMap
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:322
type TextMap<T extends void = void> = {}
TextMap T type.
We represent TextMaps as dictionaries.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | The type of the map values. |
Time
Type Alias
- Kind:
Type Alias - Source:
index.d.ts:240
type Time = string
Time type.
We represent Timess as strings with format YYYY-MM-DDThh:mm:ss[.ssssss]Z.
Variables
Bool
Variable
- Kind:
Variable - Source:
index.d.ts:190
const Bool: Serializable<boolean>
Date
Variable
- Kind:
Variable - Source:
index.d.ts:272
const Date: Serializable<string>
Decimal
Variable
- Kind:
Variable - Source:
index.d.ts:218
const Decimal: Serializable<string>
Int
Variable
- Kind:
Variable - Source:
index.d.ts:200
const Int: Serializable<string>
Party
Variable
- Kind:
Variable - Source:
index.d.ts:250
const Party: Serializable<string>
Text
Variable
- Kind:
Variable - Source:
index.d.ts:230
const Text: Serializable<string>
Time
Variable
- Kind:
Variable - Source:
index.d.ts:240
const Time: Serializable<string>
Unit
Variable
- Kind:
Variable - Source:
index.d.ts:181
const Unit: Serializable<Unit>
Functions
ContractId
Function
- Kind:
Function - Source:
index.d.ts:294
ContractId<T extends void = void>(_t: Serializable<T> | TemplateOrInterface<T & object, unknown, string>): Serializable<ContractId<T>>
ContractId<T extends void = void>(_t: Serializable<T> | TemplateOrInterface<T & object, unknown, string>): Serializable<ContractId<T>>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
T | - | - | - |
| Parameter | Type | Required | Description |
|---|---|---|---|
_t | Serializable<T> | TemplateOrInterface<T & object, unknown, string> | yes | - |
Serializable<ContractId<T>>
emptyMap
Function
- Kind:
Function - Source:
index.d.ts:351
emptyMap<K extends void = void, V extends void = void>(): Map<K, V>
emptyMap<K extends void = void, V extends void = void>(): Map<K, V>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
K | - | - | - |
V | - | - | - |
Map<K, V>
List
Function
- Kind:
Function - Source:
index.d.ts:262
List<T extends void = void>(t: Serializable<T>): Serializable<T[]>
List<T extends void = void>(t: Serializable<T>): Serializable<T[]>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
T | - | - | - |
| Parameter | Type | Required | Description |
|---|---|---|---|
t | Serializable<T> | yes | - |
Serializable<T[]>
Map
Function
- Kind:
Function - Source:
index.d.ts:340
Map<K extends void = void, V extends void = void>(kd: Serializable<K>, vd: Serializable<V>): Serializable<Map<K, V>>
Map<K extends void = void, V extends void = void>(kd: Serializable<K>, vd: Serializable<V>): Serializable<Map<K, V>>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
K | - | - | - |
V | - | - | - |
| Parameter | Type | Required | Description |
|---|---|---|---|
kd | Serializable<K> | yes | - |
vd | Serializable<V> | yes | - |
Serializable<Map<K, V>>
Numeric
Function
- Kind:
Function - Source:
index.d.ts:211
Numeric(_: number): Serializable<string>
Numeric(_: number): Serializable<string>
| Parameter | Type | Required | Description |
|---|---|---|---|
_ | number | yes | - |
Serializable<string>
Optional
Function
- Kind:
Function - Source:
index.d.ts:306
Optional<T extends void = void>(t: Serializable<T>): Serializable<Optional<T>>
Optional<T extends void = void>(t: Serializable<T>): Serializable<Optional<T>>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
T | - | - | - |
| Parameter | Type | Required | Description |
|---|---|---|---|
t | Serializable<T> | yes | - |
Serializable<Optional<T>>
TextMap
Function
- Kind:
Function - Source:
index.d.ts:322
TextMap<T extends void = void>(t: Serializable<T>): Serializable<TextMap<T>>
TextMap<T extends void = void>(t: Serializable<T>): Serializable<TextMap<T>>
| Type Parameter | Constraint | Default | Description |
|---|---|---|---|
T | - | - | - |
| Parameter | Type | Required | Description |
|---|---|---|---|
t | Serializable<T> | yes | - |
Serializable<TextMap<T>>
History
Updated
3.4.9ContractTypeCompanion: members added: templateIdWithPackageId
Template: members added: templateIdWithPackageId
TemplateOrInterface: signature updated; type parameter renamed: I -> Id