@opaquecash/react 0.2.0

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.
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from "react";
2
+ import type { OpaqueClient } from "@opaquecash/opaque";
3
+ /** Props for {@link OpaqueProvider}. */
4
+ export interface OpaqueProviderProps {
5
+ /** The shared client, or `null` while the wallet/session is not connected yet. */
6
+ client: OpaqueClient | null;
7
+ children?: ReactNode;
8
+ }
9
+ /**
10
+ * Provide one `OpaqueClient` to the tree. Construct it with `OpaqueClient.fromWallet`
11
+ * (one unified-signer shape per chain) and rebuild it when the connected wallets change;
12
+ * the hooks below re-run automatically because the context value is the client instance.
13
+ */
14
+ export declare function OpaqueProvider(props: OpaqueProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<OpaqueClient | null>>;
15
+ /** The provided client, or `null` when the session is not connected. */
16
+ export declare function useOpaqueClientOrNull(): OpaqueClient | null;
17
+ /** The provided client; throws when used outside a connected {@link OpaqueProvider}. */
18
+ export declare function useOpaqueClient(): OpaqueClient;
19
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,gGAExD;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,IAAI,YAAY,GAAG,IAAI,CAE3D;AAED,wFAAwF;AACxF,wBAAgB,eAAe,IAAI,YAAY,CAS9C"}
@@ -0,0 +1,24 @@
1
+ import { createContext, createElement, useContext } from "react";
2
+ const OpaqueContext = createContext(null);
3
+ /**
4
+ * Provide one `OpaqueClient` to the tree. Construct it with `OpaqueClient.fromWallet`
5
+ * (one unified-signer shape per chain) and rebuild it when the connected wallets change;
6
+ * the hooks below re-run automatically because the context value is the client instance.
7
+ */
8
+ export function OpaqueProvider(props) {
9
+ return createElement(OpaqueContext.Provider, { value: props.client }, props.children);
10
+ }
11
+ /** The provided client, or `null` when the session is not connected. */
12
+ export function useOpaqueClientOrNull() {
13
+ return useContext(OpaqueContext);
14
+ }
15
+ /** The provided client; throws when used outside a connected {@link OpaqueProvider}. */
16
+ export function useOpaqueClient() {
17
+ const client = useContext(OpaqueContext);
18
+ if (!client) {
19
+ throw new Error("useOpaqueClient: no OpaqueClient in context. Wrap the tree in <OpaqueProvider client={…}> " +
20
+ "and gate on useOpaqueClientOrNull() while the session connects.");
21
+ }
22
+ return client;
23
+ }
24
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAGjF,MAAM,aAAa,GAAG,aAAa,CAAsB,IAAI,CAAC,CAAC;AAS/D;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,OAAO,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxF,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,qBAAqB;IACnC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,4FAA4F;YAC1F,iEAAiE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `@opaquecash/react` — React hooks for the Opaque SDK.
3
+ *
4
+ * Wrap your tree in {@link OpaqueProvider} with a client built via
5
+ * `OpaqueClient.fromWallet` (or `create`), then read it anywhere with
6
+ * {@link useOpaqueClient}, scan the unified inbox with {@link useScan}, and resolve
7
+ * per-output native balances with {@link useStealthBalance}.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { OpaqueProvider, useOpaqueClient, useOpaqueClientOrNull } from "./context.js";
12
+ export type { OpaqueProviderProps } from "./context.js";
13
+ export { useScan } from "./useScan.js";
14
+ export type { UseScanOptions, UseScanResult } from "./useScan.js";
15
+ export { useStealthBalance } from "./useStealthBalance.js";
16
+ export type { UseStealthBalanceResult } from "./useStealthBalance.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACtF,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `@opaquecash/react` — React hooks for the Opaque SDK.
3
+ *
4
+ * Wrap your tree in {@link OpaqueProvider} with a client built via
5
+ * `OpaqueClient.fromWallet` (or `create`), then read it anywhere with
6
+ * {@link useOpaqueClient}, scan the unified inbox with {@link useScan}, and resolve
7
+ * per-output native balances with {@link useStealthBalance}.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { OpaqueProvider, useOpaqueClient, useOpaqueClientOrNull } from "./context.js";
12
+ export { useScan } from "./useScan.js";
13
+ export { useStealthBalance } from "./useStealthBalance.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { OpaqueScanChain, UnifiedOwnedOutput } from "@opaquecash/opaque";
2
+ /** Options for {@link useScan} (mirrors `OpaqueClient.scan`). */
3
+ export interface UseScanOptions {
4
+ /** Chains to scan (default both). */
5
+ chains?: OpaqueScanChain[];
6
+ /** Lower-bound cursor: EVM block number (Solana scans the most recent signatures). */
7
+ fromBlock?: bigint;
8
+ /** Upper-bound EVM block; omit for the chain tip. */
9
+ toBlock?: bigint;
10
+ /** Max Solana signatures to scan (adapter default when omitted). */
11
+ solanaLimit?: number;
12
+ /** Merge cross-chain (UAB) announcements (adapter default when omitted). */
13
+ includeCrossChain?: boolean;
14
+ /** Re-scan interval in ms; omit for scan-once (call `refresh` manually). */
15
+ pollInterval?: number;
16
+ /** Skip scanning while true (e.g. tab hidden). */
17
+ paused?: boolean;
18
+ }
19
+ /** State returned by {@link useScan}. */
20
+ export interface UseScanResult {
21
+ /** Owned outputs from the unified inbox (empty while loading the first scan). */
22
+ outputs: UnifiedOwnedOutput[];
23
+ /** True while a scan is in flight. */
24
+ loading: boolean;
25
+ /** Last scan error, cleared by the next successful scan. */
26
+ error: Error | null;
27
+ /** Trigger a re-scan now. */
28
+ refresh: () => void;
29
+ }
30
+ /**
31
+ * Scan the unified cross-chain inbox for outputs owned by the provided client's wallet.
32
+ * Scans once on mount (and whenever the client or options change); set `pollInterval`
33
+ * to keep it fresh. Returns empty state with `loading: false` while the client is null.
34
+ */
35
+ export declare function useScan(options?: UseScanOptions): UseScanResult;
36
+ //# sourceMappingURL=useScan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScan.d.ts","sourceRoot":"","sources":["../src/useScan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG9E,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,aAAa,CAkEnE"}
@@ -0,0 +1,70 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { useOpaqueClientOrNull } from "./context.js";
3
+ /**
4
+ * Scan the unified cross-chain inbox for outputs owned by the provided client's wallet.
5
+ * Scans once on mount (and whenever the client or options change); set `pollInterval`
6
+ * to keep it fresh. Returns empty state with `loading: false` while the client is null.
7
+ */
8
+ export function useScan(options = {}) {
9
+ const client = useOpaqueClientOrNull();
10
+ const [outputs, setOutputs] = useState([]);
11
+ const [loading, setLoading] = useState(false);
12
+ const [error, setError] = useState(null);
13
+ const [nonce, setNonce] = useState(0);
14
+ const generation = useRef(0);
15
+ const { fromBlock, toBlock, solanaLimit, includeCrossChain, pollInterval, paused, } = options;
16
+ const chainsKey = (options.chains ?? ["ethereum", "solana"]).join(",");
17
+ const refresh = useCallback(() => setNonce((n) => n + 1), []);
18
+ useEffect(() => {
19
+ if (!client || paused)
20
+ return;
21
+ const gen = ++generation.current;
22
+ let timer;
23
+ const run = async () => {
24
+ setLoading(true);
25
+ try {
26
+ const result = await client.scan({
27
+ chains: chainsKey.split(","),
28
+ fromBlock,
29
+ toBlock,
30
+ solanaLimit,
31
+ includeCrossChain,
32
+ });
33
+ if (generation.current !== gen)
34
+ return;
35
+ setOutputs(result);
36
+ setError(null);
37
+ }
38
+ catch (e) {
39
+ if (generation.current !== gen)
40
+ return;
41
+ setError(e instanceof Error ? e : new Error(String(e)));
42
+ }
43
+ finally {
44
+ if (generation.current === gen) {
45
+ setLoading(false);
46
+ if (pollInterval != null)
47
+ timer = setTimeout(run, pollInterval);
48
+ }
49
+ }
50
+ };
51
+ void run();
52
+ return () => {
53
+ generation.current++;
54
+ if (timer != null)
55
+ clearTimeout(timer);
56
+ };
57
+ }, [
58
+ client,
59
+ chainsKey,
60
+ fromBlock,
61
+ toBlock,
62
+ solanaLimit,
63
+ includeCrossChain,
64
+ pollInterval,
65
+ paused,
66
+ nonce,
67
+ ]);
68
+ return { outputs, loading, error, refresh };
69
+ }
70
+ //# sourceMappingURL=useScan.js.map
@@ -0,0 +1 @@
1
+ {"version":3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E,KAAK,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { OutputBalance, UnifiedOwnedOutput } from "@opaquecash/opaque";
2
+ /** State returned by {@link useStealthBalance}. */
3
+ export interface UseStealthBalanceResult {
4
+ /** Native balance per owned output (wei / lamports), in input order. */
5
+ balances: OutputBalance[];
6
+ /** Sum of `balances` per chain, in base units. */
7
+ totals: {
8
+ ethereum: bigint;
9
+ solana: bigint;
10
+ };
11
+ /** True while balances are being fetched. */
12
+ loading: boolean;
13
+ /** Last fetch error, cleared by the next successful fetch. */
14
+ error: Error | null;
15
+ }
16
+ /**
17
+ * Resolve the native balance of each owned stealth output (typically the `outputs`
18
+ * from {@link useScan}). Refetches when the output set or client changes.
19
+ */
20
+ export declare function useStealthBalance(outputs: UnifiedOwnedOutput[]): UseStealthBalanceResult;
21
+ //# sourceMappingURL=useStealthBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStealthBalance.d.ts","sourceRoot":"","sources":["../src/useStealthBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG5E,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,kDAAkD;IAClD,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,kBAAkB,EAAE,GAC5B,uBAAuB,CAgDzB"}
@@ -0,0 +1,52 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { useOpaqueClientOrNull } from "./context.js";
3
+ /**
4
+ * Resolve the native balance of each owned stealth output (typically the `outputs`
5
+ * from {@link useScan}). Refetches when the output set or client changes.
6
+ */
7
+ export function useStealthBalance(outputs) {
8
+ const client = useOpaqueClientOrNull();
9
+ const [balances, setBalances] = useState([]);
10
+ const [loading, setLoading] = useState(false);
11
+ const [error, setError] = useState(null);
12
+ const generation = useRef(0);
13
+ // Re-run only when the set of outputs actually changes, not on array identity.
14
+ const outputsKey = outputs
15
+ .map((o) => `${o.chain}:${o.stealthAddress}:${o.ephemeralPublicKey}`)
16
+ .join("|");
17
+ useEffect(() => {
18
+ if (!client || outputs.length === 0) {
19
+ setBalances([]);
20
+ return;
21
+ }
22
+ const gen = ++generation.current;
23
+ setLoading(true);
24
+ client
25
+ .getBalancesForOutputs(outputs)
26
+ .then((result) => {
27
+ if (generation.current !== gen)
28
+ return;
29
+ setBalances(result);
30
+ setError(null);
31
+ })
32
+ .catch((e) => {
33
+ if (generation.current !== gen)
34
+ return;
35
+ setError(e instanceof Error ? e : new Error(String(e)));
36
+ })
37
+ .finally(() => {
38
+ if (generation.current === gen)
39
+ setLoading(false);
40
+ });
41
+ return () => {
42
+ generation.current++;
43
+ };
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- outputsKey covers outputs
45
+ }, [client, outputsKey]);
46
+ const totals = balances.reduce((acc, b) => {
47
+ acc[b.chain] += b.nativeRaw;
48
+ return acc;
49
+ }, { ethereum: 0n, solana: 0n });
50
+ return { balances, totals, loading, error };
51
+ }
52
+ //# sourceMappingURL=useStealthBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStealthBalance.js","sourceRoot":"","sources":["../src/useStealthBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAcrD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA6B;IAE7B,MAAM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AAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;gBAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC,CAAC;QACF,oFAAoF;IACtF,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAEzB,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAC5B,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACT,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAC7B,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@opaquecash/react",
3
+ "version": "0.2.0",
4
+ "description": "React hooks for the Opaque SDK: useOpaqueClient, useScan, useStealthBalance",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json",
19
+ "clean": "rm -rf dist"
20
+ },
21
+ "dependencies": {
22
+ "@opaquecash/opaque": "0.2.0"
23
+ },
24
+ "peerDependencies": {
25
+ "react": ">=18"
26
+ },
27
+ "devDependencies": {
28
+ "@types/react": "^18.3.0",
29
+ "react": "^18.3.1"
30
+ },
31
+ "sideEffects": false,
32
+ "license": "Apache-2.0",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/opaquecash/sdk.git",
36
+ "directory": "packages/react"
37
+ },
38
+ "homepage": "https://docs.opaque.cash",
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }