@cookill/wallet-adapter 2.5.4 → 3.0.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.
package/README.md CHANGED
@@ -1,48 +1,28 @@
1
- # @cookill/wallet-adapter v2.5.0
1
+ # @cookill/wallet-adapter v3.0.0
2
2
 
3
3
  Official wallet adapter for **Sheep Wallet** on Rialo blockchain.
4
4
 
5
+ ## 🚀 What's New in v3.0
6
+
7
+ - **Anti-freeze architecture**: All provider calls wrapped with timeouts
8
+ - **Clean separation**: Core (vanilla JS) vs React layer
9
+ - **Silent auto-connect**: Uses `checkSession()` instead of `connect()` for session restoration
10
+ - **No more hangs**: 20-second timeout on connection, 30-second on operations
11
+
5
12
  ## Installation
6
13
 
7
14
  ```bash
8
15
  npm install @cookill/wallet-adapter
16
+ # or
17
+ pnpm add @cookill/wallet-adapter
18
+ # or
19
+ yarn add @cookill/wallet-adapter
9
20
  ```
10
21
 
11
- ## ⚠️ IMPORTANT: Vite Configuration
12
-
13
- **If you're using Vite**, you MUST add React deduplication to prevent "stuck connection" issues:
14
-
15
- ```typescript
16
- // vite.config.ts
17
- import { defineConfig } from "vite";
18
- import react from "@vitejs/plugin-react";
19
- import path from "path";
20
-
21
- export default defineConfig({
22
- plugins: [react()],
23
- resolve: {
24
- alias: {
25
- "@": path.resolve(__dirname, "./src"),
26
- },
27
- // CRITICAL: Prevent duplicate React instances
28
- dedupe: ["react", "react-dom", "react/jsx-runtime"],
29
- },
30
- optimizeDeps: {
31
- include: ["react", "react-dom"],
32
- },
33
- });
34
- ```
35
-
36
- **Without this configuration**, the wallet modal may not open and connections will appear "stuck".
37
-
38
- ## Quick Start
22
+ ## Quick Start (React)
39
23
 
40
24
  ```tsx
41
- import {
42
- WalletProvider,
43
- ConnectButton,
44
- WalletErrorBoundary,
45
- } from '@cookill/wallet-adapter/react';
25
+ import { WalletProvider, ConnectButton, WalletErrorBoundary } from '@cookill/wallet-adapter/react';
46
26
 
47
27
  function App() {
48
28
  return (
@@ -60,22 +40,18 @@ function App() {
60
40
 
61
41
  ### useWallet
62
42
 
63
- Main hook for wallet state and actions:
64
-
65
43
  ```tsx
66
44
  import { useWallet } from '@cookill/wallet-adapter/react';
67
45
 
68
46
  function MyComponent() {
69
47
  const {
70
48
  // State
71
- connected, // boolean - is wallet connected
72
- connecting, // boolean - connection in progress
73
- accounts, // WalletAccount[] - all connected accounts
74
- activeAccount, // WalletAccount | null - primary account
75
- network, // 'mainnet' | 'testnet' | 'devnet' | 'localnet'
49
+ connected, // boolean
50
+ connecting, // boolean
51
+ activeAccount, // WalletAccount | null
52
+ state, // Full state object
76
53
  chainId, // 'rialo:devnet' etc
77
- balance, // string | null (in kelvins)
78
- error, // Error | null
54
+ isInstalled, // boolean
79
55
 
80
56
  // Actions
81
57
  connect, // () => Promise<WalletAccount[]>
@@ -90,7 +66,6 @@ function MyComponent() {
90
66
  signAndSendTransaction, // (tx) => Promise<TransactionResult>
91
67
 
92
68
  // Modal
93
- isModalOpen,
94
69
  openModal,
95
70
  closeModal,
96
71
  } = useWallet();
@@ -100,54 +75,97 @@ function MyComponent() {
100
75
  {connected ? (
101
76
  <p>Connected: {activeAccount?.address}</p>
102
77
  ) : (
103
- <button onClick={openModal}>Connect</button>
78
+ <button onClick={connect}>Connect</button>
104
79
  )}
105
80
  </div>
106
81
  );
107
82
  }
108
83
  ```
109
84
 
110
- ### Convenience Hooks
85
+ ### Specialized Hooks
111
86
 
112
87
  ```tsx
113
- // Check connection status
88
+ // Connection
89
+ const { connect, connecting, isInstalled, error } = useConnectWallet();
90
+ const { disconnect, connected } = useDisconnectWallet();
114
91
  const connected = useIsConnected();
115
92
 
116
- // Get active account
93
+ // Account
117
94
  const account = useActiveAccount();
118
-
119
- // Get all accounts
120
95
  const accounts = useAccounts();
121
96
 
122
- // Balance with formatting
123
- const { balance, formatted, refresh } = useBalance();
124
- // formatted: "1,234.5678 RLO"
97
+ // Balance
98
+ const { balance, refresh } = useBalance();
125
99
 
126
- // Network info
127
- const { network, chainId, config } = useNetwork();
100
+ // Network
101
+ const { network, chainId } = useNetwork();
102
+ const { switchNetwork, network } = useSwitchNetwork();
128
103
 
129
- // Switch network with loading state
130
- const { switchNetwork, switching, error } = useSwitchNetwork();
104
+ // Transactions
105
+ const { signMessage, connected } = useSignMessage();
106
+ const { sendTransaction, signAndSendTransaction, connected } = useSendTransaction();
107
+ ```
131
108
 
132
- // Connect with modal
133
- const { connect, connecting, isInstalled, error } = useConnectWallet();
109
+ ## Vanilla JavaScript
134
110
 
135
- // Disconnect
136
- const { disconnect, connected } = useDisconnectWallet();
111
+ ```typescript
112
+ import { SheepWallet, isInstalled, formatBalance } from '@cookill/wallet-adapter';
113
+
114
+ // Check if installed
115
+ if (!isInstalled()) {
116
+ console.log('Please install Sheep Wallet');
117
+ }
118
+
119
+ // Create wallet instance
120
+ const wallet = new SheepWallet();
121
+
122
+ // Connect (with built-in timeout)
123
+ try {
124
+ const accounts = await wallet.connect();
125
+ console.log('Connected:', accounts[0].address);
126
+ } catch (error) {
127
+ console.error('Connection failed:', error.message);
128
+ }
129
+
130
+ // Get balance
131
+ const balance = await wallet.getBalance();
132
+ console.log('Balance:', formatBalance(balance), 'RLO');
133
+
134
+ // Sign message
135
+ const signed = await wallet.signMessage('Hello!');
136
+
137
+ // Send transaction
138
+ const tx = await wallet.signAndSendTransaction({
139
+ to: 'RecipientAddress...',
140
+ value: '1000000000', // 1 RLO in kelvins
141
+ });
142
+ console.log('TX Hash:', tx.hash);
137
143
 
138
- // Sign message with loading state
139
- const { sign, signing, signature, error } = useSignMessage();
144
+ // Silent session check (for auto-connect, never triggers approval)
145
+ const existingSession = await wallet.checkSession();
146
+ if (existingSession) {
147
+ console.log('Session restored:', existingSession[0].address);
148
+ }
149
+ ```
150
+
151
+ ## Direct Provider Access
140
152
 
141
- // Send transaction with loading state
142
- const { send, sending, txHash, error, reset } = useSendTransaction();
153
+ ```typescript
154
+ // Access window.rialo directly
155
+ if (window.rialo) {
156
+ const accounts = await window.rialo.connect();
157
+ const balance = await window.rialo.getBalance();
158
+ const tx = await window.rialo.signAndSendTransaction({
159
+ to: 'RecipientAddress...',
160
+ value: '1000000000',
161
+ });
162
+ }
143
163
  ```
144
164
 
145
165
  ## Components
146
166
 
147
167
  ### ConnectButton
148
168
 
149
- Pre-styled connect button:
150
-
151
169
  ```tsx
152
170
  <ConnectButton
153
171
  connectLabel="Connect Wallet"
@@ -155,17 +173,17 @@ Pre-styled connect button:
155
173
  showAddress={true}
156
174
  showBalance={false}
157
175
  className="my-button"
176
+ style={{ backgroundColor: '#6EB9A8' }}
158
177
  />
159
178
  ```
160
179
 
161
180
  ### WalletProvider
162
181
 
163
- Wrap your app to provide wallet context:
164
-
165
182
  ```tsx
166
183
  <WalletProvider
167
- network="devnet"
168
- autoConnect={true}
184
+ network="devnet" // 'mainnet' | 'testnet' | 'devnet' | 'localnet'
185
+ autoConnect={true} // Restore session silently on mount
186
+ wallets={[customWallet]} // Additional wallets to show
169
187
  onConnect={(accounts) => console.log('Connected', accounts)}
170
188
  onDisconnect={() => console.log('Disconnected')}
171
189
  onNetworkChange={(network) => console.log('Network:', network)}
@@ -175,71 +193,37 @@ Wrap your app to provide wallet context:
175
193
  </WalletProvider>
176
194
  ```
177
195
 
178
- ### WalletErrorBoundary
179
-
180
- Prevents blank screens from uncaught errors:
196
+ ### Error Boundary & Loading States
181
197
 
182
198
  ```tsx
183
- <WalletErrorBoundary
184
- fallback={<div>Something went wrong</div>}
185
- onError={(error, errorInfo) => logError(error)}
199
+ import {
200
+ WalletErrorBoundary,
201
+ ApprovalPending,
202
+ LoadingSpinner,
203
+ ConnectionStatus,
204
+ } from '@cookill/wallet-adapter/react';
205
+
206
+ // Error Boundary
207
+ <WalletErrorBoundary
208
+ fallback={<CustomError />}
209
+ onError={(error, info) => logError(error)}
186
210
  >
187
- <YourComponent />
211
+ <WalletProvider>...</WalletProvider>
188
212
  </WalletErrorBoundary>
189
- ```
190
-
191
- ## Vanilla JavaScript (Non-React)
192
-
193
- ```typescript
194
- import { RialoWallet, isRialoInstalled, formatBalance } from '@cookill/wallet-adapter';
195
-
196
- // Check if extension is installed
197
- if (!isRialoInstalled()) {
198
- console.log('Please install Sheep Wallet');
199
- window.open('https://rialo.io/wallet', '_blank');
200
- }
201
213
 
202
- // Create wallet instance
203
- const wallet = new RialoWallet();
204
-
205
- // Connect
206
- const accounts = await wallet.connect();
207
- console.log('Connected:', accounts[0].address);
208
-
209
- // Get balance
210
- const balance = await wallet.getBalance();
211
- console.log('Balance:', formatBalance(balance), 'RLO');
212
-
213
- // Sign message
214
- const signed = await wallet.signMessage('Hello!');
215
- console.log('Signature:', signed.signature);
216
-
217
- // Send transaction
218
- const tx = await wallet.signAndSendTransaction({
219
- to: 'RecipientAddress...',
220
- value: '1000000000', // 1 RLO in kelvins
221
- });
222
- console.log('TX Hash:', tx.hash);
223
-
224
- // Listen to events
225
- wallet.on('disconnect', () => {
226
- console.log('Wallet disconnected');
227
- });
228
- ```
229
-
230
- ## Direct Provider Access
214
+ // Loading states
215
+ <ApprovalPending
216
+ title="Waiting for Approval"
217
+ message="Please approve in Sheep Wallet"
218
+ walletName="Sheep Wallet"
219
+ onCancel={() => disconnect()}
220
+ />
231
221
 
232
- Access `window.rialo` directly:
222
+ <LoadingSpinner size="md" color="#6EB9A8" />
233
223
 
234
- ```typescript
235
- if (window.rialo) {
236
- const accounts = await window.rialo.connect();
237
- const balance = await window.rialo.getBalance();
238
- const tx = await window.rialo.signAndSendTransaction({
239
- to: 'RecipientAddress...',
240
- value: '1000000000',
241
- });
242
- }
224
+ <ConnectionStatus status="connecting" />
225
+ <ConnectionStatus status="approving" message="Check your wallet" />
226
+ <ConnectionStatus status="error" onRetry={() => connect()} />
243
227
  ```
244
228
 
245
229
  ## Networks
@@ -254,24 +238,22 @@ if (window.rialo) {
254
238
  ## Utilities
255
239
 
256
240
  ```typescript
257
- import {
258
- formatAddress, // (address, chars?) => "5YNm...VWr8"
259
- formatBalance, // (kelvins, decimals?) => "1.0000"
260
- parseBalance, // (rlo) => bigint (kelvins)
261
- isValidAddress, // (address) => boolean
262
- toChainId, // (network) => 'rialo:devnet'
263
- fromChainId, // (chainId) => 'devnet'
264
- isRialoInstalled, // () => boolean
265
- getRialoProvider, // () => RialoProvider | undefined
266
- waitForRialoProvider, // (timeout?) => Promise<RialoProvider>
267
- NETWORKS, // Network configurations
241
+ import {
242
+ formatAddress, // (address, chars?) => "5YNm...VWr8"
243
+ formatBalance, // (kelvins, decimals?) => "1.0000"
244
+ parseBalance, // (rlo) => bigint (kelvins)
245
+ isValidAddress, // (address) => boolean
246
+ toChainId, // (network) => 'rialo:devnet'
247
+ fromChainId, // (chainId) => 'devnet'
248
+ isInstalled, // () => boolean
249
+ getProvider, // () => RialoProvider | undefined
250
+ waitForProvider, // (timeout?) => Promise<RialoProvider | undefined>
251
+ NETWORKS, // Network configurations
268
252
  } from '@cookill/wallet-adapter';
269
253
  ```
270
254
 
271
255
  ## TypeScript
272
256
 
273
- Full TypeScript support with all types exported:
274
-
275
257
  ```typescript
276
258
  import type {
277
259
  WalletAccount,
@@ -283,42 +265,50 @@ import type {
283
265
  WalletInfo,
284
266
  RialoProvider,
285
267
  RialoNetwork,
286
- RialoChain,
268
+ RialoChainId,
287
269
  } from '@cookill/wallet-adapter';
288
270
  ```
289
271
 
290
272
  ## Troubleshooting
291
273
 
292
- ### Modal not opening / Connection stuck
274
+ ### Connection hangs / freezes
293
275
 
294
- 1. **Add Vite dedupe config** (see top of this README)
295
- 2. Clear `node_modules` and reinstall: `rm -rf node_modules && npm install`
296
- 3. Check console for errors
276
+ v3.0 has built-in 20-second timeout. If connection still hangs:
297
277
 
298
- ### Extension not detected
278
+ 1. Make sure extension is installed and unlocked
279
+ 2. Check if popup was blocked by browser
280
+ 3. Try refreshing the page
299
281
 
300
- 1. Make sure Sheep Wallet extension is installed
301
- 2. Refresh the page after installing
302
- 3. Check if `window.rialo` exists in browser console
282
+ ### Auto-connect not working
303
283
 
304
- ### Transaction fails
284
+ Auto-connect uses `checkSession()` which only restores **existing** sessions silently.
285
+ It won't trigger the approval popup. User must explicitly call `connect()` first time.
305
286
 
306
- 1. Ensure wallet is unlocked
307
- 2. Check you have sufficient balance
308
- 3. Verify recipient address is valid
287
+ ### Modal not opening
309
288
 
310
- ## Changelog
289
+ The `WalletProvider` renders the modal automatically. If you see issues:
311
290
 
312
- ### v2.5.0
313
- - Fixed bundling to properly externalize React
314
- - Added WalletErrorBoundary component
315
- - Added loading states (ApprovalPending, ConnectionStatus)
316
- - Improved modal with singleton pattern
317
- - Updated Vite configuration requirements
291
+ ```tsx
292
+ // Make sure you're inside WalletProvider
293
+ const { openModal } = useWallet();
294
+ openModal(); // This should work
295
+ ```
296
+
297
+ ## Migration from v2.x
318
298
 
319
- ### v2.4.x
320
- - Initial public release
299
+ ```diff
300
+ // Imports are the same
301
+ import { WalletProvider, ConnectButton } from '@cookill/wallet-adapter/react';
302
+
303
+ // Hook usage is the same
304
+ const { connect, connected } = useWallet();
305
+
306
+ // Main changes:
307
+ // - connect() now has 20s timeout built-in
308
+ // - autoConnect uses checkSession() (silent, never triggers popup)
309
+ // - New SheepWallet class for vanilla JS (replaces RialoWallet)
310
+ ```
321
311
 
322
312
  ## License
323
313
 
324
- MIT
314
+ MIT
@@ -1,127 +1,70 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/ErrorBoundary.tsx
21
- var ErrorBoundary_exports = {};
22
- __export(ErrorBoundary_exports, {
23
- WalletErrorBoundary: () => WalletErrorBoundary,
24
- default: () => ErrorBoundary_default
25
- });
26
- module.exports = __toCommonJS(ErrorBoundary_exports);
27
- var import_react = require("react");
28
- var import_jsx_runtime = require("react/jsx-runtime");
29
- var WalletErrorBoundary = class extends import_react.Component {
30
- constructor() {
31
- super(...arguments);
32
- this.state = {
33
- hasError: false,
34
- error: null
35
- };
36
- this.handleRetry = () => {
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ var WalletErrorBoundary = class extends react.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.handleReset = () => {
37
10
  this.setState({ hasError: false, error: null });
38
11
  };
12
+ this.state = { hasError: false, error: null };
39
13
  }
40
14
  static getDerivedStateFromError(error) {
41
15
  return { hasError: true, error };
42
16
  }
43
17
  componentDidCatch(error, errorInfo) {
44
- console.error("[WalletAdapter] Error caught by boundary:", error, errorInfo);
18
+ console.error("[WalletErrorBoundary] Caught error:", error, errorInfo);
45
19
  this.props.onError?.(error, errorInfo);
46
20
  }
47
21
  render() {
48
- if (this.state.hasError) {
49
- if (this.props.fallback) {
50
- return this.props.fallback;
22
+ if (this.state.hasError && this.state.error) {
23
+ const { fallback } = this.props;
24
+ if (typeof fallback === "function") {
25
+ return fallback(this.state.error, this.handleReset);
26
+ }
27
+ if (fallback) {
28
+ return fallback;
51
29
  }
52
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
53
- "div",
54
- {
55
- style: {
56
- padding: "20px",
57
- borderRadius: "12px",
58
- border: "1px solid #fee2e2",
59
- backgroundColor: "#fef2f2",
60
- textAlign: "center"
61
- },
62
- children: [
63
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
- "div",
65
- {
66
- style: {
67
- width: "48px",
68
- height: "48px",
69
- margin: "0 auto 12px",
70
- borderRadius: "50%",
71
- backgroundColor: "#fecaca",
72
- display: "flex",
73
- alignItems: "center",
74
- justifyContent: "center"
75
- },
76
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
77
- "svg",
78
- {
79
- width: "24",
80
- height: "24",
81
- viewBox: "0 0 24 24",
82
- fill: "none",
83
- stroke: "#dc2626",
84
- strokeWidth: "2",
85
- strokeLinecap: "round",
86
- strokeLinejoin: "round",
87
- children: [
88
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
89
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
90
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
91
- ]
92
- }
93
- )
94
- }
95
- ),
96
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
98
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
- "button",
100
- {
101
- onClick: this.handleRetry,
102
- style: {
103
- padding: "8px 16px",
104
- borderRadius: "8px",
105
- border: "none",
106
- backgroundColor: "#dc2626",
107
- color: "white",
108
- cursor: "pointer",
109
- fontSize: "14px",
110
- fontWeight: 500
111
- },
112
- children: "Try Again"
113
- }
114
- )
115
- ]
116
- }
117
- );
30
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
31
+ padding: "20px",
32
+ margin: "10px",
33
+ backgroundColor: "#1a1a2e",
34
+ border: "1px solid #ef4444",
35
+ borderRadius: "12px",
36
+ color: "#ffffff"
37
+ }, children: [
38
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { color: "#ef4444", margin: "0 0 12px 0" }, children: "Wallet Connection Error" }),
39
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#94a3b8", margin: "0 0 16px 0", fontSize: "14px" }, children: this.state.error.message }),
40
+ /* @__PURE__ */ jsxRuntime.jsx(
41
+ "button",
42
+ {
43
+ onClick: this.handleReset,
44
+ style: {
45
+ padding: "8px 16px",
46
+ backgroundColor: "#6EB9A8",
47
+ color: "#011B29",
48
+ border: "none",
49
+ borderRadius: "8px",
50
+ cursor: "pointer",
51
+ fontWeight: 500
52
+ },
53
+ children: "Try Again"
54
+ }
55
+ )
56
+ ] });
118
57
  }
119
58
  return this.props.children;
120
59
  }
121
60
  };
122
- var ErrorBoundary_default = WalletErrorBoundary;
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- WalletErrorBoundary
126
- });
61
+ function withWalletErrorBoundary(WrappedComponent, fallback) {
62
+ return function WithErrorBoundary(props) {
63
+ return /* @__PURE__ */ jsxRuntime.jsx(WalletErrorBoundary, { fallback, children: /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props }) });
64
+ };
65
+ }
66
+
67
+ exports.WalletErrorBoundary = WalletErrorBoundary;
68
+ exports.withWalletErrorBoundary = withWalletErrorBoundary;
69
+ //# sourceMappingURL=ErrorBoundary.cjs.map
127
70
  //# sourceMappingURL=ErrorBoundary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ErrorBoundary.tsx"],"sourcesContent":["/**\n * @cookill/wallet-adapter - Error Boundary\n * Prevents blank screens from uncaught errors\n */\n\nimport React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n fallback?: ReactNode;\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\nexport class WalletErrorBoundary extends Component<Props, State> {\n public state: State = {\n hasError: false,\n error: null,\n };\n\n public static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n public componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error('[WalletAdapter] Error caught by boundary:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n private handleRetry = () => {\n this.setState({ hasError: false, error: null });\n };\n\n public render() {\n if (this.state.hasError) {\n if (this.props.fallback) {\n return this.props.fallback;\n }\n\n return (\n <div\n style={{\n padding: '20px',\n borderRadius: '12px',\n border: '1px solid #fee2e2',\n backgroundColor: '#fef2f2',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n margin: '0 auto 12px',\n borderRadius: '50%',\n backgroundColor: '#fecaca',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"#dc2626\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\" />\n <line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\" />\n </svg>\n </div>\n <h3 style={{ margin: '0 0 8px', fontSize: '16px', fontWeight: 600, color: '#991b1b' }}>\n Wallet Connection Error\n </h3>\n <p style={{ margin: '0 0 16px', fontSize: '14px', color: '#b91c1c' }}>\n {this.state.error?.message || 'Something went wrong'}\n </p>\n <button\n onClick={this.handleRetry}\n style={{\n padding: '8px 16px',\n borderRadius: '8px',\n border: 'none',\n backgroundColor: '#dc2626',\n color: 'white',\n cursor: 'pointer',\n fontSize: '14px',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\nexport default WalletErrorBoundary;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAuD;AA4D3C;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AS,IAAA,CAAK,WAAA;AAAA,YACd,KAAA,EAAO;AAAA,cACL,OAAA,EAAS,UAAA;AAAA,cACT,eAAA,EAAiB,SAAA;AAAA,cACjB,KAAA,EAAO,SAAA;AAAA,cACP,MAAA,EAAQ,MAAA;AAAA,cACR,YAAA,EAAc,KAAA;AAAA,cACd,MAAA,EAAQ,SAAA;AAAA,cACR,UAAA,EAAY;AAAA,aACd;AAAA,YACD,QAAA,EAAA;AAAA;AAAA;AAED,OAAA,EACF,CAAA;AAAA,IAEJ;AAEA,IAAA,OAAO,KAAK,KAAA,CAAM,QAAA;AAAA,EACpB;AACF;AAKO,SAAS,uBAAA,CACd,kBACA,QAAA,EACA;AACA,EAAA,OAAO,SAAS,kBAAkB,KAAA,EAAU;AAC1C,IAAA,sCACG,mBAAA,EAAA,EAAoB,QAAA,EACnB,yCAAC,gBAAA,EAAA,EAAkB,GAAG,OAAO,CAAA,EAC/B,CAAA;AAAA,EAEJ,CAAA;AACF","file":"ErrorBoundary.cjs","sourcesContent":["/**\n * @cookill/wallet-adapter/react v3.0.0\n * Error Boundary for wallet integration\n */\n\nimport React, { Component, type ReactNode, type ErrorInfo } from 'react';\n\nexport interface WalletErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\nexport class WalletErrorBoundary extends Component<WalletErrorBoundaryProps, State> {\n constructor(props: WalletErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n console.error('[WalletErrorBoundary] Caught error:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = (): void => {\n this.setState({ hasError: false, error: null });\n };\n\n render(): ReactNode {\n if (this.state.hasError && this.state.error) {\n const { fallback } = this.props;\n \n if (typeof fallback === 'function') {\n return fallback(this.state.error, this.handleReset);\n }\n \n if (fallback) {\n return fallback;\n }\n\n return (\n <div style={{\n padding: '20px',\n margin: '10px',\n backgroundColor: '#1a1a2e',\n border: '1px solid #ef4444',\n borderRadius: '12px',\n color: '#ffffff',\n }}>\n <h3 style={{ color: '#ef4444', margin: '0 0 12px 0' }}>\n Wallet Connection Error\n </h3>\n <p style={{ color: '#94a3b8', margin: '0 0 16px 0', fontSize: '14px' }}>\n {this.state.error.message}\n </p>\n <button\n onClick={this.handleReset}\n style={{\n padding: '8px 16px',\n backgroundColor: '#6EB9A8',\n color: '#011B29',\n border: 'none',\n borderRadius: '8px',\n cursor: 'pointer',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * HOC to wrap components with error boundary\n */\nexport function withWalletErrorBoundary<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n fallback?: WalletErrorBoundaryProps['fallback']\n) {\n return function WithErrorBoundary(props: P) {\n return (\n <WalletErrorBoundary fallback={fallback}>\n <WrappedComponent {...props} />\n </WalletErrorBoundary>\n );\n };\n}\n\nexport default WalletErrorBoundary;\n"]}