@rhinestone/deposit-modal 0.2.4 → 0.3.0-alpha.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.
Files changed (43) hide show
  1. package/README.md +40 -211
  2. package/dist/{DepositModalReown-CY5MSQGK.mjs → DepositModalReown-GXY65HZP.mjs} +3 -3
  3. package/dist/{DepositModalReown-2UMPITRN.cjs → DepositModalReown-HVIEA6YA.cjs} +4 -4
  4. package/dist/QRCode-SMMYPUQC.cjs +58 -0
  5. package/dist/QRCode-YMQTKSSK.mjs +58 -0
  6. package/dist/{WithdrawModalReown-Z5BUZQ4Z.cjs → WithdrawModalReown-4M3PBY2T.cjs} +4 -4
  7. package/dist/{WithdrawModalReown-YSRO5ZTA.mjs → WithdrawModalReown-O6V6KRH6.mjs} +3 -3
  8. package/dist/{chunk-ARGMXV6E.cjs → chunk-7SYZG47X.cjs} +1723 -1881
  9. package/dist/{chunk-WHW3ZMOT.mjs → chunk-EEHUOFIW.mjs} +107 -90
  10. package/dist/{chunk-KJEHVIPZ.mjs → chunk-FKPTIHU7.mjs} +631 -423
  11. package/dist/{chunk-HFQV7EHS.mjs → chunk-U5QIFNG4.mjs} +1774 -1932
  12. package/dist/{chunk-WNFGZS56.mjs → chunk-UIHAYD7J.mjs} +1079 -784
  13. package/dist/{chunk-R2HP743T.cjs → chunk-XCAF6B3D.cjs} +51 -34
  14. package/dist/{chunk-NFXJEOE6.cjs → chunk-Y3RA3YGA.cjs} +1101 -806
  15. package/dist/{chunk-QUOP5C6V.cjs → chunk-Z2SIC2TH.cjs} +686 -478
  16. package/dist/constants.cjs +2 -2
  17. package/dist/constants.d.cts +3 -2
  18. package/dist/constants.d.ts +3 -2
  19. package/dist/constants.mjs +1 -1
  20. package/dist/deposit.cjs +4 -4
  21. package/dist/deposit.d.cts +2 -3
  22. package/dist/deposit.d.ts +2 -3
  23. package/dist/deposit.mjs +3 -3
  24. package/dist/index.cjs +5 -5
  25. package/dist/index.d.cts +5 -3
  26. package/dist/index.d.ts +5 -3
  27. package/dist/index.mjs +4 -4
  28. package/dist/styles.css +1068 -752
  29. package/dist/{types-DGQzvl6v.d.ts → types-DRou84ZM.d.cts} +147 -33
  30. package/dist/{types-DJ1fzNC7.d.cts → types-DRou84ZM.d.ts} +147 -33
  31. package/dist/withdraw.cjs +4 -4
  32. package/dist/withdraw.d.cts +2 -3
  33. package/dist/withdraw.d.ts +2 -3
  34. package/dist/withdraw.mjs +3 -3
  35. package/package.json +13 -12
  36. package/dist/reown.cjs +0 -16
  37. package/dist/reown.d.cts +0 -10
  38. package/dist/reown.d.ts +0 -10
  39. package/dist/reown.mjs +0 -16
  40. package/dist/safe.cjs +0 -1
  41. package/dist/safe.d.cts +0 -62
  42. package/dist/safe.d.ts +0 -62
  43. package/dist/safe.mjs +0 -0
@@ -1,10 +1,17 @@
1
1
  import {
2
+ AlertTriangleIcon,
3
+ BodyHeader,
2
4
  Button,
5
+ ChevronDownIcon,
6
+ ChevronLeftIcon,
7
+ CircleArrowOutUpLeftIcon,
8
+ CloseIcon,
3
9
  ConnectStep,
4
10
  Modal,
5
11
  PoweredBy,
6
12
  ProcessingStep,
7
13
  Spinner,
14
+ WalletIcon,
8
15
  accountFromPrivateKey,
9
16
  applyTheme,
10
17
  buildSessionDetails,
@@ -21,7 +28,7 @@ import {
21
28
  saveSessionOwnerToStorage,
22
29
  toEvmCaip2,
23
30
  useLatestRef
24
- } from "./chunk-WNFGZS56.mjs";
31
+ } from "./chunk-UIHAYD7J.mjs";
25
32
  import {
26
33
  DEFAULT_BACKEND_URL,
27
34
  DEFAULT_SIGNER_ADDRESS,
@@ -34,7 +41,7 @@ import {
34
41
  getTokenDecimalsByAddress,
35
42
  getTokenIcon,
36
43
  getTokenSymbol
37
- } from "./chunk-WHW3ZMOT.mjs";
44
+ } from "./chunk-EEHUOFIW.mjs";
38
45
 
39
46
  // src/WithdrawModal.tsx
40
47
  import {
@@ -42,13 +49,128 @@ import {
42
49
  useEffect as useEffect3,
43
50
  useMemo as useMemo3,
44
51
  useRef as useRef3,
45
- useState as useState3,
52
+ useState as useState4,
46
53
  lazy,
47
54
  Suspense
48
55
  } from "react";
49
56
 
50
57
  // src/WithdrawFlow.tsx
51
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
58
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
59
+
60
+ // src/store/withdraw.tsx
61
+ import { createContext, createElement, useContext } from "react";
62
+ import { useStore } from "zustand";
63
+ import { createStore } from "zustand/vanilla";
64
+ function unreachable(action) {
65
+ throw new Error(
66
+ `[deposit-modal/withdraw-store] Unhandled action: ${JSON.stringify(action)}`
67
+ );
68
+ }
69
+ function applyWithdrawAction(state, action) {
70
+ switch (action.type) {
71
+ case "wallet/id-selected":
72
+ return { ...state, selectedWalletId: action.walletId };
73
+ case "registration/started":
74
+ return {
75
+ ...state,
76
+ registration: state.registration.kind === "ready" ? {
77
+ kind: "stale",
78
+ smartAccount: state.registration.smartAccount,
79
+ registeredTarget: state.registration.registeredTarget
80
+ } : { kind: "pending" }
81
+ };
82
+ case "registration/ready":
83
+ return {
84
+ ...state,
85
+ registration: {
86
+ kind: "ready",
87
+ smartAccount: action.smartAccount,
88
+ registeredTarget: action.registeredTarget
89
+ },
90
+ step: state.step === "connect" ? "form" : state.step
91
+ };
92
+ case "registration/failed":
93
+ return {
94
+ ...state,
95
+ registration: { kind: "failed", error: action.error }
96
+ };
97
+ case "form/continue":
98
+ return {
99
+ ...state,
100
+ amount: action.amount,
101
+ recipient: action.recipient,
102
+ step: "review"
103
+ };
104
+ case "review/back":
105
+ return { ...state, step: "form" };
106
+ case "withdraw/submitted":
107
+ return { ...state, txHash: action.txHash, step: "processing" };
108
+ case "withdraw/complete":
109
+ return { ...state, step: "complete" };
110
+ case "withdraw/failed":
111
+ return { ...state, step: "failed" };
112
+ case "flow/reset":
113
+ return {
114
+ ...state,
115
+ step: "form",
116
+ amount: null,
117
+ recipient: null,
118
+ txHash: null
119
+ };
120
+ case "modal/reset":
121
+ return {
122
+ ...state,
123
+ step: "connect",
124
+ selectedWalletId: null,
125
+ registration: { kind: "idle" },
126
+ amount: null,
127
+ recipient: null,
128
+ txHash: null
129
+ };
130
+ default:
131
+ return unreachable(action);
132
+ }
133
+ }
134
+ function createWithdrawStore() {
135
+ const store = createStore(() => ({
136
+ step: "connect",
137
+ selectedWalletId: null,
138
+ registration: { kind: "idle" },
139
+ amount: null,
140
+ recipient: null,
141
+ txHash: null
142
+ }));
143
+ return {
144
+ ...store,
145
+ dispatch(action) {
146
+ store.setState((state) => applyWithdrawAction(state, action));
147
+ }
148
+ };
149
+ }
150
+ var WithdrawStoreContext = createContext(null);
151
+ function WithdrawStoreProvider({
152
+ store,
153
+ children
154
+ }) {
155
+ return createElement(
156
+ WithdrawStoreContext.Provider,
157
+ { value: store },
158
+ children
159
+ );
160
+ }
161
+ function useWithdrawStoreApi() {
162
+ const store = useContext(WithdrawStoreContext);
163
+ if (!store) {
164
+ throw new Error(
165
+ "useWithdrawStore must be called inside <WithdrawStoreProvider>"
166
+ );
167
+ }
168
+ return store;
169
+ }
170
+ function useWithdrawStore(selector) {
171
+ const store = useWithdrawStoreApi();
172
+ return useStore(store, selector);
173
+ }
52
174
 
53
175
  // src/components/steps/WithdrawFormStep.tsx
54
176
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -82,6 +204,9 @@ function WithdrawFormStep({
82
204
  switchChain,
83
205
  walletIcon,
84
206
  submitting = false,
207
+ registrationPending = false,
208
+ registrationError = null,
209
+ onRecipientChange,
85
210
  onSubmit,
86
211
  onBalanceUsdChange
87
212
  }) {
@@ -220,8 +345,9 @@ function WithdrawFormStep({
220
345
  const handleUseConnected = useCallback(() => {
221
346
  if (!preferredConnectedRecipient) return;
222
347
  setRecipient(preferredConnectedRecipient);
348
+ onRecipientChange?.(preferredConnectedRecipient);
223
349
  setError(null);
224
- }, [preferredConnectedRecipient]);
350
+ }, [preferredConnectedRecipient, onRecipientChange]);
225
351
  const handleWithdraw = useCallback(async () => {
226
352
  if (!recipient || !/^0x[a-fA-F0-9]{40}$/.test(recipient)) {
227
353
  setError("Enter a valid recipient address");
@@ -267,6 +393,7 @@ function WithdrawFormStep({
267
393
  }
268
394
  return /* @__PURE__ */ jsxs("div", { className: "rs-step", children: [
269
395
  /* @__PURE__ */ jsxs("div", { className: "rs-step-body rs-withdraw-form", children: [
396
+ /* @__PURE__ */ jsx(BodyHeader, { icon: /* @__PURE__ */ jsx(CircleArrowOutUpLeftIcon, {}), title: "Withdraw" }),
270
397
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-section", children: [
271
398
  /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label", children: "Recipient address" }),
272
399
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-input-row", children: [
@@ -278,7 +405,9 @@ function WithdrawFormStep({
278
405
  placeholder: "0x...",
279
406
  value: recipient,
280
407
  onChange: (e) => {
281
- setRecipient(e.target.value.trim());
408
+ const next = e.target.value.trim();
409
+ setRecipient(next);
410
+ onRecipientChange?.(next);
282
411
  if (error) setError(null);
283
412
  }
284
413
  }
@@ -302,24 +431,7 @@ function WithdrawFormStep({
302
431
  ),
303
432
  isRecipientConnected ? null : "Use connected"
304
433
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
305
- /* @__PURE__ */ jsx(
306
- "svg",
307
- {
308
- viewBox: "0 0 24 24",
309
- fill: "none",
310
- stroke: "currentColor",
311
- strokeWidth: "2",
312
- className: "rs-withdraw-use-connected-icon",
313
- children: /* @__PURE__ */ jsx(
314
- "path",
315
- {
316
- strokeLinecap: "round",
317
- strokeLinejoin: "round",
318
- d: "M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"
319
- }
320
- )
321
- }
322
- ),
434
+ /* @__PURE__ */ jsx(WalletIcon, { className: "rs-withdraw-use-connected-icon" }),
323
435
  isRecipientConnected ? null : "Use connected"
324
436
  ] })
325
437
  }
@@ -346,19 +458,16 @@ function WithdrawFormStep({
346
458
  }
347
459
  }
348
460
  ),
349
- /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-amount-right", children: [
350
- /* @__PURE__ */ jsx("span", { className: "rs-withdraw-token-label", children: asset.symbol }),
351
- /* @__PURE__ */ jsx(
352
- "button",
353
- {
354
- type: "button",
355
- className: "rs-withdraw-max-btn",
356
- onClick: handleMaxClick,
357
- disabled: balance === null,
358
- children: "Max"
359
- }
360
- )
361
- ] })
461
+ /* @__PURE__ */ jsx("div", { className: "rs-withdraw-amount-right", children: /* @__PURE__ */ jsx(
462
+ "button",
463
+ {
464
+ type: "button",
465
+ className: "rs-withdraw-max-btn",
466
+ onClick: handleMaxClick,
467
+ disabled: balance === null,
468
+ children: "Max"
469
+ }
470
+ ) })
362
471
  ] }),
363
472
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-amount-info", children: [
364
473
  /* @__PURE__ */ jsx("span", { className: "rs-withdraw-usd", children: amountUsd !== null ? currencyFormatter.format(amountUsd) : "$0.00" }),
@@ -372,12 +481,12 @@ function WithdrawFormStep({
372
481
  ] }),
373
482
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-receive-row", children: [
374
483
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-receive-col", children: [
375
- /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label", children: "Receive token" }),
484
+ /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label rs-withdraw-label--sm", children: "Receive chain" }),
376
485
  /* @__PURE__ */ jsxs(
377
486
  "div",
378
487
  {
379
488
  className: "rs-withdraw-dropdown-container",
380
- ref: tokenDropdownRef,
489
+ ref: chainDropdownRef,
381
490
  children: [
382
491
  /* @__PURE__ */ jsxs(
383
492
  "button",
@@ -385,79 +494,67 @@ function WithdrawFormStep({
385
494
  type: "button",
386
495
  className: "rs-withdraw-dropdown",
387
496
  onClick: () => {
388
- setShowTokenDropdown(!showTokenDropdown);
389
- setShowChainDropdown(false);
497
+ setShowChainDropdown(!showChainDropdown);
498
+ setShowTokenDropdown(false);
390
499
  },
391
500
  children: [
392
501
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-dropdown-value", children: [
393
- getTokenIcon(targetSymbol) && /* @__PURE__ */ jsx(
502
+ getChainIcon(targetChain) && /* @__PURE__ */ jsx(
394
503
  "img",
395
504
  {
396
- src: getTokenIcon(targetSymbol),
397
- alt: targetSymbol,
505
+ src: getChainIcon(targetChain),
506
+ alt: targetChainName,
398
507
  className: "rs-withdraw-dropdown-icon"
399
508
  }
400
509
  ),
401
- /* @__PURE__ */ jsx("span", { children: targetSymbol })
510
+ /* @__PURE__ */ jsx("span", { children: targetChainName })
402
511
  ] }),
403
512
  /* @__PURE__ */ jsx(
404
- "svg",
513
+ ChevronDownIcon,
405
514
  {
406
- viewBox: "0 0 24 24",
407
- fill: "none",
408
- stroke: "currentColor",
409
- strokeWidth: "2",
410
515
  className: "rs-withdraw-dropdown-arrow",
411
516
  style: {
412
- transform: showTokenDropdown ? "rotate(180deg)" : void 0
413
- },
414
- children: /* @__PURE__ */ jsx(
415
- "path",
416
- {
417
- strokeLinecap: "round",
418
- strokeLinejoin: "round",
419
- d: "M19 9l-7 7-7-7"
420
- }
421
- )
517
+ transform: showChainDropdown ? "rotate(180deg)" : void 0
518
+ }
422
519
  }
423
520
  )
424
521
  ]
425
522
  }
426
523
  ),
427
- showTokenDropdown && /* @__PURE__ */ jsx("div", { className: "rs-withdraw-dropdown-menu", children: targetTokenOptions.map((option) => /* @__PURE__ */ jsxs(
524
+ showChainDropdown && /* @__PURE__ */ jsx("div", { className: "rs-withdraw-dropdown-menu", children: targetChains.map((chain) => /* @__PURE__ */ jsxs(
428
525
  "button",
429
526
  {
430
527
  type: "button",
431
528
  className: "rs-withdraw-dropdown-item",
432
529
  onClick: () => {
433
- onTargetTokenChange(option.address);
434
- setShowTokenDropdown(false);
530
+ onTargetChainChange(chain.id);
531
+ setShowChainDropdown(false);
435
532
  },
436
533
  children: [
437
- getTokenIcon(option.symbol) && /* @__PURE__ */ jsx(
534
+ getChainIcon(chain.id) && /* @__PURE__ */ jsx(
438
535
  "img",
439
536
  {
440
- src: getTokenIcon(option.symbol),
441
- alt: option.symbol,
537
+ src: getChainIcon(chain.id),
538
+ alt: chain.name,
442
539
  className: "rs-withdraw-dropdown-icon"
443
540
  }
444
541
  ),
445
- /* @__PURE__ */ jsx("span", { children: option.symbol })
542
+ /* @__PURE__ */ jsx("span", { children: chain.name })
446
543
  ]
447
544
  },
448
- option.address
545
+ chain.id
449
546
  )) })
450
547
  ]
451
548
  }
452
549
  )
453
550
  ] }),
454
551
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-receive-col", children: [
455
- /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label", children: "Receive chain" }),
552
+ /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label rs-withdraw-label--sm", children: "Receive token" }),
456
553
  /* @__PURE__ */ jsxs(
457
554
  "div",
458
555
  {
459
556
  className: "rs-withdraw-dropdown-container",
460
- ref: chainDropdownRef,
557
+ ref: tokenDropdownRef,
461
558
  children: [
462
559
  /* @__PURE__ */ jsxs(
463
560
  "button",
@@ -465,67 +562,55 @@ function WithdrawFormStep({
465
562
  type: "button",
466
563
  className: "rs-withdraw-dropdown",
467
564
  onClick: () => {
468
- setShowChainDropdown(!showChainDropdown);
469
- setShowTokenDropdown(false);
565
+ setShowTokenDropdown(!showTokenDropdown);
566
+ setShowChainDropdown(false);
470
567
  },
471
568
  children: [
472
569
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-dropdown-value", children: [
473
- getChainIcon(targetChain) && /* @__PURE__ */ jsx(
570
+ getTokenIcon(targetSymbol) && /* @__PURE__ */ jsx(
474
571
  "img",
475
572
  {
476
- src: getChainIcon(targetChain),
477
- alt: targetChainName,
573
+ src: getTokenIcon(targetSymbol),
574
+ alt: targetSymbol,
478
575
  className: "rs-withdraw-dropdown-icon"
479
576
  }
480
577
  ),
481
- /* @__PURE__ */ jsx("span", { children: targetChainName })
578
+ /* @__PURE__ */ jsx("span", { children: targetSymbol })
482
579
  ] }),
483
580
  /* @__PURE__ */ jsx(
484
- "svg",
581
+ ChevronDownIcon,
485
582
  {
486
- viewBox: "0 0 24 24",
487
- fill: "none",
488
- stroke: "currentColor",
489
- strokeWidth: "2",
490
583
  className: "rs-withdraw-dropdown-arrow",
491
584
  style: {
492
- transform: showChainDropdown ? "rotate(180deg)" : void 0
493
- },
494
- children: /* @__PURE__ */ jsx(
495
- "path",
496
- {
497
- strokeLinecap: "round",
498
- strokeLinejoin: "round",
499
- d: "M19 9l-7 7-7-7"
500
- }
501
- )
585
+ transform: showTokenDropdown ? "rotate(180deg)" : void 0
586
+ }
502
587
  }
503
588
  )
504
589
  ]
505
590
  }
506
591
  ),
507
- showChainDropdown && /* @__PURE__ */ jsx("div", { className: "rs-withdraw-dropdown-menu", children: targetChains.map((chain) => /* @__PURE__ */ jsxs(
592
+ showTokenDropdown && /* @__PURE__ */ jsx("div", { className: "rs-withdraw-dropdown-menu", children: targetTokenOptions.map((option) => /* @__PURE__ */ jsxs(
508
593
  "button",
509
594
  {
510
595
  type: "button",
511
596
  className: "rs-withdraw-dropdown-item",
512
597
  onClick: () => {
513
- onTargetChainChange(chain.id);
514
- setShowChainDropdown(false);
598
+ onTargetTokenChange(option.address);
599
+ setShowTokenDropdown(false);
515
600
  },
516
601
  children: [
517
- getChainIcon(chain.id) && /* @__PURE__ */ jsx(
602
+ getTokenIcon(option.symbol) && /* @__PURE__ */ jsx(
518
603
  "img",
519
604
  {
520
- src: getChainIcon(chain.id),
521
- alt: chain.name,
605
+ src: getTokenIcon(option.symbol),
606
+ alt: option.symbol,
522
607
  className: "rs-withdraw-dropdown-icon"
523
608
  }
524
609
  ),
525
- /* @__PURE__ */ jsx("span", { children: chain.name })
610
+ /* @__PURE__ */ jsx("span", { children: option.symbol })
526
611
  ]
527
612
  },
528
- chain.id
613
+ option.address
529
614
  )) })
530
615
  ]
531
616
  }
@@ -534,24 +619,12 @@ function WithdrawFormStep({
534
619
  ] }),
535
620
  chainMismatch && /* @__PURE__ */ jsx("div", { className: "rs-chain-switch", children: /* @__PURE__ */ jsx("div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${getChainName(asset.chainId)}...` : `Switch to ${getChainName(asset.chainId)} to continue.` }) }),
536
621
  error && /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-error", children: [
537
- /* @__PURE__ */ jsx(
538
- "svg",
539
- {
540
- viewBox: "0 0 24 24",
541
- fill: "none",
542
- stroke: "currentColor",
543
- strokeWidth: "2",
544
- children: /* @__PURE__ */ jsx(
545
- "path",
546
- {
547
- strokeLinecap: "round",
548
- strokeLinejoin: "round",
549
- d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
550
- }
551
- )
552
- }
553
- ),
622
+ /* @__PURE__ */ jsx(AlertTriangleIcon, {}),
554
623
  /* @__PURE__ */ jsx("span", { children: error })
624
+ ] }),
625
+ !error && registrationError && /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-error", children: [
626
+ /* @__PURE__ */ jsx(AlertTriangleIcon, {}),
627
+ /* @__PURE__ */ jsx("span", { children: registrationError })
555
628
  ] })
556
629
  ] }),
557
630
  /* @__PURE__ */ jsx("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx(
@@ -560,8 +633,8 @@ function WithdrawFormStep({
560
633
  onClick: handleWithdraw,
561
634
  fullWidth: true,
562
635
  loading: isBusy,
563
- disabled: !recipient || !amount || chainMismatch || isBusy,
564
- children: isBusy ? "Preparing..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
636
+ disabled: !recipient || !amount || chainMismatch || isBusy || Boolean(registrationError),
637
+ children: isBusy ? "Preparing..." : registrationPending ? "Preparing session..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
565
638
  }
566
639
  ) }),
567
640
  /* @__PURE__ */ jsx(PoweredBy, {})
@@ -569,6 +642,129 @@ function WithdrawFormStep({
569
642
  }
570
643
  WithdrawFormStep.displayName = "WithdrawFormStep";
571
644
 
645
+ // src/components/steps/WithdrawReviewStep.tsx
646
+ import { useState as useState2 } from "react";
647
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
648
+ function shortenAddress(addr) {
649
+ return addr.length > 12 ? `${addr.slice(0, 6)}\u2026${addr.slice(-4)}` : addr;
650
+ }
651
+ function WithdrawReviewStep({
652
+ sourceChain,
653
+ sourceSymbol,
654
+ targetChain,
655
+ targetToken,
656
+ amount,
657
+ recipient,
658
+ estimatedTime = "< 1 min",
659
+ registrationPending = false,
660
+ registrationError = null,
661
+ onConfirm,
662
+ onError
663
+ }) {
664
+ const [isSubmitting, setIsSubmitting] = useState2(false);
665
+ const [error, setError] = useState2(null);
666
+ const sourceChainName = getChainName(sourceChain);
667
+ const sourceChainIcon = getChainIcon(sourceChain);
668
+ const targetSymbol = getTokenSymbol(targetToken, targetChain);
669
+ const targetChainName = getChainName(targetChain);
670
+ const targetChainIcon = getChainIcon(targetChain);
671
+ const sourceTokenIcon = getTokenIcon(sourceSymbol);
672
+ const targetTokenIcon = getTokenIcon(targetSymbol);
673
+ const handleConfirm = async () => {
674
+ setError(null);
675
+ setIsSubmitting(true);
676
+ try {
677
+ await onConfirm();
678
+ } catch (err) {
679
+ const raw = err instanceof Error ? err.message : "Withdraw failed";
680
+ const message = formatUserError(raw);
681
+ setError(message);
682
+ onError?.(message, "WITHDRAW_REVIEW_ERROR");
683
+ } finally {
684
+ setIsSubmitting(false);
685
+ }
686
+ };
687
+ const disabled = isSubmitting || registrationPending || Boolean(registrationError);
688
+ return /* @__PURE__ */ jsxs2("div", { className: "rs-screen", children: [
689
+ /* @__PURE__ */ jsxs2("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
690
+ /* @__PURE__ */ jsx2(
691
+ BodyHeader,
692
+ {
693
+ icon: /* @__PURE__ */ jsx2(CircleArrowOutUpLeftIcon, {}),
694
+ title: "Review withdrawal"
695
+ }
696
+ ),
697
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-details", children: [
698
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
699
+ /* @__PURE__ */ jsx2("span", { children: "You send" }),
700
+ /* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
701
+ /* @__PURE__ */ jsxs2("span", { children: [
702
+ amount,
703
+ " ",
704
+ sourceSymbol
705
+ ] }),
706
+ sourceTokenIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: sourceTokenIcon, alt: "" }) })
707
+ ] })
708
+ ] }),
709
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
710
+ /* @__PURE__ */ jsx2("span", { children: "Source chain" }),
711
+ /* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
712
+ /* @__PURE__ */ jsx2("span", { children: sourceChainName }),
713
+ sourceChainIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: sourceChainIcon, alt: "" }) })
714
+ ] })
715
+ ] }),
716
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
717
+ /* @__PURE__ */ jsx2("span", { children: "Recipient" }),
718
+ /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-value", children: /* @__PURE__ */ jsx2("span", { children: shortenAddress(recipient) }) })
719
+ ] }),
720
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
721
+ /* @__PURE__ */ jsx2("span", { children: "Receive" }),
722
+ /* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
723
+ /* @__PURE__ */ jsxs2("span", { children: [
724
+ amount,
725
+ " ",
726
+ targetSymbol
727
+ ] }),
728
+ targetTokenIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: targetTokenIcon, alt: "" }) })
729
+ ] })
730
+ ] }),
731
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
732
+ /* @__PURE__ */ jsx2("span", { children: "Destination chain" }),
733
+ /* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
734
+ /* @__PURE__ */ jsx2("span", { children: targetChainName }),
735
+ targetChainIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: targetChainIcon, alt: "" }) })
736
+ ] })
737
+ ] }),
738
+ /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
739
+ /* @__PURE__ */ jsx2("span", { children: "Estimated time" }),
740
+ /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-value", children: estimatedTime })
741
+ ] })
742
+ ] }),
743
+ error && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-error", role: "alert", children: [
744
+ /* @__PURE__ */ jsx2(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
745
+ /* @__PURE__ */ jsx2("span", { children: error })
746
+ ] }),
747
+ !error && registrationError && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-error", role: "alert", children: [
748
+ /* @__PURE__ */ jsx2(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
749
+ /* @__PURE__ */ jsx2("span", { children: registrationError })
750
+ ] }),
751
+ /* @__PURE__ */ jsx2(
752
+ Button,
753
+ {
754
+ onClick: handleConfirm,
755
+ loading: isSubmitting,
756
+ loadingText: "Submitting transaction...",
757
+ disabled,
758
+ fullWidth: true,
759
+ children: "Continue"
760
+ }
761
+ )
762
+ ] }),
763
+ /* @__PURE__ */ jsx2(PoweredBy, {})
764
+ ] });
765
+ }
766
+ WithdrawReviewStep.displayName = "WithdrawReviewStep";
767
+
572
768
  // src/core/safe.ts
573
769
  import {
574
770
  concat,
@@ -856,7 +1052,25 @@ async function buildSafeTransaction(params) {
856
1052
 
857
1053
  // src/WithdrawFlow.tsx
858
1054
  import { encodeFunctionData as encodeFunctionData2, erc20Abi as erc20Abi3, parseUnits as parseUnits2 } from "viem";
859
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1055
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1056
+ var ADDR_REGEX = /^0x[a-fA-F0-9]{40}$/;
1057
+ var REGISTRATION_DEBOUNCE_MS = 600;
1058
+ function resolveSessionOwner(eoaAddress) {
1059
+ const localOwner = loadSessionOwnerFromStorage(eoaAddress);
1060
+ if (localOwner) {
1061
+ return {
1062
+ account: accountFromPrivateKey(localOwner.privateKey),
1063
+ address: localOwner.address
1064
+ };
1065
+ }
1066
+ const created = createSessionOwnerKey();
1067
+ saveSessionOwnerToStorage(eoaAddress, created.privateKey, created.address);
1068
+ return { account: created.account, address: created.address };
1069
+ }
1070
+ function targetsEqual(a, b) {
1071
+ if (!a) return false;
1072
+ return a.chain === b.chain && a.token.toLowerCase() === b.token.toLowerCase() && (a.recipient?.toLowerCase() ?? "") === (b.recipient?.toLowerCase() ?? "");
1073
+ }
860
1074
  function WithdrawFlow({
861
1075
  dappWalletClient,
862
1076
  dappPublicClient,
@@ -879,30 +1093,17 @@ function WithdrawFlow({
879
1093
  onDisconnect,
880
1094
  onSignTransaction,
881
1095
  onRequestConnect,
882
- connectButtonLabel,
883
1096
  onStepChange,
884
- onTotalBalanceChange,
885
1097
  onClose,
886
- onConnected,
887
- onWithdrawSubmitted,
888
- onWithdrawComplete,
889
- onWithdrawFailed,
1098
+ onLifecycle,
890
1099
  onEvent,
891
1100
  onError,
892
1101
  debug
893
1102
  }) {
894
1103
  const onStepChangeRef = useLatestRef(onStepChange);
895
- const onTotalBalanceChangeRef = useLatestRef(onTotalBalanceChange);
896
1104
  const onEventRef = useLatestRef(onEvent);
897
- const onConnectedRef = useLatestRef(onConnected);
898
- const onWithdrawSubmittedRef = useLatestRef(onWithdrawSubmitted);
899
- const onWithdrawCompleteRef = useLatestRef(onWithdrawComplete);
900
- const onWithdrawFailedRef = useLatestRef(onWithdrawFailed);
1105
+ const onLifecycleRef = useLatestRef(onLifecycle);
901
1106
  const onErrorRef = useLatestRef(onError);
902
- const [step, setStep] = useState2({ type: "form" });
903
- const [isSubmitting, setIsSubmitting] = useState2(false);
904
- const [totalBalanceUsd, setTotalBalanceUsd] = useState2(0);
905
- const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState2(false);
906
1107
  const logFlow = useCallback2(
907
1108
  (message, data) => {
908
1109
  debugLog(debug, "withdraw-flow", message, data);
@@ -915,12 +1116,20 @@ function WithdrawFlow({
915
1116
  },
916
1117
  [debug]
917
1118
  );
918
- const [targetChain, setTargetChain] = useState2(targetChainProp);
919
- const [targetToken, setTargetToken] = useState2(targetTokenProp);
1119
+ const [targetChain, setTargetChain] = useState3(targetChainProp);
1120
+ const [targetToken, setTargetToken] = useState3(targetTokenProp);
1121
+ const [recipientInput, setRecipientInput] = useState3(
1122
+ defaultRecipient ?? ""
1123
+ );
1124
+ const [totalBalanceUsd, setTotalBalanceUsd] = useState3(0);
1125
+ const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState3(false);
920
1126
  useEffect2(() => {
921
1127
  setTargetChain(targetChainProp);
922
1128
  setTargetToken(targetTokenProp);
923
1129
  }, [targetChainProp, targetTokenProp]);
1130
+ useEffect2(() => {
1131
+ if (defaultRecipient) setRecipientInput(defaultRecipient);
1132
+ }, [defaultRecipient]);
924
1133
  const hasCustomSigner = Boolean(dappAddress && onSignTransaction);
925
1134
  const dappSwitchChain = useMemo2(() => {
926
1135
  if (!dappWalletClient?.switchChain) return void 0;
@@ -941,7 +1150,7 @@ function WithdrawFlow({
941
1150
  });
942
1151
  seen.add(id);
943
1152
  }
944
- if (reownWallet?.address && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(reownWallet.address.toLowerCase())) {
1153
+ if (reownWallet?.address && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient) {
945
1154
  const id = `evm:${reownWallet.address.toLowerCase()}`;
946
1155
  if (!seen.has(id)) {
947
1156
  options.push({
@@ -960,10 +1169,18 @@ function WithdrawFlow({
960
1169
  reownWallet?.address,
961
1170
  reownWallet?.isConnected,
962
1171
  reownWallet?.walletClient,
963
- reownWallet?.publicClient
1172
+ reownWallet?.publicClient,
1173
+ reownWallet?.icon
964
1174
  ]);
965
1175
  const canAutoLock = hasCustomSigner || Boolean(dappWalletClient?.account && dappAddress) && !reownWallet;
966
- const [selectedWalletId, setSelectedWalletId] = useState2(null);
1176
+ const storeApi = useWithdrawStoreApi();
1177
+ const selectedWalletId = useWithdrawStore((s) => s.selectedWalletId);
1178
+ const registration = useWithdrawStore((s) => s.registration);
1179
+ const flowStep = useWithdrawStore((s) => s.step);
1180
+ const setSelectedWalletId = useCallback2(
1181
+ (walletId) => storeApi.dispatch({ type: "wallet/id-selected", walletId }),
1182
+ [storeApi]
1183
+ );
967
1184
  const signerContext = useMemo2(() => {
968
1185
  if (canAutoLock) {
969
1186
  if (hasCustomSigner) {
@@ -982,7 +1199,7 @@ function WithdrawFlow({
982
1199
  };
983
1200
  }
984
1201
  if (!isConnectSelectionConfirmed || !selectedWalletId) return null;
985
- const selectedOption = walletOptions.find((option) => option.id === selectedWalletId);
1202
+ const selectedOption = walletOptions.find((o) => o.id === selectedWalletId);
986
1203
  if (!selectedOption || !selectedOption.address) return null;
987
1204
  if (selectedOption.kind === "connected" && dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
988
1205
  return {
@@ -1014,6 +1231,131 @@ function WithdrawFlow({
1014
1231
  reownWallet,
1015
1232
  sourceChain
1016
1233
  ]);
1234
+ const ownerAddress = signerContext?.ownerAddress;
1235
+ const recipientForRegistration = useMemo2(() => {
1236
+ if (!recipientInput) return void 0;
1237
+ return ADDR_REGEX.test(recipientInput) ? recipientInput : void 0;
1238
+ }, [recipientInput]);
1239
+ useEffect2(() => {
1240
+ if (!ownerAddress) return;
1241
+ const desiredTarget = {
1242
+ chain: targetChain,
1243
+ token: targetToken,
1244
+ recipient: recipientForRegistration
1245
+ };
1246
+ const current = storeApi.getState().registration;
1247
+ if (current.kind === "ready" && targetsEqual(current.registeredTarget, desiredTarget)) {
1248
+ return;
1249
+ }
1250
+ let cancelled = false;
1251
+ const timeout = setTimeout(async () => {
1252
+ try {
1253
+ storeApi.dispatch({ type: "registration/started" });
1254
+ const sessionOwner = resolveSessionOwner(ownerAddress);
1255
+ if (cancelled) return;
1256
+ logFlow("auto-register:setup", {
1257
+ ownerAddress,
1258
+ targetChain,
1259
+ targetToken,
1260
+ recipient: recipientForRegistration
1261
+ });
1262
+ const setup = await service.setupAccount({
1263
+ ownerAddress,
1264
+ sessionOwnerAddress: sessionOwner.address,
1265
+ targetChain: toEvmCaip2(targetChain),
1266
+ targetToken,
1267
+ recipient: recipientForRegistration,
1268
+ signerAddress,
1269
+ sessionChainIds,
1270
+ forceRegister
1271
+ });
1272
+ if (cancelled) return;
1273
+ if (setup.needsRegistration) {
1274
+ if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
1275
+ throw new Error("Missing registration payload from setup-account");
1276
+ }
1277
+ const typedData = setup.sessionDetailsUnsigned.data;
1278
+ if (!sessionOwner.account.signTypedData) {
1279
+ throw new Error(
1280
+ "Session owner account does not support signTypedData"
1281
+ );
1282
+ }
1283
+ const signature = await sessionOwner.account.signTypedData({
1284
+ domain: typedData.domain,
1285
+ types: typedData.types,
1286
+ primaryType: typedData.primaryType,
1287
+ message: typedData.message
1288
+ });
1289
+ if (cancelled) return;
1290
+ const sessionDetails = buildSessionDetails(
1291
+ setup.sessionDetailsUnsigned,
1292
+ signature
1293
+ );
1294
+ await service.registerAccount({
1295
+ address: setup.smartAccount,
1296
+ accountParams: {
1297
+ factory: setup.accountParams.factory,
1298
+ factoryData: setup.accountParams.factoryData,
1299
+ sessionDetails
1300
+ },
1301
+ eoaAddress: ownerAddress,
1302
+ sessionOwner: sessionOwner.address,
1303
+ target: {
1304
+ chain: toEvmCaip2(targetChain),
1305
+ token: targetToken,
1306
+ recipient: recipientForRegistration
1307
+ }
1308
+ });
1309
+ if (cancelled) return;
1310
+ logFlow("auto-register:registered", {
1311
+ smartAccount: setup.smartAccount
1312
+ });
1313
+ }
1314
+ storeApi.dispatch({
1315
+ type: "registration/ready",
1316
+ smartAccount: setup.smartAccount,
1317
+ registeredTarget: desiredTarget
1318
+ });
1319
+ onLifecycleRef.current?.({
1320
+ type: "connected",
1321
+ address: ownerAddress,
1322
+ smartAccount: setup.smartAccount
1323
+ });
1324
+ } catch (err) {
1325
+ if (cancelled) return;
1326
+ const raw = err instanceof Error ? err.message : "Registration failed";
1327
+ const message = formatUserError(raw);
1328
+ logFlowError("auto-register:failed", err, {
1329
+ ownerAddress,
1330
+ targetChain,
1331
+ targetToken
1332
+ });
1333
+ storeApi.dispatch({
1334
+ type: "registration/failed",
1335
+ error: message
1336
+ });
1337
+ onErrorRef.current?.({ message, code: "WITHDRAW_REGISTER_FAILED" });
1338
+ }
1339
+ }, REGISTRATION_DEBOUNCE_MS);
1340
+ return () => {
1341
+ cancelled = true;
1342
+ clearTimeout(timeout);
1343
+ };
1344
+ }, [
1345
+ ownerAddress,
1346
+ targetChain,
1347
+ targetToken,
1348
+ recipientForRegistration,
1349
+ service,
1350
+ signerAddress,
1351
+ sessionChainIds,
1352
+ forceRegister,
1353
+ storeApi,
1354
+ logFlow,
1355
+ logFlowError,
1356
+ onLifecycleRef,
1357
+ onErrorRef
1358
+ ]);
1017
1359
  const asset = useMemo2(() => {
1018
1360
  const symbol = getTokenSymbol(sourceToken, sourceChain);
1019
1361
  const decimals = getTokenDecimalsByAddress(sourceToken, sourceChain);
@@ -1028,60 +1370,51 @@ function WithdrawFlow({
1028
1370
  }, [sourceChain, sourceToken]);
1029
1371
  const isSourceNative = sourceToken.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase();
1030
1372
  const isSameRoute = targetChain === sourceChain && targetToken.toLowerCase() === sourceToken.toLowerCase();
1031
- const stepIndex = step.type === "form" ? 0 : 1;
1032
- const currentBackHandler = void 0;
1373
+ const reviewBackHandler = useCallback2(() => {
1374
+ storeApi.dispatch({ type: "review/back" });
1375
+ }, [storeApi]);
1033
1376
  useEffect2(() => {
1034
- onStepChangeRef.current?.(stepIndex, currentBackHandler);
1035
- }, [stepIndex, currentBackHandler, onStepChangeRef]);
1377
+ onStepChangeRef.current?.(
1378
+ flowStep === "review" ? reviewBackHandler : void 0
1379
+ );
1380
+ }, [flowStep, reviewBackHandler, onStepChangeRef]);
1036
1381
  const lastStepOpenEventKeyRef = useRef2(null);
1037
1382
  useEffect2(() => {
1038
- if (step.type !== "form") {
1383
+ if (flowStep !== "form") {
1039
1384
  lastStepOpenEventKeyRef.current = null;
1040
1385
  return;
1041
1386
  }
1042
- if (lastStepOpenEventKeyRef.current === "form") {
1043
- return;
1044
- }
1387
+ if (lastStepOpenEventKeyRef.current === "form") return;
1045
1388
  lastStepOpenEventKeyRef.current = "form";
1046
- if (step.type === "form") {
1047
- const tokenSymbol = getTokenSymbol(targetToken, targetChain);
1048
- const chainName = getChainName(targetChain);
1049
- onEventRef.current?.({
1050
- type: "withdraw_modal_select_amount_open",
1051
- pred_balance: totalBalanceUsd,
1052
- default_token: tokenSymbol,
1053
- default_chain: chainName
1054
- });
1055
- }
1056
- }, [step.type, targetToken, targetChain, totalBalanceUsd, onEventRef]);
1389
+ const tokenSymbol = getTokenSymbol(targetToken, targetChain);
1390
+ const chainName = getChainName(targetChain);
1391
+ onEventRef.current?.({
1392
+ type: "withdraw_modal_select_amount_open",
1393
+ pred_balance: totalBalanceUsd,
1394
+ default_token: tokenSymbol,
1395
+ default_chain: chainName
1396
+ });
1397
+ }, [flowStep, targetToken, targetChain, totalBalanceUsd, onEventRef]);
1057
1398
  useEffect2(() => {
1058
1399
  logFlow("state:changed", {
1059
- step: step.type,
1400
+ step: flowStep,
1060
1401
  sourceChain,
1061
1402
  sourceToken,
1062
1403
  targetChain,
1063
1404
  targetToken,
1064
- selectedWalletId
1405
+ selectedWalletId,
1406
+ registration: registration.kind
1065
1407
  });
1066
1408
  }, [
1067
1409
  logFlow,
1068
1410
  selectedWalletId,
1069
1411
  sourceChain,
1070
1412
  sourceToken,
1071
- step.type,
1413
+ flowStep,
1072
1414
  targetChain,
1073
- targetToken
1415
+ targetToken,
1416
+ registration.kind
1074
1417
  ]);
1075
- useEffect2(() => {
1076
- onTotalBalanceChangeRef.current?.(totalBalanceUsd);
1077
- }, [totalBalanceUsd, onTotalBalanceChangeRef]);
1078
- const handleConnected = useCallback2(
1079
- (addr, smartAccount) => {
1080
- logFlow("setup:connected", { address: addr, smartAccount });
1081
- onConnectedRef.current?.({ address: addr, smartAccount });
1082
- },
1083
- [logFlow, onConnectedRef]
1084
- );
1085
1418
  const handleError = useCallback2(
1086
1419
  (message, code) => {
1087
1420
  logFlowError("flow:error", message, { code });
@@ -1089,23 +1422,8 @@ function WithdrawFlow({
1089
1422
  },
1090
1423
  [logFlowError, onErrorRef]
1091
1424
  );
1092
- const resolveSessionOwner = useCallback2(async (eoaAddress) => {
1093
- const localOwner = loadSessionOwnerFromStorage(eoaAddress);
1094
- if (localOwner) {
1095
- return {
1096
- account: accountFromPrivateKey(localOwner.privateKey),
1097
- address: localOwner.address
1098
- };
1099
- }
1100
- const created = createSessionOwnerKey();
1101
- saveSessionOwnerToStorage(eoaAddress, created.privateKey, created.address);
1102
- return {
1103
- account: created.account,
1104
- address: created.address
1105
- };
1106
- }, []);
1107
- const handleFormSubmit = useCallback2(
1108
- async (recipient, amountValue) => {
1425
+ const handleFormContinue = useCallback2(
1426
+ (recipient, amountValue) => {
1109
1427
  const tokenSymbol = getTokenSymbol(targetToken, targetChain);
1110
1428
  const chainName = getChainName(targetChain);
1111
1429
  onEventRef.current?.({
@@ -1116,17 +1434,32 @@ function WithdrawFlow({
1116
1434
  amount: amountValue,
1117
1435
  cta_name: "withdraw"
1118
1436
  });
1119
- const ownerAddress2 = signerContext?.ownerAddress;
1120
- if (!ownerAddress2) {
1121
- throw new Error("Wallet not connected");
1437
+ storeApi.dispatch({
1438
+ type: "form/continue",
1439
+ amount: amountValue,
1440
+ recipient
1441
+ });
1442
+ },
1443
+ [targetToken, targetChain, totalBalanceUsd, onEventRef, storeApi]
1444
+ );
1445
+ const handleReviewConfirm = useCallback2(
1446
+ async () => {
1447
+ const state = storeApi.getState();
1448
+ if (state.registration.kind !== "ready") {
1449
+ throw new Error("Session not ready");
1450
+ }
1451
+ const smartAccount = state.registration.smartAccount;
1452
+ const recipient = state.recipient;
1453
+ const amountValue = state.amount;
1454
+ if (!recipient || !amountValue) {
1455
+ throw new Error("Missing recipient or amount");
1122
1456
  }
1123
1457
  if (!onSignTransaction && !signerContext?.walletClient) {
1124
1458
  throw new Error("Wallet not connected");
1125
1459
  }
1126
- setIsSubmitting(true);
1127
1460
  try {
1128
1461
  logFlow("submit:start", {
1129
- ownerAddress: ownerAddress2,
1462
+ smartAccount,
1130
1463
  recipient,
1131
1464
  amount: amountValue,
1132
1465
  sourceChain,
@@ -1134,60 +1467,6 @@ function WithdrawFlow({
1134
1467
  targetChain,
1135
1468
  targetToken
1136
1469
  });
1137
- const sessionOwner = await resolveSessionOwner(ownerAddress2);
1138
- const setup = await service.setupAccount({
1139
- ownerAddress: ownerAddress2,
1140
- sessionOwnerAddress: sessionOwner.address,
1141
- targetChain: toEvmCaip2(targetChain),
1142
- targetToken,
1143
- recipient,
1144
- signerAddress,
1145
- sessionChainIds,
1146
- forceRegister
1147
- });
1148
- const smartAccount = setup.smartAccount;
1149
- logFlow("setup:resolved", {
1150
- smartAccount,
1151
- needsRegistration: setup.needsRegistration
1152
- });
1153
- if (setup.needsRegistration) {
1154
- if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
1155
- throw new Error("Missing registration payload from setup-account");
1156
- }
1157
- const typedData = setup.sessionDetailsUnsigned.data;
1158
- if (!sessionOwner.account.signTypedData) {
1159
- throw new Error(
1160
- "Session owner account does not support signTypedData"
1161
- );
1162
- }
1163
- const signature = await sessionOwner.account.signTypedData({
1164
- domain: typedData.domain,
1165
- types: typedData.types,
1166
- primaryType: typedData.primaryType,
1167
- message: typedData.message
1168
- });
1169
- const sessionDetails = buildSessionDetails(
1170
- setup.sessionDetailsUnsigned,
1171
- signature
1172
- );
1173
- await service.registerAccount({
1174
- address: smartAccount,
1175
- accountParams: {
1176
- factory: setup.accountParams.factory,
1177
- factoryData: setup.accountParams.factoryData,
1178
- sessionDetails
1179
- },
1180
- eoaAddress: ownerAddress2,
1181
- sessionOwner: sessionOwner.address,
1182
- target: {
1183
- chain: toEvmCaip2(targetChain),
1184
- token: targetToken,
1185
- recipient
1186
- }
1187
- });
1188
- logFlow("register:success", { smartAccount });
1189
- }
1190
- handleConnected(ownerAddress2, smartAccount);
1191
1470
  const amountUnits = parseUnits2(amountValue, asset.decimals);
1192
1471
  const pc = signerContext?.publicClient ?? getPublicClient(sourceChain);
1193
1472
  let result;
@@ -1249,21 +1528,14 @@ function WithdrawFlow({
1249
1528
  sourceChain,
1250
1529
  sourceToken
1251
1530
  });
1252
- onWithdrawSubmittedRef.current?.({
1531
+ onLifecycleRef.current?.({
1532
+ type: "submitted",
1253
1533
  txHash: result.txHash,
1254
1534
  sourceChain,
1255
1535
  amount: amountUnits.toString(),
1256
1536
  safeAddress
1257
1537
  });
1258
- setStep({
1259
- type: "processing",
1260
- smartAccount,
1261
- txHash: result.txHash,
1262
- sourceChain,
1263
- sourceToken,
1264
- amount: amountUnits.toString(),
1265
- directTransfer: isSameRoute
1266
- });
1538
+ storeApi.dispatch({ type: "withdraw/submitted", txHash: result.txHash });
1267
1539
  } catch (err) {
1268
1540
  const raw = err instanceof Error ? err.message : "Withdraw failed";
1269
1541
  logFlowError("submit:failed", err, {
@@ -1274,20 +1546,13 @@ function WithdrawFlow({
1274
1546
  });
1275
1547
  handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
1276
1548
  throw err;
1277
- } finally {
1278
- setIsSubmitting(false);
1279
1549
  }
1280
1550
  },
1281
1551
  [
1282
1552
  signerContext,
1283
- resolveSessionOwner,
1284
- signerAddress,
1285
- sessionChainIds,
1286
- forceRegister,
1287
1553
  targetChain,
1288
1554
  targetToken,
1289
1555
  service,
1290
- handleConnected,
1291
1556
  asset.decimals,
1292
1557
  safeAddress,
1293
1558
  sourceToken,
@@ -1298,15 +1563,15 @@ function WithdrawFlow({
1298
1563
  handleError,
1299
1564
  logFlow,
1300
1565
  logFlowError,
1301
- onEventRef,
1302
- totalBalanceUsd,
1303
- onWithdrawSubmittedRef
1566
+ onLifecycleRef,
1567
+ storeApi
1304
1568
  ]
1305
1569
  );
1306
1570
  const handleWithdrawComplete = useCallback2(
1307
1571
  (txHash, destinationTxHash, context) => {
1308
1572
  logFlow("withdraw:complete", { txHash, destinationTxHash, ...context });
1309
- onWithdrawCompleteRef.current?.({
1573
+ onLifecycleRef.current?.({
1574
+ type: "complete",
1310
1575
  txHash,
1311
1576
  destinationTxHash,
1312
1577
  amount: context.amount,
@@ -1315,15 +1580,21 @@ function WithdrawFlow({
1315
1580
  targetChain: context.targetChain,
1316
1581
  targetToken: context.targetToken
1317
1582
  });
1583
+ storeApi.dispatch({ type: "withdraw/complete" });
1318
1584
  },
1319
- [logFlow, onWithdrawCompleteRef]
1585
+ [logFlow, onLifecycleRef, storeApi]
1320
1586
  );
1321
1587
  const handleWithdrawFailed = useCallback2(
1322
1588
  (txHash, error) => {
1323
1589
  logFlowError("withdraw:failed", error, { txHash });
1324
- onWithdrawFailedRef.current?.({ txHash, error });
1590
+ onLifecycleRef.current?.({
1591
+ type: "failed",
1592
+ txHash,
1593
+ error
1594
+ });
1595
+ storeApi.dispatch({ type: "withdraw/failed" });
1325
1596
  },
1326
- [logFlowError, onWithdrawFailedRef]
1597
+ [logFlowError, onLifecycleRef, storeApi]
1327
1598
  );
1328
1599
  const allowedChainSet = useMemo2(
1329
1600
  () => allowedRoutes?.sourceChains ? new Set(allowedRoutes.sourceChains) : null,
@@ -1353,20 +1624,18 @@ function WithdrawFlow({
1353
1624
  const matches = targetTokenOptions.some(
1354
1625
  (option) => option.address.toLowerCase() === targetToken.toLowerCase()
1355
1626
  );
1356
- if (!matches) {
1357
- setTargetToken(targetTokenOptions[0].address);
1358
- }
1627
+ if (!matches) setTargetToken(targetTokenOptions[0].address);
1359
1628
  }, [targetToken, targetTokenOptions]);
1360
1629
  const handleTargetChainChange = useCallback2(
1361
1630
  (chainId) => {
1362
1631
  setTargetChain(chainId);
1363
1632
  let options = getSupportedTargetTokens(chainId);
1364
1633
  if (allowedTokenSet) {
1365
- options = options.filter((t) => allowedTokenSet.has(t.symbol.toUpperCase()));
1366
- }
1367
- if (options.length === 0) {
1368
- return;
1634
+ options = options.filter(
1635
+ (t) => allowedTokenSet.has(t.symbol.toUpperCase())
1636
+ );
1369
1637
  }
1638
+ if (options.length === 0) return;
1370
1639
  const currentlySupported = options.some(
1371
1640
  (option) => option.address.toLowerCase() === targetToken.toLowerCase()
1372
1641
  );
@@ -1381,27 +1650,18 @@ function WithdrawFlow({
1381
1650
  }, []);
1382
1651
  const selectedWalletIdEffective = useMemo2(() => {
1383
1652
  if (selectedWalletId) return selectedWalletId;
1384
- if (walletOptions.length === 1) {
1385
- return walletOptions[0].id;
1386
- }
1653
+ if (walletOptions.length === 1) return walletOptions[0].id;
1387
1654
  return null;
1388
1655
  }, [selectedWalletId, walletOptions]);
1389
1656
  const walletOptionsKey = useMemo2(
1390
- () => walletOptions.map((option) => option.id).join(","),
1657
+ () => walletOptions.map((o) => o.id).join(","),
1391
1658
  [walletOptions]
1392
1659
  );
1393
1660
  const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
1394
1661
  useEffect2(() => {
1395
1662
  setIsConnectSelectionConfirmed(false);
1396
- }, [walletOptionsKey, selectedWalletIdEffective]);
1397
- useEffect2(() => {
1398
- if (!showConnectStep && isConnectSelectionConfirmed && !signerContext) {
1399
- setSelectedWalletId(null);
1400
- setIsConnectSelectionConfirmed(false);
1401
- }
1402
- }, [showConnectStep, isConnectSelectionConfirmed, signerContext]);
1403
- const ownerAddress = signerContext?.ownerAddress;
1404
- const selectedWalletOption = selectedWalletIdEffective ? walletOptions.find((option) => option.id === selectedWalletIdEffective) ?? null : null;
1663
+ }, [walletOptionsKey]);
1664
+ const selectedWalletOption = selectedWalletIdEffective ? walletOptions.find((o) => o.id === selectedWalletIdEffective) ?? null : null;
1405
1665
  const selectedWalletIcon = useMemo2(() => {
1406
1666
  if (!ownerAddress) return void 0;
1407
1667
  const selected = walletOptions.find(
@@ -1410,22 +1670,19 @@ function WithdrawFlow({
1410
1670
  return selected?.kind === "external" ? selected.icon ?? reownWallet?.icon : void 0;
1411
1671
  }, [walletOptions, ownerAddress, reownWallet?.icon]);
1412
1672
  if (showConnectStep) {
1413
- return /* @__PURE__ */ jsx2("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx2(
1673
+ return /* @__PURE__ */ jsx3("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx3(
1414
1674
  ConnectStep,
1415
1675
  {
1416
1676
  walletOptions,
1417
- selectedWalletId: selectedWalletIdEffective,
1418
- onSelectWallet: setSelectedWalletId,
1677
+ onConfirmWallet: (walletId) => {
1678
+ setSelectedWalletId(walletId);
1679
+ setIsConnectSelectionConfirmed(true);
1680
+ },
1419
1681
  onRequestConnect,
1420
1682
  onConnect,
1421
1683
  onDisconnect,
1422
- onContinue: () => {
1423
- if (selectedWalletIdEffective) {
1424
- setSelectedWalletId(selectedWalletIdEffective);
1425
- }
1426
- setIsConnectSelectionConfirmed(true);
1427
- },
1428
- connectButtonLabel
1684
+ title: "Withdraw",
1685
+ subtitle: "Choose a wallet to continue"
1429
1686
  }
1430
1687
  ) });
1431
1688
  }
@@ -1433,8 +1690,9 @@ function WithdrawFlow({
1433
1690
  if (!onSignTransaction && !signerContext.walletClient) return null;
1434
1691
  const resolvedConnectedRecipient = selectedWalletOption?.kind === "external" ? selectedWalletOption.address : void 0;
1435
1692
  const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
1436
- return /* @__PURE__ */ jsxs2("div", { className: "rs-modal-body", children: [
1437
- step.type === "form" && /* @__PURE__ */ jsx2(
1693
+ const stepView = deriveStepView(flowStep, registration);
1694
+ return /* @__PURE__ */ jsxs3("div", { className: "rs-modal-body", children: [
1695
+ stepView === "form" && /* @__PURE__ */ jsx3(
1438
1696
  WithdrawFormStep,
1439
1697
  {
1440
1698
  walletClient: signerContext.walletClient,
@@ -1452,27 +1710,44 @@ function WithdrawFlow({
1452
1710
  onTargetTokenChange: handleTargetTokenChange,
1453
1711
  switchChain: signerContext.switchChain,
1454
1712
  walletIcon: selectedWalletIcon,
1455
- submitting: isSubmitting,
1456
- onSubmit: handleFormSubmit,
1713
+ registrationPending: registration.kind === "pending" || registration.kind === "stale",
1714
+ registrationError: registration.kind === "failed" ? registration.error : null,
1715
+ onRecipientChange: setRecipientInput,
1716
+ onSubmit: async (r, a) => handleFormContinue(r, a),
1457
1717
  onBalanceUsdChange: setTotalBalanceUsd
1458
1718
  }
1459
1719
  ),
1460
- step.type === "processing" && /* @__PURE__ */ jsx2(
1720
+ stepView === "review" && /* @__PURE__ */ jsx3(
1721
+ WithdrawReviewStep,
1722
+ {
1723
+ sourceChain,
1724
+ sourceSymbol: asset.symbol,
1725
+ targetChain,
1726
+ targetToken,
1727
+ amount: storeApi.getState().amount ?? "0",
1728
+ recipient: storeApi.getState().recipient ?? recipientForRegistration ?? "0x0",
1729
+ registrationPending: registration.kind === "pending" || registration.kind === "stale",
1730
+ registrationError: registration.kind === "failed" ? registration.error : null,
1731
+ onConfirm: handleReviewConfirm,
1732
+ onError: handleError
1733
+ }
1734
+ ),
1735
+ stepView === "processing" && registration.kind !== "idle" && /* @__PURE__ */ jsx3(
1461
1736
  ProcessingStep,
1462
1737
  {
1463
- smartAccount: step.smartAccount,
1464
- txHash: step.txHash,
1465
- sourceChain: step.sourceChain,
1466
- sourceToken: step.sourceToken,
1738
+ smartAccount: registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : "0x0",
1739
+ txHash: storeApi.getState().txHash ?? "0x0",
1740
+ sourceChain,
1741
+ sourceToken,
1467
1742
  targetChain,
1468
1743
  targetToken,
1469
- amount: step.amount,
1470
- directTransfer: step.directTransfer,
1744
+ amount: storeApi.getState().amount ?? "0",
1745
+ directTransfer: isSameRoute,
1471
1746
  waitForFinalTx,
1472
1747
  service,
1473
1748
  flowLabel: "withdraw",
1474
1749
  onClose,
1475
- onNewDeposit: () => setStep({ type: "form" }),
1750
+ onNewDeposit: () => storeApi.dispatch({ type: "flow/reset" }),
1476
1751
  onDepositComplete: handleWithdrawComplete,
1477
1752
  onDepositFailed: handleWithdrawFailed,
1478
1753
  onError: handleError,
@@ -1481,20 +1756,27 @@ function WithdrawFlow({
1481
1756
  )
1482
1757
  ] });
1483
1758
  }
1759
+ function deriveStepView(step, _registration) {
1760
+ if (step === "review") return "review";
1761
+ if (step === "processing" || step === "complete" || step === "failed") {
1762
+ return "processing";
1763
+ }
1764
+ return "form";
1765
+ }
1484
1766
 
1485
1767
  // src/WithdrawModal.tsx
1486
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1768
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1487
1769
  var ReownWithdrawInner = lazy(
1488
- () => import("./WithdrawModalReown-YSRO5ZTA.mjs").then((m) => ({
1770
+ () => import("./WithdrawModalReown-O6V6KRH6.mjs").then((m) => ({
1489
1771
  default: m.WithdrawModalReown
1490
1772
  }))
1491
1773
  );
1492
1774
  function WithdrawModal(props) {
1493
1775
  const needsReown = !!props.reownAppId;
1494
1776
  if (needsReown) {
1495
- return /* @__PURE__ */ jsx3(Suspense, { fallback: null, children: /* @__PURE__ */ jsx3(ReownWithdrawInner, { ...props }) });
1777
+ return /* @__PURE__ */ jsx4(Suspense, { fallback: null, children: /* @__PURE__ */ jsx4(ReownWithdrawInner, { ...props }) });
1496
1778
  }
1497
- return /* @__PURE__ */ jsx3(WithdrawModalInner, { ...props });
1779
+ return /* @__PURE__ */ jsx4(WithdrawModalInner, { ...props });
1498
1780
  }
1499
1781
  WithdrawModal.displayName = "WithdrawModal";
1500
1782
  function WithdrawModalInner({
@@ -1523,31 +1805,36 @@ function WithdrawModalInner({
1523
1805
  onDisconnect,
1524
1806
  onSignTransaction,
1525
1807
  onRequestConnect,
1526
- connectButtonLabel,
1527
1808
  theme,
1528
- branding,
1529
1809
  uiConfig,
1530
1810
  className,
1531
1811
  onReady,
1532
- onConnected,
1533
- onWithdrawSubmitted,
1534
- onWithdrawComplete,
1535
- onWithdrawFailed,
1812
+ onLifecycle,
1536
1813
  onEvent,
1537
1814
  onError,
1538
1815
  debug
1539
1816
  }) {
1540
1817
  const modalRef = useRef3(null);
1541
1818
  const onReadyRef = useLatestRef(onReady);
1542
- const [currentStepIndex, setCurrentStepIndex] = useState3(0);
1543
- const [totalBalanceUsd, setTotalBalanceUsd] = useState3(null);
1544
- const backHandlerRef = useRef3(void 0);
1819
+ const [backHandler, setBackHandler] = useState4(
1820
+ void 0
1821
+ );
1545
1822
  const targetChain = getChainId(targetChainProp);
1546
1823
  const sourceChain = getChainId(sourceChainProp);
1547
1824
  const service = useMemo3(
1548
1825
  () => createDepositService(backendUrl, { debug, debugScope: "service:withdraw" }),
1549
1826
  [backendUrl, debug]
1550
1827
  );
1828
+ const store = useMemo3(() => createWithdrawStore(), []);
1829
+ const onErrorRef = useLatestRef(onError);
1830
+ useEffect3(() => {
1831
+ if (isOpen && onSignTransaction && !dappAddress) {
1832
+ onErrorRef.current?.({
1833
+ message: "WithdrawModal requires `dappAddress` when `onSignTransaction` is provided.",
1834
+ code: "WITHDRAW_MISSING_DAPP_ADDRESS"
1835
+ });
1836
+ }
1837
+ }, [isOpen, onSignTransaction, dappAddress, onErrorRef]);
1551
1838
  useEffect3(() => {
1552
1839
  if (isOpen && modalRef.current) {
1553
1840
  applyTheme(modalRef.current, theme);
@@ -1560,30 +1847,15 @@ function WithdrawModalInner({
1560
1847
  }, [isOpen, onReadyRef]);
1561
1848
  useEffect3(() => {
1562
1849
  if (!isOpen) {
1563
- setCurrentStepIndex(0);
1850
+ store.dispatch({ type: "modal/reset" });
1564
1851
  }
1565
- }, [isOpen]);
1566
- const handleStepChange = useCallback3(
1567
- (stepIndex, onBack) => {
1568
- setCurrentStepIndex(stepIndex);
1569
- backHandlerRef.current = onBack;
1570
- },
1571
- []
1572
- );
1573
- const handleTotalBalanceChange = useCallback3((balance2) => {
1574
- setTotalBalanceUsd(balance2);
1575
- }, []);
1576
- const handleBack = useCallback3(() => {
1577
- backHandlerRef.current?.();
1852
+ }, [isOpen, store]);
1853
+ const handleStepChange = useCallback3((onBack) => {
1854
+ setBackHandler(() => onBack);
1578
1855
  }, []);
1579
- const showLogo = uiConfig?.showLogo ?? false;
1580
- const showStepper = uiConfig?.showStepper ?? false;
1581
1856
  const showBackButton = uiConfig?.showBackButton ?? true;
1582
- const balance = uiConfig?.balance;
1583
- const logoUrl = branding?.logoUrl ?? "https://github.com/rhinestonewtf.png";
1584
- const title = branding?.title ?? "Withdraw";
1585
- const canGoBack = currentStepIndex > 0 && currentStepIndex < 3 && backHandlerRef.current;
1586
- return /* @__PURE__ */ jsx3(
1857
+ const canGoBack = backHandler !== void 0;
1858
+ return /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
1587
1859
  Modal,
1588
1860
  {
1589
1861
  isOpen,
@@ -1591,89 +1863,30 @@ function WithdrawModalInner({
1591
1863
  className,
1592
1864
  inline,
1593
1865
  closeOnOverlayClick,
1594
- children: /* @__PURE__ */ jsxs3("div", { ref: modalRef, className: "rs-modal", children: [
1595
- /* @__PURE__ */ jsxs3("div", { className: "rs-modal-header--redesigned", children: [
1596
- /* @__PURE__ */ jsx3("div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && /* @__PURE__ */ jsx3(
1866
+ children: /* @__PURE__ */ jsxs4("div", { ref: modalRef, className: "rs-modal", children: [
1867
+ /* @__PURE__ */ jsxs4("div", { className: "rs-modal-header--redesigned", children: [
1868
+ /* @__PURE__ */ jsx4("div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && backHandler && /* @__PURE__ */ jsx4(
1597
1869
  "button",
1598
1870
  {
1599
1871
  type: "button",
1600
1872
  className: "rs-modal-header-back",
1601
1873
  "aria-label": "Go back",
1602
- onClick: handleBack,
1603
- children: /* @__PURE__ */ jsx3(
1604
- "svg",
1605
- {
1606
- viewBox: "0 0 24 24",
1607
- fill: "none",
1608
- stroke: "currentColor",
1609
- strokeWidth: "2",
1610
- children: /* @__PURE__ */ jsx3(
1611
- "path",
1612
- {
1613
- strokeLinecap: "round",
1614
- strokeLinejoin: "round",
1615
- d: "M15.75 19.5L8.25 12l7.5-7.5"
1616
- }
1617
- )
1618
- }
1619
- )
1874
+ onClick: backHandler,
1875
+ children: /* @__PURE__ */ jsx4(ChevronLeftIcon, {})
1620
1876
  }
1621
1877
  ) }),
1622
- /* @__PURE__ */ jsxs3("div", { className: "rs-modal-header-nav-center", children: [
1623
- /* @__PURE__ */ jsxs3("div", { className: "rs-modal-header-title-row", children: [
1624
- showLogo && logoUrl && /* @__PURE__ */ jsx3(
1625
- "img",
1626
- {
1627
- src: logoUrl,
1628
- alt: "",
1629
- className: "rs-modal-logo",
1630
- onError: (e) => {
1631
- e.target.style.display = "none";
1632
- }
1633
- }
1634
- ),
1635
- /* @__PURE__ */ jsx3("span", { className: "rs-modal-header-title", children: title }),
1636
- showStepper && /* @__PURE__ */ jsx3("div", { className: "rs-modal-progress", style: { marginLeft: 8 }, children: [0, 1].map((i) => /* @__PURE__ */ jsx3(
1637
- "div",
1638
- {
1639
- className: `rs-modal-progress-dot ${i <= currentStepIndex ? "rs-modal-progress-dot--active" : "rs-modal-progress-dot--inactive"}`
1640
- },
1641
- i
1642
- )) })
1643
- ] }),
1644
- balance && /* @__PURE__ */ jsxs3("div", { className: "rs-modal-header-balance", children: [
1645
- /* @__PURE__ */ jsx3("span", { className: "rs-modal-header-balance-label", children: balance.title }),
1646
- /* @__PURE__ */ jsx3("span", { className: "rs-modal-header-balance-value", children: balance.amount ?? (totalBalanceUsd !== null ? currencyFormatter.format(totalBalanceUsd) : null) })
1647
- ] })
1648
- ] }),
1649
- /* @__PURE__ */ jsx3("div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ jsx3(
1878
+ /* @__PURE__ */ jsx4("div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ jsx4(
1650
1879
  "button",
1651
1880
  {
1652
1881
  type: "button",
1653
1882
  onClick: onClose,
1654
1883
  className: "rs-modal-close",
1655
1884
  "aria-label": "Close",
1656
- children: /* @__PURE__ */ jsx3(
1657
- "svg",
1658
- {
1659
- viewBox: "0 0 24 24",
1660
- fill: "none",
1661
- stroke: "currentColor",
1662
- strokeWidth: "2",
1663
- children: /* @__PURE__ */ jsx3(
1664
- "path",
1665
- {
1666
- strokeLinecap: "round",
1667
- strokeLinejoin: "round",
1668
- d: "M6 18L18 6M6 6l12 12"
1669
- }
1670
- )
1671
- }
1672
- )
1885
+ children: /* @__PURE__ */ jsx4(CloseIcon, {})
1673
1886
  }
1674
1887
  ) })
1675
1888
  ] }),
1676
- /* @__PURE__ */ jsx3(
1889
+ /* @__PURE__ */ jsx4(
1677
1890
  WithdrawFlow,
1678
1891
  {
1679
1892
  dappWalletClient,
@@ -1697,14 +1910,9 @@ function WithdrawModalInner({
1697
1910
  onDisconnect,
1698
1911
  onSignTransaction,
1699
1912
  onRequestConnect,
1700
- connectButtonLabel,
1701
1913
  onStepChange: handleStepChange,
1702
- onTotalBalanceChange: handleTotalBalanceChange,
1703
1914
  onClose,
1704
- onConnected,
1705
- onWithdrawSubmitted,
1706
- onWithdrawComplete,
1707
- onWithdrawFailed,
1915
+ onLifecycle,
1708
1916
  onEvent,
1709
1917
  onError,
1710
1918
  debug
@@ -1712,7 +1920,7 @@ function WithdrawModalInner({
1712
1920
  )
1713
1921
  ] })
1714
1922
  }
1715
- );
1923
+ ) });
1716
1924
  }
1717
1925
 
1718
1926
  export {