@solana/connector 0.1.10 → 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.
- package/README.md +344 -88
- package/dist/{chunk-MN7XNCYI.js → chunk-BJAVJQLK.js} +6 -6
- package/dist/{chunk-MN7XNCYI.js.map → chunk-BJAVJQLK.js.map} +1 -1
- package/dist/{chunk-6AJJJG5B.js → chunk-BZ2VBJCZ.js} +618 -415
- package/dist/chunk-BZ2VBJCZ.js.map +1 -0
- package/dist/{chunk-ATYK5OKR.js → chunk-EM4KNOKG.js} +614 -194
- package/dist/chunk-EM4KNOKG.js.map +1 -0
- package/dist/{chunk-4JT24DIX.js → chunk-HN5AJF7F.js} +61 -20
- package/dist/chunk-HN5AJF7F.js.map +1 -0
- package/dist/{chunk-FVA4TUI4.mjs → chunk-HPQ5T32K.mjs} +4 -4
- package/dist/{chunk-FVA4TUI4.mjs.map → chunk-HPQ5T32K.mjs.map} +1 -1
- package/dist/{chunk-QOIQBWMP.mjs → chunk-IDTUFDNB.mjs} +531 -339
- package/dist/chunk-IDTUFDNB.mjs.map +1 -0
- package/dist/{chunk-WGZYKDXF.mjs → chunk-RTXUS5KG.mjs} +529 -115
- package/dist/chunk-RTXUS5KG.mjs.map +1 -0
- package/dist/{chunk-64LV76OK.js → chunk-SITQ4JWM.js} +23 -2
- package/dist/chunk-SITQ4JWM.js.map +1 -0
- package/dist/{chunk-7XHVZW2L.mjs → chunk-UCISIAOG.mjs} +60 -19
- package/dist/chunk-UCISIAOG.mjs.map +1 -0
- package/dist/{chunk-DKCZA2QI.mjs → chunk-ZZTY3O4N.mjs} +21 -3
- package/dist/chunk-ZZTY3O4N.mjs.map +1 -0
- package/dist/compat.d.mts +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +2 -2
- package/dist/compat.mjs +1 -1
- package/dist/headless.d.mts +25 -7
- package/dist/headless.d.ts +25 -7
- package/dist/headless.js +196 -132
- package/dist/headless.mjs +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +255 -175
- package/dist/index.mjs +5 -5
- package/dist/react.d.mts +230 -8
- package/dist/react.d.ts +230 -8
- package/dist/react.js +78 -42
- package/dist/react.mjs +2 -2
- package/dist/{standard-shim-BTUm7cur.d.mts → standard-shim-CGB88PPO.d.mts} +396 -54
- package/dist/{standard-shim-LsQ97i9T.d.ts → standard-shim-tmnQelaJ.d.ts} +396 -54
- package/dist/{transaction-signer-T-KVQFi8.d.ts → transaction-signer-7NaYmP5w.d.mts} +1 -0
- package/dist/{transaction-signer-T-KVQFi8.d.mts → transaction-signer-7NaYmP5w.d.ts} +1 -0
- package/dist/{walletconnect-D4JN6H2O.js → walletconnect-447EY3OJ.js} +8 -8
- package/dist/{walletconnect-D4JN6H2O.js.map → walletconnect-447EY3OJ.js.map} +1 -1
- package/dist/walletconnect-U455PO4I.mjs +3 -0
- package/dist/{walletconnect-I3PZUBTA.mjs.map → walletconnect-U455PO4I.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-4JT24DIX.js.map +0 -1
- package/dist/chunk-64LV76OK.js.map +0 -1
- package/dist/chunk-6AJJJG5B.js.map +0 -1
- package/dist/chunk-7XHVZW2L.mjs.map +0 -1
- package/dist/chunk-ATYK5OKR.js.map +0 -1
- package/dist/chunk-DKCZA2QI.mjs.map +0 -1
- package/dist/chunk-QOIQBWMP.mjs.map +0 -1
- package/dist/chunk-WGZYKDXF.mjs.map +0 -1
- package/dist/walletconnect-I3PZUBTA.mjs +0 -3
|
@@ -1,35 +1,309 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkBZ2VBJCZ_js = require('./chunk-BZ2VBJCZ.js');
|
|
4
|
+
var chunkSITQ4JWM_js = require('./chunk-SITQ4JWM.js');
|
|
5
|
+
var React2 = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var addresses = require('@solana/addresses');
|
|
8
8
|
var keys = require('@solana/keys');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var logger = chunkSITQ4JWM_js.createLogger("ErrorBoundary");
|
|
15
|
+
var ErrorLogger = class {
|
|
16
|
+
static log(error, errorInfo, context) {
|
|
17
|
+
if (process.env.NODE_ENV === "development" && logger.error(error.message, {
|
|
18
|
+
error,
|
|
19
|
+
errorInfo,
|
|
20
|
+
context
|
|
21
|
+
}), process.env.NODE_ENV === "production" && typeof window < "u")
|
|
22
|
+
try {
|
|
23
|
+
let gtag = window.gtag;
|
|
24
|
+
typeof gtag == "function" && gtag("event", "exception", {
|
|
25
|
+
description: error.message,
|
|
26
|
+
fatal: false,
|
|
27
|
+
custom_map: { error_type: "wallet_error", ...context }
|
|
28
|
+
});
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function classifyError(error) {
|
|
34
|
+
if (chunkSITQ4JWM_js.isConnectorError(error)) {
|
|
35
|
+
let typeMapping = {
|
|
36
|
+
WALLET_NOT_CONNECTED: chunkSITQ4JWM_js.WalletErrorType.CONNECTION_FAILED,
|
|
37
|
+
WALLET_NOT_FOUND: chunkSITQ4JWM_js.WalletErrorType.WALLET_NOT_FOUND,
|
|
38
|
+
CONNECTION_FAILED: chunkSITQ4JWM_js.WalletErrorType.CONNECTION_FAILED,
|
|
39
|
+
USER_REJECTED: chunkSITQ4JWM_js.WalletErrorType.USER_REJECTED,
|
|
40
|
+
RPC_ERROR: chunkSITQ4JWM_js.WalletErrorType.NETWORK_ERROR,
|
|
41
|
+
NETWORK_TIMEOUT: chunkSITQ4JWM_js.WalletErrorType.NETWORK_ERROR,
|
|
42
|
+
SIGNING_FAILED: chunkSITQ4JWM_js.WalletErrorType.TRANSACTION_FAILED,
|
|
43
|
+
SEND_FAILED: chunkSITQ4JWM_js.WalletErrorType.TRANSACTION_FAILED
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
...error,
|
|
47
|
+
type: typeMapping[error.code] || chunkSITQ4JWM_js.WalletErrorType.UNKNOWN_ERROR,
|
|
48
|
+
recoverable: error.recoverable,
|
|
49
|
+
context: error.context
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
let walletError = error;
|
|
53
|
+
if (walletError.type) return walletError;
|
|
54
|
+
let type = chunkSITQ4JWM_js.WalletErrorType.UNKNOWN_ERROR, recoverable = false;
|
|
55
|
+
return error.message.includes("User rejected") || error.message.includes("User denied") ? (type = chunkSITQ4JWM_js.WalletErrorType.USER_REJECTED, recoverable = true) : error.message.includes("Insufficient funds") ? (type = chunkSITQ4JWM_js.WalletErrorType.INSUFFICIENT_FUNDS, recoverable = false) : error.message.includes("Network") || error.message.includes("fetch") ? (type = chunkSITQ4JWM_js.WalletErrorType.NETWORK_ERROR, recoverable = true) : error.message.includes("Wallet not found") || error.message.includes("not installed") ? (type = chunkSITQ4JWM_js.WalletErrorType.WALLET_NOT_FOUND, recoverable = true) : (error.message.includes("Failed to connect") || error.message.includes("Connection")) && (type = chunkSITQ4JWM_js.WalletErrorType.CONNECTION_FAILED, recoverable = true), {
|
|
56
|
+
...error,
|
|
57
|
+
type,
|
|
58
|
+
recoverable,
|
|
59
|
+
context: { originalMessage: error.message }
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var ConnectorErrorBoundary = class extends React2.Component {
|
|
63
|
+
constructor(props) {
|
|
64
|
+
super(props);
|
|
65
|
+
chunkSITQ4JWM_js.__publicField(this, "retryTimeouts", /* @__PURE__ */ new Set());
|
|
66
|
+
chunkSITQ4JWM_js.__publicField(this, "retry", () => {
|
|
67
|
+
let { maxRetries = 3 } = this.props;
|
|
68
|
+
this.state.retryCount >= maxRetries || this.setState((prevState) => ({
|
|
69
|
+
hasError: false,
|
|
70
|
+
error: null,
|
|
71
|
+
errorInfo: null,
|
|
72
|
+
retryCount: prevState.retryCount + 1
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
this.state = {
|
|
76
|
+
hasError: false,
|
|
77
|
+
error: null,
|
|
78
|
+
errorInfo: null,
|
|
79
|
+
errorId: "",
|
|
80
|
+
retryCount: 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static getDerivedStateFromError(error) {
|
|
84
|
+
return {
|
|
85
|
+
hasError: true,
|
|
86
|
+
error,
|
|
87
|
+
errorId: `error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
componentDidCatch(error, errorInfo) {
|
|
91
|
+
this.setState({ errorInfo }), ErrorLogger.log(error, errorInfo, {
|
|
92
|
+
retryCount: this.state.retryCount,
|
|
93
|
+
errorId: this.state.errorId,
|
|
94
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
95
|
+
}), this.props.onError?.(error, errorInfo);
|
|
96
|
+
}
|
|
97
|
+
componentWillUnmount() {
|
|
98
|
+
this.retryTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
if (this.state.hasError && this.state.error) {
|
|
102
|
+
let walletError = classifyError(this.state.error);
|
|
103
|
+
return this.props.fallback ? this.props.fallback(walletError, this.retry) : /* @__PURE__ */ jsxRuntime.jsx(DefaultErrorFallback, { error: walletError, onRetry: this.retry });
|
|
104
|
+
}
|
|
105
|
+
return this.props.children;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function DefaultErrorFallback({ error, onRetry }) {
|
|
109
|
+
let [isPending, startTransition] = React2.useTransition(), [isRetrying, setIsRetrying] = React2.useState(false), handleRetry = React2.useCallback(() => {
|
|
110
|
+
setIsRetrying(true), startTransition(() => {
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
onRetry(), setIsRetrying(false);
|
|
113
|
+
}, 500);
|
|
114
|
+
});
|
|
115
|
+
}, [onRetry]), { title, message, actionText, showRetry } = React2.useMemo(() => {
|
|
116
|
+
switch (error.type) {
|
|
117
|
+
case chunkSITQ4JWM_js.WalletErrorType.USER_REJECTED:
|
|
118
|
+
return {
|
|
119
|
+
title: "Transaction Cancelled",
|
|
120
|
+
message: "You cancelled the transaction. No problem!",
|
|
121
|
+
actionText: "Try Again",
|
|
122
|
+
showRetry: true
|
|
123
|
+
};
|
|
124
|
+
case chunkSITQ4JWM_js.WalletErrorType.WALLET_NOT_FOUND:
|
|
125
|
+
return {
|
|
126
|
+
title: "Wallet Not Found",
|
|
127
|
+
message: "Please install a supported Solana wallet to continue.",
|
|
128
|
+
actionText: "Check Wallets",
|
|
129
|
+
showRetry: true
|
|
130
|
+
};
|
|
131
|
+
case chunkSITQ4JWM_js.WalletErrorType.NETWORK_ERROR:
|
|
132
|
+
return {
|
|
133
|
+
title: "Network Error",
|
|
134
|
+
message: "Having trouble connecting. Please check your internet connection.",
|
|
135
|
+
actionText: "Retry",
|
|
136
|
+
showRetry: true
|
|
137
|
+
};
|
|
138
|
+
case chunkSITQ4JWM_js.WalletErrorType.INSUFFICIENT_FUNDS:
|
|
139
|
+
return {
|
|
140
|
+
title: "Insufficient Funds",
|
|
141
|
+
message: "You don't have enough SOL for this transaction.",
|
|
142
|
+
actionText: "Add Funds",
|
|
143
|
+
showRetry: false
|
|
144
|
+
};
|
|
145
|
+
default:
|
|
146
|
+
return {
|
|
147
|
+
title: "Something went wrong",
|
|
148
|
+
message: "An unexpected error occurred. Please try again.",
|
|
149
|
+
actionText: "Retry",
|
|
150
|
+
showRetry: error.recoverable
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}, [error.type, error.recoverable]);
|
|
154
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
style: {
|
|
158
|
+
display: "flex",
|
|
159
|
+
flexDirection: "column",
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
justifyContent: "center",
|
|
162
|
+
padding: "2rem",
|
|
163
|
+
textAlign: "center",
|
|
164
|
+
borderRadius: "12px",
|
|
165
|
+
border: "1px solid #e5e7eb",
|
|
166
|
+
backgroundColor: "#fafafa",
|
|
167
|
+
maxWidth: "400px",
|
|
168
|
+
margin: "0 auto"
|
|
169
|
+
},
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
style: {
|
|
175
|
+
width: "48px",
|
|
176
|
+
height: "48px",
|
|
177
|
+
borderRadius: "50%",
|
|
178
|
+
backgroundColor: "#fee2e2",
|
|
179
|
+
display: "flex",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
justifyContent: "center",
|
|
182
|
+
marginBottom: "1rem"
|
|
183
|
+
},
|
|
184
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "#dc2626", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" }) })
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
"h3",
|
|
189
|
+
{
|
|
190
|
+
style: {
|
|
191
|
+
margin: "0 0 0.5rem 0",
|
|
192
|
+
fontSize: "1.125rem",
|
|
193
|
+
fontWeight: "600",
|
|
194
|
+
color: "#111827"
|
|
195
|
+
},
|
|
196
|
+
children: title
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
200
|
+
"p",
|
|
201
|
+
{
|
|
202
|
+
style: {
|
|
203
|
+
margin: "0 0 1.5rem 0",
|
|
204
|
+
fontSize: "0.875rem",
|
|
205
|
+
color: "#6b7280",
|
|
206
|
+
lineHeight: "1.5"
|
|
207
|
+
},
|
|
208
|
+
children: message
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "0.75rem", flexWrap: "wrap" }, children: [
|
|
212
|
+
showRetry && /* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
onClick: handleRetry,
|
|
216
|
+
disabled: isPending || isRetrying,
|
|
217
|
+
style: {
|
|
218
|
+
padding: "0.5rem 1rem",
|
|
219
|
+
backgroundColor: "#3b82f6",
|
|
220
|
+
color: "white",
|
|
221
|
+
border: "none",
|
|
222
|
+
borderRadius: "6px",
|
|
223
|
+
fontSize: "0.875rem",
|
|
224
|
+
fontWeight: "500",
|
|
225
|
+
cursor: isPending || isRetrying ? "wait" : "pointer",
|
|
226
|
+
opacity: isPending || isRetrying ? 0.7 : 1,
|
|
227
|
+
transition: "all 0.2s"
|
|
228
|
+
},
|
|
229
|
+
children: isRetrying ? "Retrying..." : actionText
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
233
|
+
"button",
|
|
234
|
+
{
|
|
235
|
+
onClick: () => window.location.reload(),
|
|
236
|
+
style: {
|
|
237
|
+
padding: "0.5rem 1rem",
|
|
238
|
+
backgroundColor: "transparent",
|
|
239
|
+
color: "#6b7280",
|
|
240
|
+
border: "1px solid #d1d5db",
|
|
241
|
+
borderRadius: "6px",
|
|
242
|
+
fontSize: "0.875rem",
|
|
243
|
+
fontWeight: "500",
|
|
244
|
+
cursor: "pointer",
|
|
245
|
+
transition: "all 0.2s"
|
|
246
|
+
},
|
|
247
|
+
children: "Refresh Page"
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }),
|
|
251
|
+
process.env.NODE_ENV === "development" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
252
|
+
"details",
|
|
253
|
+
{
|
|
254
|
+
style: {
|
|
255
|
+
marginTop: "1rem",
|
|
256
|
+
fontSize: "0.75rem",
|
|
257
|
+
color: "#6b7280",
|
|
258
|
+
width: "100%"
|
|
259
|
+
},
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { style: { cursor: "pointer", marginBottom: "0.5rem" }, children: "Error Details" }),
|
|
262
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
+
"pre",
|
|
264
|
+
{
|
|
265
|
+
style: {
|
|
266
|
+
whiteSpace: "pre-wrap",
|
|
267
|
+
wordBreak: "break-all",
|
|
268
|
+
backgroundColor: "#f3f4f6",
|
|
269
|
+
padding: "0.5rem",
|
|
270
|
+
borderRadius: "4px",
|
|
271
|
+
overflow: "auto",
|
|
272
|
+
maxHeight: "200px"
|
|
273
|
+
},
|
|
274
|
+
children: error.message
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
function withErrorBoundary(Component2, errorBoundaryProps) {
|
|
285
|
+
let WrappedComponent = (props) => /* @__PURE__ */ jsxRuntime.jsx(ConnectorErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsx(Component2, { ...props }) });
|
|
286
|
+
return WrappedComponent.displayName = `withErrorBoundary(${Component2.displayName || Component2.name})`, WrappedComponent;
|
|
287
|
+
}
|
|
288
|
+
var WalletConnectContext = React2.createContext(null);
|
|
15
289
|
function WalletConnectProvider({ children }) {
|
|
16
|
-
let [uri, setUriState] =
|
|
17
|
-
|
|
290
|
+
let [uri, setUriState] = React2.useState(null), isMountedRef = React2.useRef(false), pendingUriRef = React2.useRef(null);
|
|
291
|
+
React2.useEffect(() => (isMountedRef.current = true, pendingUriRef.current !== null && (setUriState(pendingUriRef.current), pendingUriRef.current = null), () => {
|
|
18
292
|
isMountedRef.current = false;
|
|
19
293
|
}), []);
|
|
20
|
-
let setUri =
|
|
294
|
+
let setUri = React2.useCallback((newUri) => {
|
|
21
295
|
if (!isMountedRef.current) {
|
|
22
296
|
pendingUriRef.current = newUri;
|
|
23
297
|
return;
|
|
24
298
|
}
|
|
25
299
|
setUriState(newUri);
|
|
26
|
-
}, []), clearUri =
|
|
300
|
+
}, []), clearUri = React2.useCallback(() => {
|
|
27
301
|
pendingUriRef.current = null, isMountedRef.current && setUriState(null);
|
|
28
302
|
}, []);
|
|
29
303
|
return /* @__PURE__ */ jsxRuntime.jsx(WalletConnectContext.Provider, { value: { uri, setUri, clearUri }, children });
|
|
30
304
|
}
|
|
31
305
|
function useWalletConnectUri() {
|
|
32
|
-
let context =
|
|
306
|
+
let context = React2.useContext(WalletConnectContext);
|
|
33
307
|
return context || {
|
|
34
308
|
uri: null,
|
|
35
309
|
setUri: () => {
|
|
@@ -38,22 +312,22 @@ function useWalletConnectUri() {
|
|
|
38
312
|
}
|
|
39
313
|
};
|
|
40
314
|
}
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
var ConnectorContext =
|
|
315
|
+
var logger2 = chunkSITQ4JWM_js.createLogger("ConnectorProvider");
|
|
316
|
+
chunkBZ2VBJCZ_js.installPolyfills();
|
|
317
|
+
var ConnectorContext = React2.createContext(null);
|
|
44
318
|
ConnectorContext.displayName = "ConnectorContext";
|
|
45
319
|
function ConnectorProviderInternal({
|
|
46
320
|
children,
|
|
47
321
|
config,
|
|
48
322
|
mobile
|
|
49
323
|
}) {
|
|
50
|
-
let clientRef =
|
|
324
|
+
let clientRef = React2.useRef(null), client = React2__default.default.useCallback(() => {
|
|
51
325
|
if (!clientRef.current)
|
|
52
326
|
try {
|
|
53
|
-
clientRef.current = new
|
|
327
|
+
clientRef.current = new chunkBZ2VBJCZ_js.ConnectorClient(config), typeof window < "u" && (window.__connectorClient = clientRef.current), config?.debug && logger2.info("Client initialized successfully");
|
|
54
328
|
} catch (error) {
|
|
55
329
|
let err = error;
|
|
56
|
-
|
|
330
|
+
logger2.error("Failed to initialize client", { error: err });
|
|
57
331
|
let extendedConfig = config;
|
|
58
332
|
return extendedConfig?.errorBoundary?.onError && extendedConfig.errorBoundary.onError(err, {
|
|
59
333
|
componentStack: "client-initialization",
|
|
@@ -62,7 +336,7 @@ function ConnectorProviderInternal({
|
|
|
62
336
|
}
|
|
63
337
|
return clientRef.current;
|
|
64
338
|
}, [config])();
|
|
65
|
-
return
|
|
339
|
+
return React2__default.default.useEffect(() => {
|
|
66
340
|
let currentClient = clientRef.current;
|
|
67
341
|
if (currentClient) {
|
|
68
342
|
let privateClient = currentClient;
|
|
@@ -71,7 +345,7 @@ function ConnectorProviderInternal({
|
|
|
71
345
|
return () => {
|
|
72
346
|
typeof window < "u" && (window.__connectorClient = void 0), currentClient && typeof currentClient.destroy == "function" && currentClient.destroy();
|
|
73
347
|
};
|
|
74
|
-
}, []),
|
|
348
|
+
}, []), React2__default.default.useEffect(() => {
|
|
75
349
|
if (!mobile) return;
|
|
76
350
|
let cancelled = false;
|
|
77
351
|
return (async () => {
|
|
@@ -110,7 +384,7 @@ function ConnectorProvider({
|
|
|
110
384
|
}) {
|
|
111
385
|
let errorBoundaryConfig = config?.errorBoundary;
|
|
112
386
|
return errorBoundaryConfig?.enabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
-
|
|
387
|
+
ConnectorErrorBoundary,
|
|
114
388
|
{
|
|
115
389
|
maxRetries: errorBoundaryConfig.maxRetries ?? 3,
|
|
116
390
|
onError: errorBoundaryConfig.onError,
|
|
@@ -120,38 +394,58 @@ function ConnectorProvider({
|
|
|
120
394
|
) : /* @__PURE__ */ jsxRuntime.jsx(ConnectorProviderInternal, { config, mobile, children });
|
|
121
395
|
}
|
|
122
396
|
function useConnector() {
|
|
123
|
-
let client =
|
|
397
|
+
let client = React2.useContext(ConnectorContext);
|
|
124
398
|
if (!client)
|
|
125
399
|
throw new Error(
|
|
126
400
|
"useConnector must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use connector hooks."
|
|
127
401
|
);
|
|
128
|
-
let { uri: walletConnectUri, clearUri: clearWalletConnectUri } = useWalletConnectUri(), state =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
), methods =
|
|
402
|
+
let { uri: walletConnectUri, clearUri: clearWalletConnectUri } = useWalletConnectUri(), state = React2.useSyncExternalStore(
|
|
403
|
+
React2__default.default.useCallback((cb) => client.subscribe(cb), [client]),
|
|
404
|
+
React2__default.default.useCallback(() => client.getSnapshot(), [client]),
|
|
405
|
+
React2__default.default.useCallback(() => client.getSnapshot(), [client])
|
|
406
|
+
), methods = React2.useMemo(
|
|
133
407
|
() => ({
|
|
408
|
+
// Legacy (kept for backwards compatibility)
|
|
134
409
|
select: client.select.bind(client),
|
|
135
410
|
disconnect: client.disconnect.bind(client),
|
|
136
|
-
selectAccount: client.selectAccount.bind(client)
|
|
411
|
+
selectAccount: client.selectAccount.bind(client),
|
|
412
|
+
// vNext
|
|
413
|
+
connectWallet: client.connectWallet.bind(client),
|
|
414
|
+
disconnectWallet: client.disconnectWallet.bind(client)
|
|
137
415
|
}),
|
|
138
416
|
[client]
|
|
139
|
-
)
|
|
140
|
-
|
|
417
|
+
), vNextFields = React2.useMemo(() => {
|
|
418
|
+
let walletStatus = state.wallet, isConnected2 = walletStatus.status === "connected", isConnecting2 = walletStatus.status === "connecting", isError = walletStatus.status === "error", connectorId = null, account = null, sessionAccounts = [], walletError = null;
|
|
419
|
+
walletStatus.status === "connected" ? (connectorId = walletStatus.session.connectorId, account = walletStatus.session.selectedAccount.address, sessionAccounts = walletStatus.session.accounts) : walletStatus.status === "connecting" ? connectorId = walletStatus.connectorId : walletStatus.status === "error" && (walletError = walletStatus.error, connectorId = walletStatus.connectorId ?? null);
|
|
420
|
+
let connector = connectorId ? state.connectors.find((c) => c.id === connectorId) ?? null : null;
|
|
421
|
+
return {
|
|
422
|
+
walletStatus,
|
|
423
|
+
isConnected: isConnected2,
|
|
424
|
+
isConnecting: isConnecting2,
|
|
425
|
+
isError,
|
|
426
|
+
walletError,
|
|
427
|
+
account,
|
|
428
|
+
sessionAccounts,
|
|
429
|
+
connectorId,
|
|
430
|
+
connector
|
|
431
|
+
};
|
|
432
|
+
}, [state.wallet, state.connectors]);
|
|
433
|
+
return React2.useMemo(
|
|
141
434
|
() => ({
|
|
142
435
|
...state,
|
|
143
436
|
...methods,
|
|
437
|
+
...vNextFields,
|
|
144
438
|
walletConnectUri,
|
|
145
439
|
clearWalletConnectUri
|
|
146
440
|
}),
|
|
147
|
-
[state, methods, walletConnectUri, clearWalletConnectUri]
|
|
441
|
+
[state, methods, vNextFields, walletConnectUri, clearWalletConnectUri]
|
|
148
442
|
);
|
|
149
443
|
}
|
|
150
444
|
function useConnectorClient() {
|
|
151
|
-
return
|
|
445
|
+
return React2.useContext(ConnectorContext);
|
|
152
446
|
}
|
|
153
447
|
function AppProviderInner({ children, connectorConfig, mobile, providers = [] }) {
|
|
154
|
-
let { setUri, clearUri } = useWalletConnectUri(), enhancedConfig =
|
|
448
|
+
let { setUri, clearUri } = useWalletConnectUri(), enhancedConfig = React2.useMemo(() => {
|
|
155
449
|
if (!connectorConfig?.walletConnect?.enabled)
|
|
156
450
|
return connectorConfig;
|
|
157
451
|
let wcConfig = connectorConfig.walletConnect;
|
|
@@ -176,18 +470,104 @@ function AppProvider(props) {
|
|
|
176
470
|
return props.connectorConfig?.walletConnect?.enabled ? /* @__PURE__ */ jsxRuntime.jsx(WalletConnectProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AppProviderInner, { ...props }) }) : /* @__PURE__ */ jsxRuntime.jsx(AppProviderInner, { ...props });
|
|
177
471
|
}
|
|
178
472
|
var UnifiedProvider = AppProvider;
|
|
473
|
+
function useWallet() {
|
|
474
|
+
let client = React2.useContext(ConnectorContext);
|
|
475
|
+
if (!client)
|
|
476
|
+
throw new Error(
|
|
477
|
+
"useWallet must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use wallet hooks."
|
|
478
|
+
);
|
|
479
|
+
let walletStatus = React2.useSyncExternalStore(
|
|
480
|
+
React2.useCallback((cb) => client.subscribe(cb), [client]),
|
|
481
|
+
React2.useCallback(() => client.getSnapshot().wallet, [client]),
|
|
482
|
+
React2.useCallback(() => client.getSnapshot().wallet, [client])
|
|
483
|
+
);
|
|
484
|
+
return React2.useMemo(() => {
|
|
485
|
+
let status = walletStatus.status, isConnected2 = status === "connected", isConnecting2 = status === "connecting", isError = status === "error", connectorId = null, account = null, accounts = [], session = null, error = null;
|
|
486
|
+
return walletStatus.status === "connected" ? (connectorId = walletStatus.session.connectorId, account = walletStatus.session.selectedAccount.address, accounts = walletStatus.session.accounts, session = walletStatus.session) : walletStatus.status === "connecting" ? connectorId = walletStatus.connectorId : walletStatus.status === "error" && (error = walletStatus.error, connectorId = walletStatus.connectorId ?? null), {
|
|
487
|
+
status,
|
|
488
|
+
walletStatus,
|
|
489
|
+
isConnected: isConnected2,
|
|
490
|
+
isConnecting: isConnecting2,
|
|
491
|
+
isError,
|
|
492
|
+
error,
|
|
493
|
+
connectorId,
|
|
494
|
+
account,
|
|
495
|
+
accounts,
|
|
496
|
+
session
|
|
497
|
+
};
|
|
498
|
+
}, [walletStatus]);
|
|
499
|
+
}
|
|
500
|
+
function useWalletConnectors() {
|
|
501
|
+
let client = React2.useContext(ConnectorContext);
|
|
502
|
+
if (!client)
|
|
503
|
+
throw new Error(
|
|
504
|
+
"useWalletConnectors must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use wallet hooks."
|
|
505
|
+
);
|
|
506
|
+
return React2.useSyncExternalStore(
|
|
507
|
+
React2.useCallback((cb) => client.subscribe(cb), [client]),
|
|
508
|
+
React2.useCallback(() => client.getSnapshot().connectors, [client]),
|
|
509
|
+
React2.useCallback(() => client.getSnapshot().connectors, [client])
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
function useConnectWallet() {
|
|
513
|
+
let client = React2.useContext(ConnectorContext), [isConnecting2, setIsConnecting] = React2.useState(false), [error, setError] = React2.useState(null);
|
|
514
|
+
if (!client)
|
|
515
|
+
throw new Error(
|
|
516
|
+
"useConnectWallet must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use wallet hooks."
|
|
517
|
+
);
|
|
518
|
+
let connect = React2.useCallback(
|
|
519
|
+
async (connectorId, options) => {
|
|
520
|
+
setIsConnecting(true), setError(null);
|
|
521
|
+
try {
|
|
522
|
+
await client.connectWallet(connectorId, options);
|
|
523
|
+
} catch (e) {
|
|
524
|
+
let connectError = e instanceof Error ? e : new Error(String(e));
|
|
525
|
+
throw setError(connectError), connectError;
|
|
526
|
+
} finally {
|
|
527
|
+
setIsConnecting(false);
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
[client]
|
|
531
|
+
), resetError = React2.useCallback(() => {
|
|
532
|
+
setError(null);
|
|
533
|
+
}, []);
|
|
534
|
+
return {
|
|
535
|
+
connect,
|
|
536
|
+
isConnecting: isConnecting2,
|
|
537
|
+
error,
|
|
538
|
+
resetError
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function useDisconnectWallet() {
|
|
542
|
+
let client = React2.useContext(ConnectorContext), [isDisconnecting, setIsDisconnecting] = React2.useState(false);
|
|
543
|
+
if (!client)
|
|
544
|
+
throw new Error(
|
|
545
|
+
"useDisconnectWallet must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use wallet hooks."
|
|
546
|
+
);
|
|
547
|
+
return {
|
|
548
|
+
disconnect: React2.useCallback(async () => {
|
|
549
|
+
setIsDisconnecting(true);
|
|
550
|
+
try {
|
|
551
|
+
await client.disconnectWallet();
|
|
552
|
+
} finally {
|
|
553
|
+
setIsDisconnecting(false);
|
|
554
|
+
}
|
|
555
|
+
}, [client]),
|
|
556
|
+
isDisconnecting
|
|
557
|
+
};
|
|
558
|
+
}
|
|
179
559
|
function useCluster() {
|
|
180
560
|
let { cluster, clusters } = useConnector(), client = useConnectorClient();
|
|
181
561
|
if (!client)
|
|
182
562
|
throw new Error("useCluster must be used within ConnectorProvider");
|
|
183
|
-
let setCluster =
|
|
563
|
+
let setCluster = React2.useMemo(
|
|
184
564
|
() => async (id) => {
|
|
185
565
|
await client.setCluster(id);
|
|
186
566
|
},
|
|
187
567
|
[client]
|
|
188
568
|
);
|
|
189
|
-
return
|
|
190
|
-
let isMainnet = cluster ?
|
|
569
|
+
return React2.useMemo(() => {
|
|
570
|
+
let isMainnet = cluster ? chunkBZ2VBJCZ_js.isMainnetCluster(cluster) : false, isDevnet = cluster ? chunkBZ2VBJCZ_js.isDevnetCluster(cluster) : false, isTestnet = cluster ? chunkBZ2VBJCZ_js.isTestnetCluster(cluster) : false, isLocal = cluster ? chunkBZ2VBJCZ_js.isLocalCluster(cluster) : false, explorerUrl = cluster ? chunkBZ2VBJCZ_js.getClusterExplorerUrl(cluster) : "", type = cluster ? chunkBZ2VBJCZ_js.getClusterType(cluster) : null;
|
|
191
571
|
return {
|
|
192
572
|
cluster,
|
|
193
573
|
clusters,
|
|
@@ -202,10 +582,10 @@ function useCluster() {
|
|
|
202
582
|
}, [cluster, clusters, setCluster]);
|
|
203
583
|
}
|
|
204
584
|
function useAccount() {
|
|
205
|
-
let { selectedAccount, accounts, connected, selectAccount } = useConnector(), [copied, setCopied] =
|
|
585
|
+
let { selectedAccount, accounts, connected, selectAccount } = useConnector(), [copied, setCopied] = React2.useState(false), copyTimeoutRef = React2__default.default.useRef(void 0), account = React2.useMemo(
|
|
206
586
|
() => accounts.find((a) => a.address === selectedAccount) ?? null,
|
|
207
587
|
[accounts, selectedAccount]
|
|
208
|
-
), formatted =
|
|
588
|
+
), formatted = React2.useMemo(() => selectedAccount ? chunkBZ2VBJCZ_js.formatAddress(selectedAccount) : "", [selectedAccount]), copy = React2.useCallback(async () => selectedAccount ? (copyTimeoutRef.current && clearTimeout(copyTimeoutRef.current), await chunkBZ2VBJCZ_js.copyAddressToClipboard(selectedAccount, {
|
|
209
589
|
onSuccess: () => {
|
|
210
590
|
setCopied(true), copyTimeoutRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
211
591
|
}
|
|
@@ -214,9 +594,9 @@ function useAccount() {
|
|
|
214
594
|
error: "empty_value" /* EMPTY_VALUE */,
|
|
215
595
|
errorMessage: "No account selected"
|
|
216
596
|
}, [selectedAccount]);
|
|
217
|
-
return
|
|
597
|
+
return React2__default.default.useEffect(() => () => {
|
|
218
598
|
copyTimeoutRef.current && clearTimeout(copyTimeoutRef.current);
|
|
219
|
-
}, []),
|
|
599
|
+
}, []), React2.useMemo(
|
|
220
600
|
() => ({
|
|
221
601
|
address: selectedAccount,
|
|
222
602
|
account,
|
|
@@ -231,17 +611,18 @@ function useAccount() {
|
|
|
231
611
|
);
|
|
232
612
|
}
|
|
233
613
|
function useWalletInfo() {
|
|
234
|
-
let { selectedWallet, wallets, connected, connecting } = useConnector(), mappedWallets =
|
|
614
|
+
let { selectedWallet, wallets, connected, connecting } = useConnector(), mappedWallets = React2.useMemo(
|
|
235
615
|
() => wallets.map(
|
|
236
616
|
(walletInfo) => ({
|
|
237
617
|
name: walletInfo.wallet.name,
|
|
618
|
+
connectorId: chunkBZ2VBJCZ_js.createConnectorId(walletInfo.wallet.name),
|
|
238
619
|
icon: walletInfo.wallet.icon,
|
|
239
620
|
installed: walletInfo.installed,
|
|
240
621
|
connectable: walletInfo.connectable
|
|
241
622
|
})
|
|
242
623
|
),
|
|
243
624
|
[wallets]
|
|
244
|
-
), selectedWalletInfo =
|
|
625
|
+
), selectedWalletInfo = React2.useMemo(() => {
|
|
245
626
|
if (!selectedWallet)
|
|
246
627
|
return {
|
|
247
628
|
name: null,
|
|
@@ -257,7 +638,7 @@ function useWalletInfo() {
|
|
|
257
638
|
connectable: walletInfo?.connectable ?? false
|
|
258
639
|
};
|
|
259
640
|
}, [selectedWallet, wallets]);
|
|
260
|
-
return
|
|
641
|
+
return React2.useMemo(
|
|
261
642
|
() => ({
|
|
262
643
|
...selectedWalletInfo,
|
|
263
644
|
connected,
|
|
@@ -268,10 +649,10 @@ function useWalletInfo() {
|
|
|
268
649
|
);
|
|
269
650
|
}
|
|
270
651
|
function useTransactionSigner() {
|
|
271
|
-
let { selectedWallet, selectedAccount, accounts, cluster, connected } = useConnector(), client = useConnectorClient(), account =
|
|
652
|
+
let { selectedWallet, selectedAccount, accounts, cluster, connected } = useConnector(), client = useConnectorClient(), account = React2.useMemo(
|
|
272
653
|
() => accounts.find((a) => a.address === selectedAccount)?.raw ?? null,
|
|
273
654
|
[accounts, selectedAccount]
|
|
274
|
-
), signer =
|
|
655
|
+
), signer = React2.useMemo(() => !connected || !selectedWallet || !account ? null : chunkBZ2VBJCZ_js.createTransactionSigner({
|
|
275
656
|
wallet: selectedWallet,
|
|
276
657
|
account,
|
|
277
658
|
cluster: cluster ?? void 0,
|
|
@@ -280,7 +661,7 @@ function useTransactionSigner() {
|
|
|
280
661
|
client.emitEvent(event);
|
|
281
662
|
}
|
|
282
663
|
} : void 0
|
|
283
|
-
}), [connected, selectedWallet, account, cluster, client]), capabilities =
|
|
664
|
+
}), [connected, selectedWallet, account, cluster, client]), capabilities = React2.useMemo(
|
|
284
665
|
() => signer?.getCapabilities() ?? {
|
|
285
666
|
canSign: false,
|
|
286
667
|
canSend: false,
|
|
@@ -299,27 +680,27 @@ function useTransactionSigner() {
|
|
|
299
680
|
function useKitTransactionSigner() {
|
|
300
681
|
let { signer: connectorSigner, ready } = useTransactionSigner();
|
|
301
682
|
return {
|
|
302
|
-
signer:
|
|
683
|
+
signer: React2.useMemo(() => connectorSigner ? chunkBZ2VBJCZ_js.createKitTransactionSigner(connectorSigner) : null, [connectorSigner]),
|
|
303
684
|
ready
|
|
304
685
|
};
|
|
305
686
|
}
|
|
306
687
|
var useGillTransactionSigner = useKitTransactionSigner;
|
|
307
|
-
var
|
|
688
|
+
var logger3 = chunkSITQ4JWM_js.createLogger("useSolanaClient");
|
|
308
689
|
function useSolanaClient() {
|
|
309
|
-
let { type } = useCluster(), connectorClient = useConnectorClient(), client =
|
|
690
|
+
let { type } = useCluster(), connectorClient = useConnectorClient(), client = React2.useMemo(() => {
|
|
310
691
|
if (!type || !connectorClient) return null;
|
|
311
692
|
try {
|
|
312
693
|
let rpcUrl = connectorClient.getRpcUrl();
|
|
313
|
-
return rpcUrl ?
|
|
694
|
+
return rpcUrl ? chunkSITQ4JWM_js.createSolanaClient({
|
|
314
695
|
urlOrMoniker: rpcUrl
|
|
315
|
-
}) : type !== "custom" ?
|
|
696
|
+
}) : type !== "custom" ? chunkSITQ4JWM_js.createSolanaClient({
|
|
316
697
|
urlOrMoniker: type
|
|
317
698
|
}) : null;
|
|
318
699
|
} catch (error) {
|
|
319
|
-
return
|
|
700
|
+
return logger3.error("Failed to create Solana client", { error }), null;
|
|
320
701
|
}
|
|
321
702
|
}, [type, connectorClient]);
|
|
322
|
-
return
|
|
703
|
+
return React2.useMemo(
|
|
323
704
|
() => ({
|
|
324
705
|
client,
|
|
325
706
|
ready: !!client,
|
|
@@ -330,11 +711,11 @@ function useSolanaClient() {
|
|
|
330
711
|
}
|
|
331
712
|
var useGillSolanaClient = useSolanaClient;
|
|
332
713
|
function useTransactionPreparer() {
|
|
333
|
-
let { client, ready } = useSolanaClient(), prepare =
|
|
714
|
+
let { client, ready } = useSolanaClient(), prepare = React2.useCallback(
|
|
334
715
|
async (transaction, options = {}) => {
|
|
335
716
|
if (!client)
|
|
336
|
-
throw new
|
|
337
|
-
return
|
|
717
|
+
throw new chunkSITQ4JWM_js.NetworkError("RPC_ERROR", "Solana client not available. Cannot prepare transaction.");
|
|
718
|
+
return chunkSITQ4JWM_js.prepareTransaction({
|
|
338
719
|
transaction,
|
|
339
720
|
rpc: client.rpc,
|
|
340
721
|
computeUnitLimitMultiplier: options.computeUnitLimitMultiplier,
|
|
@@ -344,7 +725,7 @@ function useTransactionPreparer() {
|
|
|
344
725
|
},
|
|
345
726
|
[client]
|
|
346
727
|
);
|
|
347
|
-
return
|
|
728
|
+
return React2.useMemo(
|
|
348
729
|
() => ({
|
|
349
730
|
prepare,
|
|
350
731
|
ready
|
|
@@ -483,13 +864,13 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
483
864
|
refetchOnMount = "stale",
|
|
484
865
|
refetchIntervalMs = false,
|
|
485
866
|
select
|
|
486
|
-
} = options, queryFnRef =
|
|
867
|
+
} = options, queryFnRef = React2.useRef(queryFn);
|
|
487
868
|
queryFnRef.current = queryFn;
|
|
488
|
-
let stableQueryFn =
|
|
869
|
+
let stableQueryFn = React2.useCallback((signal) => queryFnRef.current(signal), []), subscribe = React2.useCallback(
|
|
489
870
|
(onChange) => key ? subscribeSharedQuery(key, onChange, cacheTimeMs) : () => {
|
|
490
871
|
},
|
|
491
872
|
[key, cacheTimeMs]
|
|
492
|
-
), emptySnapshot =
|
|
873
|
+
), emptySnapshot = React2.useMemo(
|
|
493
874
|
() => ({
|
|
494
875
|
data: void 0,
|
|
495
876
|
error: null,
|
|
@@ -498,8 +879,8 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
498
879
|
isFetching: false
|
|
499
880
|
}),
|
|
500
881
|
[]
|
|
501
|
-
), getSnapshot =
|
|
502
|
-
|
|
882
|
+
), getSnapshot = React2.useCallback(() => key ? getOrCreateEntry(key).snapshot : emptySnapshot, [key, emptySnapshot]), snapshot = React2.useSyncExternalStore(subscribe, getSnapshot, getSnapshot), selectedData = React2.useMemo(() => select ? select(snapshot.data) : snapshot.data, [snapshot.data, select]), prevSelectedRef = React2.useRef(selectedData), stableSelectedData = React2.useMemo(() => Object.is(prevSelectedRef.current, selectedData) ? prevSelectedRef.current : (prevSelectedRef.current = selectedData, selectedData), [selectedData]), fetchedKeyRef = React2.useRef(null);
|
|
883
|
+
React2.useEffect(() => {
|
|
503
884
|
if (!key || !enabled) {
|
|
504
885
|
fetchedKeyRef.current = null;
|
|
505
886
|
return;
|
|
@@ -513,7 +894,7 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
513
894
|
force: refetchOnMount === true
|
|
514
895
|
}).catch(() => {
|
|
515
896
|
})) : fetchedKeyRef.current = key;
|
|
516
|
-
}, [key, enabled, staleTimeMs, refetchOnMount, stableQueryFn]),
|
|
897
|
+
}, [key, enabled, staleTimeMs, refetchOnMount, stableQueryFn]), React2.useEffect(() => {
|
|
517
898
|
if (!key || !enabled || refetchIntervalMs === false) return;
|
|
518
899
|
let entry = getOrCreateEntry(key);
|
|
519
900
|
entry.queryFn = stableQueryFn;
|
|
@@ -523,7 +904,7 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
523
904
|
count <= 1 ? entry.intervalCounts.delete(refetchIntervalMs) : entry.intervalCounts.set(refetchIntervalMs, count - 1), startOrRestartInterval(key, entry);
|
|
524
905
|
};
|
|
525
906
|
}, [key, enabled, refetchIntervalMs, stableQueryFn]);
|
|
526
|
-
let refetch =
|
|
907
|
+
let refetch = React2.useCallback(
|
|
527
908
|
async (refetchOptions) => {
|
|
528
909
|
if (key)
|
|
529
910
|
return fetchSharedQuery(key, stableQueryFn, {
|
|
@@ -532,12 +913,12 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
532
913
|
});
|
|
533
914
|
},
|
|
534
915
|
[key, stableQueryFn]
|
|
535
|
-
), abort =
|
|
916
|
+
), abort = React2.useCallback(() => {
|
|
536
917
|
if (!key) return;
|
|
537
918
|
let entry = store.get(key);
|
|
538
919
|
entry?.abortController && entry.abortController.abort();
|
|
539
920
|
}, [key]);
|
|
540
|
-
return
|
|
921
|
+
return React2.useMemo(
|
|
541
922
|
() => ({
|
|
542
923
|
data: stableSelectedData,
|
|
543
924
|
error: snapshot.error,
|
|
@@ -616,11 +997,11 @@ function useWalletAssets(options = {}) {
|
|
|
616
997
|
refetchIntervalMs = false,
|
|
617
998
|
client: clientOverride,
|
|
618
999
|
select
|
|
619
|
-
} = options, { address, connected } = useAccount(), { client: providerClient } = useSolanaClient(), rpcClient = clientOverride ?? providerClient, key =
|
|
1000
|
+
} = options, { address, connected } = useAccount(), { client: providerClient } = useSolanaClient(), rpcClient = clientOverride ?? providerClient, key = React2.useMemo(() => {
|
|
620
1001
|
if (!enabled || !connected || !address || !rpcClient) return null;
|
|
621
1002
|
let rpcUrl = rpcClient.urlOrMoniker instanceof URL ? rpcClient.urlOrMoniker.toString() : String(rpcClient.urlOrMoniker);
|
|
622
1003
|
return getWalletAssetsQueryKey(rpcUrl, address);
|
|
623
|
-
}, [enabled, connected, address, rpcClient]), queryFn =
|
|
1004
|
+
}, [enabled, connected, address, rpcClient]), queryFn = React2.useCallback(
|
|
624
1005
|
async (signal) => {
|
|
625
1006
|
if (!connected || !address || !rpcClient)
|
|
626
1007
|
return { lamports: 0n, tokenAccounts: [] };
|
|
@@ -664,7 +1045,7 @@ function useWalletAssets(options = {}) {
|
|
|
664
1045
|
select
|
|
665
1046
|
}
|
|
666
1047
|
), isLoading = status === "loading" || status === "idle";
|
|
667
|
-
return
|
|
1048
|
+
return React2.useMemo(
|
|
668
1049
|
() => ({
|
|
669
1050
|
data,
|
|
670
1051
|
isLoading,
|
|
@@ -684,7 +1065,7 @@ function getBalanceQueryKey(rpcUrl, address) {
|
|
|
684
1065
|
}
|
|
685
1066
|
var LAMPORTS_PER_SOL2 = 1000000000n;
|
|
686
1067
|
function formatTokenAccount(account) {
|
|
687
|
-
let formatted =
|
|
1068
|
+
let formatted = chunkBZ2VBJCZ_js.formatBigIntBalance(account.amount, account.decimals, {
|
|
688
1069
|
maxDecimals: Math.min(account.decimals, 6)
|
|
689
1070
|
});
|
|
690
1071
|
return {
|
|
@@ -728,13 +1109,13 @@ function useBalance(options = {}) {
|
|
|
728
1109
|
refetchIntervalMs: autoRefresh ? refreshInterval : false,
|
|
729
1110
|
client: clientOverride,
|
|
730
1111
|
select: selectBalance
|
|
731
|
-
}), lamports = data?.lamports ?? 0n, tokens = data?.tokens ?? [], solBalance =
|
|
1112
|
+
}), lamports = data?.lamports ?? 0n, tokens = data?.tokens ?? [], solBalance = React2.useMemo(() => Number(lamports) / Number(LAMPORTS_PER_SOL2), [lamports]), formattedSol = React2.useMemo(() => chunkBZ2VBJCZ_js.formatLamportsToSolSafe(lamports, { maxDecimals: 4, suffix: true }), [lamports]), visibleError = updatedAt ? null : error, refetch = React2.useCallback(
|
|
732
1113
|
async (opts) => {
|
|
733
1114
|
await sharedRefetch(opts);
|
|
734
1115
|
},
|
|
735
1116
|
[sharedRefetch]
|
|
736
1117
|
);
|
|
737
|
-
return
|
|
1118
|
+
return React2.useMemo(
|
|
738
1119
|
() => ({
|
|
739
1120
|
solBalance,
|
|
740
1121
|
lamports,
|
|
@@ -1109,7 +1490,7 @@ function useTransactions(options = {}) {
|
|
|
1109
1490
|
// 5 minutes
|
|
1110
1491
|
refetchOnMount = "stale",
|
|
1111
1492
|
client: clientOverride
|
|
1112
|
-
} = options, { address, connected } = useAccount(), { cluster } = useCluster(), { client: providerClient } = useSolanaClient(), connectorClient = useConnectorClient(), [paginatedTransactions, setPaginatedTransactions] =
|
|
1493
|
+
} = options, { address, connected } = useAccount(), { cluster } = useCluster(), { client: providerClient } = useSolanaClient(), connectorClient = useConnectorClient(), [paginatedTransactions, setPaginatedTransactions] = React2.useState([]), [isPaginationLoading, setIsPaginationLoading] = React2.useState(false), [hasMore, setHasMore] = React2.useState(true), beforeSignatureRef = React2.useRef(void 0), rpcClient = clientOverride ?? providerClient, connectorConfig = connectorClient?.getConfig(), imageProxy = connectorConfig?.imageProxy, programLabels = connectorConfig?.programLabels, parseTransaction = React2.useCallback(
|
|
1113
1494
|
(tx, walletAddress, sig, blockTime, slot, err, explorerUrl) => {
|
|
1114
1495
|
let { date, time } = formatDate(blockTime), baseInfo = {
|
|
1115
1496
|
signature: sig,
|
|
@@ -1160,15 +1541,15 @@ function useTransactions(options = {}) {
|
|
|
1160
1541
|
}
|
|
1161
1542
|
},
|
|
1162
1543
|
[programLabels]
|
|
1163
|
-
), key =
|
|
1544
|
+
), key = React2.useMemo(() => {
|
|
1164
1545
|
if (!enabled || !connected || !address || !rpcClient || !cluster) return null;
|
|
1165
1546
|
let rpcUrl = rpcClient.urlOrMoniker instanceof URL ? rpcClient.urlOrMoniker.toString() : String(rpcClient.urlOrMoniker);
|
|
1166
1547
|
return getTransactionsQueryKey({ rpcUrl, address, clusterId: cluster.id, limit, fetchDetails });
|
|
1167
1548
|
}, [enabled, connected, address, rpcClient, cluster, limit, fetchDetails]);
|
|
1168
|
-
|
|
1549
|
+
React2.useEffect(() => {
|
|
1169
1550
|
beforeSignatureRef.current = void 0, setPaginatedTransactions([]), setIsPaginationLoading(false), setHasMore(true);
|
|
1170
1551
|
}, [key]);
|
|
1171
|
-
let fetchAndEnrichTransactions =
|
|
1552
|
+
let fetchAndEnrichTransactions = React2.useCallback(
|
|
1172
1553
|
async (beforeSignature, currentCluster, signal) => {
|
|
1173
1554
|
if (!rpcClient || !address)
|
|
1174
1555
|
return { transactions: [], hasMore: false };
|
|
@@ -1197,7 +1578,7 @@ function useTransactions(options = {}) {
|
|
|
1197
1578
|
blockTimeNum,
|
|
1198
1579
|
Number(sig.slot),
|
|
1199
1580
|
sig.err,
|
|
1200
|
-
|
|
1581
|
+
chunkBZ2VBJCZ_js.getTransactionUrl(String(sig.signature), currentCluster)
|
|
1201
1582
|
);
|
|
1202
1583
|
});
|
|
1203
1584
|
} else
|
|
@@ -1212,7 +1593,7 @@ function useTransactions(options = {}) {
|
|
|
1212
1593
|
type: "unknown",
|
|
1213
1594
|
formattedDate: date,
|
|
1214
1595
|
formattedTime: time,
|
|
1215
|
-
explorerUrl:
|
|
1596
|
+
explorerUrl: chunkBZ2VBJCZ_js.getTransactionUrl(String(sig.signature), currentCluster)
|
|
1216
1597
|
};
|
|
1217
1598
|
});
|
|
1218
1599
|
let mintsToFetch = [
|
|
@@ -1226,7 +1607,7 @@ function useTransactions(options = {}) {
|
|
|
1226
1607
|
throwIfAborted(signal);
|
|
1227
1608
|
let tokenMetadata = await fetchTransactionTokenMetadata(mintsToFetch, {
|
|
1228
1609
|
signal,
|
|
1229
|
-
cluster:
|
|
1610
|
+
cluster: chunkBZ2VBJCZ_js.getClusterType(currentCluster)
|
|
1230
1611
|
});
|
|
1231
1612
|
tokenMetadata.size > 0 && (newTransactions = newTransactions.map((tx) => {
|
|
1232
1613
|
let enrichedTx = { ...tx };
|
|
@@ -1270,7 +1651,7 @@ function useTransactions(options = {}) {
|
|
|
1270
1651
|
};
|
|
1271
1652
|
},
|
|
1272
1653
|
[rpcClient, address, limit, fetchDetails, detailsConcurrency, parseTransaction, imageProxy]
|
|
1273
|
-
), queryFn =
|
|
1654
|
+
), queryFn = React2.useCallback(
|
|
1274
1655
|
async (signal) => {
|
|
1275
1656
|
if (!connected || !address || !rpcClient || !cluster)
|
|
1276
1657
|
return [];
|
|
@@ -1293,10 +1674,10 @@ function useTransactions(options = {}) {
|
|
|
1293
1674
|
refetchOnMount,
|
|
1294
1675
|
refetchIntervalMs: autoRefresh ? refreshInterval : false
|
|
1295
1676
|
});
|
|
1296
|
-
|
|
1677
|
+
React2.useEffect(() => {
|
|
1297
1678
|
initialTransactions && (beforeSignatureRef.current = initialTransactions.length ? initialTransactions[initialTransactions.length - 1].signature : void 0, setHasMore(initialTransactions.length === limit), setPaginatedTransactions((prev) => prev.length ? [] : prev));
|
|
1298
1679
|
}, [initialTransactions, limit]);
|
|
1299
|
-
let loadMoreFn =
|
|
1680
|
+
let loadMoreFn = React2.useCallback(async () => {
|
|
1300
1681
|
if (!(!hasMore || isPaginationLoading || !cluster)) {
|
|
1301
1682
|
setIsPaginationLoading(true);
|
|
1302
1683
|
try {
|
|
@@ -1308,13 +1689,13 @@ function useTransactions(options = {}) {
|
|
|
1308
1689
|
setIsPaginationLoading(false);
|
|
1309
1690
|
}
|
|
1310
1691
|
}
|
|
1311
|
-
}, [hasMore, isPaginationLoading, cluster, fetchAndEnrichTransactions]), refetch =
|
|
1692
|
+
}, [hasMore, isPaginationLoading, cluster, fetchAndEnrichTransactions]), refetch = React2.useCallback(
|
|
1312
1693
|
async (opts) => {
|
|
1313
1694
|
beforeSignatureRef.current = void 0, setPaginatedTransactions([]), setHasMore(true), await sharedRefetch(opts);
|
|
1314
1695
|
},
|
|
1315
1696
|
[sharedRefetch]
|
|
1316
|
-
), transactions =
|
|
1317
|
-
return
|
|
1697
|
+
), transactions = React2.useMemo(() => [...initialTransactions ?? [], ...paginatedTransactions], [initialTransactions, paginatedTransactions]), isLoading = isInitialLoading || isPaginationLoading, visibleError = updatedAt ? null : error;
|
|
1698
|
+
return React2.useMemo(
|
|
1318
1699
|
() => ({
|
|
1319
1700
|
transactions,
|
|
1320
1701
|
isLoading,
|
|
@@ -1333,10 +1714,10 @@ function getTokensQueryKey(rpcUrl, address) {
|
|
|
1333
1714
|
}
|
|
1334
1715
|
var CACHE_MAX_SIZE = 500, PRICE_CACHE_TTL = 6e4, STALE_CLEANUP_INTERVAL = 12e4, COINGECKO_DEFAULT_MAX_RETRIES = 3, COINGECKO_DEFAULT_BASE_DELAY = 1e3, COINGECKO_DEFAULT_MAX_TIMEOUT = 3e4, COINGECKO_API_BASE_URL = "https://api.coingecko.com/api/v3", LRUCache = class {
|
|
1335
1716
|
constructor(maxSize, options) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1717
|
+
chunkSITQ4JWM_js.__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
1718
|
+
chunkSITQ4JWM_js.__publicField(this, "maxSize");
|
|
1719
|
+
chunkSITQ4JWM_js.__publicField(this, "getTtl");
|
|
1720
|
+
chunkSITQ4JWM_js.__publicField(this, "getTimestamp");
|
|
1340
1721
|
this.maxSize = maxSize, this.getTtl = options?.getTtl, this.getTimestamp = options?.getTimestamp;
|
|
1341
1722
|
}
|
|
1342
1723
|
get(key) {
|
|
@@ -1506,12 +1887,12 @@ async function fetchTokenMetadataHybrid(mints, coingeckoConfig, options) {
|
|
|
1506
1887
|
return didUpdatePrices && options?.onUpdate?.(), didUpdate;
|
|
1507
1888
|
}
|
|
1508
1889
|
function formatBalance(amount, decimals) {
|
|
1509
|
-
return
|
|
1890
|
+
return chunkBZ2VBJCZ_js.formatBigIntBalance(amount, decimals, {
|
|
1510
1891
|
maxDecimals: Math.min(decimals, 6)
|
|
1511
1892
|
});
|
|
1512
1893
|
}
|
|
1513
1894
|
function formatUsd(amount, decimals, usdPrice) {
|
|
1514
|
-
return
|
|
1895
|
+
return chunkBZ2VBJCZ_js.formatBigIntUsd(amount, decimals, usdPrice);
|
|
1515
1896
|
}
|
|
1516
1897
|
function selectTokens(assets, address) {
|
|
1517
1898
|
return {
|
|
@@ -1539,7 +1920,7 @@ function useTokens(options = {}) {
|
|
|
1539
1920
|
// 5 minutes
|
|
1540
1921
|
refetchOnMount = "stale",
|
|
1541
1922
|
client: clientOverride
|
|
1542
|
-
} = options, { address, connected } = useAccount(), { type: clusterType } = useCluster(), connectorConfig = useConnectorClient()?.getConfig(), imageProxy = connectorConfig?.imageProxy, coingeckoConfig = connectorConfig?.coingecko, selectFn =
|
|
1923
|
+
} = options, { address, connected } = useAccount(), { type: clusterType } = useCluster(), connectorConfig = useConnectorClient()?.getConfig(), imageProxy = connectorConfig?.imageProxy, coingeckoConfig = connectorConfig?.coingecko, selectFn = React2.useCallback(
|
|
1543
1924
|
(assets) => selectTokens(assets, address ?? ""),
|
|
1544
1925
|
[address]
|
|
1545
1926
|
), {
|
|
@@ -1557,7 +1938,7 @@ function useTokens(options = {}) {
|
|
|
1557
1938
|
refetchIntervalMs: autoRefresh ? refreshInterval : false,
|
|
1558
1939
|
client: clientOverride,
|
|
1559
1940
|
select: selectFn
|
|
1560
|
-
}), lamports = selection?.lamports ?? 0n, tokenAccounts = selection?.tokenAccounts ?? [], walletAddress = selection?.address ?? "", baseTokens =
|
|
1941
|
+
}), lamports = selection?.lamports ?? 0n, tokenAccounts = selection?.tokenAccounts ?? [], walletAddress = selection?.address ?? "", baseTokens = React2.useMemo(() => {
|
|
1561
1942
|
let result = [];
|
|
1562
1943
|
includeNativeSol && walletAddress && (includeZeroBalance || lamports > 0n) && result.push({
|
|
1563
1944
|
mint: NATIVE_SOL_MINT,
|
|
@@ -1580,13 +1961,13 @@ function useTokens(options = {}) {
|
|
|
1580
1961
|
programId: account.programId
|
|
1581
1962
|
});
|
|
1582
1963
|
return result;
|
|
1583
|
-
}, [lamports, tokenAccounts, walletAddress, includeNativeSol, includeZeroBalance]), mints =
|
|
1964
|
+
}, [lamports, tokenAccounts, walletAddress, includeNativeSol, includeZeroBalance]), mints = React2.useMemo(() => {
|
|
1584
1965
|
let unique = /* @__PURE__ */ new Set();
|
|
1585
1966
|
for (let token of baseTokens)
|
|
1586
1967
|
unique.add(token.mint);
|
|
1587
1968
|
return [...unique].sort();
|
|
1588
|
-
}, [baseTokens]), mintsKey =
|
|
1589
|
-
|
|
1969
|
+
}, [baseTokens]), mintsKey = React2.useMemo(() => mints.join(","), [mints]), [metadataVersion, setMetadataVersion] = React2.useState(0);
|
|
1970
|
+
React2.useEffect(() => {
|
|
1590
1971
|
if (!fetchMetadata || !mintsKey) return;
|
|
1591
1972
|
let isMounted = true;
|
|
1592
1973
|
return (async () => {
|
|
@@ -1605,7 +1986,7 @@ function useTokens(options = {}) {
|
|
|
1605
1986
|
isMounted = false;
|
|
1606
1987
|
};
|
|
1607
1988
|
}, [mintsKey, fetchMetadata, coingeckoConfig, clusterType]);
|
|
1608
|
-
let tokens =
|
|
1989
|
+
let tokens = React2.useMemo(() => fetchMetadata ? baseTokens.map((token) => {
|
|
1609
1990
|
let meta = metadataCache.get(token.mint);
|
|
1610
1991
|
if (!meta) return token;
|
|
1611
1992
|
let usdPrice = (meta.coingeckoId ? priceCache.get(meta.coingeckoId) : void 0)?.price ?? meta.usdPrice;
|
|
@@ -1618,18 +1999,18 @@ function useTokens(options = {}) {
|
|
|
1618
1999
|
formattedUsd: usdPrice ? formatUsd(token.amount, token.decimals, usdPrice) : void 0
|
|
1619
2000
|
};
|
|
1620
2001
|
}).sort(sortByValueDesc) : baseTokens.slice().sort(sortByValueDesc), [baseTokens, fetchMetadata, imageProxy, metadataVersion]), totalAccounts = tokenAccounts.length + (includeNativeSol ? 1 : 0);
|
|
1621
|
-
|
|
1622
|
-
let wasConnectedRef =
|
|
1623
|
-
|
|
2002
|
+
React2.useEffect(() => (startCacheCleanup(), () => stopCacheCleanup()), []);
|
|
2003
|
+
let wasConnectedRef = React2.useRef(connected);
|
|
2004
|
+
React2.useEffect(() => {
|
|
1624
2005
|
wasConnectedRef.current && !connected && clearTokenCaches(), wasConnectedRef.current = connected;
|
|
1625
2006
|
}, [connected]);
|
|
1626
|
-
let visibleError = updatedAt ? null : error, refetch =
|
|
2007
|
+
let visibleError = updatedAt ? null : error, refetch = React2.useCallback(
|
|
1627
2008
|
async (opts) => {
|
|
1628
2009
|
await sharedRefetch(opts);
|
|
1629
2010
|
},
|
|
1630
2011
|
[sharedRefetch]
|
|
1631
2012
|
);
|
|
1632
|
-
return
|
|
2013
|
+
return React2.useMemo(
|
|
1633
2014
|
() => ({
|
|
1634
2015
|
tokens,
|
|
1635
2016
|
isLoading: isFetching,
|
|
@@ -1651,7 +2032,7 @@ function DisconnectElement({
|
|
|
1651
2032
|
onDisconnect,
|
|
1652
2033
|
render
|
|
1653
2034
|
}) {
|
|
1654
|
-
let { disconnect, connecting } = useConnector(), [disconnecting, setDisconnecting] =
|
|
2035
|
+
let { disconnect, connecting } = useConnector(), [disconnecting, setDisconnecting] = React2__default.default.useState(false), handleDisconnect = async () => {
|
|
1655
2036
|
setDisconnecting(true);
|
|
1656
2037
|
try {
|
|
1657
2038
|
await disconnect(), onDisconnect?.();
|
|
@@ -1895,7 +2276,7 @@ function ClusterElement({
|
|
|
1895
2276
|
labels = {},
|
|
1896
2277
|
render
|
|
1897
2278
|
}) {
|
|
1898
|
-
let { cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal } = useCluster(), [isOpen, setIsOpen] =
|
|
2279
|
+
let { cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal } = useCluster(), [isOpen, setIsOpen] = React2__default.default.useState(false);
|
|
1899
2280
|
if (render)
|
|
1900
2281
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: render({ cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal }) });
|
|
1901
2282
|
if (!cluster) return null;
|
|
@@ -2102,14 +2483,32 @@ function WalletListElement({
|
|
|
2102
2483
|
variant = "list",
|
|
2103
2484
|
showStatus = true,
|
|
2104
2485
|
onSelect,
|
|
2486
|
+
onConnect,
|
|
2105
2487
|
render,
|
|
2106
2488
|
renderWallet
|
|
2107
2489
|
}) {
|
|
2108
2490
|
let { wallets, connecting } = useWalletInfo(), { select } = useConnector(), installedWallets = wallets.filter((w) => w.installed), displayWallets = installedOnly ? installedWallets : wallets, handleSelect = async (walletName) => {
|
|
2109
2491
|
await select(walletName), onSelect?.(walletName);
|
|
2492
|
+
}, handleConnectById = async (connectorId) => {
|
|
2493
|
+
let wallet = wallets.find((w) => w.connectorId === connectorId);
|
|
2494
|
+
if (!wallet) {
|
|
2495
|
+
let availableConnectorIds = wallets.map((w) => w.connectorId);
|
|
2496
|
+
console.warn(
|
|
2497
|
+
`[WalletListElement] Wallet not found for connectorId: ${connectorId}. Available connectorIds (${availableConnectorIds.length}):`,
|
|
2498
|
+
availableConnectorIds
|
|
2499
|
+
);
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
await select(wallet.name), onConnect?.(connectorId);
|
|
2110
2503
|
};
|
|
2111
2504
|
if (render)
|
|
2112
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: render({
|
|
2505
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: render({
|
|
2506
|
+
wallets,
|
|
2507
|
+
installedWallets,
|
|
2508
|
+
select: handleSelect,
|
|
2509
|
+
connectById: handleConnectById,
|
|
2510
|
+
connecting
|
|
2511
|
+
}) });
|
|
2113
2512
|
if (displayWallets.length === 0)
|
|
2114
2513
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2115
2514
|
"div",
|
|
@@ -2167,28 +2566,33 @@ function WalletListElement({
|
|
|
2167
2566
|
className: `ck-wallet-list-block ck-wallet-list-block--grid ${className || ""}`,
|
|
2168
2567
|
"data-slot": "wallet-list-element",
|
|
2169
2568
|
"data-variant": "grid",
|
|
2170
|
-
children: displayWallets.map((wallet) =>
|
|
2171
|
-
wallet
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2569
|
+
children: displayWallets.map((wallet) => {
|
|
2570
|
+
let handleWalletConnect = () => handleConnectById(wallet.connectorId);
|
|
2571
|
+
return renderWallet ? /* @__PURE__ */ jsxRuntime.jsx(React2__default.default.Fragment, { children: renderWallet({
|
|
2572
|
+
wallet,
|
|
2573
|
+
select: handleWalletConnect,
|
|
2574
|
+
connect: handleWalletConnect,
|
|
2575
|
+
connecting
|
|
2576
|
+
}) }, wallet.name) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2577
|
+
"button",
|
|
2578
|
+
{
|
|
2579
|
+
type: "button",
|
|
2580
|
+
className: "ck-wallet-list-item ck-wallet-list-item--grid",
|
|
2581
|
+
onClick: handleWalletConnect,
|
|
2582
|
+
disabled: connecting || !wallet.installed && installedOnly,
|
|
2583
|
+
"data-slot": "wallet-list-item",
|
|
2584
|
+
"data-wallet": wallet.name,
|
|
2585
|
+
"data-connector-id": wallet.connectorId,
|
|
2586
|
+
"data-installed": wallet.installed,
|
|
2587
|
+
children: [
|
|
2588
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
|
|
2589
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name }),
|
|
2590
|
+
showStatus && !wallet.installed && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-wallet-list-item-status", "data-slot": "wallet-list-item-status", children: "Not installed" })
|
|
2591
|
+
]
|
|
2592
|
+
},
|
|
2593
|
+
wallet.name
|
|
2594
|
+
);
|
|
2595
|
+
})
|
|
2192
2596
|
}
|
|
2193
2597
|
) : variant === "compact" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2194
2598
|
"div",
|
|
@@ -2196,27 +2600,32 @@ function WalletListElement({
|
|
|
2196
2600
|
className: `ck-wallet-list-block ck-wallet-list-block--compact ${className || ""}`,
|
|
2197
2601
|
"data-slot": "wallet-list-element",
|
|
2198
2602
|
"data-variant": "compact",
|
|
2199
|
-
children: displayWallets.map((wallet) =>
|
|
2200
|
-
wallet
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2603
|
+
children: displayWallets.map((wallet) => {
|
|
2604
|
+
let handleWalletConnect = () => handleConnectById(wallet.connectorId);
|
|
2605
|
+
return renderWallet ? /* @__PURE__ */ jsxRuntime.jsx(React2__default.default.Fragment, { children: renderWallet({
|
|
2606
|
+
wallet,
|
|
2607
|
+
select: handleWalletConnect,
|
|
2608
|
+
connect: handleWalletConnect,
|
|
2609
|
+
connecting
|
|
2610
|
+
}) }, wallet.name) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2611
|
+
"button",
|
|
2612
|
+
{
|
|
2613
|
+
type: "button",
|
|
2614
|
+
className: "ck-wallet-list-item ck-wallet-list-item--compact",
|
|
2615
|
+
onClick: handleWalletConnect,
|
|
2616
|
+
disabled: connecting || !wallet.installed && installedOnly,
|
|
2617
|
+
"data-slot": "wallet-list-item",
|
|
2618
|
+
"data-wallet": wallet.name,
|
|
2619
|
+
"data-connector-id": wallet.connectorId,
|
|
2620
|
+
"data-installed": wallet.installed,
|
|
2621
|
+
children: [
|
|
2622
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
|
|
2623
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name })
|
|
2624
|
+
]
|
|
2625
|
+
},
|
|
2626
|
+
wallet.name
|
|
2627
|
+
);
|
|
2628
|
+
})
|
|
2220
2629
|
}
|
|
2221
2630
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2222
2631
|
"div",
|
|
@@ -2224,54 +2633,59 @@ function WalletListElement({
|
|
|
2224
2633
|
className: `ck-wallet-list-block ck-wallet-list-block--list ${className || ""}`,
|
|
2225
2634
|
"data-slot": "wallet-list-element",
|
|
2226
2635
|
"data-variant": "list",
|
|
2227
|
-
children: displayWallets.map((wallet) =>
|
|
2228
|
-
wallet
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2636
|
+
children: displayWallets.map((wallet) => {
|
|
2637
|
+
let handleWalletConnect = () => handleConnectById(wallet.connectorId);
|
|
2638
|
+
return renderWallet ? /* @__PURE__ */ jsxRuntime.jsx(React2__default.default.Fragment, { children: renderWallet({
|
|
2639
|
+
wallet,
|
|
2640
|
+
select: handleWalletConnect,
|
|
2641
|
+
connect: handleWalletConnect,
|
|
2642
|
+
connecting
|
|
2643
|
+
}) }, wallet.name) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2644
|
+
"button",
|
|
2645
|
+
{
|
|
2646
|
+
type: "button",
|
|
2647
|
+
className: "ck-wallet-list-item ck-wallet-list-item--list",
|
|
2648
|
+
onClick: handleWalletConnect,
|
|
2649
|
+
disabled: connecting || !wallet.installed && installedOnly,
|
|
2650
|
+
"data-slot": "wallet-list-item",
|
|
2651
|
+
"data-wallet": wallet.name,
|
|
2652
|
+
"data-connector-id": wallet.connectorId,
|
|
2653
|
+
"data-installed": wallet.installed,
|
|
2654
|
+
children: [
|
|
2655
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-wallet-list-item-info", "data-slot": "wallet-list-item-info", children: [
|
|
2657
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name }),
|
|
2658
|
+
showStatus && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2659
|
+
"span",
|
|
2660
|
+
{
|
|
2661
|
+
className: "ck-wallet-list-item-status",
|
|
2662
|
+
"data-slot": "wallet-list-item-status",
|
|
2663
|
+
"data-installed": wallet.installed,
|
|
2664
|
+
children: wallet.installed ? "Detected" : "Not installed"
|
|
2665
|
+
}
|
|
2666
|
+
)
|
|
2667
|
+
] }),
|
|
2668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2669
|
+
"svg",
|
|
2247
2670
|
{
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
"
|
|
2251
|
-
|
|
2671
|
+
width: "16",
|
|
2672
|
+
height: "16",
|
|
2673
|
+
viewBox: "0 0 24 24",
|
|
2674
|
+
fill: "none",
|
|
2675
|
+
stroke: "currentColor",
|
|
2676
|
+
strokeWidth: "2",
|
|
2677
|
+
strokeLinecap: "round",
|
|
2678
|
+
strokeLinejoin: "round",
|
|
2679
|
+
className: "ck-wallet-list-item-arrow",
|
|
2680
|
+
"data-slot": "wallet-list-item-arrow",
|
|
2681
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
2252
2682
|
}
|
|
2253
2683
|
)
|
|
2254
|
-
]
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
height: "16",
|
|
2260
|
-
viewBox: "0 0 24 24",
|
|
2261
|
-
fill: "none",
|
|
2262
|
-
stroke: "currentColor",
|
|
2263
|
-
strokeWidth: "2",
|
|
2264
|
-
strokeLinecap: "round",
|
|
2265
|
-
strokeLinejoin: "round",
|
|
2266
|
-
className: "ck-wallet-list-item-arrow",
|
|
2267
|
-
"data-slot": "wallet-list-item-arrow",
|
|
2268
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
2269
|
-
}
|
|
2270
|
-
)
|
|
2271
|
-
]
|
|
2272
|
-
},
|
|
2273
|
-
wallet.name
|
|
2274
|
-
))
|
|
2684
|
+
]
|
|
2685
|
+
},
|
|
2686
|
+
wallet.name
|
|
2687
|
+
);
|
|
2688
|
+
})
|
|
2275
2689
|
}
|
|
2276
2690
|
);
|
|
2277
2691
|
}
|
|
@@ -2308,7 +2722,7 @@ function injectStyles() {
|
|
|
2308
2722
|
}
|
|
2309
2723
|
}
|
|
2310
2724
|
function SkeletonShine() {
|
|
2311
|
-
return
|
|
2725
|
+
return React2__default.default.useEffect(() => {
|
|
2312
2726
|
injectStyles();
|
|
2313
2727
|
}, []), /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-skeleton-shine", "data-slot": "skeleton-shine" });
|
|
2314
2728
|
}
|
|
@@ -2846,6 +3260,7 @@ exports.AccountElement = AccountElement;
|
|
|
2846
3260
|
exports.AppProvider = AppProvider;
|
|
2847
3261
|
exports.BalanceElement = BalanceElement;
|
|
2848
3262
|
exports.ClusterElement = ClusterElement;
|
|
3263
|
+
exports.ConnectorErrorBoundary = ConnectorErrorBoundary;
|
|
2849
3264
|
exports.ConnectorProvider = ConnectorProvider;
|
|
2850
3265
|
exports.DisconnectElement = DisconnectElement;
|
|
2851
3266
|
exports.SkeletonShine = SkeletonShine;
|
|
@@ -2864,8 +3279,10 @@ exports.invalidateSharedQuery = invalidateSharedQuery;
|
|
|
2864
3279
|
exports.useAccount = useAccount;
|
|
2865
3280
|
exports.useBalance = useBalance;
|
|
2866
3281
|
exports.useCluster = useCluster;
|
|
3282
|
+
exports.useConnectWallet = useConnectWallet;
|
|
2867
3283
|
exports.useConnector = useConnector;
|
|
2868
3284
|
exports.useConnectorClient = useConnectorClient;
|
|
3285
|
+
exports.useDisconnectWallet = useDisconnectWallet;
|
|
2869
3286
|
exports.useGillSolanaClient = useGillSolanaClient;
|
|
2870
3287
|
exports.useGillTransactionSigner = useGillTransactionSigner;
|
|
2871
3288
|
exports.useKitTransactionSigner = useKitTransactionSigner;
|
|
@@ -2874,7 +3291,10 @@ exports.useTokens = useTokens;
|
|
|
2874
3291
|
exports.useTransactionPreparer = useTransactionPreparer;
|
|
2875
3292
|
exports.useTransactionSigner = useTransactionSigner;
|
|
2876
3293
|
exports.useTransactions = useTransactions;
|
|
3294
|
+
exports.useWallet = useWallet;
|
|
2877
3295
|
exports.useWalletConnectUri = useWalletConnectUri;
|
|
3296
|
+
exports.useWalletConnectors = useWalletConnectors;
|
|
2878
3297
|
exports.useWalletInfo = useWalletInfo;
|
|
2879
|
-
|
|
2880
|
-
//# sourceMappingURL=chunk-
|
|
3298
|
+
exports.withErrorBoundary = withErrorBoundary;
|
|
3299
|
+
//# sourceMappingURL=chunk-EM4KNOKG.js.map
|
|
3300
|
+
//# sourceMappingURL=chunk-EM4KNOKG.js.map
|