Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ledger

An object of type Ledger represents a handle to a Daml ledger.

Hierarchy

  • Ledger

Index

Constructors

  • Construct a new Ledger object. See LedgerOptions for the constructor arguments.

    Parameters

    Returns Ledger

Properties

httpBaseUrl: string
multiplexQueryStreams: boolean
queryStreamsManager: QueryStreamsManager
reconnectThreshold: number
token: string
wsBaseUrl: string

Methods

  • allocateParty(partyOpt: { displayName?: string; identifierHint?: string }): Promise<PartyInfo>
  • Allocate a new party.

    Parameters

    • partyOpt: { displayName?: string; identifierHint?: string }

      Parameters for party allocation.

      • Optional displayName?: string
      • Optional identifierHint?: string

    Returns Promise<PartyInfo>

    PartyInfo for the newly created party.

  • archive<T, K, I>(template: Template<T, K, I>, contractId: ContractId<T>): Promise<ArchiveEvent<T, I>>
  • Archive a contract identified by its contract ID.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contract to archive.

    • contractId: ContractId<T>

      The contract id of the contract to archive.

    Returns Promise<ArchiveEvent<T, I>>

  • archiveByKey<T, K, I>(template: Template<T, K, I>, key: K): Promise<ArchiveEvent<T, I>>
  • Archive a contract identified by its contract key. Same as archive, but the contract to be archived is identified by its contract key.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contract to be archived.

    • key: K

      The contract key of the contract to be archived.

    Returns Promise<ArchiveEvent<T, I>>

  • auth(): {}
  • internal

    Returns {}

    • [headers: string]: string
  • constantStream<T, K, I, V>(value: V): Stream<T, K, I, V>
  • internal

    Returns the same API as streamSubmit but does not, in fact, establish any socket connection. Instead, this is a stream that always has the given value as its accumulated state.

    Type parameters

    • T: object

    • K

    • I: string

    • V

    Parameters

    • value: V

    Returns Stream<T, K, I, V>

  • create<T, K, I>(template: Template<T, K, I>, payload: T): Promise<CreateEvent<T, K, I>>
  • Create a contract for a given template.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contract to be created.

    • payload: T

      The template arguments for the contract to be created.

    Returns Promise<CreateEvent<T, K, I>>

  • createAndExercise<T, C, R, K>(choice: ChoiceFrom<Template<T, K, string>> & Choice<T, C, R, K>, payload: T, argument: C): Promise<[R, Event<object, unknown, string>[]]>
  • Exercse a choice on a newly-created contract, in a single transaction.

    Type parameters

    • T: object

      The contract template type.

    • C

      The type of the contract choice.

    • R

      The return type of the choice.

    • K

    Parameters

    • choice: ChoiceFrom<Template<T, K, string>> & Choice<T, C, R, K>

      The choice to exercise.

    • payload: T

      The template arguments for the newly-created contract.

    • argument: C

      The choice arguments.

    Returns Promise<[R, Event<object, unknown, string>[]]>

    The return value of the choice together with a list of [[event]]'s that includes the creation event for the created contract as well as all the events that were created as a result of exercising the choice, including the archive event for the created contract if the choice is consuming (or otherwise archives it as part of its execution).

  • createUser(userId: string, rights: UserRight[], primaryParty?: string): Promise<void>
  • Creates a user

    Parameters

    • userId: string

      The user ID

    • rights: UserRight[]

      The initial rights the user should have

    • Optional primaryParty: string

      The primary party the user should have

    Returns Promise<void>

  • deleteUser(userId: string): Promise<void>
  • Deletes a user

    Parameters

    • userId: string

      The user ID

    Returns Promise<void>

  • exercise<T, C, R, K>(choice: Choice<T, C, R, K>, contractId: ContractId<T>, argument: C): Promise<[R, Event<object, unknown, string>[]]>
  • Exercise a choice on a contract identified by its contract ID.

    Type parameters

    • T: object

      The contract template type.

    • C

      The type of the contract choice.

    • R

      The return type of the choice.

    • K

    Parameters

    • choice: Choice<T, C, R, K>

      The choice to exercise.

    • contractId: ContractId<T>

      The contract id of the contract to exercise.

    • argument: C

      The choice arguments.

    Returns Promise<[R, Event<object, unknown, string>[]]>

    The return value of the choice together with a list of [[event]]'s that were created as a result of exercising the choice.

  • exerciseByKey<T, C, R, K>(choice: ChoiceFrom<Template<T, K, string>> & Choice<T, C, R, K>, key: K, argument: C): Promise<[R, Event<object, unknown, string>[]]>
  • Exercise a choice on a contract identified by its contract key.

    Same as exercise, but the contract is identified by its contract key instead of its contract id.

    Type parameters

    • T: object

      The contract template type.

    • C

      The type of the contract choice.

    • R

      The return type of the choice.

    • K

      The type of the contract key.

    Parameters

    • choice: ChoiceFrom<Template<T, K, string>> & Choice<T, C, R, K>

      The choice to exercise.

    • key: K

      The contract key of the contract to exercise.

    • argument: C

      The choice arguments.

    Returns Promise<[R, Event<object, unknown, string>[]]>

    The return value of the choice together with a list of [[event]]'s that where created as a result of exercising the choice.

  • fetch<T, K, I>(template: TemplateOrInterface<T, K, I>, contractId: ContractId<T>): Promise<null | CreateEvent<T, K, I>>
  • Fetch a contract identified by its contract ID.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: TemplateOrInterface<T, K, I>

      The template of the contract to be fetched.

    • contractId: ContractId<T>

      The contract id of the contract to be fetched.

    Returns Promise<null | CreateEvent<T, K, I>>

  • fetchByKey<T, K, I>(template: Template<T, K, I>, key: K): Promise<null | CreateEvent<T, K, I>>
  • Fetch a contract identified by its contract key.

    Same as fetch, but the contract to be fetched is identified by its contract key instead of its contract id.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contract to be fetched.

    • key: K

      The contract key of the contract to be fetched.

    Returns Promise<null | CreateEvent<T, K, I>>

  • getPackage(id: string): Promise<ArrayBuffer>
  • Fetch a binary package.

    Parameters

    • id: string

    Returns Promise<ArrayBuffer>

    The content of the package as a raw ArrayBuffer.

  • getParties(parties: string[]): Promise<(null | PartyInfo)[]>
  • Fetch parties by identifier.

    Parameters

    • parties: string[]

      An array of Party identifiers.

    Returns Promise<(null | PartyInfo)[]>

    An array of the same length, where each element corresponds to the same-index element of the given parties, ans is either a PartyInfo object if the party exists or null if it does not.

  • getUser(userId?: string): Promise<User>
  • Get the current user details obtained by the currently used JWT.

    Parameters

    • Optional userId: string

      The user id

    Returns Promise<User>

    User details

  • Grants rights to a user

    Parameters

    • userId: string

      The user to which rights shall be granted

    • rights: UserRight[]

      The rights which shall be granted

    Returns Promise<UserRight[]>

    The rights which actually were granted (if a right was already granted, then it will not be in the return list)

  • Fetch all parties on the ledger.

    Returns Promise<PartyInfo[]>

    All parties on the ledger, in no particular order.

  • listPackages(): Promise<string[]>
  • Fetch a list of all package IDs from the ledger.

    Returns Promise<string[]>

    List of package IDs.

  • listUserRights(userId?: string): Promise<UserRight[]>
  • Lists the rights associated with the given user id

    Parameters

    • Optional userId: string

    Returns Promise<UserRight[]>

    list of user rights

  • listUsers(): Promise<User[]>
  • Lists the users on the ledger

    Returns Promise<User[]>

    user list

  • query<T, K, I>(template: TemplateOrInterface<T, K, I>, query?: Query<T>): Promise<CreateEvent<T, K, I>[]>
  • Retrieve contracts for a given template.

    When no query argument is given, all contracts visible to the submitting party are returned. When a query argument is given, only those contracts matching the query are returned. See https://docs.daml.com/json-api/search-query-language.html for a description of the query language.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: TemplateOrInterface<T, K, I>

      The contract template of the contracts to be matched against.

    • Optional query: Query<T>

      The contract query for the contracts to be matched against.

    Returns Promise<CreateEvent<T, K, I>[]>

  • Revokes rights from a user

    Parameters

    • userId: string

      The user from which rights shall be revoked

    • rights: UserRight[]

      The rights which shall be revoked

    Returns Promise<UserRight[]>

    The rights which actually were revoked (if a right was already revoked, then it will not be in the return list)

  • streamFetchByKey<T, K, I>(template: Template<T, K, I>, key: K): Stream<T, K, I, null | CreateEvent<T, K, I>>
  • Retrieve a consolidated stream of events for a given template and contract key.

    The accumulated state is either the current active contract for the given key, or null if there is no active contract for the given key.

    deprecated

    Prefer streamFetchByKeys.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>
    • key: K

    Returns Stream<T, K, I, null | CreateEvent<T, K, I>>

  • streamFetchByKeys<T, K, I>(template: Template<T, K, I>, keys: K[]): Stream<T, K, I, (null | CreateEvent<T, K, I>)[]>
  • Retrieve a consolidated stream of events for a list of keys and a single template.

    The accumulated state is an array of the same length as the given list of keys, with positional correspondence. Each element in the array represents the current contract for the given key, or is explicitly null if there is currently no active contract matching that key.

    Note: the given key objects will be compared for (deep) equality with the values returned by the API. As such, they have to be given in the "output" format of the API, including the values of encodeDecimalAsString and encodeInt64AsString. See the JSON API docs for details.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: Template<T, K, I>
    • keys: K[]

    Returns Stream<T, K, I, (null | CreateEvent<T, K, I>)[]>

  • streamQueries<T, K, I>(template: TemplateOrInterface<T, K, I>, queries: Query<T>[]): Stream<T, K, I, readonly CreateEvent<T, K, I>[]>
  • Retrieve a consolidated stream of events for a given template and queries.

    If the given list is empty, the accumulated state is the set of all active contracts for the given template. Otherwise, the accumulated state is the set of all contracts that match at least one of the given queries.

    See https://docs.daml.com/json-api/search-query-language.html for a description of the query language.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: TemplateOrInterface<T, K, I>

      The contract template to match contracts against.

    • queries: Query<T>[]

      A query to match contracts against.

    Returns Stream<T, K, I, readonly CreateEvent<T, K, I>[]>

  • streamQuery<T, K, I>(template: TemplateOrInterface<T, K, I>, query?: Query<T>): Stream<T, K, I, readonly CreateEvent<T, K, I>[]>
  • Retrieve a consolidated stream of events for a given template and query.

    The accumulated state is the current set of active contracts matching the query. When no query argument is given, all events visible to the submitting party are returned. When a query argument is given, only those create events matching the query are returned. See https://docs.daml.com/json-api/search-query-language.html for a description of the query language.

    deprecated

    Prefer streamQueries.

    Type parameters

    • T: object

      The contract template type.

    • K

      The contract key type.

    • I: string

      The contract id type.

    Parameters

    • template: TemplateOrInterface<T, K, I>

      The contract template to match contracts against.

    • Optional query: Query<T>

      The query to match contracts agains.

    Returns Stream<T, K, I, readonly CreateEvent<T, K, I>[]>

  • streamQueryCommon<T, K, I>(template: TemplateOrInterface<T, K, I>, queries: Query<T>[], name: string): Stream<T, K, I, readonly CreateEvent<T, K, I>[]>
  • internal

    Type parameters

    • T: object

    • K

    • I: string

    Parameters

    • template: TemplateOrInterface<T, K, I>
    • queries: Query<T>[]
    • name: string

    Returns Stream<T, K, I, readonly CreateEvent<T, K, I>[]>

  • streamSubmit<T, K, I, State>(callerName: string, template: TemplateOrInterface<T, K, I>, endpoint: string, request: unknown, reconnectRequest: () => unknown, init: State, change: (state: State, events: readonly Event<T, K, I>[]) => State): Stream<T, K, I, State>
  • internal

    Internal command to submit a request to a streaming endpoint of the JSON API. Returns a stream consisting of accumulated state together with the events that produced the latest state change. The change function must be an operation of the monoid Event<T, K, I>[] on the set State, i.e., for all s: State and x, y: Event<T, K, I>[] we must have the structural equalities

    change(s, []) == s
    change(s, x.concat(y)) == change(change(s, x), y)

    Also, change must never change its arguments.

    Type parameters

    • T: object

    • K

    • I: string

    • State

    Parameters

    • callerName: string
    • template: TemplateOrInterface<T, K, I>
    • endpoint: string
    • request: unknown
    • reconnectRequest: () => unknown
        • (): unknown
        • Returns unknown

    • init: State
    • change: (state: State, events: readonly Event<T, K, I>[]) => State
        • (state: State, events: readonly Event<T, K, I>[]): State
        • Parameters

          • state: State
          • events: readonly Event<T, K, I>[]

          Returns State

    Returns Stream<T, K, I, State>

  • submit(endpoint: string, payload: unknown, method?: string): Promise<unknown>
  • internal

    Internal function to submit a command to the JSON API.

    Parameters

    • endpoint: string
    • payload: unknown
    • method: string = "post"

    Returns Promise<unknown>

  • throwOnError(r: Response): Promise<void>
  • internal

    Parameters

    • r: Response

    Returns Promise<void>

  • uploadDarFile(abuf: ArrayBuffer): Promise<void>
  • Upload a binary archive. Note that this requires admin privileges.

    Parameters

    • abuf: ArrayBuffer

    Returns Promise<void>

    No return value on success; throws on error.

Generated using TypeDoc