@solana/connector 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -50
- package/dist/chunk-4KD6HQQG.js +69 -0
- package/dist/chunk-4KD6HQQG.js.map +1 -0
- package/dist/chunk-BJAVJQLK.js +230 -0
- package/dist/chunk-BJAVJQLK.js.map +1 -0
- package/dist/{chunk-5HRJKCIL.js → chunk-BZ2VBJCZ.js} +1061 -424
- package/dist/chunk-BZ2VBJCZ.js.map +1 -0
- package/dist/{chunk-WDXEP4AJ.js → chunk-EM4KNOKG.js} +658 -190
- package/dist/chunk-EM4KNOKG.js.map +1 -0
- package/dist/chunk-HN5AJF7F.js +507 -0
- package/dist/chunk-HN5AJF7F.js.map +1 -0
- package/dist/chunk-HO6QNKFM.mjs +61 -0
- package/dist/chunk-HO6QNKFM.mjs.map +1 -0
- package/dist/chunk-HPQ5T32K.mjs +178 -0
- package/dist/chunk-HPQ5T32K.mjs.map +1 -0
- package/dist/{chunk-MAXA3HEP.mjs → chunk-IDTUFDNB.mjs} +962 -344
- package/dist/chunk-IDTUFDNB.mjs.map +1 -0
- package/dist/{chunk-P5LXUDP6.mjs → chunk-RTXUS5KG.mjs} +579 -119
- package/dist/chunk-RTXUS5KG.mjs.map +1 -0
- package/dist/{chunk-DSUCH44G.js → chunk-SITQ4JWM.js} +23 -67
- package/dist/chunk-SITQ4JWM.js.map +1 -0
- package/dist/chunk-UCISIAOG.mjs +501 -0
- package/dist/chunk-UCISIAOG.mjs.map +1 -0
- package/dist/{chunk-J7DHGLW6.mjs → chunk-ZZTY3O4N.mjs} +21 -61
- 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 +10 -9
- package/dist/compat.js.map +1 -1
- package/dist/compat.mjs +2 -1
- package/dist/compat.mjs.map +1 -1
- package/dist/headless.d.mts +239 -104
- package/dist/headless.d.ts +239 -104
- package/dist/headless.js +255 -169
- package/dist/headless.mjs +5 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +316 -206
- package/dist/index.mjs +6 -4
- package/dist/react.d.mts +299 -9
- package/dist/react.d.ts +299 -9
- package/dist/react.js +90 -38
- package/dist/react.mjs +2 -2
- package/dist/{standard-shim-CT49DM5l.d.mts → standard-shim-CGB88PPO.d.mts} +673 -52
- package/dist/{standard-shim-D9guL5fz.d.ts → standard-shim-tmnQelaJ.d.ts} +673 -52
- package/dist/{transaction-signer-T-KVQFi8.d.mts → transaction-signer-7NaYmP5w.d.mts} +1 -0
- package/dist/{transaction-signer-T-KVQFi8.d.ts → transaction-signer-7NaYmP5w.d.ts} +1 -0
- package/dist/walletconnect-447EY3OJ.js +28 -0
- package/dist/walletconnect-447EY3OJ.js.map +1 -0
- package/dist/walletconnect-U455PO4I.mjs +3 -0
- package/dist/walletconnect-U455PO4I.mjs.map +1 -0
- package/package.json +6 -2
- package/dist/chunk-5HRJKCIL.js.map +0 -1
- package/dist/chunk-DSUCH44G.js.map +0 -1
- package/dist/chunk-I6TJLYNA.js +0 -535
- package/dist/chunk-I6TJLYNA.js.map +0 -1
- package/dist/chunk-J7DHGLW6.mjs.map +0 -1
- package/dist/chunk-JOBLG62A.mjs +0 -476
- package/dist/chunk-JOBLG62A.mjs.map +0 -1
- package/dist/chunk-MAXA3HEP.mjs.map +0 -1
- package/dist/chunk-P5LXUDP6.mjs.map +0 -1
- package/dist/chunk-WDXEP4AJ.js.map +0 -1
|
@@ -1,32 +1,333 @@
|
|
|
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 logger =
|
|
15
|
-
|
|
16
|
-
|
|
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);
|
|
289
|
+
function WalletConnectProvider({ children }) {
|
|
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), () => {
|
|
292
|
+
isMountedRef.current = false;
|
|
293
|
+
}), []);
|
|
294
|
+
let setUri = React2.useCallback((newUri) => {
|
|
295
|
+
if (!isMountedRef.current) {
|
|
296
|
+
pendingUriRef.current = newUri;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
setUriState(newUri);
|
|
300
|
+
}, []), clearUri = React2.useCallback(() => {
|
|
301
|
+
pendingUriRef.current = null, isMountedRef.current && setUriState(null);
|
|
302
|
+
}, []);
|
|
303
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WalletConnectContext.Provider, { value: { uri, setUri, clearUri }, children });
|
|
304
|
+
}
|
|
305
|
+
function useWalletConnectUri() {
|
|
306
|
+
let context = React2.useContext(WalletConnectContext);
|
|
307
|
+
return context || {
|
|
308
|
+
uri: null,
|
|
309
|
+
setUri: () => {
|
|
310
|
+
},
|
|
311
|
+
clearUri: () => {
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
var logger2 = chunkSITQ4JWM_js.createLogger("ConnectorProvider");
|
|
316
|
+
chunkBZ2VBJCZ_js.installPolyfills();
|
|
317
|
+
var ConnectorContext = React2.createContext(null);
|
|
17
318
|
ConnectorContext.displayName = "ConnectorContext";
|
|
18
319
|
function ConnectorProviderInternal({
|
|
19
320
|
children,
|
|
20
321
|
config,
|
|
21
322
|
mobile
|
|
22
323
|
}) {
|
|
23
|
-
let clientRef =
|
|
324
|
+
let clientRef = React2.useRef(null), client = React2__default.default.useCallback(() => {
|
|
24
325
|
if (!clientRef.current)
|
|
25
326
|
try {
|
|
26
|
-
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");
|
|
27
328
|
} catch (error) {
|
|
28
329
|
let err = error;
|
|
29
|
-
|
|
330
|
+
logger2.error("Failed to initialize client", { error: err });
|
|
30
331
|
let extendedConfig = config;
|
|
31
332
|
return extendedConfig?.errorBoundary?.onError && extendedConfig.errorBoundary.onError(err, {
|
|
32
333
|
componentStack: "client-initialization",
|
|
@@ -35,7 +336,7 @@ function ConnectorProviderInternal({
|
|
|
35
336
|
}
|
|
36
337
|
return clientRef.current;
|
|
37
338
|
}, [config])();
|
|
38
|
-
return
|
|
339
|
+
return React2__default.default.useEffect(() => {
|
|
39
340
|
let currentClient = clientRef.current;
|
|
40
341
|
if (currentClient) {
|
|
41
342
|
let privateClient = currentClient;
|
|
@@ -44,7 +345,7 @@ function ConnectorProviderInternal({
|
|
|
44
345
|
return () => {
|
|
45
346
|
typeof window < "u" && (window.__connectorClient = void 0), currentClient && typeof currentClient.destroy == "function" && currentClient.destroy();
|
|
46
347
|
};
|
|
47
|
-
}, []),
|
|
348
|
+
}, []), React2__default.default.useEffect(() => {
|
|
48
349
|
if (!mobile) return;
|
|
49
350
|
let cancelled = false;
|
|
50
351
|
return (async () => {
|
|
@@ -83,7 +384,7 @@ function ConnectorProvider({
|
|
|
83
384
|
}) {
|
|
84
385
|
let errorBoundaryConfig = config?.errorBoundary;
|
|
85
386
|
return errorBoundaryConfig?.enabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
86
|
-
|
|
387
|
+
ConnectorErrorBoundary,
|
|
87
388
|
{
|
|
88
389
|
maxRetries: errorBoundaryConfig.maxRetries ?? 3,
|
|
89
390
|
onError: errorBoundaryConfig.onError,
|
|
@@ -93,55 +394,180 @@ function ConnectorProvider({
|
|
|
93
394
|
) : /* @__PURE__ */ jsxRuntime.jsx(ConnectorProviderInternal, { config, mobile, children });
|
|
94
395
|
}
|
|
95
396
|
function useConnector() {
|
|
96
|
-
let client =
|
|
397
|
+
let client = React2.useContext(ConnectorContext);
|
|
97
398
|
if (!client)
|
|
98
399
|
throw new Error(
|
|
99
400
|
"useConnector must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use connector hooks."
|
|
100
401
|
);
|
|
101
|
-
let state =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
), 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(
|
|
106
407
|
() => ({
|
|
408
|
+
// Legacy (kept for backwards compatibility)
|
|
107
409
|
select: client.select.bind(client),
|
|
108
410
|
disconnect: client.disconnect.bind(client),
|
|
109
|
-
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)
|
|
110
415
|
}),
|
|
111
416
|
[client]
|
|
112
|
-
)
|
|
113
|
-
|
|
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(
|
|
114
434
|
() => ({
|
|
115
435
|
...state,
|
|
116
|
-
...methods
|
|
436
|
+
...methods,
|
|
437
|
+
...vNextFields,
|
|
438
|
+
walletConnectUri,
|
|
439
|
+
clearWalletConnectUri
|
|
117
440
|
}),
|
|
118
|
-
[state, methods]
|
|
441
|
+
[state, methods, vNextFields, walletConnectUri, clearWalletConnectUri]
|
|
119
442
|
);
|
|
120
443
|
}
|
|
121
444
|
function useConnectorClient() {
|
|
122
|
-
return
|
|
445
|
+
return React2.useContext(ConnectorContext);
|
|
123
446
|
}
|
|
124
|
-
function
|
|
125
|
-
let
|
|
447
|
+
function AppProviderInner({ children, connectorConfig, mobile, providers = [] }) {
|
|
448
|
+
let { setUri, clearUri } = useWalletConnectUri(), enhancedConfig = React2.useMemo(() => {
|
|
449
|
+
if (!connectorConfig?.walletConnect?.enabled)
|
|
450
|
+
return connectorConfig;
|
|
451
|
+
let wcConfig = connectorConfig.walletConnect;
|
|
452
|
+
return {
|
|
453
|
+
...connectorConfig,
|
|
454
|
+
walletConnect: {
|
|
455
|
+
...wcConfig,
|
|
456
|
+
// Auto-wire callbacks - use provided ones or fall back to context-based ones
|
|
457
|
+
onDisplayUri: wcConfig.onDisplayUri ?? setUri,
|
|
458
|
+
onSessionEstablished: wcConfig.onSessionEstablished ?? clearUri,
|
|
459
|
+
onSessionDisconnected: wcConfig.onSessionDisconnected ?? clearUri
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}, [connectorConfig, setUri, clearUri]), content = /* @__PURE__ */ jsxRuntime.jsx(ConnectorProvider, { config: enhancedConfig, mobile, children });
|
|
126
463
|
for (let i = providers.length - 1; i >= 0; i--) {
|
|
127
464
|
let { component: Provider, props = {} } = providers[i];
|
|
128
465
|
content = /* @__PURE__ */ jsxRuntime.jsx(Provider, { ...props, children: content });
|
|
129
466
|
}
|
|
130
467
|
return content;
|
|
131
468
|
}
|
|
469
|
+
function AppProvider(props) {
|
|
470
|
+
return props.connectorConfig?.walletConnect?.enabled ? /* @__PURE__ */ jsxRuntime.jsx(WalletConnectProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AppProviderInner, { ...props }) }) : /* @__PURE__ */ jsxRuntime.jsx(AppProviderInner, { ...props });
|
|
471
|
+
}
|
|
132
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
|
+
}
|
|
133
559
|
function useCluster() {
|
|
134
560
|
let { cluster, clusters } = useConnector(), client = useConnectorClient();
|
|
135
561
|
if (!client)
|
|
136
562
|
throw new Error("useCluster must be used within ConnectorProvider");
|
|
137
|
-
let setCluster =
|
|
563
|
+
let setCluster = React2.useMemo(
|
|
138
564
|
() => async (id) => {
|
|
139
565
|
await client.setCluster(id);
|
|
140
566
|
},
|
|
141
567
|
[client]
|
|
142
568
|
);
|
|
143
|
-
return
|
|
144
|
-
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;
|
|
145
571
|
return {
|
|
146
572
|
cluster,
|
|
147
573
|
clusters,
|
|
@@ -156,10 +582,10 @@ function useCluster() {
|
|
|
156
582
|
}, [cluster, clusters, setCluster]);
|
|
157
583
|
}
|
|
158
584
|
function useAccount() {
|
|
159
|
-
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(
|
|
160
586
|
() => accounts.find((a) => a.address === selectedAccount) ?? null,
|
|
161
587
|
[accounts, selectedAccount]
|
|
162
|
-
), 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, {
|
|
163
589
|
onSuccess: () => {
|
|
164
590
|
setCopied(true), copyTimeoutRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
165
591
|
}
|
|
@@ -168,9 +594,9 @@ function useAccount() {
|
|
|
168
594
|
error: "empty_value" /* EMPTY_VALUE */,
|
|
169
595
|
errorMessage: "No account selected"
|
|
170
596
|
}, [selectedAccount]);
|
|
171
|
-
return
|
|
597
|
+
return React2__default.default.useEffect(() => () => {
|
|
172
598
|
copyTimeoutRef.current && clearTimeout(copyTimeoutRef.current);
|
|
173
|
-
}, []),
|
|
599
|
+
}, []), React2.useMemo(
|
|
174
600
|
() => ({
|
|
175
601
|
address: selectedAccount,
|
|
176
602
|
account,
|
|
@@ -185,17 +611,18 @@ function useAccount() {
|
|
|
185
611
|
);
|
|
186
612
|
}
|
|
187
613
|
function useWalletInfo() {
|
|
188
|
-
let { selectedWallet, wallets, connected, connecting } = useConnector(), mappedWallets =
|
|
614
|
+
let { selectedWallet, wallets, connected, connecting } = useConnector(), mappedWallets = React2.useMemo(
|
|
189
615
|
() => wallets.map(
|
|
190
616
|
(walletInfo) => ({
|
|
191
617
|
name: walletInfo.wallet.name,
|
|
618
|
+
connectorId: chunkBZ2VBJCZ_js.createConnectorId(walletInfo.wallet.name),
|
|
192
619
|
icon: walletInfo.wallet.icon,
|
|
193
620
|
installed: walletInfo.installed,
|
|
194
621
|
connectable: walletInfo.connectable
|
|
195
622
|
})
|
|
196
623
|
),
|
|
197
624
|
[wallets]
|
|
198
|
-
), selectedWalletInfo =
|
|
625
|
+
), selectedWalletInfo = React2.useMemo(() => {
|
|
199
626
|
if (!selectedWallet)
|
|
200
627
|
return {
|
|
201
628
|
name: null,
|
|
@@ -211,7 +638,7 @@ function useWalletInfo() {
|
|
|
211
638
|
connectable: walletInfo?.connectable ?? false
|
|
212
639
|
};
|
|
213
640
|
}, [selectedWallet, wallets]);
|
|
214
|
-
return
|
|
641
|
+
return React2.useMemo(
|
|
215
642
|
() => ({
|
|
216
643
|
...selectedWalletInfo,
|
|
217
644
|
connected,
|
|
@@ -222,10 +649,10 @@ function useWalletInfo() {
|
|
|
222
649
|
);
|
|
223
650
|
}
|
|
224
651
|
function useTransactionSigner() {
|
|
225
|
-
let { selectedWallet, selectedAccount, accounts, cluster, connected } = useConnector(), client = useConnectorClient(), account =
|
|
652
|
+
let { selectedWallet, selectedAccount, accounts, cluster, connected } = useConnector(), client = useConnectorClient(), account = React2.useMemo(
|
|
226
653
|
() => accounts.find((a) => a.address === selectedAccount)?.raw ?? null,
|
|
227
654
|
[accounts, selectedAccount]
|
|
228
|
-
), signer =
|
|
655
|
+
), signer = React2.useMemo(() => !connected || !selectedWallet || !account ? null : chunkBZ2VBJCZ_js.createTransactionSigner({
|
|
229
656
|
wallet: selectedWallet,
|
|
230
657
|
account,
|
|
231
658
|
cluster: cluster ?? void 0,
|
|
@@ -234,7 +661,7 @@ function useTransactionSigner() {
|
|
|
234
661
|
client.emitEvent(event);
|
|
235
662
|
}
|
|
236
663
|
} : void 0
|
|
237
|
-
}), [connected, selectedWallet, account, cluster, client]), capabilities =
|
|
664
|
+
}), [connected, selectedWallet, account, cluster, client]), capabilities = React2.useMemo(
|
|
238
665
|
() => signer?.getCapabilities() ?? {
|
|
239
666
|
canSign: false,
|
|
240
667
|
canSend: false,
|
|
@@ -253,27 +680,27 @@ function useTransactionSigner() {
|
|
|
253
680
|
function useKitTransactionSigner() {
|
|
254
681
|
let { signer: connectorSigner, ready } = useTransactionSigner();
|
|
255
682
|
return {
|
|
256
|
-
signer:
|
|
683
|
+
signer: React2.useMemo(() => connectorSigner ? chunkBZ2VBJCZ_js.createKitTransactionSigner(connectorSigner) : null, [connectorSigner]),
|
|
257
684
|
ready
|
|
258
685
|
};
|
|
259
686
|
}
|
|
260
687
|
var useGillTransactionSigner = useKitTransactionSigner;
|
|
261
|
-
var
|
|
688
|
+
var logger3 = chunkSITQ4JWM_js.createLogger("useSolanaClient");
|
|
262
689
|
function useSolanaClient() {
|
|
263
|
-
let { type } = useCluster(), connectorClient = useConnectorClient(), client =
|
|
690
|
+
let { type } = useCluster(), connectorClient = useConnectorClient(), client = React2.useMemo(() => {
|
|
264
691
|
if (!type || !connectorClient) return null;
|
|
265
692
|
try {
|
|
266
693
|
let rpcUrl = connectorClient.getRpcUrl();
|
|
267
|
-
return rpcUrl ?
|
|
694
|
+
return rpcUrl ? chunkSITQ4JWM_js.createSolanaClient({
|
|
268
695
|
urlOrMoniker: rpcUrl
|
|
269
|
-
}) : type !== "custom" ?
|
|
696
|
+
}) : type !== "custom" ? chunkSITQ4JWM_js.createSolanaClient({
|
|
270
697
|
urlOrMoniker: type
|
|
271
698
|
}) : null;
|
|
272
699
|
} catch (error) {
|
|
273
|
-
return
|
|
700
|
+
return logger3.error("Failed to create Solana client", { error }), null;
|
|
274
701
|
}
|
|
275
702
|
}, [type, connectorClient]);
|
|
276
|
-
return
|
|
703
|
+
return React2.useMemo(
|
|
277
704
|
() => ({
|
|
278
705
|
client,
|
|
279
706
|
ready: !!client,
|
|
@@ -284,11 +711,11 @@ function useSolanaClient() {
|
|
|
284
711
|
}
|
|
285
712
|
var useGillSolanaClient = useSolanaClient;
|
|
286
713
|
function useTransactionPreparer() {
|
|
287
|
-
let { client, ready } = useSolanaClient(), prepare =
|
|
714
|
+
let { client, ready } = useSolanaClient(), prepare = React2.useCallback(
|
|
288
715
|
async (transaction, options = {}) => {
|
|
289
716
|
if (!client)
|
|
290
|
-
throw new
|
|
291
|
-
return
|
|
717
|
+
throw new chunkSITQ4JWM_js.NetworkError("RPC_ERROR", "Solana client not available. Cannot prepare transaction.");
|
|
718
|
+
return chunkSITQ4JWM_js.prepareTransaction({
|
|
292
719
|
transaction,
|
|
293
720
|
rpc: client.rpc,
|
|
294
721
|
computeUnitLimitMultiplier: options.computeUnitLimitMultiplier,
|
|
@@ -298,7 +725,7 @@ function useTransactionPreparer() {
|
|
|
298
725
|
},
|
|
299
726
|
[client]
|
|
300
727
|
);
|
|
301
|
-
return
|
|
728
|
+
return React2.useMemo(
|
|
302
729
|
() => ({
|
|
303
730
|
prepare,
|
|
304
731
|
ready
|
|
@@ -437,13 +864,13 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
437
864
|
refetchOnMount = "stale",
|
|
438
865
|
refetchIntervalMs = false,
|
|
439
866
|
select
|
|
440
|
-
} = options, queryFnRef =
|
|
867
|
+
} = options, queryFnRef = React2.useRef(queryFn);
|
|
441
868
|
queryFnRef.current = queryFn;
|
|
442
|
-
let stableQueryFn =
|
|
869
|
+
let stableQueryFn = React2.useCallback((signal) => queryFnRef.current(signal), []), subscribe = React2.useCallback(
|
|
443
870
|
(onChange) => key ? subscribeSharedQuery(key, onChange, cacheTimeMs) : () => {
|
|
444
871
|
},
|
|
445
872
|
[key, cacheTimeMs]
|
|
446
|
-
), emptySnapshot =
|
|
873
|
+
), emptySnapshot = React2.useMemo(
|
|
447
874
|
() => ({
|
|
448
875
|
data: void 0,
|
|
449
876
|
error: null,
|
|
@@ -452,8 +879,8 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
452
879
|
isFetching: false
|
|
453
880
|
}),
|
|
454
881
|
[]
|
|
455
|
-
), getSnapshot =
|
|
456
|
-
|
|
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(() => {
|
|
457
884
|
if (!key || !enabled) {
|
|
458
885
|
fetchedKeyRef.current = null;
|
|
459
886
|
return;
|
|
@@ -467,7 +894,7 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
467
894
|
force: refetchOnMount === true
|
|
468
895
|
}).catch(() => {
|
|
469
896
|
})) : fetchedKeyRef.current = key;
|
|
470
|
-
}, [key, enabled, staleTimeMs, refetchOnMount, stableQueryFn]),
|
|
897
|
+
}, [key, enabled, staleTimeMs, refetchOnMount, stableQueryFn]), React2.useEffect(() => {
|
|
471
898
|
if (!key || !enabled || refetchIntervalMs === false) return;
|
|
472
899
|
let entry = getOrCreateEntry(key);
|
|
473
900
|
entry.queryFn = stableQueryFn;
|
|
@@ -477,7 +904,7 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
477
904
|
count <= 1 ? entry.intervalCounts.delete(refetchIntervalMs) : entry.intervalCounts.set(refetchIntervalMs, count - 1), startOrRestartInterval(key, entry);
|
|
478
905
|
};
|
|
479
906
|
}, [key, enabled, refetchIntervalMs, stableQueryFn]);
|
|
480
|
-
let refetch =
|
|
907
|
+
let refetch = React2.useCallback(
|
|
481
908
|
async (refetchOptions) => {
|
|
482
909
|
if (key)
|
|
483
910
|
return fetchSharedQuery(key, stableQueryFn, {
|
|
@@ -486,12 +913,12 @@ function useSharedQuery(key, queryFn, options = {}) {
|
|
|
486
913
|
});
|
|
487
914
|
},
|
|
488
915
|
[key, stableQueryFn]
|
|
489
|
-
), abort =
|
|
916
|
+
), abort = React2.useCallback(() => {
|
|
490
917
|
if (!key) return;
|
|
491
918
|
let entry = store.get(key);
|
|
492
919
|
entry?.abortController && entry.abortController.abort();
|
|
493
920
|
}, [key]);
|
|
494
|
-
return
|
|
921
|
+
return React2.useMemo(
|
|
495
922
|
() => ({
|
|
496
923
|
data: stableSelectedData,
|
|
497
924
|
error: snapshot.error,
|
|
@@ -570,11 +997,11 @@ function useWalletAssets(options = {}) {
|
|
|
570
997
|
refetchIntervalMs = false,
|
|
571
998
|
client: clientOverride,
|
|
572
999
|
select
|
|
573
|
-
} = 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(() => {
|
|
574
1001
|
if (!enabled || !connected || !address || !rpcClient) return null;
|
|
575
1002
|
let rpcUrl = rpcClient.urlOrMoniker instanceof URL ? rpcClient.urlOrMoniker.toString() : String(rpcClient.urlOrMoniker);
|
|
576
1003
|
return getWalletAssetsQueryKey(rpcUrl, address);
|
|
577
|
-
}, [enabled, connected, address, rpcClient]), queryFn =
|
|
1004
|
+
}, [enabled, connected, address, rpcClient]), queryFn = React2.useCallback(
|
|
578
1005
|
async (signal) => {
|
|
579
1006
|
if (!connected || !address || !rpcClient)
|
|
580
1007
|
return { lamports: 0n, tokenAccounts: [] };
|
|
@@ -618,7 +1045,7 @@ function useWalletAssets(options = {}) {
|
|
|
618
1045
|
select
|
|
619
1046
|
}
|
|
620
1047
|
), isLoading = status === "loading" || status === "idle";
|
|
621
|
-
return
|
|
1048
|
+
return React2.useMemo(
|
|
622
1049
|
() => ({
|
|
623
1050
|
data,
|
|
624
1051
|
isLoading,
|
|
@@ -638,7 +1065,7 @@ function getBalanceQueryKey(rpcUrl, address) {
|
|
|
638
1065
|
}
|
|
639
1066
|
var LAMPORTS_PER_SOL2 = 1000000000n;
|
|
640
1067
|
function formatTokenAccount(account) {
|
|
641
|
-
let formatted =
|
|
1068
|
+
let formatted = chunkBZ2VBJCZ_js.formatBigIntBalance(account.amount, account.decimals, {
|
|
642
1069
|
maxDecimals: Math.min(account.decimals, 6)
|
|
643
1070
|
});
|
|
644
1071
|
return {
|
|
@@ -682,13 +1109,13 @@ function useBalance(options = {}) {
|
|
|
682
1109
|
refetchIntervalMs: autoRefresh ? refreshInterval : false,
|
|
683
1110
|
client: clientOverride,
|
|
684
1111
|
select: selectBalance
|
|
685
|
-
}), 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(
|
|
686
1113
|
async (opts) => {
|
|
687
1114
|
await sharedRefetch(opts);
|
|
688
1115
|
},
|
|
689
1116
|
[sharedRefetch]
|
|
690
1117
|
);
|
|
691
|
-
return
|
|
1118
|
+
return React2.useMemo(
|
|
692
1119
|
() => ({
|
|
693
1120
|
solBalance,
|
|
694
1121
|
lamports,
|
|
@@ -1063,7 +1490,7 @@ function useTransactions(options = {}) {
|
|
|
1063
1490
|
// 5 minutes
|
|
1064
1491
|
refetchOnMount = "stale",
|
|
1065
1492
|
client: clientOverride
|
|
1066
|
-
} = 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(
|
|
1067
1494
|
(tx, walletAddress, sig, blockTime, slot, err, explorerUrl) => {
|
|
1068
1495
|
let { date, time } = formatDate(blockTime), baseInfo = {
|
|
1069
1496
|
signature: sig,
|
|
@@ -1114,15 +1541,15 @@ function useTransactions(options = {}) {
|
|
|
1114
1541
|
}
|
|
1115
1542
|
},
|
|
1116
1543
|
[programLabels]
|
|
1117
|
-
), key =
|
|
1544
|
+
), key = React2.useMemo(() => {
|
|
1118
1545
|
if (!enabled || !connected || !address || !rpcClient || !cluster) return null;
|
|
1119
1546
|
let rpcUrl = rpcClient.urlOrMoniker instanceof URL ? rpcClient.urlOrMoniker.toString() : String(rpcClient.urlOrMoniker);
|
|
1120
1547
|
return getTransactionsQueryKey({ rpcUrl, address, clusterId: cluster.id, limit, fetchDetails });
|
|
1121
1548
|
}, [enabled, connected, address, rpcClient, cluster, limit, fetchDetails]);
|
|
1122
|
-
|
|
1549
|
+
React2.useEffect(() => {
|
|
1123
1550
|
beforeSignatureRef.current = void 0, setPaginatedTransactions([]), setIsPaginationLoading(false), setHasMore(true);
|
|
1124
1551
|
}, [key]);
|
|
1125
|
-
let fetchAndEnrichTransactions =
|
|
1552
|
+
let fetchAndEnrichTransactions = React2.useCallback(
|
|
1126
1553
|
async (beforeSignature, currentCluster, signal) => {
|
|
1127
1554
|
if (!rpcClient || !address)
|
|
1128
1555
|
return { transactions: [], hasMore: false };
|
|
@@ -1151,7 +1578,7 @@ function useTransactions(options = {}) {
|
|
|
1151
1578
|
blockTimeNum,
|
|
1152
1579
|
Number(sig.slot),
|
|
1153
1580
|
sig.err,
|
|
1154
|
-
|
|
1581
|
+
chunkBZ2VBJCZ_js.getTransactionUrl(String(sig.signature), currentCluster)
|
|
1155
1582
|
);
|
|
1156
1583
|
});
|
|
1157
1584
|
} else
|
|
@@ -1166,7 +1593,7 @@ function useTransactions(options = {}) {
|
|
|
1166
1593
|
type: "unknown",
|
|
1167
1594
|
formattedDate: date,
|
|
1168
1595
|
formattedTime: time,
|
|
1169
|
-
explorerUrl:
|
|
1596
|
+
explorerUrl: chunkBZ2VBJCZ_js.getTransactionUrl(String(sig.signature), currentCluster)
|
|
1170
1597
|
};
|
|
1171
1598
|
});
|
|
1172
1599
|
let mintsToFetch = [
|
|
@@ -1180,7 +1607,7 @@ function useTransactions(options = {}) {
|
|
|
1180
1607
|
throwIfAborted(signal);
|
|
1181
1608
|
let tokenMetadata = await fetchTransactionTokenMetadata(mintsToFetch, {
|
|
1182
1609
|
signal,
|
|
1183
|
-
cluster:
|
|
1610
|
+
cluster: chunkBZ2VBJCZ_js.getClusterType(currentCluster)
|
|
1184
1611
|
});
|
|
1185
1612
|
tokenMetadata.size > 0 && (newTransactions = newTransactions.map((tx) => {
|
|
1186
1613
|
let enrichedTx = { ...tx };
|
|
@@ -1224,7 +1651,7 @@ function useTransactions(options = {}) {
|
|
|
1224
1651
|
};
|
|
1225
1652
|
},
|
|
1226
1653
|
[rpcClient, address, limit, fetchDetails, detailsConcurrency, parseTransaction, imageProxy]
|
|
1227
|
-
), queryFn =
|
|
1654
|
+
), queryFn = React2.useCallback(
|
|
1228
1655
|
async (signal) => {
|
|
1229
1656
|
if (!connected || !address || !rpcClient || !cluster)
|
|
1230
1657
|
return [];
|
|
@@ -1247,10 +1674,10 @@ function useTransactions(options = {}) {
|
|
|
1247
1674
|
refetchOnMount,
|
|
1248
1675
|
refetchIntervalMs: autoRefresh ? refreshInterval : false
|
|
1249
1676
|
});
|
|
1250
|
-
|
|
1677
|
+
React2.useEffect(() => {
|
|
1251
1678
|
initialTransactions && (beforeSignatureRef.current = initialTransactions.length ? initialTransactions[initialTransactions.length - 1].signature : void 0, setHasMore(initialTransactions.length === limit), setPaginatedTransactions((prev) => prev.length ? [] : prev));
|
|
1252
1679
|
}, [initialTransactions, limit]);
|
|
1253
|
-
let loadMoreFn =
|
|
1680
|
+
let loadMoreFn = React2.useCallback(async () => {
|
|
1254
1681
|
if (!(!hasMore || isPaginationLoading || !cluster)) {
|
|
1255
1682
|
setIsPaginationLoading(true);
|
|
1256
1683
|
try {
|
|
@@ -1262,13 +1689,13 @@ function useTransactions(options = {}) {
|
|
|
1262
1689
|
setIsPaginationLoading(false);
|
|
1263
1690
|
}
|
|
1264
1691
|
}
|
|
1265
|
-
}, [hasMore, isPaginationLoading, cluster, fetchAndEnrichTransactions]), refetch =
|
|
1692
|
+
}, [hasMore, isPaginationLoading, cluster, fetchAndEnrichTransactions]), refetch = React2.useCallback(
|
|
1266
1693
|
async (opts) => {
|
|
1267
1694
|
beforeSignatureRef.current = void 0, setPaginatedTransactions([]), setHasMore(true), await sharedRefetch(opts);
|
|
1268
1695
|
},
|
|
1269
1696
|
[sharedRefetch]
|
|
1270
|
-
), transactions =
|
|
1271
|
-
return
|
|
1697
|
+
), transactions = React2.useMemo(() => [...initialTransactions ?? [], ...paginatedTransactions], [initialTransactions, paginatedTransactions]), isLoading = isInitialLoading || isPaginationLoading, visibleError = updatedAt ? null : error;
|
|
1698
|
+
return React2.useMemo(
|
|
1272
1699
|
() => ({
|
|
1273
1700
|
transactions,
|
|
1274
1701
|
isLoading,
|
|
@@ -1287,10 +1714,10 @@ function getTokensQueryKey(rpcUrl, address) {
|
|
|
1287
1714
|
}
|
|
1288
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 {
|
|
1289
1716
|
constructor(maxSize, options) {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
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");
|
|
1294
1721
|
this.maxSize = maxSize, this.getTtl = options?.getTtl, this.getTimestamp = options?.getTimestamp;
|
|
1295
1722
|
}
|
|
1296
1723
|
get(key) {
|
|
@@ -1460,12 +1887,12 @@ async function fetchTokenMetadataHybrid(mints, coingeckoConfig, options) {
|
|
|
1460
1887
|
return didUpdatePrices && options?.onUpdate?.(), didUpdate;
|
|
1461
1888
|
}
|
|
1462
1889
|
function formatBalance(amount, decimals) {
|
|
1463
|
-
return
|
|
1890
|
+
return chunkBZ2VBJCZ_js.formatBigIntBalance(amount, decimals, {
|
|
1464
1891
|
maxDecimals: Math.min(decimals, 6)
|
|
1465
1892
|
});
|
|
1466
1893
|
}
|
|
1467
1894
|
function formatUsd(amount, decimals, usdPrice) {
|
|
1468
|
-
return
|
|
1895
|
+
return chunkBZ2VBJCZ_js.formatBigIntUsd(amount, decimals, usdPrice);
|
|
1469
1896
|
}
|
|
1470
1897
|
function selectTokens(assets, address) {
|
|
1471
1898
|
return {
|
|
@@ -1493,7 +1920,7 @@ function useTokens(options = {}) {
|
|
|
1493
1920
|
// 5 minutes
|
|
1494
1921
|
refetchOnMount = "stale",
|
|
1495
1922
|
client: clientOverride
|
|
1496
|
-
} = 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(
|
|
1497
1924
|
(assets) => selectTokens(assets, address ?? ""),
|
|
1498
1925
|
[address]
|
|
1499
1926
|
), {
|
|
@@ -1511,7 +1938,7 @@ function useTokens(options = {}) {
|
|
|
1511
1938
|
refetchIntervalMs: autoRefresh ? refreshInterval : false,
|
|
1512
1939
|
client: clientOverride,
|
|
1513
1940
|
select: selectFn
|
|
1514
|
-
}), 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(() => {
|
|
1515
1942
|
let result = [];
|
|
1516
1943
|
includeNativeSol && walletAddress && (includeZeroBalance || lamports > 0n) && result.push({
|
|
1517
1944
|
mint: NATIVE_SOL_MINT,
|
|
@@ -1534,13 +1961,13 @@ function useTokens(options = {}) {
|
|
|
1534
1961
|
programId: account.programId
|
|
1535
1962
|
});
|
|
1536
1963
|
return result;
|
|
1537
|
-
}, [lamports, tokenAccounts, walletAddress, includeNativeSol, includeZeroBalance]), mints =
|
|
1964
|
+
}, [lamports, tokenAccounts, walletAddress, includeNativeSol, includeZeroBalance]), mints = React2.useMemo(() => {
|
|
1538
1965
|
let unique = /* @__PURE__ */ new Set();
|
|
1539
1966
|
for (let token of baseTokens)
|
|
1540
1967
|
unique.add(token.mint);
|
|
1541
1968
|
return [...unique].sort();
|
|
1542
|
-
}, [baseTokens]), mintsKey =
|
|
1543
|
-
|
|
1969
|
+
}, [baseTokens]), mintsKey = React2.useMemo(() => mints.join(","), [mints]), [metadataVersion, setMetadataVersion] = React2.useState(0);
|
|
1970
|
+
React2.useEffect(() => {
|
|
1544
1971
|
if (!fetchMetadata || !mintsKey) return;
|
|
1545
1972
|
let isMounted = true;
|
|
1546
1973
|
return (async () => {
|
|
@@ -1559,7 +1986,7 @@ function useTokens(options = {}) {
|
|
|
1559
1986
|
isMounted = false;
|
|
1560
1987
|
};
|
|
1561
1988
|
}, [mintsKey, fetchMetadata, coingeckoConfig, clusterType]);
|
|
1562
|
-
let tokens =
|
|
1989
|
+
let tokens = React2.useMemo(() => fetchMetadata ? baseTokens.map((token) => {
|
|
1563
1990
|
let meta = metadataCache.get(token.mint);
|
|
1564
1991
|
if (!meta) return token;
|
|
1565
1992
|
let usdPrice = (meta.coingeckoId ? priceCache.get(meta.coingeckoId) : void 0)?.price ?? meta.usdPrice;
|
|
@@ -1572,18 +1999,18 @@ function useTokens(options = {}) {
|
|
|
1572
1999
|
formattedUsd: usdPrice ? formatUsd(token.amount, token.decimals, usdPrice) : void 0
|
|
1573
2000
|
};
|
|
1574
2001
|
}).sort(sortByValueDesc) : baseTokens.slice().sort(sortByValueDesc), [baseTokens, fetchMetadata, imageProxy, metadataVersion]), totalAccounts = tokenAccounts.length + (includeNativeSol ? 1 : 0);
|
|
1575
|
-
|
|
1576
|
-
let wasConnectedRef =
|
|
1577
|
-
|
|
2002
|
+
React2.useEffect(() => (startCacheCleanup(), () => stopCacheCleanup()), []);
|
|
2003
|
+
let wasConnectedRef = React2.useRef(connected);
|
|
2004
|
+
React2.useEffect(() => {
|
|
1578
2005
|
wasConnectedRef.current && !connected && clearTokenCaches(), wasConnectedRef.current = connected;
|
|
1579
2006
|
}, [connected]);
|
|
1580
|
-
let visibleError = updatedAt ? null : error, refetch =
|
|
2007
|
+
let visibleError = updatedAt ? null : error, refetch = React2.useCallback(
|
|
1581
2008
|
async (opts) => {
|
|
1582
2009
|
await sharedRefetch(opts);
|
|
1583
2010
|
},
|
|
1584
2011
|
[sharedRefetch]
|
|
1585
2012
|
);
|
|
1586
|
-
return
|
|
2013
|
+
return React2.useMemo(
|
|
1587
2014
|
() => ({
|
|
1588
2015
|
tokens,
|
|
1589
2016
|
isLoading: isFetching,
|
|
@@ -1605,7 +2032,7 @@ function DisconnectElement({
|
|
|
1605
2032
|
onDisconnect,
|
|
1606
2033
|
render
|
|
1607
2034
|
}) {
|
|
1608
|
-
let { disconnect, connecting } = useConnector(), [disconnecting, setDisconnecting] =
|
|
2035
|
+
let { disconnect, connecting } = useConnector(), [disconnecting, setDisconnecting] = React2__default.default.useState(false), handleDisconnect = async () => {
|
|
1609
2036
|
setDisconnecting(true);
|
|
1610
2037
|
try {
|
|
1611
2038
|
await disconnect(), onDisconnect?.();
|
|
@@ -1849,7 +2276,7 @@ function ClusterElement({
|
|
|
1849
2276
|
labels = {},
|
|
1850
2277
|
render
|
|
1851
2278
|
}) {
|
|
1852
|
-
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);
|
|
1853
2280
|
if (render)
|
|
1854
2281
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: render({ cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal }) });
|
|
1855
2282
|
if (!cluster) return null;
|
|
@@ -2056,14 +2483,32 @@ function WalletListElement({
|
|
|
2056
2483
|
variant = "list",
|
|
2057
2484
|
showStatus = true,
|
|
2058
2485
|
onSelect,
|
|
2486
|
+
onConnect,
|
|
2059
2487
|
render,
|
|
2060
2488
|
renderWallet
|
|
2061
2489
|
}) {
|
|
2062
2490
|
let { wallets, connecting } = useWalletInfo(), { select } = useConnector(), installedWallets = wallets.filter((w) => w.installed), displayWallets = installedOnly ? installedWallets : wallets, handleSelect = async (walletName) => {
|
|
2063
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);
|
|
2064
2503
|
};
|
|
2065
2504
|
if (render)
|
|
2066
|
-
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
|
+
}) });
|
|
2067
2512
|
if (displayWallets.length === 0)
|
|
2068
2513
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2069
2514
|
"div",
|
|
@@ -2121,28 +2566,33 @@ function WalletListElement({
|
|
|
2121
2566
|
className: `ck-wallet-list-block ck-wallet-list-block--grid ${className || ""}`,
|
|
2122
2567
|
"data-slot": "wallet-list-element",
|
|
2123
2568
|
"data-variant": "grid",
|
|
2124
|
-
children: displayWallets.map((wallet) =>
|
|
2125
|
-
wallet
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
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
|
+
})
|
|
2146
2596
|
}
|
|
2147
2597
|
) : variant === "compact" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2148
2598
|
"div",
|
|
@@ -2150,27 +2600,32 @@ function WalletListElement({
|
|
|
2150
2600
|
className: `ck-wallet-list-block ck-wallet-list-block--compact ${className || ""}`,
|
|
2151
2601
|
"data-slot": "wallet-list-element",
|
|
2152
2602
|
"data-variant": "compact",
|
|
2153
|
-
children: displayWallets.map((wallet) =>
|
|
2154
|
-
wallet
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
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
|
+
})
|
|
2174
2629
|
}
|
|
2175
2630
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2176
2631
|
"div",
|
|
@@ -2178,54 +2633,59 @@ function WalletListElement({
|
|
|
2178
2633
|
className: `ck-wallet-list-block ck-wallet-list-block--list ${className || ""}`,
|
|
2179
2634
|
"data-slot": "wallet-list-element",
|
|
2180
2635
|
"data-variant": "list",
|
|
2181
|
-
children: displayWallets.map((wallet) =>
|
|
2182
|
-
wallet
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
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",
|
|
2201
2670
|
{
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
"
|
|
2205
|
-
|
|
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" })
|
|
2206
2682
|
}
|
|
2207
2683
|
)
|
|
2208
|
-
]
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
height: "16",
|
|
2214
|
-
viewBox: "0 0 24 24",
|
|
2215
|
-
fill: "none",
|
|
2216
|
-
stroke: "currentColor",
|
|
2217
|
-
strokeWidth: "2",
|
|
2218
|
-
strokeLinecap: "round",
|
|
2219
|
-
strokeLinejoin: "round",
|
|
2220
|
-
className: "ck-wallet-list-item-arrow",
|
|
2221
|
-
"data-slot": "wallet-list-item-arrow",
|
|
2222
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
2223
|
-
}
|
|
2224
|
-
)
|
|
2225
|
-
]
|
|
2226
|
-
},
|
|
2227
|
-
wallet.name
|
|
2228
|
-
))
|
|
2684
|
+
]
|
|
2685
|
+
},
|
|
2686
|
+
wallet.name
|
|
2687
|
+
);
|
|
2688
|
+
})
|
|
2229
2689
|
}
|
|
2230
2690
|
);
|
|
2231
2691
|
}
|
|
@@ -2262,7 +2722,7 @@ function injectStyles() {
|
|
|
2262
2722
|
}
|
|
2263
2723
|
}
|
|
2264
2724
|
function SkeletonShine() {
|
|
2265
|
-
return
|
|
2725
|
+
return React2__default.default.useEffect(() => {
|
|
2266
2726
|
injectStyles();
|
|
2267
2727
|
}, []), /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-skeleton-shine", "data-slot": "skeleton-shine" });
|
|
2268
2728
|
}
|
|
@@ -2800,12 +3260,14 @@ exports.AccountElement = AccountElement;
|
|
|
2800
3260
|
exports.AppProvider = AppProvider;
|
|
2801
3261
|
exports.BalanceElement = BalanceElement;
|
|
2802
3262
|
exports.ClusterElement = ClusterElement;
|
|
3263
|
+
exports.ConnectorErrorBoundary = ConnectorErrorBoundary;
|
|
2803
3264
|
exports.ConnectorProvider = ConnectorProvider;
|
|
2804
3265
|
exports.DisconnectElement = DisconnectElement;
|
|
2805
3266
|
exports.SkeletonShine = SkeletonShine;
|
|
2806
3267
|
exports.TokenListElement = TokenListElement;
|
|
2807
3268
|
exports.TransactionHistoryElement = TransactionHistoryElement;
|
|
2808
3269
|
exports.UnifiedProvider = UnifiedProvider;
|
|
3270
|
+
exports.WalletConnectProvider = WalletConnectProvider;
|
|
2809
3271
|
exports.WalletListElement = WalletListElement;
|
|
2810
3272
|
exports.clearSharedQueryCache = clearSharedQueryCache;
|
|
2811
3273
|
exports.clearTokenCaches = clearTokenCaches;
|
|
@@ -2817,8 +3279,10 @@ exports.invalidateSharedQuery = invalidateSharedQuery;
|
|
|
2817
3279
|
exports.useAccount = useAccount;
|
|
2818
3280
|
exports.useBalance = useBalance;
|
|
2819
3281
|
exports.useCluster = useCluster;
|
|
3282
|
+
exports.useConnectWallet = useConnectWallet;
|
|
2820
3283
|
exports.useConnector = useConnector;
|
|
2821
3284
|
exports.useConnectorClient = useConnectorClient;
|
|
3285
|
+
exports.useDisconnectWallet = useDisconnectWallet;
|
|
2822
3286
|
exports.useGillSolanaClient = useGillSolanaClient;
|
|
2823
3287
|
exports.useGillTransactionSigner = useGillTransactionSigner;
|
|
2824
3288
|
exports.useKitTransactionSigner = useKitTransactionSigner;
|
|
@@ -2827,6 +3291,10 @@ exports.useTokens = useTokens;
|
|
|
2827
3291
|
exports.useTransactionPreparer = useTransactionPreparer;
|
|
2828
3292
|
exports.useTransactionSigner = useTransactionSigner;
|
|
2829
3293
|
exports.useTransactions = useTransactions;
|
|
3294
|
+
exports.useWallet = useWallet;
|
|
3295
|
+
exports.useWalletConnectUri = useWalletConnectUri;
|
|
3296
|
+
exports.useWalletConnectors = useWalletConnectors;
|
|
2830
3297
|
exports.useWalletInfo = useWalletInfo;
|
|
2831
|
-
|
|
2832
|
-
//# sourceMappingURL=chunk-
|
|
3298
|
+
exports.withErrorBoundary = withErrorBoundary;
|
|
3299
|
+
//# sourceMappingURL=chunk-EM4KNOKG.js.map
|
|
3300
|
+
//# sourceMappingURL=chunk-EM4KNOKG.js.map
|