@cookill/wallet-adapter 2.5.1 → 2.5.3
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 +110 -176
- package/dist/ErrorBoundary.cjs +20 -40
- package/dist/ErrorBoundary.cjs.map +1 -1
- package/dist/ErrorBoundary.js +6 -6
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/LoadingStates.cjs +32 -54
- package/dist/LoadingStates.cjs.map +1 -1
- package/dist/LoadingStates.js +5 -7
- package/dist/LoadingStates.js.map +1 -1
- package/dist/index.cjs +17 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -14
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +225 -244
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +136 -133
- package/dist/react.js.map +1 -1
- package/dist/standard.cjs +14 -42
- package/dist/standard.cjs.map +1 -1
- package/dist/standard.d.cts +1 -1
- package/dist/standard.d.ts +1 -1
- package/dist/standard.js +3 -11
- package/dist/standard.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @cookill/wallet-adapter v2.
|
|
1
|
+
# @cookill/wallet-adapter v2.4.0
|
|
2
2
|
|
|
3
3
|
Official wallet adapter for **Sheep Wallet** on Rialo blockchain.
|
|
4
4
|
|
|
@@ -8,33 +8,6 @@ Official wallet adapter for **Sheep Wallet** on Rialo blockchain.
|
|
|
8
8
|
npm install @cookill/wallet-adapter
|
|
9
9
|
```
|
|
10
10
|
|
|
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
11
|
## Quick Start
|
|
39
12
|
|
|
40
13
|
```tsx
|
|
@@ -47,6 +20,7 @@ import {
|
|
|
47
20
|
function App() {
|
|
48
21
|
return (
|
|
49
22
|
<WalletErrorBoundary>
|
|
23
|
+
{/* WalletProvider will render a default WalletModal automatically */}
|
|
50
24
|
<WalletProvider network="devnet" autoConnect>
|
|
51
25
|
<ConnectButton />
|
|
52
26
|
<YourDApp />
|
|
@@ -56,89 +30,76 @@ function App() {
|
|
|
56
30
|
}
|
|
57
31
|
```
|
|
58
32
|
|
|
33
|
+
## Troubleshooting (Connect stuck)
|
|
34
|
+
|
|
35
|
+
If clicking **Connect** does nothing or feels "stuck":
|
|
36
|
+
|
|
37
|
+
- Make sure your dApp is wrapped in `<WalletProvider>` (and ideally `<WalletErrorBoundary>`).
|
|
38
|
+
- Prefer `useConnectWallet().connect` (opens the modal) instead of `connectDirect`.
|
|
39
|
+
- The modal is rendered automatically by `WalletProvider`.
|
|
40
|
+
|
|
59
41
|
## React Hooks
|
|
60
42
|
|
|
61
43
|
### useWallet
|
|
62
44
|
|
|
63
|
-
Main hook for wallet state and actions:
|
|
64
|
-
|
|
65
45
|
```tsx
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
closeModal,
|
|
96
|
-
} = useWallet();
|
|
46
|
+
const {
|
|
47
|
+
// State
|
|
48
|
+
connected, // boolean
|
|
49
|
+
connecting, // boolean
|
|
50
|
+
accounts, // WalletAccount[]
|
|
51
|
+
activeAccount, // WalletAccount | null
|
|
52
|
+
network, // 'mainnet' | 'testnet' | 'devnet' | 'localnet'
|
|
53
|
+
chainId, // 'rialo:devnet' etc
|
|
54
|
+
balance, // string | null (in kelvins)
|
|
55
|
+
error, // Error | null
|
|
56
|
+
|
|
57
|
+
// Actions
|
|
58
|
+
connect, // () => Promise<WalletAccount[]>
|
|
59
|
+
disconnect, // () => Promise<void>
|
|
60
|
+
switchNetwork, // (network) => Promise<void>
|
|
61
|
+
refreshBalance, // () => Promise<void>
|
|
62
|
+
|
|
63
|
+
// Transactions
|
|
64
|
+
signMessage, // (message: string) => Promise<SignedMessage>
|
|
65
|
+
signTransaction, // (tx) => Promise<string>
|
|
66
|
+
sendTransaction, // (tx) => Promise<TransactionResult>
|
|
67
|
+
signAndSendTransaction, // (tx) => Promise<TransactionResult>
|
|
68
|
+
|
|
69
|
+
// Modal
|
|
70
|
+
isModalOpen,
|
|
71
|
+
openModal,
|
|
72
|
+
closeModal,
|
|
73
|
+
} = useWallet();
|
|
74
|
+
```
|
|
97
75
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
### useConnectWallet
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
const {
|
|
80
|
+
connect, // Opens modal (recommended)
|
|
81
|
+
connectDirect, // Calls provider directly
|
|
82
|
+
connecting,
|
|
83
|
+
isInstalled,
|
|
84
|
+
error,
|
|
85
|
+
openModal,
|
|
86
|
+
} = useConnectWallet();
|
|
87
|
+
|
|
88
|
+
<button onClick={connect}>Connect Wallet</button>
|
|
108
89
|
```
|
|
109
90
|
|
|
110
|
-
###
|
|
91
|
+
### Other Hooks
|
|
111
92
|
|
|
112
93
|
```tsx
|
|
113
|
-
// Check connection status
|
|
114
94
|
const connected = useIsConnected();
|
|
115
|
-
|
|
116
|
-
// Get active account
|
|
117
95
|
const account = useActiveAccount();
|
|
118
|
-
|
|
119
|
-
// Get all accounts
|
|
120
96
|
const accounts = useAccounts();
|
|
121
|
-
|
|
122
|
-
// Balance with formatting
|
|
123
97
|
const { balance, formatted, refresh } = useBalance();
|
|
124
|
-
// formatted: "1,234.5678 RLO"
|
|
125
|
-
|
|
126
|
-
// Network info
|
|
127
98
|
const { network, chainId, config } = useNetwork();
|
|
128
|
-
|
|
129
|
-
// Switch network with loading state
|
|
130
|
-
const { switchNetwork, switching, error } = useSwitchNetwork();
|
|
131
|
-
|
|
132
|
-
// Connect with modal
|
|
133
|
-
const { connect, connecting, isInstalled, error } = useConnectWallet();
|
|
134
|
-
|
|
135
|
-
// Disconnect
|
|
99
|
+
const { switchNetwork, switching, error, currentNetwork } = useSwitchNetwork();
|
|
136
100
|
const { disconnect, connected } = useDisconnectWallet();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const { sign, signing, signature, error } = useSignMessage();
|
|
140
|
-
|
|
141
|
-
// Send transaction with loading state
|
|
101
|
+
const { sign, signing, signature, error, address } = useSignMessage();
|
|
102
|
+
const { sign, signing, signature, error } = useSignTransaction();
|
|
142
103
|
const { send, sending, txHash, error, reset } = useSendTransaction();
|
|
143
104
|
```
|
|
144
105
|
|
|
@@ -146,8 +107,6 @@ const { send, sending, txHash, error, reset } = useSendTransaction();
|
|
|
146
107
|
|
|
147
108
|
### ConnectButton
|
|
148
109
|
|
|
149
|
-
Pre-styled connect button:
|
|
150
|
-
|
|
151
110
|
```tsx
|
|
152
111
|
<ConnectButton
|
|
153
112
|
connectLabel="Connect Wallet"
|
|
@@ -158,14 +117,19 @@ Pre-styled connect button:
|
|
|
158
117
|
/>
|
|
159
118
|
```
|
|
160
119
|
|
|
161
|
-
###
|
|
120
|
+
### WalletModal
|
|
162
121
|
|
|
163
|
-
|
|
122
|
+
```tsx
|
|
123
|
+
<WalletModal title="Select Wallet" className="my-modal" />
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### WalletProvider
|
|
164
127
|
|
|
165
128
|
```tsx
|
|
166
129
|
<WalletProvider
|
|
167
130
|
network="devnet"
|
|
168
131
|
autoConnect={true}
|
|
132
|
+
wallets={[customWallet]}
|
|
169
133
|
onConnect={(accounts) => console.log('Connected', accounts)}
|
|
170
134
|
onDisconnect={() => console.log('Disconnected')}
|
|
171
135
|
onNetworkChange={(network) => console.log('Network:', network)}
|
|
@@ -175,62 +139,66 @@ Wrap your app to provide wallet context:
|
|
|
175
139
|
</WalletProvider>
|
|
176
140
|
```
|
|
177
141
|
|
|
178
|
-
###
|
|
179
|
-
|
|
180
|
-
Prevents blank screens from uncaught errors:
|
|
142
|
+
### Error Boundary & Loading States
|
|
181
143
|
|
|
182
144
|
```tsx
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
145
|
+
import {
|
|
146
|
+
WalletErrorBoundary,
|
|
147
|
+
SafeWalletProvider,
|
|
148
|
+
ApprovalPending,
|
|
149
|
+
LoadingSpinner,
|
|
150
|
+
ConnectionStatus,
|
|
151
|
+
} from '@cookill/wallet-adapter/react';
|
|
152
|
+
|
|
153
|
+
// Option 1: Error Boundary wrapper
|
|
154
|
+
<WalletErrorBoundary fallback={<CustomError />} onError={logError}>
|
|
155
|
+
<WalletProvider>...</WalletProvider>
|
|
188
156
|
</WalletErrorBoundary>
|
|
157
|
+
|
|
158
|
+
// Option 2: SafeWalletProvider (includes boundary)
|
|
159
|
+
<SafeWalletProvider network="devnet" errorFallback={<CustomError />}>
|
|
160
|
+
...
|
|
161
|
+
</SafeWalletProvider>
|
|
162
|
+
|
|
163
|
+
// Loading states
|
|
164
|
+
<ApprovalPending
|
|
165
|
+
title="Waiting for Approval"
|
|
166
|
+
message="Please approve in Sheep Wallet"
|
|
167
|
+
walletName="Sheep Wallet"
|
|
168
|
+
onCancel={() => disconnect()}
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
<LoadingSpinner size="md" color="#6EB9A8" />
|
|
172
|
+
|
|
173
|
+
<ConnectionStatus status="connecting" />
|
|
174
|
+
<ConnectionStatus status="approving" message="Check your wallet" />
|
|
175
|
+
<ConnectionStatus status="signing" />
|
|
176
|
+
<ConnectionStatus status="success" />
|
|
177
|
+
<ConnectionStatus status="error" onRetry={() => connect()} />
|
|
189
178
|
```
|
|
190
179
|
|
|
191
|
-
## Vanilla JavaScript
|
|
180
|
+
## Vanilla JavaScript
|
|
192
181
|
|
|
193
182
|
```typescript
|
|
194
183
|
import { RialoWallet, isRialoInstalled, formatBalance } from '@cookill/wallet-adapter';
|
|
195
184
|
|
|
196
|
-
|
|
185
|
+
const wallet = new RialoWallet();
|
|
186
|
+
|
|
197
187
|
if (!isRialoInstalled()) {
|
|
198
188
|
console.log('Please install Sheep Wallet');
|
|
199
|
-
window.open('https://rialo.io/wallet', '_blank');
|
|
200
189
|
}
|
|
201
190
|
|
|
202
|
-
// Create wallet instance
|
|
203
|
-
const wallet = new RialoWallet();
|
|
204
|
-
|
|
205
|
-
// Connect
|
|
206
191
|
const accounts = await wallet.connect();
|
|
207
|
-
console.log('Connected:', accounts[0].address);
|
|
208
|
-
|
|
209
|
-
// Get balance
|
|
210
192
|
const balance = await wallet.getBalance();
|
|
211
|
-
console.log('Balance:', formatBalance(balance), 'RLO');
|
|
212
|
-
|
|
213
|
-
// Sign message
|
|
214
193
|
const signed = await wallet.signMessage('Hello!');
|
|
215
|
-
console.log('Signature:', signed.signature);
|
|
216
|
-
|
|
217
|
-
// Send transaction
|
|
218
194
|
const tx = await wallet.signAndSendTransaction({
|
|
219
195
|
to: 'RecipientAddress...',
|
|
220
196
|
value: '1000000000', // 1 RLO in kelvins
|
|
221
197
|
});
|
|
222
|
-
console.log('TX Hash:', tx.hash);
|
|
223
|
-
|
|
224
|
-
// Listen to events
|
|
225
|
-
wallet.on('disconnect', () => {
|
|
226
|
-
console.log('Wallet disconnected');
|
|
227
|
-
});
|
|
228
198
|
```
|
|
229
199
|
|
|
230
200
|
## Direct Provider Access
|
|
231
201
|
|
|
232
|
-
Access `window.rialo` directly:
|
|
233
|
-
|
|
234
202
|
```typescript
|
|
235
203
|
if (window.rialo) {
|
|
236
204
|
const accounts = await window.rialo.connect();
|
|
@@ -254,24 +222,22 @@ if (window.rialo) {
|
|
|
254
222
|
## Utilities
|
|
255
223
|
|
|
256
224
|
```typescript
|
|
257
|
-
import {
|
|
258
|
-
formatAddress,
|
|
259
|
-
formatBalance,
|
|
260
|
-
parseBalance,
|
|
261
|
-
isValidAddress,
|
|
262
|
-
toChainId,
|
|
263
|
-
fromChainId,
|
|
264
|
-
isRialoInstalled,
|
|
265
|
-
getRialoProvider,
|
|
225
|
+
import {
|
|
226
|
+
formatAddress, // (address, chars?) => "5YNm...VWr8"
|
|
227
|
+
formatBalance, // (kelvins, decimals?) => "1.0000"
|
|
228
|
+
parseBalance, // (rlo) => bigint (kelvins)
|
|
229
|
+
isValidAddress, // (address) => boolean
|
|
230
|
+
toChainId, // (network) => 'rialo:devnet'
|
|
231
|
+
fromChainId, // (chainId) => 'devnet'
|
|
232
|
+
isRialoInstalled, // () => boolean
|
|
233
|
+
getRialoProvider, // () => RialoProvider | undefined
|
|
266
234
|
waitForRialoProvider, // (timeout?) => Promise<RialoProvider>
|
|
267
|
-
NETWORKS,
|
|
235
|
+
NETWORKS, // Network configurations
|
|
268
236
|
} from '@cookill/wallet-adapter';
|
|
269
237
|
```
|
|
270
238
|
|
|
271
239
|
## TypeScript
|
|
272
240
|
|
|
273
|
-
Full TypeScript support with all types exported:
|
|
274
|
-
|
|
275
241
|
```typescript
|
|
276
242
|
import type {
|
|
277
243
|
WalletAccount,
|
|
@@ -287,38 +253,6 @@ import type {
|
|
|
287
253
|
} from '@cookill/wallet-adapter';
|
|
288
254
|
```
|
|
289
255
|
|
|
290
|
-
## Troubleshooting
|
|
291
|
-
|
|
292
|
-
### Modal not opening / Connection stuck
|
|
293
|
-
|
|
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
|
|
297
|
-
|
|
298
|
-
### Extension not detected
|
|
299
|
-
|
|
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
|
|
303
|
-
|
|
304
|
-
### Transaction fails
|
|
305
|
-
|
|
306
|
-
1. Ensure wallet is unlocked
|
|
307
|
-
2. Check you have sufficient balance
|
|
308
|
-
3. Verify recipient address is valid
|
|
309
|
-
|
|
310
|
-
## Changelog
|
|
311
|
-
|
|
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
|
|
318
|
-
|
|
319
|
-
### v2.4.x
|
|
320
|
-
- Initial public release
|
|
321
|
-
|
|
322
256
|
## License
|
|
323
257
|
|
|
324
|
-
MIT
|
|
258
|
+
MIT
|
package/dist/ErrorBoundary.cjs
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
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';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
19
7
|
|
|
20
8
|
// src/ErrorBoundary.tsx
|
|
21
|
-
var
|
|
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 {
|
|
9
|
+
var WalletErrorBoundary = class extends react.Component {
|
|
30
10
|
constructor() {
|
|
31
11
|
super(...arguments);
|
|
32
12
|
this.state = {
|
|
@@ -49,7 +29,7 @@ var WalletErrorBoundary = class extends import_react.Component {
|
|
|
49
29
|
if (this.props.fallback) {
|
|
50
30
|
return this.props.fallback;
|
|
51
31
|
}
|
|
52
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53
33
|
"div",
|
|
54
34
|
{
|
|
55
35
|
style: {
|
|
@@ -60,7 +40,7 @@ var WalletErrorBoundary = class extends import_react.Component {
|
|
|
60
40
|
textAlign: "center"
|
|
61
41
|
},
|
|
62
42
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
64
44
|
"div",
|
|
65
45
|
{
|
|
66
46
|
style: {
|
|
@@ -73,7 +53,7 @@ var WalletErrorBoundary = class extends import_react.Component {
|
|
|
73
53
|
alignItems: "center",
|
|
74
54
|
justifyContent: "center"
|
|
75
55
|
},
|
|
76
|
-
children: /* @__PURE__ */
|
|
56
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
77
57
|
"svg",
|
|
78
58
|
{
|
|
79
59
|
width: "24",
|
|
@@ -85,17 +65,17 @@ var WalletErrorBoundary = class extends import_react.Component {
|
|
|
85
65
|
strokeLinecap: "round",
|
|
86
66
|
strokeLinejoin: "round",
|
|
87
67
|
children: [
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
91
71
|
]
|
|
92
72
|
}
|
|
93
73
|
)
|
|
94
74
|
}
|
|
95
75
|
),
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
99
79
|
"button",
|
|
100
80
|
{
|
|
101
81
|
onClick: this.handleRetry,
|
|
@@ -120,8 +100,8 @@ var WalletErrorBoundary = class extends import_react.Component {
|
|
|
120
100
|
}
|
|
121
101
|
};
|
|
122
102
|
var ErrorBoundary_default = WalletErrorBoundary;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
103
|
+
|
|
104
|
+
exports.WalletErrorBoundary = WalletErrorBoundary;
|
|
105
|
+
exports.default = ErrorBoundary_default;
|
|
106
|
+
//# sourceMappingURL=ErrorBoundary.cjs.map
|
|
127
107
|
//# 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"]
|
|
1
|
+
{"version":3,"sources":["../src/ErrorBoundary.tsx"],"names":["Component","jsxs","jsx"],"mappings":";;;;;;;;AAkBO,IAAM,mBAAA,GAAN,cAAkCA,eAAA,CAAwB;AAAA,EAA1D,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAO,KAAA,GAAe;AAAA,MACpB,QAAA,EAAU,KAAA;AAAA,MACV,KAAA,EAAO;AAAA,KACT;AAWA,IAAA,IAAA,CAAQ,cAAc,MAAM;AAC1B,MAAA,IAAA,CAAK,SAAS,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,MAAM,CAAA;AAAA,IAChD,CAAA;AAAA,EAAA;AAAA,EAXA,OAAc,yBAAyB,KAAA,EAAqB;AAC1D,IAAA,OAAO,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,MAAA;AAAA,kBACV,UAAA,EAAY;AAAA,iBACd;AAAA,gBACD,QAAA,EAAA;AAAA;AAAA;AAED;AAAA;AAAA,OACF;AAAA,IAEJ;AAEA,IAAA,OAAO,KAAK,KAAA,CAAM,QAAA;AAAA,EACpB;AACF;AAEA,IAAO,qBAAA,GAAQ","file":"ErrorBoundary.cjs","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"]}
|
package/dist/ErrorBoundary.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
1
4
|
// src/ErrorBoundary.tsx
|
|
2
|
-
import { Component } from "react";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
var WalletErrorBoundary = class extends Component {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
@@ -95,8 +96,7 @@ var WalletErrorBoundary = class extends Component {
|
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
var ErrorBoundary_default = WalletErrorBoundary;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
99
|
+
|
|
100
|
+
export { WalletErrorBoundary, ErrorBoundary_default as default };
|
|
101
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
102
102
|
//# sourceMappingURL=ErrorBoundary.js.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>\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AEvF,CAAA;AAAA,4BACA,GAAA,CAAC,GAAA,EAAA,EAAE,KAAA,EAAO,EAAE,QAAQ,UAAA,EAAY,QAAA,EAAU,MAAA,EAAQ,KAAA,EAAO,WAAU,EAChE,QAAA,EAAA,IAAA,CAAK,KAAA,CAAM,KAAA,EAAO,WAAW,sBAAA,EAChC,CAAA;AAAA,4BACA,GAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,SAAS,IAAA,CAAK,WAAA;AAAA,gBACd,KAAA,EAAO;AAAA,kBACL,OAAA,EAAS,UAAA;AAAA,kBACT,YAAA,EAAc,KAAA;AAAA,kBACd,MAAA,EAAQ,MAAA;AAAA,kBACR,eAAA,EAAiB,SAAA;AAAA,kBACjB,KAAA,EAAO,OAAA;AAAA,kBACP,MAAA,EAAQ,SAAA;AAAA,kBACR,QAAA,EAAU,MAAA;AAAA,kBACV,UAAA,EAAY;AAAA,iBACd;AAAA,gBACD,QAAA,EAAA;AAAA;AAAA;AAED;AAAA;AAAA,OACF;AAAA,IAEJ;AAEA,IAAA,OAAO,KAAK,KAAA,CAAM,QAAA;AAAA,EACpB;AACF;AAEA,IAAO,qBAAA,GAAQ","file":"ErrorBoundary.js","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"]}
|