cantonjs-react 0.2.0 → 0.3.1
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 +34 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -61,6 +61,40 @@ function AssetList() {
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Public Scan Data Alongside Ledger Hooks
|
|
65
|
+
|
|
66
|
+
`cantonjs-react` stays focused on participant-private ledger state. For public Splice data, use TanStack Query directly with `cantonjs-splice-scan`:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { useQuery } from '@tanstack/react-query'
|
|
70
|
+
import { useContracts } from 'cantonjs-react'
|
|
71
|
+
import { createScanClient } from 'cantonjs-splice-scan'
|
|
72
|
+
|
|
73
|
+
const scan = createScanClient({
|
|
74
|
+
url: import.meta.env.VITE_SPLICE_SCAN_URL,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
function NetworkDashboard() {
|
|
78
|
+
const { data: dso } = useQuery({
|
|
79
|
+
queryKey: ['scan', 'dso'],
|
|
80
|
+
queryFn: () => scan.getDsoInfo(),
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const { data: assets } = useContracts({
|
|
84
|
+
templateId: '#my-pkg:Main:Asset',
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<pre>{JSON.stringify(dso, null, 2)}</pre>
|
|
90
|
+
<pre>{JSON.stringify(assets, null, 2)}</pre>
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This keeps public Scan reads and party-private ledger reads clearly separated. See [`../../docs/examples/react.md`](../../docs/examples/react.md) for the full example.
|
|
97
|
+
|
|
64
98
|
## Hooks
|
|
65
99
|
|
|
66
100
|
### `useContracts(options)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cantonjs-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "React hooks for Canton Network dApps — built on cantonjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"typecheck": "tsc --noEmit",
|
|
12
12
|
"test": "vitest run",
|
|
13
13
|
"test:watch": "vitest",
|
|
14
|
+
"test:coverage": "node ../../scripts/verify-coverage-exclusions.mjs && vitest run --coverage",
|
|
14
15
|
"lint": "eslint src",
|
|
15
16
|
"clean": "rm -rf dist",
|
|
16
17
|
"prepublishOnly": "npm run clean && npm run build"
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@tanstack/react-query": "^5.0.0",
|
|
38
|
-
"cantonjs": "^0.
|
|
39
|
+
"cantonjs": "^0.3.1",
|
|
39
40
|
"react": "^18.0.0 || ^19.0.0"
|
|
40
41
|
},
|
|
41
42
|
"peerDependenciesMeta": {
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"@testing-library/dom": "^10.4.1",
|
|
49
50
|
"@testing-library/react": "^16.0.0",
|
|
50
51
|
"@types/react": "^18.0.0",
|
|
52
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
51
53
|
"jsdom": "^29.0.1",
|
|
52
54
|
"react": "^18.0.0",
|
|
53
55
|
"react-dom": "^18.0.0",
|