Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "createLedgerContext"

Index

Type aliases

FetchByKeysResult

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

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

LedgerContext: { DamlLedger: React.FC<LedgerProps>; useFetch: <T, K, I>(template: Template<T, K, I>, contractId: ContractId<T>) => FetchResult<T, K, I>; useFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[]) => FetchResult<T, K, I>; useLedger: () => Ledger; useParty: () => Party; useQuery: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[]) => QueryResult<T, K, I>; useReload: () => () => void; useStreamFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => FetchResult<T, K, I>; useStreamFetchByKeys: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K[], keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => FetchByKeysResult<T, K, I>; useStreamQueries: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>[], queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => QueryResult<T, K, I>; useStreamQuery: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => QueryResult<T, K, I> }

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

  • useParty: () => Party
      • (): Party
      • Returns Party

  • useQuery: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[]) => QueryResult<T, K, I>
      • <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: () => () => void
      • (): () => void
      • Returns () => void

          • (): void
          • Returns void

  • useStreamFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => FetchResult<T, K, I>
      • <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: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K[], keyDeps: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => FetchByKeysResult<T, K, I>
      • <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: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>[], queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => QueryResult<T, K, I>
      • <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: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: readonly unknown[], closeHandler?: (e: StreamCloseEvent) => void) => QueryResult<T, K, I>
      • <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>

LedgerProps

LedgerProps: { httpBaseUrl?: string; party: Party; reconnectThreshold?: number; token: string; wsBaseUrl?: string }

React props to initiate a connect to a Daml ledger.

Type declaration

  • Optional httpBaseUrl?: string
  • party: Party
  • Optional reconnectThreshold?: number
  • token: string
  • Optional wsBaseUrl?: string

Functions

createLedgerContext

  • 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

    • Default value contextName: string = "DamlLedgerContext"

      Used to refer to a context in case of errors.

    Returns LedgerContext

Generated using TypeDoc