@c7-digital/react 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @c7/react
1
+ # @c7-digital/react
2
2
 
3
3
  React hooks for Daml ledger integration using Canton JSON API v2
4
4
 
@@ -12,11 +12,11 @@ React hooks for Daml ledger integration using Canton JSON API v2
12
12
 
13
13
  ## Versioning
14
14
 
15
- This package follows the Canton SDK versioning scheme, matching the `@c7/ledger` package it depends on.
15
+ This package follows the Canton SDK versioning scheme, matching the `@c7-digital/ledger` package it depends on.
16
16
 
17
17
  **Current version**: `3.3.0-snapshot.20250507.0`
18
18
 
19
- - Versioned to match the Canton SDK and `@c7/ledger` package
19
+ - Versioned to match the Canton SDK and `@c7-digital/ledger` package
20
20
  - Ensures compatibility with the specific Canton OpenAPI types
21
21
  - When Canton releases a new version, both packages will be updated together
22
22
 
@@ -25,7 +25,7 @@ This package follows the Canton SDK versioning scheme, matching the `@c7/ledger`
25
25
  ## Installation
26
26
 
27
27
  ```bash
28
- pnpm install @c7/react @c7/ledger
28
+ pnpm install @c7-digital/react @c7-digital/ledger
29
29
  ```
30
30
 
31
31
  ## Build Output
@@ -43,8 +43,8 @@ The library builds to the `dist/` folder with:
43
43
  Wrap your app with `DamlLedger` provider:
44
44
 
45
45
  ```tsx
46
- import { DamlLedger } from "@c7/react";
47
- import { Ledger } from "@c7/ledger";
46
+ import { DamlLedger } from "@c7-digital/react";
47
+ import { Ledger } from "@c7-digital/ledger";
48
48
 
49
49
  const ledger = new Ledger({
50
50
  baseUrl: "http://localhost:7575",
@@ -66,7 +66,7 @@ function App() {
66
66
  Use `useQuery` to fetch active contracts:
67
67
 
68
68
  ```tsx
69
- import { useQuery } from "@c7/react";
69
+ import { useQuery } from "@c7-digital/react";
70
70
 
71
71
  function MyComponent() {
72
72
  const { contracts, loading, error, reload } = useQuery(
@@ -96,7 +96,7 @@ function MyComponent() {
96
96
  Use `useLedger` to get the ledger instance and `useUser` for the current user information:
97
97
 
98
98
  ```tsx
99
- import { useLedger, useUser } from "@c7/react";
99
+ import { useLedger, useUser } from "@c7-digital/react";
100
100
 
101
101
  function ApprovalComponent({ contractId }: { contractId: string }) {
102
102
  const ledger = useLedger();
@@ -129,7 +129,7 @@ function ApprovalComponent({ contractId }: { contractId: string }) {
129
129
  Use `useStreamQuery` for live updates:
130
130
 
131
131
  ```tsx
132
- import { useStreamQuery } from "@c7/react";
132
+ import { useStreamQuery } from "@c7-digital/react";
133
133
 
134
134
  function LiveContracts() {
135
135
  const { contracts, loading, connected, error } = useStreamQuery(
@@ -239,7 +239,7 @@ function useReload(): () => void;
239
239
 
240
240
  This package provides a compatible API with `@daml/react` but uses the newer Canton JSON API v2:
241
241
 
242
- | @daml/react | @c7/react | Notes |
242
+ | @daml/react | @c7-digital/react | Notes |
243
243
  | ------------------ | -------------------- | ------------------------------ |
244
244
  | `DamlLedger` | `DamlLedger` | Same API, different backend |
245
245
  | `useParty()` | `useParty()` | Identical |
@@ -0,0 +1,107 @@
1
+ /**
2
+ * React context for Daml ledger integration
3
+ */
4
+ import { ReactNode } from "react";
5
+ import type { FunctionComponent } from "react";
6
+ import type { InterfaceCompanion, Template } from "@daml/types";
7
+ import { Ledger, type LedgerOptions, type TemplateMapping, type InterfaceMapping } from "@c7-digital/ledger/lite";
8
+ import type { DamlLedgerConfig, QueryOptions, QueryResult, InterfaceQueryResult, StreamQueryResult, StreamQueryInterfaceResult, UserResult, MultiStreamQueryResult, MultiStreamInterfaceQueryResult } from "./types";
9
+ export interface DamlLedgerProps extends LedgerOptions {
10
+ children: ReactNode;
11
+ }
12
+ /**
13
+ * Provider component that wraps your app and provides ledger access to hooks
14
+ */
15
+ export declare const DamlLedger: FunctionComponent<DamlLedgerProps>;
16
+ /**
17
+ * Hook to get the current ledger configuration
18
+ * @internal
19
+ */
20
+ export declare function useDamlLedgerContext(): DamlLedgerConfig;
21
+ /**
22
+ * Hook to get the ledger instance
23
+ * @returns The Ledger instance from the context
24
+ */
25
+ export declare function useLedger(): Ledger;
26
+ /**
27
+ * Hook to get the current user information from the token
28
+ * @returns Object with user data, loading state, and error
29
+ */
30
+ export declare function useUser(): UserResult;
31
+ /**
32
+ * Hook to get decomposed user rights
33
+ *
34
+ * @param userId Default to the user defined by the token.
35
+ * @returns Object of { actAsParties, readAsParties, loading, error }
36
+ */
37
+ export declare function useRightsAs(userId?: string): {
38
+ actAsParties: string[];
39
+ readAsParties: string[];
40
+ loading: boolean;
41
+ error: string | null;
42
+ };
43
+ /**
44
+ * Hook to get a reload function for refreshing queries
45
+ * @returns Function that can be used to trigger query reloads across all hooks
46
+ */
47
+ export declare function useReload(): () => void;
48
+ /**
49
+ * Hook to query active contracts for a specific template
50
+ * @param template - The template to query
51
+ * @param options - Query options
52
+ * @returns Query result with contracts, loading state, and reload function
53
+ */
54
+ export declare function useQuery<TContract extends object = object, TKey = any, TTemplateId extends string = string>(template: Template<TContract, TKey, TTemplateId>, options?: QueryOptions): QueryResult<TContract, TKey>;
55
+ /**
56
+ * Hook to query interface views for a specific interface
57
+ * @param interface_ - The Daml interface to query
58
+ * @param options - Query options
59
+ * @returns Query result with contracts, loading state, and reload function
60
+ */
61
+ export declare function useQueryInterface<TInterface extends object = object, TKey = unknown, TInterfaceId extends string = string>(interface_: InterfaceCompanion<TInterface, TKey, TInterfaceId>, options?: QueryOptions): InterfaceQueryResult<TInterface>;
62
+ /**
63
+ * Hook to stream active contracts for a single template with real-time updates
64
+ * @param template - The template to query
65
+ * @param options - Query options
66
+ * @returns Stream query result with contracts, loading state, connection status, and reload function
67
+ */
68
+ export declare function useStreamQuery<TContract extends object = object, TKey = any, TTemplateId extends string = string>(template: Template<TContract, TKey, TTemplateId>, options?: QueryOptions): StreamQueryResult<TContract, TKey>;
69
+ /**
70
+ * Hook to stream active contracts for a single interface with real-time updates
71
+ * @param interface_ - The interface to query
72
+ * @param options - Query options
73
+ * @returns Stream query result with contracts, loading state, connection status, and reload function
74
+ */
75
+ export declare function useStreamQueryInterface<IContract extends object = object, IId extends string = string>(interface_: InterfaceCompanion<IContract, unknown, IId>, options?: QueryOptions): StreamQueryInterfaceResult<IContract>;
76
+ /**
77
+ * Hook to stream active contracts for multiple templates with real-time updates
78
+ * @param templateMapping - Mapping of template IDs to their contract and key types
79
+ * @param options - Query options
80
+ * @returns Multi-stream query result with stream instance, loading state, connection status, and reload function
81
+ */
82
+ export declare function useMultiStreamQuery<TM extends TemplateMapping>(templateMapping: TM, options?: QueryOptions): MultiStreamQueryResult<TM>;
83
+ /**
84
+ * Hook to stream active contracts for multiple interfaces with real-time updates
85
+ * @param interfaceMapping - Mapping of interface IDs to their contract types
86
+ * @param options - Query options
87
+ * @returns Multi-stream query result with stream instance, loading state, connection status, and reload function
88
+ */
89
+ export declare function useMultiStreamInterfaceQuery<IM extends InterfaceMapping>(interfaceMapping: IM, options?: QueryOptions): MultiStreamInterfaceQueryResult<IM>;
90
+ /**
91
+ * Creates a ledger context object with hooks for accessing ledger functionality
92
+ * This maintains compatibility with @daml/react patterns while using our new implementation
93
+ */
94
+ export declare function createLedgerContext(): {
95
+ DamlLedger: FunctionComponent<DamlLedgerProps>;
96
+ useLedger: typeof useLedger;
97
+ useUser: typeof useUser;
98
+ useReload: typeof useReload;
99
+ useQuery: typeof useQuery;
100
+ useQueryInterface: typeof useQueryInterface;
101
+ useStreamQuery: typeof useStreamQuery;
102
+ useStreamQueryInterface: typeof useStreamQueryInterface;
103
+ useMultiStreamQuery: typeof useMultiStreamQuery;
104
+ useMultiStreamInterfaceQuery: typeof useMultiStreamInterfaceQuery;
105
+ useRightsAs: typeof useRightsAs;
106
+ };
107
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,SAAS,EAOV,MAAM,OAAO,CAAC;AACf,OAAO,KAA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AAG,MAAM,EAEpC,UAAU,EAAE,kBAAkB,CAAC,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC,EAC9D,OAAO,GAAE,YAAiB,GACzB,oBAAoB,CAAC,UAAU,CAAC,CA2ClC;AAwID;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,SAAS,SAAS,MAAM,GAAG,MAAM,EACjC,IAAI,GAAG,GAAG,EACV,WAAW,SAAS,MAAM,GAAG,MAAM,EAEnC,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,EAChD,OAAO,GAAE,YAAiB,GACzB,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,CAepC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,SAAS,MAAM,GAAG,MAAM,EACjC,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,UAAU,EAAE,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,EACvD,OAAO,GAAE,YAAiB,GACzB,0BAA0B,CAAC,SAAS,CAAC,CA2CvC;AAgHD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,SAAS,eAAe,EAC5D,eAAe,EAAE,EAAE,EACnB,OAAO,GAAE,YAAiB,GACzB,sBAAsB,CAAC,EAAE,CAAC,CAyB5B;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,SAAS,gBAAgB,EACtE,gBAAgB,EAAE,EAAE,EACpB,OAAO,GAAE,YAAiB,GACzB,+BAA+B,CAAC,EAAE,CAAC,CAyBrC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB;;;;;;;;;;;;EAclC"}
@@ -0,0 +1,527 @@
1
+ /**
2
+ * React context for Daml ledger integration
3
+ */
4
+ import { createContext, useContext, createElement, useMemo, useState, useEffect, useCallback, useRef, } from "react";
5
+ import { Ledger, } from "@c7-digital/ledger/lite";
6
+ const DamlLedgerContext = createContext(null);
7
+ /**
8
+ * Provider component that wraps your app and provides ledger access to hooks
9
+ */
10
+ export const DamlLedger = props => {
11
+ const { children, token, ...otherOptions } = props;
12
+ const [reloadTrigger, setReloadTrigger] = useState(0);
13
+ // Capture initial options on first render and never change them
14
+ // These options should be static for the lifetime of the component
15
+ const initialOptionsRef = useRef(otherOptions);
16
+ // Create ledger with initial token, but don't recreate when token changes
17
+ // Token updates are handled via updateToken() on streams
18
+ // Only recreate when reloadTrigger changes (explicit reload requested)
19
+ const ledger = useMemo(() => {
20
+ return new Ledger({ ...initialOptionsRef.current, token });
21
+ }, [reloadTrigger]);
22
+ const triggerReload = useCallback(() => {
23
+ setReloadTrigger(prev => prev + 1);
24
+ }, []);
25
+ const contextValue = useMemo(() => ({
26
+ ledger,
27
+ reloadTrigger,
28
+ triggerReload,
29
+ }), [ledger, reloadTrigger, triggerReload]);
30
+ return createElement(DamlLedgerContext.Provider, { value: contextValue }, children);
31
+ };
32
+ /**
33
+ * Hook to get the current ledger configuration
34
+ * @internal
35
+ */
36
+ export function useDamlLedgerContext() {
37
+ const context = useContext(DamlLedgerContext);
38
+ if (!context) {
39
+ throw new Error("useDamlLedgerContext must be used within a DamlLedger provider");
40
+ }
41
+ return context;
42
+ }
43
+ /**
44
+ * Hook to get the ledger instance
45
+ * @returns The Ledger instance from the context
46
+ */
47
+ export function useLedger() {
48
+ const { ledger } = useDamlLedgerContext();
49
+ return ledger;
50
+ }
51
+ /**
52
+ * Hook to get the current user information from the token
53
+ * @returns Object with user data, loading state, and error
54
+ */
55
+ export function useUser() {
56
+ const ledger = useLedger();
57
+ const [user, setUser] = useState(null);
58
+ const [loading, setLoading] = useState(true);
59
+ const [error, setError] = useState(null);
60
+ useEffect(() => {
61
+ const fetchUser = async () => {
62
+ try {
63
+ setLoading(true);
64
+ setError(null);
65
+ const userInfo = await ledger.getTokenUserInfo();
66
+ setUser(userInfo);
67
+ }
68
+ catch (err) {
69
+ const errorMessage = err instanceof Error ? err : new Error("Failed to get user info");
70
+ setError(errorMessage);
71
+ setUser(null);
72
+ }
73
+ finally {
74
+ setLoading(false);
75
+ }
76
+ };
77
+ void fetchUser();
78
+ }, [ledger]);
79
+ return { user, loading, error };
80
+ }
81
+ /**
82
+ * Hook to get decomposed user rights
83
+ *
84
+ * @param userId Default to the user defined by the token.
85
+ * @returns Object of { actAsParties, readAsParties, loading, error }
86
+ */
87
+ export function useRightsAs(userId) {
88
+ const ledger = useLedger();
89
+ const [actAsParties, setActAsParties] = useState([]);
90
+ const [readAsParties, setReadAsParties] = useState([]);
91
+ const [loading, setLoading] = useState(true);
92
+ const [error, setError] = useState(null);
93
+ useEffect(() => {
94
+ const fetchActAsParties = async () => {
95
+ try {
96
+ const rights = await ledger.getUserInfo(userId || ledger.getTokenUserId());
97
+ const [actAsParties, readAsParties] = (rights?.rights || []).reduce((acc, right) => {
98
+ if (right.type === "canActAs" && right.party) {
99
+ acc[0].push(right.party);
100
+ }
101
+ else if (right.type === "canReadAs" && right.party) {
102
+ acc[1].push(right.party);
103
+ }
104
+ else {
105
+ console.warn(`This party has a right that is not canActAs or canReadAs: ${JSON.stringify(right)}`);
106
+ }
107
+ return acc;
108
+ }, [[], []]);
109
+ setActAsParties(actAsParties);
110
+ setReadAsParties(readAsParties);
111
+ }
112
+ catch (err) {
113
+ setError(err instanceof Error ? err.message : "Failed to fetch user rights");
114
+ }
115
+ finally {
116
+ setLoading(false);
117
+ }
118
+ };
119
+ fetchActAsParties();
120
+ }, [ledger, userId]);
121
+ return {
122
+ actAsParties,
123
+ readAsParties,
124
+ loading,
125
+ error,
126
+ };
127
+ }
128
+ /**
129
+ * Hook to get a reload function for refreshing queries
130
+ * @returns Function that can be used to trigger query reloads across all hooks
131
+ */
132
+ export function useReload() {
133
+ const { triggerReload } = useDamlLedgerContext();
134
+ return triggerReload;
135
+ }
136
+ /**
137
+ * Hook to query active contracts for a specific template
138
+ * @param template - The template to query
139
+ * @param options - Query options
140
+ * @returns Query result with contracts, loading state, and reload function
141
+ */
142
+ export function useQuery(template, options = {}) {
143
+ const { ledger, reloadTrigger } = useDamlLedgerContext();
144
+ const [contracts, setContracts] = useState([]);
145
+ const [loading, setLoading] = useState(true);
146
+ const [error, setError] = useState(null);
147
+ // Extract options values to avoid object reference issues in useEffect
148
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
149
+ const reload = useCallback(async () => {
150
+ try {
151
+ setLoading(true);
152
+ setError(null);
153
+ const result = await ledger.query(template, atOffset, includeCreatedEventBlob, false, // do not care about verbose stream
154
+ readAsParties);
155
+ setContracts(result);
156
+ }
157
+ catch (err) {
158
+ const errorMessage = err instanceof Error ? err : new Error("Failed to query contracts");
159
+ setError(errorMessage);
160
+ setContracts([]);
161
+ }
162
+ finally {
163
+ setLoading(false);
164
+ }
165
+ }, [ledger, template, atOffset, includeCreatedEventBlob]);
166
+ // Initial load and reload when trigger changes
167
+ useEffect(() => {
168
+ reload();
169
+ }, [reload, reloadTrigger]);
170
+ return {
171
+ contracts,
172
+ loading,
173
+ error,
174
+ reload,
175
+ };
176
+ }
177
+ /**
178
+ * Hook to query interface views for a specific interface
179
+ * @param interface_ - The Daml interface to query
180
+ * @param options - Query options
181
+ * @returns Query result with contracts, loading state, and reload function
182
+ */
183
+ export function useQueryInterface(interface_, options = {}) {
184
+ const { ledger, reloadTrigger } = useDamlLedgerContext();
185
+ const [interfaces, setInterfaces] = useState([]);
186
+ const [loading, setLoading] = useState(true);
187
+ const [error, setError] = useState(null);
188
+ // Extract options values to avoid object reference issues in useEffect
189
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
190
+ const reload = useCallback(async () => {
191
+ try {
192
+ setLoading(true);
193
+ setError(null);
194
+ const result = await ledger.queryInterface(interface_, atOffset, includeCreatedEventBlob, false, // do not care about verbose stream
195
+ readAsParties);
196
+ setInterfaces(result);
197
+ }
198
+ catch (err) {
199
+ const errorMessage = err instanceof Error ? err : new Error("Failed to query contracts");
200
+ setError(errorMessage);
201
+ setInterfaces([]);
202
+ }
203
+ finally {
204
+ setLoading(false);
205
+ }
206
+ }, [ledger, interface_, atOffset, includeCreatedEventBlob]);
207
+ // Initial load and reload when trigger changes
208
+ useEffect(() => {
209
+ reload();
210
+ }, [reload, reloadTrigger]);
211
+ return {
212
+ interfaces,
213
+ loading,
214
+ error,
215
+ reload,
216
+ };
217
+ }
218
+ /**
219
+ * Base hook for streaming functionality - handles common state management and lifecycle
220
+ */
221
+ function useStreamBase(createStream, setupAdditionalEventHandlers, dependencies = []) {
222
+ const { reloadTrigger } = useDamlLedgerContext();
223
+ const [contractsMap, setContractsMap] = useState(() => new Map());
224
+ const [loading, setLoading] = useState(true);
225
+ const [connected, setConnected] = useState(false);
226
+ const [error, setError] = useState(null);
227
+ // Use refs to prevent garbage collection
228
+ const streamRef = useRef(null);
229
+ const isCleanedUpRef = useRef(false);
230
+ const reconnectTimeoutRef = useRef(null);
231
+ const reload = useCallback(async () => {
232
+ setLoading(true);
233
+ setError(null);
234
+ setContractsMap(new Map());
235
+ }, []);
236
+ const updateToken = useCallback((newToken) => {
237
+ if (streamRef.current) {
238
+ streamRef.current.updateToken(newToken);
239
+ }
240
+ }, []);
241
+ // Setup real streaming connection
242
+ useEffect(() => {
243
+ isCleanedUpRef.current = false;
244
+ const setupStream = async () => {
245
+ if (isCleanedUpRef.current)
246
+ return;
247
+ try {
248
+ setLoading(true);
249
+ setError(null);
250
+ streamRef.current = await createStream();
251
+ // Handle common create events
252
+ streamRef.current.on("create", (event) => {
253
+ setContractsMap((prevMap) => new Map(prevMap).set(event.contractId, event));
254
+ });
255
+ // Handle common archive events
256
+ streamRef.current.on("archive", (event) => {
257
+ setContractsMap((prevMap) => {
258
+ const newMap = new Map(prevMap);
259
+ newMap.delete(event.contractId);
260
+ return newMap;
261
+ });
262
+ });
263
+ // Setup additional event handlers (e.g., interfaceView for interface streams)
264
+ if (setupAdditionalEventHandlers) {
265
+ setupAdditionalEventHandlers(streamRef.current);
266
+ }
267
+ // Common error and state handling
268
+ streamRef.current.on("error", (err) => {
269
+ setError(err.cause);
270
+ setConnected(false);
271
+ });
272
+ streamRef.current.on("state", (state) => {
273
+ setConnected(state === "live");
274
+ if (state === "live") {
275
+ setLoading(false);
276
+ }
277
+ });
278
+ streamRef.current.start();
279
+ }
280
+ catch (err) {
281
+ if (!isCleanedUpRef.current) {
282
+ const errorMessage = err instanceof Error ? `${err.name}: ${err.message}` : "Failed to setup stream";
283
+ setError(errorMessage);
284
+ setConnected(false);
285
+ setLoading(false);
286
+ reconnectTimeoutRef.current = setTimeout(() => {
287
+ void setupStream();
288
+ }, 5000);
289
+ }
290
+ }
291
+ };
292
+ void setupStream();
293
+ return () => {
294
+ isCleanedUpRef.current = true;
295
+ if (reconnectTimeoutRef.current) {
296
+ clearTimeout(reconnectTimeoutRef.current);
297
+ reconnectTimeoutRef.current = null;
298
+ }
299
+ if (streamRef.current) {
300
+ streamRef.current.close();
301
+ streamRef.current = null;
302
+ }
303
+ setConnected(false);
304
+ };
305
+ }, dependencies);
306
+ // Handle manual reload triggers
307
+ useEffect(() => {
308
+ if (reloadTrigger > 0) {
309
+ reload();
310
+ }
311
+ }, [reloadTrigger, reload]);
312
+ return {
313
+ contractsMap,
314
+ loading,
315
+ connected,
316
+ error,
317
+ reload,
318
+ updateToken,
319
+ };
320
+ }
321
+ /**
322
+ * Hook to stream active contracts for a single template with real-time updates
323
+ * @param template - The template to query
324
+ * @param options - Query options
325
+ * @returns Stream query result with contracts, loading state, connection status, and reload function
326
+ */
327
+ export function useStreamQuery(template, options = {}) {
328
+ const { ledger } = useDamlLedgerContext();
329
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
330
+ const result = useStreamBase(() => ledger.streamQuery(template, atOffset, false, includeCreatedEventBlob, readAsParties), undefined, // No additional event handlers needed for template streaming
331
+ [ledger, template.templateId, atOffset, includeCreatedEventBlob, readAsParties]);
332
+ // Return only the fields expected by StreamQueryResult (without interfacesMap)
333
+ return {
334
+ ...result,
335
+ contractsMap: result.contractsMap,
336
+ };
337
+ }
338
+ /**
339
+ * Hook to stream active contracts for a single interface with real-time updates
340
+ * @param interface_ - The interface to query
341
+ * @param options - Query options
342
+ * @returns Stream query result with contracts, loading state, connection status, and reload function
343
+ */
344
+ export function useStreamQueryInterface(interface_, options = {}) {
345
+ const { ledger } = useDamlLedgerContext();
346
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
347
+ // Manage interfacesMap state locally since it's interface-specific
348
+ const [interfacesMap, setInterfacesMap] = useState(() => new Map());
349
+ const result = useStreamBase(() => ledger.streamQueryInterface(interface_, atOffset, false, includeCreatedEventBlob, readAsParties), (stream) => {
350
+ // Handle interface view events (create/archive handled by base hook)
351
+ stream.on("interfaceView", (interfaceEvent) => {
352
+ setInterfacesMap((prevMap) => new Map(prevMap).set(interfaceEvent.contractId, interfaceEvent));
353
+ });
354
+ // Handle archived contracts for interfacesMap (contractsMap handled by base hook)
355
+ stream.on("archive", (event) => {
356
+ setInterfacesMap((prevMap) => {
357
+ const newMap = new Map(prevMap);
358
+ newMap.delete(event.contractId);
359
+ return newMap;
360
+ });
361
+ });
362
+ }, [ledger, interface_.templateId, atOffset, includeCreatedEventBlob, readAsParties]);
363
+ // Override the base hook's reload to also clear interfacesMap
364
+ const reload = useCallback(async () => {
365
+ setInterfacesMap(new Map());
366
+ await result.reload();
367
+ }, [result.reload]);
368
+ return {
369
+ ...result,
370
+ contractsMap: result.contractsMap,
371
+ interfacesMap,
372
+ reload, // Override with our custom reload that also clears interfacesMap
373
+ };
374
+ }
375
+ /**
376
+ * Base hook for multi-stream functionality - handles common state management and lifecycle
377
+ */
378
+ function useMultiStreamBase(createStream, dependencies) {
379
+ const { reloadTrigger } = useDamlLedgerContext();
380
+ const [multiStream, setMultiStream] = useState(null);
381
+ const [loading, setLoading] = useState(true);
382
+ const [connected, setConnected] = useState(false);
383
+ const [error, setError] = useState(null);
384
+ // Use refs to prevent garbage collection
385
+ const streamRef = useRef(null);
386
+ const isCleanedUpRef = useRef(false);
387
+ const reconnectTimeoutRef = useRef(null);
388
+ const reload = useCallback(async () => {
389
+ setLoading(true);
390
+ setError(null);
391
+ setMultiStream(null);
392
+ }, []);
393
+ const updateToken = useCallback((newToken) => {
394
+ if (streamRef.current) {
395
+ streamRef.current.updateToken(newToken);
396
+ }
397
+ }, []);
398
+ // Setup real streaming connection
399
+ useEffect(() => {
400
+ isCleanedUpRef.current = false;
401
+ const setupStream = async () => {
402
+ if (isCleanedUpRef.current)
403
+ return;
404
+ try {
405
+ setLoading(true);
406
+ setError(null);
407
+ streamRef.current = await createStream();
408
+ // Handle connection state
409
+ streamRef.current.onState((state) => {
410
+ setConnected(state === "live");
411
+ if (state === "live") {
412
+ setLoading(false);
413
+ }
414
+ });
415
+ // Handle errors
416
+ streamRef.current.onError((err) => {
417
+ setError(err.cause);
418
+ });
419
+ setMultiStream(streamRef.current);
420
+ streamRef.current.start();
421
+ }
422
+ catch (err) {
423
+ const errorMessage = err instanceof Error ? `${err.name}: ${err.message}` : "Failed to setup multi-stream";
424
+ setError(errorMessage);
425
+ setConnected(false);
426
+ setLoading(false);
427
+ // Retry on setup failure (unless cleaned up)
428
+ if (!isCleanedUpRef.current) {
429
+ reconnectTimeoutRef.current = setTimeout(() => {
430
+ void setupStream();
431
+ }, 5000);
432
+ }
433
+ }
434
+ };
435
+ void setupStream();
436
+ return () => {
437
+ isCleanedUpRef.current = true;
438
+ if (reconnectTimeoutRef.current) {
439
+ clearTimeout(reconnectTimeoutRef.current);
440
+ reconnectTimeoutRef.current = null;
441
+ }
442
+ if (streamRef.current) {
443
+ streamRef.current.close();
444
+ streamRef.current = null;
445
+ }
446
+ setConnected(false);
447
+ setMultiStream(null);
448
+ };
449
+ }, dependencies);
450
+ // Handle manual reload triggers
451
+ useEffect(() => {
452
+ if (reloadTrigger > 0) {
453
+ reload();
454
+ }
455
+ }, [reloadTrigger, reload]);
456
+ return {
457
+ multiStream,
458
+ loading,
459
+ connected,
460
+ error,
461
+ reload,
462
+ updateToken,
463
+ };
464
+ }
465
+ /**
466
+ * Hook to stream active contracts for multiple templates with real-time updates
467
+ * @param templateMapping - Mapping of template IDs to their contract and key types
468
+ * @param options - Query options
469
+ * @returns Multi-stream query result with stream instance, loading state, connection status, and reload function
470
+ */
471
+ export function useMultiStreamQuery(templateMapping, options = {}) {
472
+ const { ledger } = useDamlLedgerContext();
473
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
474
+ const result = useMultiStreamBase(() => ledger.createMultiStream(templateMapping, atOffset, false, // skipAcs
475
+ includeCreatedEventBlob, readAsParties), [
476
+ ledger,
477
+ JSON.stringify(templateMapping),
478
+ atOffset,
479
+ includeCreatedEventBlob,
480
+ JSON.stringify(readAsParties),
481
+ ]);
482
+ return {
483
+ ...result,
484
+ multiStream: result.multiStream,
485
+ };
486
+ }
487
+ /**
488
+ * Hook to stream active contracts for multiple interfaces with real-time updates
489
+ * @param interfaceMapping - Mapping of interface IDs to their contract types
490
+ * @param options - Query options
491
+ * @returns Multi-stream query result with stream instance, loading state, connection status, and reload function
492
+ */
493
+ export function useMultiStreamInterfaceQuery(interfaceMapping, options = {}) {
494
+ const { ledger } = useDamlLedgerContext();
495
+ const { atOffset = "end", includeCreatedEventBlob = false, readAsParties } = options;
496
+ const result = useMultiStreamBase(() => ledger.createMultiInterfaceStream(interfaceMapping, atOffset, false, // skipAcs
497
+ includeCreatedEventBlob, readAsParties), [
498
+ ledger,
499
+ JSON.stringify(interfaceMapping),
500
+ atOffset,
501
+ includeCreatedEventBlob,
502
+ JSON.stringify(readAsParties),
503
+ ]);
504
+ return {
505
+ ...result,
506
+ multiStream: result.multiStream,
507
+ };
508
+ }
509
+ /**
510
+ * Creates a ledger context object with hooks for accessing ledger functionality
511
+ * This maintains compatibility with @daml/react patterns while using our new implementation
512
+ */
513
+ export function createLedgerContext() {
514
+ return {
515
+ DamlLedger,
516
+ useLedger,
517
+ useUser,
518
+ useReload,
519
+ useQuery,
520
+ useQueryInterface,
521
+ useStreamQuery,
522
+ useStreamQueryInterface,
523
+ useMultiStreamQuery,
524
+ useMultiStreamInterfaceQuery,
525
+ useRightsAs,
526
+ };
527
+ }
@@ -0,0 +1,2 @@
1
+ export declare const DamlLedger: import("react").FunctionComponent<import("./context").DamlLedgerProps>, useLedger: typeof import("./context").useLedger, useUser: typeof import("./context").useUser, useReload: typeof import("./context").useReload, useQuery: typeof import("./context").useQuery, useQueryInterface: typeof import("./context").useQueryInterface, useStreamQuery: typeof import("./context").useStreamQuery, useStreamQueryInterface: typeof import("./context").useStreamQueryInterface, useMultiStreamQuery: typeof import("./context").useMultiStreamQuery, useMultiStreamInterfaceQuery: typeof import("./context").useMultiStreamInterfaceQuery, useRightsAs: typeof import("./context").useRightsAs;
2
+ //# sourceMappingURL=defaultLedgerContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultLedgerContext.d.ts","sourceRoot":"","sources":["../src/defaultLedgerContext.ts"],"names":[],"mappings":"AAOA,eAAO,MACL,UAAU,0EACV,SAAS,wCACT,OAAO,sCACP,SAAS,wCACT,QAAQ,uCACR,iBAAiB,gDACjB,cAAc,6CACd,uBAAuB,sDACvB,mBAAmB,kDACnB,4BAA4B,2DAC5B,WAAW,wCACY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Default ledger context - provides the standard hooks implementation
3
+ * This is the equivalent of @daml/react's default exports
4
+ */
5
+ import { createLedgerContext } from "./context";
6
+ // Create and export the default context
7
+ export const { DamlLedger, useLedger, useUser, useReload, useQuery, useQueryInterface, useStreamQuery, useStreamQueryInterface, useMultiStreamQuery, useMultiStreamInterfaceQuery, useRightsAs, } = createLedgerContext();
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @c7-digital/react - React hooks for Daml ledger integration
3
+ *
4
+ * A replacement for @daml/react that uses the Canton JSON API v2
5
+ * with TypeScript support and modern React patterns.
6
+ */
7
+ export { createLedgerContext } from "./context";
8
+ export type { DamlLedgerProps } from "./context";
9
+ export { DamlLedger, useLedger, useUser, useReload, useQuery, useQueryInterface, useStreamQuery, useStreamQueryInterface, useMultiStreamQuery, useMultiStreamInterfaceQuery, useRightsAs, } from "./defaultLedgerContext";
10
+ export type { DamlLedgerConfig, QueryOptions, QueryResult, InterfaceQueryResult, StreamQueryResult, UserResult, TemplateId, } from "./types";
11
+ export type { Ledger, User, CreateEvent, ArchiveEvent, Event, Interface } from "@c7-digital/ledger/lite";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,EACL,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,4BAA4B,EAC5B,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @c7-digital/react - React hooks for Daml ledger integration
3
+ *
4
+ * A replacement for @daml/react that uses the Canton JSON API v2
5
+ * with TypeScript support and modern React patterns.
6
+ */
7
+ // Core components and context utilities
8
+ export { createLedgerContext } from "./context";
9
+ // Default hooks (the main exports most users will use)
10
+ export { DamlLedger, useLedger, useUser, useReload, useQuery, useQueryInterface, useStreamQuery, useStreamQueryInterface, useMultiStreamQuery, useMultiStreamInterfaceQuery, useRightsAs, } from "./defaultLedgerContext";
@@ -0,0 +1,94 @@
1
+ import { ContractId, Party } from "@daml/types";
2
+ import { type Ledger, type User, type CreateEvent, LedgerOffset, type MultiStream, type TemplateMapping, type InterfaceMapping, type InterfaceMultiStream, CantonError, Interface } from "@c7-digital/ledger/lite";
3
+ export type TemplateId = string & {
4
+ readonly __templateId: unique symbol;
5
+ };
6
+ export interface DamlLedgerConfig {
7
+ readonly ledger: Ledger;
8
+ readonly reloadTrigger: number;
9
+ readonly triggerReload: () => void;
10
+ }
11
+ export interface QueryOptions {
12
+ /** The offset to query at, defaults to "end" */
13
+ readonly atOffset?: LedgerOffset;
14
+ /** Whether to include the created event blob, defaults to false */
15
+ readonly includeCreatedEventBlob?: boolean;
16
+ /** Whether to query as a specific party, defaults to all of the Parties in the token. */
17
+ readonly readAsParties?: Party[];
18
+ /** Whether to automatically reload on updates, defaults to false */
19
+ readonly autoReload?: boolean;
20
+ }
21
+ export interface QueryResult<TContract extends object = object, TKey = any> {
22
+ /** Array of matching contracts */
23
+ readonly contracts: readonly CreateEvent<TContract, TKey>[];
24
+ /** Loading state */
25
+ readonly loading: boolean;
26
+ /** Error if query failed */
27
+ readonly error: Error | null;
28
+ /** Function to manually reload the query */
29
+ readonly reload: () => void;
30
+ }
31
+ export interface InterfaceQueryResult<TInterface extends object = object> {
32
+ /** Array of matching interface contracts */
33
+ readonly interfaces: readonly Interface<TInterface>[];
34
+ /** Loading state */
35
+ readonly loading: boolean;
36
+ /** Error if query failed */
37
+ readonly error: Error | null;
38
+ /** Function to manually reload the query */
39
+ readonly reload: () => void;
40
+ }
41
+ export interface StreamQueryResult<TContract extends object = object, TKey = any> {
42
+ /** Map of matching contracts, with contractId as key */
43
+ readonly contractsMap: ReadonlyMap<ContractId<TContract>, CreateEvent<TContract, TKey>>;
44
+ /** Loading state */
45
+ readonly loading: boolean;
46
+ /** Error if query failed */
47
+ readonly error: CantonError | string | null;
48
+ /** Function to manually reload the query */
49
+ readonly reload: () => void;
50
+ /** Whether the stream is connected */
51
+ readonly connected: boolean;
52
+ /** Function to update the authentication token */
53
+ readonly updateToken: (newToken: string) => void;
54
+ }
55
+ export interface StreamQueryInterfaceResult<IContract extends object> extends StreamQueryResult<object, unknown> {
56
+ readonly interfacesMap: ReadonlyMap<ContractId<IContract>, Interface<IContract>>;
57
+ }
58
+ export interface UserResult {
59
+ /** The user information from the token */
60
+ readonly user: User | null;
61
+ /** Loading state */
62
+ readonly loading: boolean;
63
+ /** Error if user fetch failed */
64
+ readonly error: Error | null;
65
+ }
66
+ export interface MultiStreamQueryResult<TM extends TemplateMapping> {
67
+ /** The multi-stream instance for registering template-specific handlers */
68
+ readonly multiStream: MultiStream<TM> | null;
69
+ /** Loading state */
70
+ readonly loading: boolean;
71
+ /** Error if stream setup failed */
72
+ readonly error: CantonError | string | null;
73
+ /** Function to manually reload the query */
74
+ readonly reload: () => void;
75
+ /** Whether the stream is connected */
76
+ readonly connected: boolean;
77
+ /** Function to update the authentication token */
78
+ readonly updateToken: (newToken: string) => void;
79
+ }
80
+ export interface MultiStreamInterfaceQueryResult<IM extends InterfaceMapping> {
81
+ /** The multi-stream instance for interface streaming */
82
+ readonly multiStream: InterfaceMultiStream<IM> | null;
83
+ /** Loading state */
84
+ readonly loading: boolean;
85
+ /** Error if query failed */
86
+ readonly error: CantonError | string | null;
87
+ /** Function to manually reload the query */
88
+ readonly reload: () => void;
89
+ /** Whether the stream is connected */
90
+ readonly connected: boolean;
91
+ /** Function to update the authentication token */
92
+ readonly updateToken: (newToken: string) => void;
93
+ }
94
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB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AChE,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAC7C,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,+BAA+B,CAAC,EAAE,SAAS,gBAAgB;IAC1E,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACtD,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c7-digital/react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "React hooks for Daml ledger integration using Canton JSON API v2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "build": "tsc",
12
12
  "dev": "tsc --watch",
13
- "clean": "rm -rf dist",
13
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
14
14
  "prepare": "tsc",
15
15
  "prepublishOnly": "pnpm run clean && pnpm run build"
16
16
  },
@@ -25,7 +25,7 @@
25
25
  "author": "",
26
26
  "license": "Apache-2.0",
27
27
  "peerDependencies": {
28
- "@c7/ledger": "^0.0.4",
28
+ "@c7-digital/ledger": "^0.0.6",
29
29
  "react": "^18.0.0"
30
30
  },
31
31
  "dependencies": {