@cookill/wallet-adapter 2.5.3 → 2.5.4

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/dist/react.cjs CHANGED
@@ -1,13 +1,66 @@
1
- 'use strict';
2
-
3
- var React2 = require('react');
4
- var jsxRuntime = require('react/jsx-runtime');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var React2__default = /*#__PURE__*/_interopDefault(React2);
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
9
29
 
10
30
  // src/react.tsx
31
+ var react_exports = {};
32
+ __export(react_exports, {
33
+ ApprovalPending: () => ApprovalPending,
34
+ ConnectButton: () => ConnectButton,
35
+ ConnectionStatus: () => ConnectionStatus,
36
+ LoadingSpinner: () => LoadingSpinner,
37
+ NETWORKS: () => NETWORKS,
38
+ SafeWalletProvider: () => SafeWalletProvider,
39
+ WalletErrorBoundary: () => WalletErrorBoundary,
40
+ WalletModal: () => WalletModal,
41
+ WalletProvider: () => WalletProvider,
42
+ formatAddress: () => formatAddress,
43
+ formatBalance: () => formatBalance,
44
+ getRialoProvider: () => getRialoProvider,
45
+ isRialoInstalled: () => isRialoInstalled,
46
+ isValidAddress: () => isValidAddress,
47
+ useAccounts: () => useAccounts,
48
+ useActiveAccount: () => useActiveAccount,
49
+ useBalance: () => useBalance,
50
+ useChainId: () => useChainId,
51
+ useConnectWallet: () => useConnectWallet,
52
+ useDisconnectWallet: () => useDisconnectWallet,
53
+ useIsConnected: () => useIsConnected,
54
+ useNetwork: () => useNetwork,
55
+ useSendTransaction: () => useSendTransaction,
56
+ useSignMessage: () => useSignMessage,
57
+ useSignTransaction: () => useSignTransaction,
58
+ useSwitchNetwork: () => useSwitchNetwork,
59
+ useWallet: () => useWallet,
60
+ withWalletErrorBoundary: () => withWalletErrorBoundary
61
+ });
62
+ module.exports = __toCommonJS(react_exports);
63
+ var import_react2 = __toESM(require("react"), 1);
11
64
 
12
65
  // src/index.ts
13
66
  var NETWORKS = {
@@ -103,7 +156,11 @@ function isValidAddress(address) {
103
156
  if (address.length < 32 || address.length > 50) return false;
104
157
  return /^[1-9A-HJ-NP-Za-km-z]+$/.test(address);
105
158
  }
106
- var WalletErrorBoundary = class extends React2.Component {
159
+
160
+ // src/ErrorBoundary.tsx
161
+ var import_react = require("react");
162
+ var import_jsx_runtime = require("react/jsx-runtime");
163
+ var WalletErrorBoundary = class extends import_react.Component {
107
164
  constructor() {
108
165
  super(...arguments);
109
166
  this.state = {
@@ -126,7 +183,7 @@ var WalletErrorBoundary = class extends React2.Component {
126
183
  if (this.props.fallback) {
127
184
  return this.props.fallback;
128
185
  }
129
- return /* @__PURE__ */ jsxRuntime.jsxs(
186
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
130
187
  "div",
131
188
  {
132
189
  style: {
@@ -137,7 +194,7 @@ var WalletErrorBoundary = class extends React2.Component {
137
194
  textAlign: "center"
138
195
  },
139
196
  children: [
140
- /* @__PURE__ */ jsxRuntime.jsx(
197
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
198
  "div",
142
199
  {
143
200
  style: {
@@ -150,7 +207,7 @@ var WalletErrorBoundary = class extends React2.Component {
150
207
  alignItems: "center",
151
208
  justifyContent: "center"
152
209
  },
153
- children: /* @__PURE__ */ jsxRuntime.jsxs(
210
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
154
211
  "svg",
155
212
  {
156
213
  width: "24",
@@ -162,17 +219,17 @@ var WalletErrorBoundary = class extends React2.Component {
162
219
  strokeLinecap: "round",
163
220
  strokeLinejoin: "round",
164
221
  children: [
165
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
166
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
167
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
223
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
224
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
168
225
  ]
169
226
  }
170
227
  )
171
228
  }
172
229
  ),
173
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
174
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
175
- /* @__PURE__ */ jsxRuntime.jsx(
230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
232
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
176
233
  "button",
177
234
  {
178
235
  onClick: this.handleRetry,
@@ -196,6 +253,9 @@ var WalletErrorBoundary = class extends React2.Component {
196
253
  return this.props.children;
197
254
  }
198
255
  };
256
+
257
+ // src/LoadingStates.tsx
258
+ var import_jsx_runtime2 = require("react/jsx-runtime");
199
259
  function LoadingSpinner({ size = "md", color = "#6EB9A8", className = "" }) {
200
260
  const sizes = {
201
261
  sm: { container: 20, stroke: 2 },
@@ -205,7 +265,7 @@ function LoadingSpinner({ size = "md", color = "#6EB9A8", className = "" }) {
205
265
  const { container, stroke } = sizes[size];
206
266
  const radius = (container - stroke) / 2;
207
267
  const circumference = radius * 2 * Math.PI;
208
- return /* @__PURE__ */ jsxRuntime.jsxs(
268
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
209
269
  "svg",
210
270
  {
211
271
  width: container,
@@ -214,13 +274,13 @@ function LoadingSpinner({ size = "md", color = "#6EB9A8", className = "" }) {
214
274
  className,
215
275
  style: { animation: "wallet-spin 1s linear infinite" },
216
276
  children: [
217
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
277
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: `
218
278
  @keyframes wallet-spin {
219
279
  from { transform: rotate(0deg); }
220
280
  to { transform: rotate(360deg); }
221
281
  }
222
282
  ` }),
223
- /* @__PURE__ */ jsxRuntime.jsx(
283
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
224
284
  "circle",
225
285
  {
226
286
  cx: container / 2,
@@ -232,7 +292,7 @@ function LoadingSpinner({ size = "md", color = "#6EB9A8", className = "" }) {
232
292
  strokeOpacity: 0.2
233
293
  }
234
294
  ),
235
- /* @__PURE__ */ jsxRuntime.jsx(
295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
236
296
  "circle",
237
297
  {
238
298
  cx: container / 2,
@@ -256,7 +316,7 @@ function ApprovalPending({
256
316
  walletName = "Sheep Wallet",
257
317
  onCancel
258
318
  }) {
259
- return /* @__PURE__ */ jsxRuntime.jsxs(
319
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
260
320
  "div",
261
321
  {
262
322
  style: {
@@ -267,7 +327,7 @@ function ApprovalPending({
267
327
  border: "1px solid #e2e8f0"
268
328
  },
269
329
  children: [
270
- /* @__PURE__ */ jsxRuntime.jsxs(
330
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
271
331
  "div",
272
332
  {
273
333
  style: {
@@ -282,8 +342,8 @@ function ApprovalPending({
282
342
  position: "relative"
283
343
  },
284
344
  children: [
285
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, { size: "lg" }),
286
- /* @__PURE__ */ jsxRuntime.jsx(
345
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner, { size: "lg" }),
346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
287
347
  "div",
288
348
  {
289
349
  style: {
@@ -299,7 +359,7 @@ function ApprovalPending({
299
359
  ]
300
360
  }
301
361
  ),
302
- /* @__PURE__ */ jsxRuntime.jsx(
362
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
303
363
  "h3",
304
364
  {
305
365
  style: {
@@ -311,7 +371,7 @@ function ApprovalPending({
311
371
  children: title
312
372
  }
313
373
  ),
314
- /* @__PURE__ */ jsxRuntime.jsx(
374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
315
375
  "p",
316
376
  {
317
377
  style: {
@@ -322,7 +382,7 @@ function ApprovalPending({
322
382
  children: message
323
383
  }
324
384
  ),
325
- /* @__PURE__ */ jsxRuntime.jsxs(
385
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
326
386
  "p",
327
387
  {
328
388
  style: {
@@ -337,7 +397,7 @@ function ApprovalPending({
337
397
  ]
338
398
  }
339
399
  ),
340
- onCancel && /* @__PURE__ */ jsxRuntime.jsx(
400
+ onCancel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
341
401
  "button",
342
402
  {
343
403
  onClick: onCancel,
@@ -396,7 +456,7 @@ function ConnectionStatus({ status, message, onRetry }) {
396
456
  }
397
457
  };
398
458
  const config = statusConfig[status];
399
- return /* @__PURE__ */ jsxRuntime.jsxs(
459
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
400
460
  "div",
401
461
  {
402
462
  style: {
@@ -407,7 +467,7 @@ function ConnectionStatus({ status, message, onRetry }) {
407
467
  textAlign: "center"
408
468
  },
409
469
  children: [
410
- /* @__PURE__ */ jsxRuntime.jsx(
470
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
411
471
  "div",
412
472
  {
413
473
  style: {
@@ -420,15 +480,15 @@ function ConnectionStatus({ status, message, onRetry }) {
420
480
  alignItems: "center",
421
481
  justifyContent: "center"
422
482
  },
423
- children: status === "success" ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: config.color, strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "20,6 9,17 4,12" }) }) : status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: config.color, strokeWidth: "2", children: [
424
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
425
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
426
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, { size: "sm", color: config.color })
483
+ children: status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: config.color, strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "20,6 9,17 4,12" }) }) : status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: config.color, strokeWidth: "2", children: [
484
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
485
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
486
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSpinner, { size: "sm", color: config.color })
427
487
  }
428
488
  ),
429
- /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 4px", fontSize: "14px", fontWeight: 600, color: config.color }, children: config.title }),
430
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: message || config.defaultMessage }),
431
- status === "error" && onRetry && /* @__PURE__ */ jsxRuntime.jsx(
489
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h4", { style: { margin: "0 0 4px", fontSize: "14px", fontWeight: 600, color: config.color }, children: config.title }),
490
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: message || config.defaultMessage }),
491
+ status === "error" && onRetry && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
432
492
  "button",
433
493
  {
434
494
  onClick: onRetry,
@@ -450,25 +510,19 @@ function ConnectionStatus({ status, message, onRetry }) {
450
510
  }
451
511
  );
452
512
  }
513
+
514
+ // src/react.tsx
515
+ var import_jsx_runtime3 = require("react/jsx-runtime");
516
+ var SHEEP_WALLET_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHJ4PSI4IiBmaWxsPSIjMUExQTFBIi8+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNCIgcj0iOCIgZmlsbD0iI0ZGRjhGMCIvPjxjaXJjbGUgY3g9IjEyIiBjeT0iMTAiIHI9IjQiIGZpbGw9IiNGRkY4RjAiLz48Y2lyY2xlIGN4PSIyMCIgY3k9IjEwIiByPSI0IiBmaWxsPSIjRkZGOEYwIi8+PGNpcmNsZSBjeD0iMTMiIGN5PSIxMyIgcj0iMS41IiBmaWxsPSIjMzMzIi8+PGNpcmNsZSBjeD0iMTkiIGN5PSIxMyIgcj0iMS41IiBmaWxsPSIjMzMzIi8+PGVsbGlwc2UgY3g9IjE2IiBjeT0iMTciIHJ4PSIyIiByeT0iMS41IiBmaWxsPSIjRkZDMENCIi8+PHBhdGggZD0iTTE0IDI0QzE0IDIyLjkgMTQuOSAyMiAxNiAyMkMxNy4xIDIyIDE4IDIyLjkgMTggMjRWMjZIMTRWMjRaIiBmaWxsPSIjNkVCOUE4Ii8+PC9zdmc+";
453
517
  var DEFAULT_WALLETS = [
454
518
  {
455
519
  id: "sheep-wallet",
456
520
  name: "Sheep Wallet",
457
- icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHJ4PSI4IiBmaWxsPSIjMDExQjI5Ii8+PHRleHQgeD0iNTAlIiB5PSI1NSUiIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXdlaWdodD0iYm9sZCIgZm9udC1zaXplPSIxNiIgZmlsbD0iIzZFQjlBOCI+Uzwvc2VsZj48L3N2Zz4=",
521
+ icon: SHEEP_WALLET_ICON,
458
522
  downloadUrl: "https://rialo.io/wallet"
459
523
  }
460
524
  ];
461
- var CONNECT_TIMEOUT_MS = 2e4;
462
- function withTimeout(promise, ms, message) {
463
- let timeoutId;
464
- const timeout = new Promise((_, reject) => {
465
- timeoutId = setTimeout(() => reject(new Error(message)), ms);
466
- });
467
- return Promise.race([promise, timeout]).finally(() => {
468
- if (timeoutId) clearTimeout(timeoutId);
469
- });
470
- }
471
- var WalletContext = React2.createContext(null);
525
+ var WalletContext = (0, import_react2.createContext)(null);
472
526
  function WalletProvider({
473
527
  children,
474
528
  network: initialNetwork = "devnet",
@@ -479,27 +533,26 @@ function WalletProvider({
479
533
  onError,
480
534
  onNetworkChange
481
535
  }) {
482
- const [connected, setConnected] = React2.useState(false);
483
- const [connecting, setConnecting] = React2.useState(false);
484
- const [accounts, setAccounts] = React2.useState([]);
485
- const [network, setNetwork] = React2.useState(initialNetwork);
486
- const [balance, setBalance] = React2.useState(null);
487
- const [selectedWallet, setSelectedWallet] = React2.useState(null);
488
- const [isModalOpen, setIsModalOpen] = React2.useState(false);
489
- const [provider, setProvider] = React2.useState();
490
- const [error, setError] = React2.useState(null);
491
- const connectPromiseRef = React2.useRef(null);
492
- const chainId = React2.useMemo(() => `rialo:${network}`, [network]);
536
+ const [connected, setConnected] = (0, import_react2.useState)(false);
537
+ const [connecting, setConnecting] = (0, import_react2.useState)(false);
538
+ const [accounts, setAccounts] = (0, import_react2.useState)([]);
539
+ const [network, setNetwork] = (0, import_react2.useState)(initialNetwork);
540
+ const [balance, setBalance] = (0, import_react2.useState)(null);
541
+ const [selectedWallet, setSelectedWallet] = (0, import_react2.useState)(null);
542
+ const [isModalOpen, setIsModalOpen] = (0, import_react2.useState)(false);
543
+ const [provider, setProvider] = (0, import_react2.useState)();
544
+ const [error, setError] = (0, import_react2.useState)(null);
545
+ const chainId = (0, import_react2.useMemo)(() => `rialo:${network}`, [network]);
493
546
  const activeAccount = accounts[0] || null;
494
547
  const isInstalled = isRialoInstalled();
495
- const wallets = React2.useMemo(() => {
548
+ const wallets = (0, import_react2.useMemo)(() => {
496
549
  const installed = isRialoInstalled();
497
550
  return [...DEFAULT_WALLETS, ...customWallets].map((w) => ({
498
551
  ...w,
499
552
  installed: w.id === "sheep-wallet" ? installed : false
500
553
  }));
501
554
  }, [customWallets]);
502
- React2.useEffect(() => {
555
+ (0, import_react2.useEffect)(() => {
503
556
  const init = async () => {
504
557
  const p = await waitForRialoProvider(3e3);
505
558
  setProvider(p);
@@ -509,7 +562,7 @@ function WalletProvider({
509
562
  };
510
563
  init();
511
564
  }, [wallets]);
512
- const refreshBalance = React2.useCallback(async () => {
565
+ const refreshBalance = (0, import_react2.useCallback)(async () => {
513
566
  if (!provider || !activeAccount) return;
514
567
  try {
515
568
  const result = await provider.getBalance(activeAccount.address);
@@ -519,42 +572,24 @@ function WalletProvider({
519
572
  console.error("Balance fetch error:", e);
520
573
  }
521
574
  }, [provider, activeAccount]);
522
- React2.useEffect(() => {
575
+ (0, import_react2.useEffect)(() => {
523
576
  if (connected && activeAccount && provider) {
524
577
  refreshBalance();
525
578
  const interval = setInterval(refreshBalance, 3e4);
526
579
  return () => clearInterval(interval);
527
580
  }
528
581
  }, [connected, activeAccount, provider, refreshBalance]);
529
- React2.useEffect(() => {
530
- if (!autoConnect || !provider || connected || connecting) return;
531
- let cancelled = false;
532
- provider.isConnected().then(async (isConn) => {
533
- if (!isConn || cancelled) return;
534
- try {
535
- const rawAccounts = await withTimeout(provider.getAccounts(), 5e3, "Auto-connect timed out");
536
- const normalized = (rawAccounts || []).map((acc) => {
537
- if (typeof acc === "string") return { address: acc, publicKey: acc };
538
- return { address: acc.address, publicKey: acc.publicKey || acc.address };
539
- });
540
- if (cancelled) return;
541
- setAccounts(normalized);
542
- setConnected(true);
543
- try {
544
- const net = await provider.getNetwork();
545
- if (!cancelled) setNetwork(net);
546
- } catch {
582
+ (0, import_react2.useEffect)(() => {
583
+ if (autoConnect && provider && !connected && !connecting) {
584
+ provider.isConnected().then((isConn) => {
585
+ if (isConn) {
586
+ handleConnect();
547
587
  }
548
- onConnect?.(normalized);
549
- } catch {
550
- }
551
- }).catch(() => {
552
- });
553
- return () => {
554
- cancelled = true;
555
- };
556
- }, [provider, autoConnect, connected, connecting, onConnect]);
557
- React2.useEffect(() => {
588
+ }).catch(() => {
589
+ });
590
+ }
591
+ }, [provider, autoConnect, connected, connecting]);
592
+ (0, import_react2.useEffect)(() => {
558
593
  if (!provider) return;
559
594
  const cleanupFns = [];
560
595
  cleanupFns.push(
@@ -603,65 +638,48 @@ function WalletProvider({
603
638
  cleanupFns.forEach((fn) => fn?.());
604
639
  };
605
640
  }, [provider, onDisconnect, onNetworkChange]);
606
- const handleConnect = React2.useCallback(async () => {
607
- if (connectPromiseRef.current) {
608
- return connectPromiseRef.current;
641
+ const handleConnect = (0, import_react2.useCallback)(async () => {
642
+ if (!provider) {
643
+ const err = new Error("Rialo Wallet not installed");
644
+ setError(err);
645
+ onError?.(err);
646
+ throw err;
609
647
  }
610
- const run = (async () => {
611
- if (!provider) {
612
- const err = new Error("Rialo Wallet not installed");
613
- setError(err);
614
- onError?.(err);
615
- throw err;
616
- }
617
- setIsModalOpen(true);
618
- setConnecting(true);
619
- setError(null);
620
- try {
621
- console.log("[Adapter] Calling provider.connect()...");
622
- const result = await withTimeout(
623
- provider.connect(),
624
- CONNECT_TIMEOUT_MS,
625
- "Connect timed out. Please open Sheep Wallet extension and approve the request."
626
- );
627
- console.log("[Adapter] Connect result:", result);
628
- const walletAccounts = result.map((acc) => {
629
- if (typeof acc === "string") {
630
- return { address: acc, publicKey: acc };
631
- }
632
- return {
633
- address: acc.address,
634
- publicKey: acc.publicKey || acc.address
635
- };
636
- });
637
- setAccounts(walletAccounts);
638
- setConnected(true);
639
- setIsModalOpen(false);
640
- try {
641
- const net = await withTimeout(provider.getNetwork(), 5e3, "Network request timed out");
642
- setNetwork(net);
643
- } catch {
648
+ setConnecting(true);
649
+ setError(null);
650
+ try {
651
+ console.log("[Adapter] Calling provider.connect()...");
652
+ const result = await provider.connect();
653
+ console.log("[Adapter] Connect result:", result);
654
+ const walletAccounts = result.map((acc) => {
655
+ if (typeof acc === "string") {
656
+ return { address: acc, publicKey: acc };
644
657
  }
645
- onConnect?.(walletAccounts);
646
- return walletAccounts;
647
- } catch (e) {
648
- const err = e;
649
- setError(err);
650
- onError?.(err);
651
- setIsModalOpen(true);
652
- throw err;
653
- } finally {
654
- setConnecting(false);
658
+ return {
659
+ address: acc.address,
660
+ publicKey: acc.publicKey || acc.address
661
+ };
662
+ });
663
+ setAccounts(walletAccounts);
664
+ setConnected(true);
665
+ setIsModalOpen(false);
666
+ try {
667
+ const net = await provider.getNetwork();
668
+ setNetwork(net);
669
+ } catch {
655
670
  }
656
- })();
657
- connectPromiseRef.current = run;
658
- try {
659
- return await run;
671
+ onConnect?.(walletAccounts);
672
+ return walletAccounts;
673
+ } catch (e) {
674
+ const err = e;
675
+ setError(err);
676
+ onError?.(err);
677
+ throw err;
660
678
  } finally {
661
- connectPromiseRef.current = null;
679
+ setConnecting(false);
662
680
  }
663
681
  }, [provider, onConnect, onError]);
664
- const handleDisconnect = React2.useCallback(async () => {
682
+ const handleDisconnect = (0, import_react2.useCallback)(async () => {
665
683
  try {
666
684
  if (provider) {
667
685
  await provider.disconnect();
@@ -673,7 +691,7 @@ function WalletProvider({
673
691
  setBalance(null);
674
692
  onDisconnect?.();
675
693
  }, [provider, onDisconnect]);
676
- const selectWallet = React2.useCallback((walletId) => {
694
+ const selectWallet = (0, import_react2.useCallback)((walletId) => {
677
695
  const wallet = wallets.find((w) => w.id === walletId);
678
696
  if (wallet) {
679
697
  setSelectedWallet(wallet);
@@ -684,40 +702,40 @@ function WalletProvider({
684
702
  }
685
703
  }
686
704
  }, [wallets, handleConnect]);
687
- const handleSwitchNetwork = React2.useCallback(async (newNetwork) => {
705
+ const handleSwitchNetwork = (0, import_react2.useCallback)(async (newNetwork) => {
688
706
  if (provider) {
689
707
  await provider.switchNetwork(newNetwork);
690
708
  }
691
709
  setNetwork(newNetwork);
692
710
  onNetworkChange?.(newNetwork);
693
711
  }, [provider, onNetworkChange]);
694
- const handleSignMessage = React2.useCallback(async (message) => {
712
+ const handleSignMessage = (0, import_react2.useCallback)(async (message) => {
695
713
  if (!provider || !connected) {
696
714
  throw new Error("Wallet not connected");
697
715
  }
698
716
  return provider.signMessage(message);
699
717
  }, [provider, connected]);
700
- const handleSignTransaction = React2.useCallback(async (tx) => {
718
+ const handleSignTransaction = (0, import_react2.useCallback)(async (tx) => {
701
719
  if (!provider || !connected) {
702
720
  throw new Error("Wallet not connected");
703
721
  }
704
722
  const result = await provider.signTransaction(tx);
705
723
  return result.signature;
706
724
  }, [provider, connected]);
707
- const handleSendTransaction = React2.useCallback(async (tx) => {
725
+ const handleSendTransaction = (0, import_react2.useCallback)(async (tx) => {
708
726
  if (!provider || !connected) {
709
727
  throw new Error("Wallet not connected");
710
728
  }
711
729
  return provider.sendTransaction(tx);
712
730
  }, [provider, connected]);
713
- const handleSignAndSendTransaction = React2.useCallback(async (tx) => {
731
+ const handleSignAndSendTransaction = (0, import_react2.useCallback)(async (tx) => {
714
732
  if (!provider || !connected) {
715
733
  throw new Error("Wallet not connected");
716
734
  }
717
735
  return provider.signAndSendTransaction(tx);
718
736
  }, [provider, connected]);
719
- const openModal = React2.useCallback(() => setIsModalOpen(true), []);
720
- const closeModal = React2.useCallback(() => setIsModalOpen(false), []);
737
+ const openModal = (0, import_react2.useCallback)(() => setIsModalOpen(true), []);
738
+ const closeModal = (0, import_react2.useCallback)(() => setIsModalOpen(false), []);
721
739
  const value = {
722
740
  connected,
723
741
  connecting,
@@ -743,13 +761,13 @@ function WalletProvider({
743
761
  openModal,
744
762
  closeModal
745
763
  };
746
- return /* @__PURE__ */ jsxRuntime.jsxs(WalletContext.Provider, { value, children: [
764
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(WalletContext.Provider, { value, children: [
747
765
  children,
748
- /* @__PURE__ */ jsxRuntime.jsx(WalletModal, {})
766
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WalletModal, {})
749
767
  ] });
750
768
  }
751
769
  function useWallet() {
752
- const context = React2.useContext(WalletContext);
770
+ const context = (0, import_react2.useContext)(WalletContext);
753
771
  if (!context) {
754
772
  throw new Error("useWallet must be used within WalletProvider");
755
773
  }
@@ -789,9 +807,9 @@ function useChainId() {
789
807
  }
790
808
  function useSwitchNetwork() {
791
809
  const { switchNetwork, network } = useWallet();
792
- const [switching, setSwitching] = React2.useState(false);
793
- const [error, setError] = React2.useState(null);
794
- const doSwitch = React2.useCallback(async (newNetwork) => {
810
+ const [switching, setSwitching] = (0, import_react2.useState)(false);
811
+ const [error, setError] = (0, import_react2.useState)(null);
812
+ const doSwitch = (0, import_react2.useCallback)(async (newNetwork) => {
795
813
  setSwitching(true);
796
814
  setError(null);
797
815
  try {
@@ -807,7 +825,7 @@ function useSwitchNetwork() {
807
825
  }
808
826
  function useConnectWallet() {
809
827
  const { connect, connecting, openModal, isInstalled, error } = useWallet();
810
- const handleConnect = React2.useCallback(() => {
828
+ const handleConnect = (0, import_react2.useCallback)(() => {
811
829
  openModal();
812
830
  }, [openModal]);
813
831
  return {
@@ -825,10 +843,10 @@ function useDisconnectWallet() {
825
843
  }
826
844
  function useSignMessage() {
827
845
  const { signMessage, connected, activeAccount } = useWallet();
828
- const [signing, setSigning] = React2.useState(false);
829
- const [signature, setSignature] = React2.useState(null);
830
- const [error, setError] = React2.useState(null);
831
- const sign = React2.useCallback(async (message) => {
846
+ const [signing, setSigning] = (0, import_react2.useState)(false);
847
+ const [signature, setSignature] = (0, import_react2.useState)(null);
848
+ const [error, setError] = (0, import_react2.useState)(null);
849
+ const sign = (0, import_react2.useCallback)(async (message) => {
832
850
  if (!connected) {
833
851
  setError(new Error("Wallet not connected"));
834
852
  return null;
@@ -850,10 +868,10 @@ function useSignMessage() {
850
868
  }
851
869
  function useSendTransaction() {
852
870
  const { signAndSendTransaction, connected } = useWallet();
853
- const [sending, setSending] = React2.useState(false);
854
- const [txHash, setTxHash] = React2.useState(null);
855
- const [error, setError] = React2.useState(null);
856
- const send = React2.useCallback(async (tx) => {
871
+ const [sending, setSending] = (0, import_react2.useState)(false);
872
+ const [txHash, setTxHash] = (0, import_react2.useState)(null);
873
+ const [error, setError] = (0, import_react2.useState)(null);
874
+ const send = (0, import_react2.useCallback)(async (tx) => {
857
875
  if (!connected) {
858
876
  setError(new Error("Wallet not connected"));
859
877
  return null;
@@ -878,10 +896,10 @@ function useSendTransaction() {
878
896
  }
879
897
  function useSignTransaction() {
880
898
  const { signTransaction, connected } = useWallet();
881
- const [signing, setSigning] = React2.useState(false);
882
- const [signature, setSignature] = React2.useState(null);
883
- const [error, setError] = React2.useState(null);
884
- const sign = React2.useCallback(async (tx) => {
899
+ const [signing, setSigning] = (0, import_react2.useState)(false);
900
+ const [signature, setSignature] = (0, import_react2.useState)(null);
901
+ const [error, setError] = (0, import_react2.useState)(null);
902
+ const sign = (0, import_react2.useCallback)(async (tx) => {
885
903
  if (!connected) {
886
904
  setError(new Error("Wallet not connected"));
887
905
  return null;
@@ -921,7 +939,7 @@ function ConnectButton({
921
939
  ...style
922
940
  };
923
941
  if (connecting) {
924
- return /* @__PURE__ */ jsxRuntime.jsx(
942
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
925
943
  "button",
926
944
  {
927
945
  disabled: true,
@@ -932,7 +950,7 @@ function ConnectButton({
932
950
  );
933
951
  }
934
952
  if (connected && activeAccount) {
935
- return /* @__PURE__ */ jsxRuntime.jsxs(
953
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
936
954
  "button",
937
955
  {
938
956
  onClick: () => disconnect(),
@@ -943,7 +961,7 @@ function ConnectButton({
943
961
  color: "white"
944
962
  },
945
963
  children: [
946
- showBalance && balance && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { marginRight: 8 }, children: [
964
+ showBalance && balance && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { marginRight: 8 }, children: [
947
965
  formatBalance(balance),
948
966
  " RLO"
949
967
  ] }),
@@ -952,7 +970,7 @@ function ConnectButton({
952
970
  }
953
971
  );
954
972
  }
955
- return /* @__PURE__ */ jsxRuntime.jsx(
973
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
956
974
  "button",
957
975
  {
958
976
  onClick: openModal,
@@ -968,15 +986,15 @@ function ConnectButton({
968
986
  }
969
987
  var walletModalOwnerToken = null;
970
988
  function WalletModal({ title = "Connect Wallet", className = "" }) {
971
- const ownerRef = React2__default.default.useRef({});
972
- const [isOwner] = React2.useState(() => {
989
+ const ownerRef = import_react2.default.useRef({});
990
+ const [isOwner] = (0, import_react2.useState)(() => {
973
991
  if (!walletModalOwnerToken) {
974
992
  walletModalOwnerToken = ownerRef.current;
975
993
  return true;
976
994
  }
977
995
  return walletModalOwnerToken === ownerRef.current;
978
996
  });
979
- React2.useEffect(() => {
997
+ (0, import_react2.useEffect)(() => {
980
998
  return () => {
981
999
  if (isOwner && walletModalOwnerToken === ownerRef.current) {
982
1000
  walletModalOwnerToken = null;
@@ -986,7 +1004,7 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
986
1004
  if (!isOwner) return null;
987
1005
  const { isModalOpen, closeModal, wallets, selectWallet, connecting } = useWallet();
988
1006
  if (!isModalOpen) return null;
989
- return /* @__PURE__ */ jsxRuntime.jsx(
1007
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
990
1008
  "div",
991
1009
  {
992
1010
  className,
@@ -1000,7 +1018,7 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
1000
1018
  backgroundColor: "rgba(0, 0, 0, 0.5)"
1001
1019
  },
1002
1020
  onClick: closeModal,
1003
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1021
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1004
1022
  "div",
1005
1023
  {
1006
1024
  style: {
@@ -1014,9 +1032,9 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
1014
1032
  },
1015
1033
  onClick: (e) => e.stopPropagation(),
1016
1034
  children: [
1017
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
1018
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: 0, fontSize: "18px", fontWeight: 600 }, children: title }),
1019
- /* @__PURE__ */ jsxRuntime.jsx(
1035
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
1036
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { style: { margin: 0, fontSize: "18px", fontWeight: 600 }, children: title }),
1037
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1020
1038
  "button",
1021
1039
  {
1022
1040
  onClick: closeModal,
@@ -1025,7 +1043,7 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
1025
1043
  }
1026
1044
  )
1027
1045
  ] }),
1028
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: wallets.map((wallet) => /* @__PURE__ */ jsxRuntime.jsxs(
1046
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: wallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1029
1047
  "button",
1030
1048
  {
1031
1049
  onClick: () => selectWallet(wallet.id),
@@ -1043,17 +1061,17 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
1043
1061
  transition: "all 0.2s ease"
1044
1062
  },
1045
1063
  children: [
1046
- /* @__PURE__ */ jsxRuntime.jsx("img", { src: wallet.icon, alt: wallet.name, style: { width: 40, height: 40, borderRadius: 8 } }),
1047
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "left", flex: 1 }, children: [
1048
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 500 }, children: wallet.name }),
1049
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "#666" }, children: wallet.installed ? "Detected" : "Not installed" })
1064
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src: wallet.icon, alt: wallet.name, style: { width: 40, height: 40, borderRadius: 8 } }),
1065
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { textAlign: "left", flex: 1 }, children: [
1066
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 500 }, children: wallet.name }),
1067
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "12px", color: "#666" }, children: wallet.installed ? "Detected" : "Not installed" })
1050
1068
  ] }),
1051
- !wallet.installed && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "12px", color: "#6EB9A8" }, children: "Install \u2192" })
1069
+ !wallet.installed && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: "12px", color: "#6EB9A8" }, children: "Install \u2192" })
1052
1070
  ]
1053
1071
  },
1054
1072
  wallet.id
1055
1073
  )) }),
1056
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "20px", textAlign: "center", fontSize: "12px", color: "#999" }, children: "Powered by CookilLabs" })
1074
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { marginTop: "20px", textAlign: "center", fontSize: "12px", color: "#999" }, children: "Powered by CookilLabs" })
1057
1075
  ]
1058
1076
  }
1059
1077
  )
@@ -1062,41 +1080,42 @@ function WalletModal({ title = "Connect Wallet", className = "" }) {
1062
1080
  }
1063
1081
  function withWalletErrorBoundary(WrappedComponent, fallback) {
1064
1082
  return function WithErrorBoundary(props) {
1065
- return /* @__PURE__ */ jsxRuntime.jsx(WalletErrorBoundary, { fallback, children: /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props }) });
1083
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WalletErrorBoundary, { fallback, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WrappedComponent, { ...props }) });
1066
1084
  };
1067
1085
  }
1068
1086
  function SafeWalletProvider(props) {
1069
1087
  const { errorFallback, ...providerProps } = props;
1070
- return /* @__PURE__ */ jsxRuntime.jsx(WalletErrorBoundary, { fallback: errorFallback, children: /* @__PURE__ */ jsxRuntime.jsx(WalletProvider, { ...providerProps }) });
1088
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WalletErrorBoundary, { fallback: errorFallback, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WalletProvider, { ...providerProps }) });
1071
1089
  }
1072
-
1073
- exports.ApprovalPending = ApprovalPending;
1074
- exports.ConnectButton = ConnectButton;
1075
- exports.ConnectionStatus = ConnectionStatus;
1076
- exports.LoadingSpinner = LoadingSpinner;
1077
- exports.NETWORKS = NETWORKS;
1078
- exports.SafeWalletProvider = SafeWalletProvider;
1079
- exports.WalletErrorBoundary = WalletErrorBoundary;
1080
- exports.WalletModal = WalletModal;
1081
- exports.WalletProvider = WalletProvider;
1082
- exports.formatAddress = formatAddress;
1083
- exports.formatBalance = formatBalance;
1084
- exports.getRialoProvider = getRialoProvider;
1085
- exports.isRialoInstalled = isRialoInstalled;
1086
- exports.isValidAddress = isValidAddress;
1087
- exports.useAccounts = useAccounts;
1088
- exports.useActiveAccount = useActiveAccount;
1089
- exports.useBalance = useBalance;
1090
- exports.useChainId = useChainId;
1091
- exports.useConnectWallet = useConnectWallet;
1092
- exports.useDisconnectWallet = useDisconnectWallet;
1093
- exports.useIsConnected = useIsConnected;
1094
- exports.useNetwork = useNetwork;
1095
- exports.useSendTransaction = useSendTransaction;
1096
- exports.useSignMessage = useSignMessage;
1097
- exports.useSignTransaction = useSignTransaction;
1098
- exports.useSwitchNetwork = useSwitchNetwork;
1099
- exports.useWallet = useWallet;
1100
- exports.withWalletErrorBoundary = withWalletErrorBoundary;
1101
- //# sourceMappingURL=react.cjs.map
1090
+ // Annotate the CommonJS export names for ESM import in node:
1091
+ 0 && (module.exports = {
1092
+ ApprovalPending,
1093
+ ConnectButton,
1094
+ ConnectionStatus,
1095
+ LoadingSpinner,
1096
+ NETWORKS,
1097
+ SafeWalletProvider,
1098
+ WalletErrorBoundary,
1099
+ WalletModal,
1100
+ WalletProvider,
1101
+ formatAddress,
1102
+ formatBalance,
1103
+ getRialoProvider,
1104
+ isRialoInstalled,
1105
+ isValidAddress,
1106
+ useAccounts,
1107
+ useActiveAccount,
1108
+ useBalance,
1109
+ useChainId,
1110
+ useConnectWallet,
1111
+ useDisconnectWallet,
1112
+ useIsConnected,
1113
+ useNetwork,
1114
+ useSendTransaction,
1115
+ useSignMessage,
1116
+ useSignTransaction,
1117
+ useSwitchNetwork,
1118
+ useWallet,
1119
+ withWalletErrorBoundary
1120
+ });
1102
1121
  //# sourceMappingURL=react.cjs.map