@naculus/connect-appkit-react 0.1.9 → 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.
Files changed (94) hide show
  1. package/README.md +4 -4
  2. package/dist/client.cjs +1 -1
  3. package/dist/client.cjs.map +1 -1
  4. package/dist/client.d.cts +144 -0
  5. package/dist/client.d.ts +144 -0
  6. package/dist/client.js +1 -1
  7. package/dist/client.js.map +1 -1
  8. package/dist/index.cjs +2 -1
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +2270 -0
  11. package/dist/index.d.ts +2270 -0
  12. package/dist/index.js +2 -1
  13. package/dist/index.js.map +1 -1
  14. package/package.json +30 -12
  15. package/api-extractor.json +0 -21
  16. package/src/chain-abstraction/index.ts +0 -8
  17. package/src/chain-abstraction/useCompareCosts.ts +0 -137
  18. package/src/chain-abstraction/useExecuteRoute.ts +0 -129
  19. package/src/chain-abstraction/useRouteQuote.ts +0 -168
  20. package/src/client.test.ts +0 -242
  21. package/src/client.ts +0 -265
  22. package/src/hooks/useAccount.test.ts +0 -67
  23. package/src/hooks/useAccount.ts +0 -37
  24. package/src/hooks/useBalance.test.ts +0 -459
  25. package/src/hooks/useBalance.ts +0 -170
  26. package/src/hooks/useChain.test.ts +0 -160
  27. package/src/hooks/useChain.ts +0 -53
  28. package/src/hooks/useConnect.test.ts +0 -112
  29. package/src/hooks/useConnect.ts +0 -29
  30. package/src/hooks/useDisconnect.test.ts +0 -75
  31. package/src/hooks/useDisconnect.ts +0 -32
  32. package/src/hooks/useERC20Allowance.ts +0 -93
  33. package/src/hooks/useERC20Approve.ts +0 -220
  34. package/src/hooks/useERC20Transfer.ts +0 -134
  35. package/src/hooks/useERC20TransferSimulation.ts +0 -147
  36. package/src/hooks/useEmbeddedWallet.test.ts +0 -266
  37. package/src/hooks/useEmbeddedWallet.ts +0 -181
  38. package/src/hooks/useLastTx.test.ts +0 -117
  39. package/src/hooks/useLastTx.ts +0 -73
  40. package/src/hooks/useLookupAddress.ts +0 -131
  41. package/src/hooks/useNotification.ts +0 -308
  42. package/src/hooks/useResolveName.ts +0 -128
  43. package/src/hooks/useSIWxLogin.test.ts +0 -307
  44. package/src/hooks/useSIWxLogin.ts +0 -163
  45. package/src/hooks/useSIWxSession.test.ts +0 -481
  46. package/src/hooks/useSIWxSession.ts +0 -290
  47. package/src/hooks/useSendCalls.ts +0 -103
  48. package/src/hooks/useSendTransaction.test.ts +0 -175
  49. package/src/hooks/useSendTransaction.ts +0 -80
  50. package/src/hooks/useSendUserOperation.ts +0 -313
  51. package/src/hooks/useSession.ts +0 -96
  52. package/src/hooks/useSessionKeys.ts +0 -356
  53. package/src/hooks/useSignInWithEthereum.test.ts +0 -224
  54. package/src/hooks/useSignInWithEthereum.ts +0 -46
  55. package/src/hooks/useSignInWithX.test.ts +0 -210
  56. package/src/hooks/useSignInWithX.ts +0 -141
  57. package/src/hooks/useSignMessage.test.ts +0 -151
  58. package/src/hooks/useSignMessage.ts +0 -65
  59. package/src/hooks/useSimulateTransfer.ts +0 -165
  60. package/src/hooks/useSiwxAuthSession.test.ts +0 -456
  61. package/src/hooks/useSiwxAuthSession.ts +0 -163
  62. package/src/hooks/useSmartAccount.ts +0 -194
  63. package/src/hooks/useSwitchChain.ts +0 -68
  64. package/src/hooks/useTokenBalance.test.ts +0 -337
  65. package/src/hooks/useTokenBalance.ts +0 -210
  66. package/src/hooks/useTransactionSimulation.ts +0 -401
  67. package/src/hooks/useTxHistory.test.ts +0 -108
  68. package/src/hooks/useTxHistory.ts +0 -83
  69. package/src/hooks/useTxMonitor.test.ts +0 -127
  70. package/src/hooks/useTxMonitor.ts +0 -178
  71. package/src/hooks/useUserOpStatus.ts +0 -245
  72. package/src/hooks/useValidateDestination.test.ts +0 -96
  73. package/src/hooks/useValidateDestination.ts +0 -72
  74. package/src/hooks/useViemClient.test.ts +0 -155
  75. package/src/hooks/useViemClient.ts +0 -65
  76. package/src/hooks/useWallet.test.ts +0 -133
  77. package/src/hooks/useWallet.ts +0 -39
  78. package/src/hooks/useWeb3ErrorHandler.ts +0 -102
  79. package/src/index.ts +0 -186
  80. package/src/provider/Web3ConnectProvider.test.tsx +0 -178
  81. package/src/provider/Web3ConnectProvider.tsx +0 -530
  82. package/src/token-list/TokenSelector.tsx +0 -351
  83. package/src/token-list/defaults.ts +0 -39
  84. package/src/token-list/index.ts +0 -14
  85. package/src/token-list/useTokenList.ts +0 -119
  86. package/src/token-list/useTokenSearch.ts +0 -99
  87. package/src/types/index.ts +0 -99
  88. package/src/utils/chains.ts +0 -115
  89. package/src/utils/errorMessages.ts +0 -142
  90. package/src/utils/i18n.ts +0 -90
  91. package/src/wc-generated/components.ts +0 -377
  92. package/test/setup.ts +0 -17
  93. package/test/test-utils.tsx +0 -78
  94. package/tsup.config.ts +0 -18
package/package.json CHANGED
@@ -1,21 +1,39 @@
1
1
  {
2
2
  "name": "@naculus/connect-appkit-react",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
- "main": "./dist/index.js",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
6
7
  "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./client": {
15
+ "types": "./dist/client.d.ts",
16
+ "import": "./dist/client.js",
17
+ "require": "./dist/client.cjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/",
22
+ "README.md"
23
+ ],
7
24
  "dependencies": {
8
25
  "@stencil/react-output-target": "^1.6.1",
9
26
  "viem": "^2.54.6",
10
- "@naculus/connect-core": "^0.1.2",
11
- "@naculus/connector-walletconnect": "^0.1.2",
12
- "@naculus/connector-evm-injected": "^0.1.2",
13
- "@naculus/connector-embedded": "^0.1.2",
14
- "@naculus/connector-passkeys": "^0.1.2",
15
- "@naculus/connector-solana": "^0.1.2",
16
- "@naculus/siwx": "^0.1.2",
17
- "@naculus/wallet-engine": "^0.1.2",
18
- "@naculus/connect-appkit-wc": "0.1.9"
27
+ "@naculus/connect-core": "^0.2.0",
28
+ "@naculus/connector-walletconnect": "^0.2.0",
29
+ "@naculus/connector-evm-injected": "^0.2.0",
30
+ "@naculus/connector-embedded": "^0.2.0",
31
+ "@naculus/connector-passkeys": "^0.2.0",
32
+ "@naculus/connector-solana": "^0.2.0",
33
+ "@naculus/siwx": "^0.2.0",
34
+ "@naculus/wallet-engine": "^0.2.0",
35
+ "@naculus/connect-appkit-wc": "0.2.0",
36
+ "@naculus/connect-appkit-core": "0.2.0"
19
37
  },
20
38
  "peerDependencies": {
21
39
  "react": "^18.0.0 || ^19.0.0"
@@ -49,7 +67,7 @@
49
67
  "react"
50
68
  ],
51
69
  "optionalDependencies": {
52
- "@naculus/connect-appkit-ui": "0.1.9"
70
+ "@naculus/connect-appkit-ui": "0.2.0"
53
71
  },
54
72
  "scripts": {
55
73
  "build": "tsup",
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "mainEntryPointFilePath": "<projectFolder>/packages/react/dist/index.d.ts",
4
- "bundledPackages": [],
5
- "compiler": {
6
- "overrideTsconfig": {
7
- "skipLibCheck": true
8
- }
9
- },
10
- "dtsRollup": {
11
- "enabled": true,
12
- "untrimmedFilePath": "<projectFolder>/packages/react/dist/connect-react.d.ts"
13
- },
14
- "apiReport": {
15
- "enabled": true,
16
- "reportFileName": "connect-react.api.md",
17
- "reportFolder": "<projectFolder>/packages/react/etc/"
18
- },
19
- "docModel": { "enabled": false },
20
- "tsdocMetadata": { "enabled": false }
21
- }
@@ -1,8 +0,0 @@
1
- export { useRouteQuote } from "./useRouteQuote";
2
- export type { UseRouteQuoteInput, UseRouteQuoteReturn, Quote, QuoteOptions } from "./useRouteQuote";
3
-
4
- export { useExecuteRoute } from "./useExecuteRoute";
5
- export type { UseExecuteRouteReturn, ExecuteError, ExecuteRouteResult, ExecuteOptions } from "./useExecuteRoute";
6
-
7
- export { useCompareCosts } from "./useCompareCosts";
8
- export type { UseCompareCostsInput, UseCompareCostsReturn, CostComparison, CostComparisonOperation, CostComparisonOptions } from "./useCompareCosts";
@@ -1,137 +0,0 @@
1
- /**
2
- * useCompareCosts — React hook for comparing operation costs across chains.
3
- *
4
- * Provides reactive state for comparing gas costs, fees, and estimated
5
- * times for a given operation across multiple chains.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { useCompareCosts } from "@naculus/connect-appkit-react";
10
- *
11
- * function CostComparisonPanel() {
12
- * const { comparisons, loading, error, refresh } = useCompareCosts({
13
- * operation: "send_erc20",
14
- * chains: ["eip155:1", "eip155:137", "eip155:10"],
15
- * });
16
- *
17
- * if (loading) return <div>Loading...</div>;
18
- *
19
- * return (
20
- * <div>
21
- * {comparisons.map(c => (
22
- * <div key={c.chain}>
23
- * {c.chainName}: ${c.totalCost} (gas: ${c.gasCost})
24
- * </div>
25
- * ))}
26
- * </div>
27
- * );
28
- * }
29
- * ```
30
- */
31
-
32
- import { useState, useEffect, useCallback, useRef } from "react";
33
- // ── Local type definitions (hook domain types, not core exports) ──────
34
-
35
- export interface CostComparison {
36
- chain: string;
37
- chainName: string;
38
- totalCost: string;
39
- gasCost: string;
40
- estimatedTimeMs: number;
41
- }
42
-
43
- export type CostComparisonOperation = "send_erc20" | "swap" | "bridge" | (string & {});
44
-
45
- export interface CostComparisonOptions {
46
- amount?: string;
47
- token?: string;
48
- [key: string]: unknown;
49
- }
50
-
51
-
52
- export interface UseCompareCostsInput {
53
- operation: CostComparisonOperation;
54
- chains: string[];
55
- options?: CostComparisonOptions;
56
- }
57
-
58
- export interface UseCompareCostsReturn {
59
- /** Sorted cost comparisons (cheapest first) */
60
- comparisons: CostComparison[];
61
- /** Whether a comparison request is in flight */
62
- loading: boolean;
63
- /** Error that occurred during the last request */
64
- error: Error | null;
65
- /** Manually trigger a refresh */
66
- refresh: () => Promise<void>;
67
- }
68
-
69
- /**
70
- * Hook for comparing operation costs across multiple chains.
71
- *
72
- * Automatically re-fetches when input parameters change.
73
- * Helpful for chain selection UIs ("show me the cheapest chain").
74
- *
75
- * @param input - Comparison parameters
76
- * @param compareCostsFn - Function that performs the actual comparison
77
- */
78
- export function useCompareCosts(
79
- input: UseCompareCostsInput,
80
- compareCostsFn?: (
81
- operation: string,
82
- chains: string[],
83
- options?: CostComparisonOptions,
84
- ) => Promise<CostComparison[]>,
85
- ): UseCompareCostsReturn {
86
- const { operation, chains, options } = input;
87
- const [comparisons, setComparisons] = useState<CostComparison[]>([]);
88
- const [loading, setLoading] = useState(false);
89
- const [error, setError] = useState<Error | null>(null);
90
- const mountedRef = useRef(true);
91
-
92
- const fetchComparisons = useCallback(async () => {
93
- if (!chains || chains.length === 0) {
94
- setComparisons([]);
95
- return;
96
- }
97
-
98
- if (!compareCostsFn) return;
99
-
100
- setLoading(true);
101
- setError(null);
102
-
103
- try {
104
- const result = await compareCostsFn(operation, chains, options);
105
-
106
- if (mountedRef.current) {
107
- setComparisons(result);
108
- }
109
- } catch (err) {
110
- if (mountedRef.current) {
111
- setError(err instanceof Error ? err : new Error(String(err)));
112
- setComparisons([]);
113
- }
114
- } finally {
115
- if (mountedRef.current) {
116
- setLoading(false);
117
- }
118
- }
119
- }, [operation, chains, options, compareCostsFn]);
120
-
121
- useEffect(() => {
122
- fetchComparisons();
123
- }, [fetchComparisons]);
124
-
125
- useEffect(() => {
126
- mountedRef.current = true;
127
- return () => {
128
- mountedRef.current = false;
129
- };
130
- }, []);
131
-
132
- const refresh = useCallback(async () => {
133
- await fetchComparisons();
134
- }, [fetchComparisons]);
135
-
136
- return { comparisons, loading, error, refresh };
137
- }
@@ -1,129 +0,0 @@
1
- /**
2
- * useExecuteRoute — React hook for executing cross-chain routes.
3
- *
4
- * Manages the execution lifecycle of a cross-chain transfer.
5
- * Tracks execution status, bridge reference, and completion state.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { useExecuteRoute } from "@naculus/connect-appkit-react";
10
- *
11
- * function RouteExecutionPanel({ quote }) {
12
- * const { execute, executing, result, error } = useExecuteRoute();
13
- *
14
- * return (
15
- * <div>
16
- * <button onClick={() => execute(quote, "0xRecipient")} disabled={executing}>
17
- * {executing ? "Executing..." : "Execute Route"}
18
- * </button>
19
- * {result && <div>Tx: {result.fromTxHash}</div>}
20
- * {error && <div>Error: {error.message}</div>}
21
- * </div>
22
- * );
23
- * }
24
- * ```
25
- */
26
-
27
- import { useState, useCallback, useRef } from "react";
28
- // ── Local type definitions (hook domain types, not core exports) ──────
29
-
30
- export interface Quote {
31
- routeId: string;
32
- provider: string;
33
- totalCost?: bigint;
34
- estimatedTimeMs?: number;
35
- }
36
-
37
- export interface ExecuteRouteResult {
38
- fromTxHash: string;
39
- toTxHash?: string;
40
- }
41
-
42
- export interface ExecuteOptions {
43
- timeoutMs?: number;
44
- gasLimit?: bigint;
45
- }
46
-
47
- export interface UseExecuteRouteReturn {
48
- /** Execute a route (call this with the selected quote) */
49
- execute: (quote: Quote, recipient: string, options?: ExecuteOptions) => Promise<void>;
50
- /** Whether execution is in progress */
51
- executing: boolean;
52
- /** The execution result (populated after successful execution) */
53
- result: ExecuteRouteResult | null;
54
- /** Error that occurred during execution */
55
- error: ExecuteError | null;
56
- /** Reset execution state back to initial */
57
- reset: () => void;
58
- }
59
-
60
- export interface ExecuteError {
61
- code: string;
62
- message: string;
63
- details?: Record<string, unknown>;
64
- }
65
-
66
- /**
67
- * Hook for executing a cross-chain route.
68
- *
69
- * Manages the full lifecycle from calling executeRoute to
70
- * tracking the result. For auto-approve flows, handles the
71
- * approve → cross-chain sequence.
72
- *
73
- * @param executeRouteFn - Function that performs the actual route execution
74
- */
75
- export function useExecuteRoute(
76
- executeRouteFn?: (quote: Quote, recipient: string, options?: ExecuteOptions) => Promise<ExecuteRouteResult>,
77
- ): UseExecuteRouteReturn {
78
- const [executing, setExecuting] = useState(false);
79
- const [result, setResult] = useState<ExecuteRouteResult | null>(null);
80
- const [error, setError] = useState<ExecuteError | null>(null);
81
- const mountedRef = useRef(true);
82
-
83
- const execute = useCallback(async (
84
- quote: Quote,
85
- recipient: string,
86
- options?: ExecuteOptions,
87
- ) => {
88
- if (!executeRouteFn) {
89
- setError({
90
- code: "no_executor",
91
- message: "No executeRoute function provided",
92
- });
93
- return;
94
- }
95
-
96
- setExecuting(true);
97
- setError(null);
98
- setResult(null);
99
-
100
- try {
101
- const execResult = await executeRouteFn(quote, recipient, options);
102
-
103
- if (mountedRef.current) {
104
- setResult(execResult);
105
- }
106
- } catch (err) {
107
- if (mountedRef.current) {
108
- const executionError = err as Error;
109
- setError({
110
- code: (executionError as any).code ?? "execution_failed",
111
- message: executionError.message,
112
- details: (executionError as any).details,
113
- });
114
- }
115
- } finally {
116
- if (mountedRef.current) {
117
- setExecuting(false);
118
- }
119
- }
120
- }, [executeRouteFn]);
121
-
122
- const reset = useCallback(() => {
123
- setResult(null);
124
- setError(null);
125
- setExecuting(false);
126
- }, []);
127
-
128
- return { execute, executing, result, error, reset };
129
- }
@@ -1,168 +0,0 @@
1
- /**
2
- * useRouteQuote — React hook for cross-chain route quoting.
3
- *
4
- * Provides reactive state for discovering routes and getting quotes
5
- * from the RouteEngine. Returns loading, error, and result states.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { useRouteQuote } from "@naculus/connect-appkit-react";
10
- *
11
- * function QuotePanel() {
12
- * const { quotes, loading, error, refresh } = useRouteQuote({
13
- * fromChain: "eip155:1",
14
- * toChain: "eip155:137",
15
- * fromToken: "USDC",
16
- * amount: "1000000",
17
- * });
18
- *
19
- * if (loading) return <div>Loading quotes...</div>;
20
- * if (error) return <div>Error: {error.message}</div>;
21
- *
22
- * return (
23
- * <div>
24
- * {quotes.map(q => (
25
- * <div key={q.routeId}>
26
- * {q.provider} — {q.netReceiveFormatted} {q.toTokenSymbol}
27
- * </div>
28
- * ))}
29
- * </div>
30
- * );
31
- * }
32
- * ```
33
- */
34
-
35
- import { useState, useEffect, useCallback, useRef } from "react";
36
- // ── Local type definitions (hook domain types, not core exports) ──────
37
-
38
- export interface Quote {
39
- routeId: string;
40
- provider: string;
41
- netReceiveFormatted: string;
42
- toTokenSymbol: string;
43
- }
44
-
45
- export interface QuoteOptions {
46
- sortBy?: "cost" | "time" | "balance";
47
- maxSlippage?: number;
48
- }
49
-
50
- export interface UseRouteQuoteInput {
51
- fromChain: string;
52
- toChain: string;
53
- fromToken: string;
54
- toToken?: string;
55
- amount: string;
56
- options?: QuoteOptions;
57
- }
58
-
59
- export interface UseRouteQuoteReturn {
60
- /** Current list of quotes (sorted by options.sortBy) */
61
- quotes: Quote[];
62
- /** Whether a quote request is in flight */
63
- loading: boolean;
64
- /** Error that occurred during the last request */
65
- error: Error | null;
66
- /** Manually trigger a refresh (re-fetches quotes) */
67
- refresh: () => Promise<void>;
68
- /** Clear the current quotes and error state */
69
- clear: () => void;
70
- }
71
-
72
- /**
73
- * Hook for fetching cross-chain route quotes.
74
- *
75
- * Automatically re-fetches when input parameters change.
76
- * Debounces rapid changes to avoid excessive API calls.
77
- *
78
- * @param input - Quote request parameters
79
- * @param getQuoteFn - Function that performs the actual quote fetch
80
- */
81
- export function useRouteQuote(
82
- input: UseRouteQuoteInput,
83
- getQuoteFn?: (from: string, to: string, token: string, amount: string, options?: QuoteOptions) => Promise<Quote[]>,
84
- ): UseRouteQuoteReturn {
85
- const { fromChain, toChain, fromToken, toToken, amount, options } = input;
86
- const [quotes, setQuotes] = useState<Quote[]>([]);
87
- const [loading, setLoading] = useState(false);
88
- const [error, setError] = useState<Error | null>(null);
89
- const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
90
- const mountedRef = useRef(true);
91
-
92
- const fetchQuotes = useCallback(async () => {
93
- if (!fromChain || !toChain || !fromToken || !amount || BigInt(amount) <= 0n) {
94
- setQuotes([]);
95
- return;
96
- }
97
-
98
- if (!getQuoteFn) return;
99
-
100
- setLoading(true);
101
- setError(null);
102
-
103
- try {
104
- const result = await getQuoteFn(
105
- fromChain,
106
- toChain,
107
- fromToken,
108
- amount,
109
- options,
110
- );
111
-
112
- if (mountedRef.current) {
113
- setQuotes(result);
114
- }
115
- } catch (err) {
116
- if (mountedRef.current) {
117
- setError(err instanceof Error ? err : new Error(String(err)));
118
- setQuotes([]);
119
- }
120
- } finally {
121
- if (mountedRef.current) {
122
- setLoading(false);
123
- }
124
- }
125
- }, [fromChain, toChain, fromToken, amount, options, getQuoteFn]);
126
-
127
- // Debounced auto-fetch on input change
128
- useEffect(() => {
129
- if (debounceTimer.current) {
130
- clearTimeout(debounceTimer.current);
131
- }
132
-
133
- // Don't fetch if parameters are incomplete
134
- if (!fromChain || !toChain || !fromToken || !amount) {
135
- setQuotes([]);
136
- return;
137
- }
138
-
139
- debounceTimer.current = setTimeout(() => {
140
- fetchQuotes();
141
- }, 300); // 300ms debounce
142
-
143
- return () => {
144
- if (debounceTimer.current) {
145
- clearTimeout(debounceTimer.current);
146
- }
147
- };
148
- }, [fetchQuotes, fromChain, toChain, fromToken, amount]);
149
-
150
- useEffect(() => {
151
- mountedRef.current = true;
152
- return () => {
153
- mountedRef.current = false;
154
- };
155
- }, []);
156
-
157
- const refresh = useCallback(async () => {
158
- await fetchQuotes();
159
- }, [fetchQuotes]);
160
-
161
- const clear = useCallback(() => {
162
- setQuotes([]);
163
- setError(null);
164
- setLoading(false);
165
- }, []);
166
-
167
- return { quotes, loading, error, refresh, clear };
168
- }