import { type QueryDataset } from "../canonical/query-dataset.js"; import type { ContractRow, EventRow, ExerciseRow, TransactionRow } from "../model-types.js"; import type { GrpcPackageMetadata } from "./grpc-package-relation-reader.js"; import type { Transaction } from "../../transports/grpc/generated/canton/com/daml/ledger/api/v2/transaction.js"; import type { GetActiveContractsResponse } from "../../transports/grpc/generated/canton/com/daml/ledger/api/v2/state_service.js"; export interface GrpcQueryTypeIdentity { readonly pk: string; readonly templateId: Readonly<{ packageId: string; moduleName: string; entityName: string; }>; readonly packageId: string; /** * The owning package's name when the event states it reliably: always for contract types * (CreatedEvent/ExercisedEvent packageName is the contract's package), and for choice types only on * direct exercises — an interface-exercised choice is owned by the interface, whose package name the * event does not carry. */ readonly packageName?: string; readonly choice?: string; readonly consuming?: boolean; } export interface GrpcQueryPackageIdentity { readonly pk: string; readonly id: string; } export interface GrpcQueryCreationIdentity { readonly contractId: string; readonly offset: string; readonly templateId: Readonly<{ packageId: string; moduleName: string; entityName: string; }>; readonly creationPackageId: string; readonly representativePackageId: string | null; readonly packageName: string; readonly payload: unknown; readonly witnesses: readonly string[]; readonly createdAt: Date; } /** Private Task 5 activation metadata retained for later relation construction. */ export interface GrpcActiveContractIdentity { readonly contractId: string; readonly synchronizerId: string; readonly reassignmentCounter: string; readonly activationOffset: string; readonly activationNodeId: number; } /** * The Task 5 transport-neutral core. Task 6 enriches its identity descriptors with * package metadata and creates the complete QueryDataset/edges; public rows never * receive private PQS join columns. */ export interface GrpcQueryRelationFragment { readonly contracts: readonly ContractRow[]; readonly transactions: readonly TransactionRow[]; readonly events: readonly EventRow[]; readonly exercises: readonly ExerciseRow[]; readonly typeIdentities: readonly GrpcQueryTypeIdentity[]; readonly packageIdentities: readonly GrpcQueryPackageIdentity[]; readonly creationIdentities: readonly GrpcQueryCreationIdentity[]; readonly activeContractIdentities: readonly GrpcActiveContractIdentity[]; } /** Materializes ledger-effects transactions and optionally seeds still-active ACS contracts. */ export declare function mapGrpcQueryRelationFragment(source: readonly Transaction[], activeContracts?: readonly GetActiveContractsResponse[]): GrpcQueryRelationFragment; /** * Combines the Task 5 ledger fragment with decoded LF package metadata into the * complete immutable eight-relation snapshot. Private edge keys retain the * creation template identity without exposing a synthetic field in contract rows. */ export declare function createGrpcQueryDataset(fragment: GrpcQueryRelationFragment, packages: readonly GrpcPackageMetadata[], endInclusive: string, instanceId: string): QueryDataset; /** Package payloads required for a contract/history relation plan, excluding creation-only provenance. */ export declare function referencedGrpcPackageIds(fragment: GrpcQueryRelationFragment): readonly string[]; /** The minimal creation facts needed to derive a contract's type metadata without decoding its package. */ export type GrpcCreationTypeSource = Pick; /** * Derives contractType metadata straight from already-fetched created-contract events instead of the * Package Service. Only valid where the caller has confirmed the query's relation closure is a subset of * {contracts, contractTypes} — every contract's own creation event already carries packageName directly, * so no archive decode is needed. "version" is a per-package placeholder: this path is unreachable from * any query that can see the "packages" relation, so it is never observed. */ export declare function contractTypeMetadataFromCreations(creationIdentities: readonly GrpcCreationTypeSource[]): readonly GrpcPackageMetadata[]; /** * Extends the creations-only derivation to exercises: for a direct exercise the choice owner IS the * exercised template, so the event's own packageName names the owner's package and choice/consuming come * straight off the event. Returns undefined when the window contains an interface-exercised choice — its * owner is the interface, whose package name the event does not carry, so only the decoded archive can * produce its canonical choiceFqn. Unobserved choices are simply absent, which is complete for query plans * that reach exerciseTypes only through observed exercises (never for exerciseTypes catalog queries). */ export declare function packageMetadataFromEvents(fragment: Pick): readonly GrpcPackageMetadata[] | undefined;