Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "defaultLedgerContext"

Index

Functions

DamlLedger

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

    Parameters

    • props: React.PropsWithChildren<LedgerProps>

      React props and children for this element.

    Returns React.ReactElement | null

useFetch

  • 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

  • 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

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

    Returns Ledger

useParty

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

    Returns Party

useQuery

  • 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

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

    Returns () => void

      • (): void
      • Returns void

useStreamFetchByKey

  • useStreamFetchByKey<T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[]): 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
        • (): K
        • Returns K

    • keyDeps: readonly unknown[]

    Returns FetchResult<T, K, I>

    The matching (unique) contract, or null.

useStreamFetchByKeys

  • useStreamFetchByKeys<T, K, I>(template: Template<T, K, I>, keyFactory: () => K[], keyDeps: readonly unknown[]): 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[]
        • (): K[]
        • Returns K[]

    • keyDeps: readonly unknown[]

    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

  • 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

  • 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.

Generated using TypeDoc