/** * Canton gRPC JSON API event parsing utilities. * * The Canton Ledger JSON API (gRPC-gateway) wraps each ledger event as: * `{ Event: { Created: { template_id, create_arguments, ... } } }` * * Field values use a `{ Sum: { Text|Numeric|Int64|Party|ContractId|... } }` * envelope. The helpers in this module decode that format into plain * JavaScript objects that the rest of the SDK can work with. */ import { type ExecutionReceipt, ExecutionState } from '../types.ts'; /** * Structured result extracted from a `CCIPMessageSent` Created event in a * Canton transaction response. */ export interface CantonSendResultFields { messageId: string; encodedMessage: string; sequenceNumber: bigint; nonce?: bigint; onRampAddress?: string; } /** * Walk a Canton transaction response and extract the `CCIPMessageSent` fields. * * The Canton gRPC JSON API returns Created events with the structure: * ```json * { "Event": { "Created": { * "template_id": { "entity_name": "CCIPMessageSent" }, * "create_arguments": { "fields": [ * { "label": "event", "value": { "Sum": { "Record": { "fields": [...] } } } } * ]} * }}} * ``` * Field values use a `{ Sum: { Text|Numeric|... } }` envelope. * * @throws {@link CCIPError} if no `CCIPMessageSent` event is found. */ export declare function parseCantonSendResult(transaction: unknown, updateId: string): CantonSendResultFields; /** * Walk a Canton transaction response and extract an {@link ExecutionReceipt}. * * Looks for an `ExecutionStateChanged` Created event and extracts the * relevant fields. If no matching event is found, returns a minimal * receipt with {@link ExecutionState.Success} (the command succeeded if we * reached this point). */ export declare function parseCantonExecutionReceipt(transaction: unknown, updateId: string): ExecutionReceipt; /** * Resolve the record-time from a Canton transaction record. * * The gRPC API returns `{ record_time: { seconds: N, nanos: N } }` while * the legacy JSON API returns `{ recordTime: "ISO-string" }`. */ export declare function resolveTimestamp(txRecord: Record): number; /** * Recursively extract normalised event objects from a Canton transaction tree. * * The gRPC JSON API wraps each event as `{ Event: { Created: { ... } } }`. * This function unwraps those wrappers so callers always receive the inner * Created / Exercised record directly (which carries `template_id`, * `create_arguments`, etc.). */ export declare function extractEventsFromTransaction(obj: unknown): unknown[]; /** * Dig into a `create_arguments` / `createArgument` object to find the nested * `CCIPMessageSentEvent` record and return it as a flat `label → value` map. * * The gRPC-style event format stores the nested `event` field as: * ```json * { "label": "event", "value": { "Sum": { "Record": { "fields": [...] } } } } * ``` */ export declare function extractCCIPMessageSentEvent(arg: Record | undefined): Record | undefined; /** * Resolve a Canton field `value` for the `event` label. * * Handles: * - `{ Sum: { Record: { fields: [...] } } }` — gRPC style * - `{ fields: [...] }` — already a Record, just flatten * - plain object — return as-is */ export declare function resolveEventFieldValue(value: unknown): Record | undefined; /** * Convert a Canton record `{ fields: [{ label, value }] }` into a plain * `{ [label]: extractedValue }` map. When no `fields` array is present the * record is returned unchanged. */ export declare function flattenCantonRecord(record: Record): Record; /** * Extract the entity name from a Canton event, supporting both the gRPC format * (`template_id.entity_name`) and the legacy flat format (`templateId` string * with colon-separated parts). */ export declare function getTemplateEntityName(event: Record): string; /** * Extract a primitive value from a Canton Daml field value, handling both the * gRPC `{ Sum: { Text|Numeric|Int64|Party|ContractId } }` envelope and the * legacy verbose JSON API `{ text|int64|numeric|... }` form. * * Numeric values returned by the gRPC API have a trailing `"."` (e.g. `"1."`) * which is stripped to yield a clean integer string. */ export declare function extractFieldValue(value: unknown): unknown; /** * Safely convert an unknown value to bigint, defaulting to `0n`. */ export declare function toBigIntSafe(v: unknown): bigint; /** * Map a Canton execution state value to the SDK {@link ExecutionState}. */ export declare function mapExecutionState(state: unknown): ExecutionState; //# sourceMappingURL=events.d.ts.map