Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

FetchByKeysResult<T, K, I>: { contracts: (CreateEvent<T, K, I> | null)[]; loading: boolean }

The result of a streaming fetchByKeys against the ledger.

Type parameters

  • T: object

    The contract template type of the query.

  • K

    The contract key type of the query.

  • I: string

    The template id type.

Type declaration

  • contracts: (CreateEvent<T, K, I> | null)[]

    Contracts of the given contract template and key.

  • loading: boolean

    Indicator for whether the fetch is executing.

FetchResult<T, K, I>: { contract: CreateEvent<T, K, I> | null; loading: boolean }

The result of a fetch against the ledger.

Type parameters

  • T: object

    The contract template type of the query.

  • K

    The contract key type of the query.

  • I: string

    The template id type.

Type declaration

  • contract: CreateEvent<T, K, I> | null

    Contracts of the given contract template and key.

  • loading: boolean

    Indicator for whether the fetch is executing.

LedgerContext: { DamlLedger: React.FC<LedgerProps>; useFetch: any; useFetchByKey: any; useLedger: any; useParty: any; useQuery: any; useReload: any; useStreamFetchByKey: any; useStreamFetchByKeys: any; useStreamQueries: any; useStreamQuery: any; useUser: any }

A LedgerContext is a React context that stores information about a Daml Ledger and hooks necessary to use it.

Type declaration

  • DamlLedger: React.FC<LedgerProps>
  • useFetch:function
    • useFetch<T, K, I>(template: Template<T, K, I>, contractId: ContractId<T>): FetchResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • contractId: ContractId<T>

      Returns FetchResult<T, K, I>

  • useFetchByKey:function
    • useFetchByKey<T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[]): FetchResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • keyFactory: () => K
          • (): K
          • Returns K

      • keyDeps: readonly unknown[]

      Returns FetchResult<T, K, I>

  • useLedger:function
    • useLedger(): Ledger
    • Returns Ledger

  • useParty:function
    • useParty(): string
    • Returns string

  • useQuery:function
    • useQuery<T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[]): QueryResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • Optional queryFactory: () => Query<T>
          • (): Query<T>
          • Returns Query<T>

      • Optional queryDeps: readonly unknown[]

      Returns QueryResult<T, K, I>

  • useReload:function
    • useReload(): () => void
    • Returns () => void

        • (): void
        • Returns void

  • useStreamFetchByKey:function
    • useStreamFetchByKey<T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): FetchResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • keyFactory: () => K
          • (): K
          • Returns K

      • keyDeps: readonly unknown[]
      • Optional closeHandler: (e: StreamCloseEvent) => void
          • (e: StreamCloseEvent): void
          • Parameters

            • e: StreamCloseEvent

            Returns void

      Returns FetchResult<T, K, I>

  • useStreamFetchByKeys:function
    • useStreamFetchByKeys<T, K, I>(template: Template<T, K, I>, keyFactory: () => K[], keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): FetchByKeysResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • keyFactory: () => K[]
          • (): K[]
          • Returns K[]

      • keyDeps: readonly unknown[]
      • Optional closeHandler: (e: StreamCloseEvent) => void
          • (e: StreamCloseEvent): void
          • Parameters

            • e: StreamCloseEvent

            Returns void

      Returns FetchByKeysResult<T, K, I>

  • useStreamQueries:function
    • useStreamQueries<T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>[], queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): QueryResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • Optional queryFactory: () => Query<T>[]
          • (): Query<T>[]
          • Returns Query<T>[]

      • Optional queryDeps: readonly unknown[]
      • Optional closeHandler: (e: StreamCloseEvent) => void
          • (e: StreamCloseEvent): void
          • Parameters

            • e: StreamCloseEvent

            Returns void

      Returns QueryResult<T, K, I>

  • useStreamQuery:function
    • useStreamQuery<T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): QueryResult<T, K, I>
    • Type parameters

      • T: object

      • K

      • I: string

      Parameters

      • template: Template<T, K, I>
      • Optional queryFactory: () => Query<T>
          • (): Query<T>
          • Returns Query<T>

      • Optional queryDeps: readonly unknown[]
      • Optional closeHandler: (e: StreamCloseEvent) => void
          • (e: StreamCloseEvent): void
          • Parameters

            • e: StreamCloseEvent

            Returns void

      Returns QueryResult<T, K, I>

  • useUser:function
    • useUser(): User
    • Returns User

QueryResult<T, K, I>: { contracts: readonly CreateEvent<T, K, I>[]; loading: boolean }

The result of a query against the ledger.

Note: this is meant to be used by @daml/react.

Type parameters

  • T: object

    The contract template type of the query.

  • K

    The contract key type of the query.

  • I: string

    The template id type.

Type declaration

  • contracts: readonly CreateEvent<T, K, I>[]

    Contracts matching the query.

  • loading: boolean

    Indicator for whether the query is executing.

Functions

  • Create a LedgerContext. One should use this function, instead of the default DamlLedger, where one needs to be able to nest ledger interactions, by different parties or connections, within one React application.

    Parameters

    • contextName: string = "DamlLedgerContext"

      Used to refer to a context in case of errors.

    Returns LedgerContext

  • default(props: PropsWithChildren<LedgerProps>): React.ReactElement | null
  • Within a DamlLedger one can use the hooks provided here.

    Parameters

    • props: PropsWithChildren<LedgerProps>

      React props and children for this element.

    Returns React.ReactElement | null

  • useFetch<T, K, I>(template: Template<T, K, I>, contractId: ContractId<T>): FetchResult<T, K, I>
  • React Hook for a lookup by contractId against the /v1/fetch endpoint of the JSON API.

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contract to fetch.

    • contractId: ContractId<T>

      The contractId to fetch.

    Returns FetchResult<T, K, I>

    The fetched contract.

  • useFetchByKey<T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[]): FetchResult<T, K, I>
  • React Hook for a lookup by key against the /v1/fetch endpoint of the JSON API.

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contracts to fetch.

    • keyFactory: () => K

      A function returning the contract key of the contracts to fetch.

        • (): K
        • Returns K

    • keyDeps: readonly unknown[]

      Dependencies of this hook (for which the fetch is reexecuted on change).

    Returns FetchResult<T, K, I>

    The fetched contract.

  • useLedger(): Ledger
  • React Hook that returns the Ledger instance to interact with the connected Daml ledger.

    Returns Ledger

  • useParty(): Party
  • React hook to get the party currently connected to the ledger.

    Returns Party

  • useQuery<T, K, I>(template: Template<T, K, I>, queryFactory: () => Query<T>, queryDeps: readonly unknown[]): QueryResult<T, K, I>
  • useQuery<T, K, I>(template: Template<T, K, I>): QueryResult<T, K, I>
  • React Hook for a query against the ledger.

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The contract template to filter for.

    • queryFactory: () => Query<T>

      A function returning a query. If the query is omitted, all visible contracts of the given template are returned.

        • (): Query<T>
        • Returns Query<T>

    • queryDeps: readonly unknown[]

      The dependencies of the query (which trigger a reload when changed).

    Returns QueryResult<T, K, I>

    The result of the query.

  • Type parameters

    • T: object

    • K

    • I: string

    Parameters

    • template: Template<T, K, I>

    Returns QueryResult<T, K, I>

  • useReload(): () => void
  • React Hook to reload all active queries.

    Returns () => void

      • (): void
      • React Hook to reload all active queries.

        Returns void

  • useStreamFetchByKey<T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): FetchResult<T, K, I>
  • React Hook to query the ledger. Same as useStreamQuery, but query by contract key instead.

    deprecated

    prefer useStreamFetchByKeys

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contracts to match.

    • keyFactory: () => K

      A function returning a contract key. Contract keys must be in "output" format as defined in the JSON API docs, i.e., have to match the types generated by the daml-types library.

        • (): K
        • Returns K

    • keyDeps: readonly unknown[]

      The dependencies of the fetch-by-key (for which a change triggers an update of the result).

    • Optional closeHandler: (e: StreamCloseEvent) => void

      A callback that will be called if the underlying WebSocket connection fails in an unrecoverable way.

        • (e: StreamCloseEvent): void
        • Parameters

          • e: StreamCloseEvent

          Returns void

    Returns FetchResult<T, K, I>

    The matching (unique) contract, or null.

  • useStreamFetchByKeys<T, K, I>(template: Template<T, K, I>, keyFactory: () => K[], keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): FetchByKeysResult<T, K, I>
  • React Hook to query the ledger. Same as useStreamQueries, but query by contract keys instead.

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contracts to match.

    • keyFactory: () => K[]

      A function returning an array of contract keys. Contract keys must be in "output" format as defined in the JSON API docs, i.e., have to match the types generated by the daml-types library.

        • (): K[]
        • Returns K[]

    • keyDeps: readonly unknown[]

      The dependencies of the fetch-by-key (for which a change triggers an update of the result).

    • Optional closeHandler: (e: StreamCloseEvent) => void

      A callback that will be called if the underlying WebSocket connection fails in an unrecoverable way.

        • (e: StreamCloseEvent): void
        • Parameters

          • e: StreamCloseEvent

          Returns void

    Returns FetchByKeysResult<T, K, I>

    An array of the same length as the given array of keys, where each element is either the currently active contract that matches the corresponding key, or null if no active contract matches the key in the same position.

  • useStreamQueries<T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>[], queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): QueryResult<T, K, I>
  • React Hook to query the ledger, the returned result is updated as the ledger state changes.

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contracts to match.

    • Optional queryFactory: () => Query<T>[]

      A function returning an array of queries. If no queryFactory is given, or if the given factory returns an empty array, all visible contracts of the given template are returned. Otherwise, returns a union of all the contracts that match at least one of the given queries.

        • (): Query<T>[]
        • Returns Query<T>[]

    • Optional queryDeps: readonly unknown[]

      The dependencies of the query (for which a change triggers an update of the result).

    • Optional closeHandler: (e: StreamCloseEvent) => void

      A callback that will be called if the underlying WebSocket connection fails in an unrecoverable way.

        • (e: StreamCloseEvent): void
        • Parameters

          • e: StreamCloseEvent

          Returns void

    Returns QueryResult<T, K, I>

    The matching contracts.

  • useStreamQuery<T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void): QueryResult<T, K, I>
  • React Hook to query the ledger, the returned result is updated as the ledger state changes.

    deprecated

    prefer useStreamQueries

    Type parameters

    • T: object

      The contract template type of the query.

    • K

      The contract key type of the query.

    • I: string

      The template id type.

    Parameters

    • template: Template<T, K, I>

      The template of the contracts to match.

    • Optional queryFactory: () => Query<T>

      A function returning a query. If the query is omitted, all visible contracts of the given template are returned.

        • (): Query<T>
        • Returns Query<T>

    • Optional queryDeps: readonly unknown[]

      The dependencies of the query (for which a change triggers an update of the result).

    • Optional closeHandler: (e: StreamCloseEvent) => void

      A callback that will be called if the underlying WebSocket connection fails in an unrecoverable way.

        • (e: StreamCloseEvent): void
        • Parameters

          • e: StreamCloseEvent

          Returns void

    Returns QueryResult<T, K, I>

    The matching contracts.

  • useUser(): User
  • React hook to get the user currently connected to the ledger participant.

    Returns User

Generated using TypeDoc