Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "createLedgerContext"

Index

Type aliases

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>; useFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: keyof unknown[]) => FetchResult<T, K, I>; useLedger: () => Ledger; useParty: () => Party; useQuery: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: keyof unknown[]) => QueryResult<T, K, I>; useReload: () => () => void; useStreamFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: keyof unknown[]) => FetchResult<T, K, I>; useStreamQuery: <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: keyof unknown[]) => 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>
  • useFetchByKey: <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: keyof unknown[]) => FetchResult<T, K, I>
      • <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: keyof unknown[]): FetchResult<T, K, I>
      • Type parameters

        • T: object

        • K

        • I: string

        Parameters

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

        • keyDeps: keyof 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?: keyof unknown[]) => QueryResult<T, K, I>
      • <T, K, I>(template: Template<T, K, I>, queryFactory?: () => Query<T>, queryDeps?: keyof 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: keyof 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: keyof unknown[]) => FetchResult<T, K, I>
      • <T, K, I>(template: Template<T, K, I>, keyFactory: () => K, keyDeps: keyof unknown[]): FetchResult<T, K, I>
      • Type parameters

        • T: object

        • K

        • I: string

        Parameters

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

        • keyDeps: keyof unknown[]

        Returns FetchResult<T, K, I>

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

        Returns QueryResult<T, K, I>

LedgerProps

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

React props to initiate a connect to a DAML ledger.

Type declaration

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

QueryResult

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

The result of 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.

Type declaration

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

    Contracts matching the query.

  • loading: boolean

    Indicator for whether the query is executing.

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