@rhinestone/deposit-modal 0.1.61 → 0.1.62

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.
@@ -19,8 +19,9 @@ import {
19
19
  isNativeAsset,
20
20
  loadSessionOwnerFromStorage,
21
21
  saveSessionOwnerToStorage,
22
- toEvmCaip2
23
- } from "./chunk-7TTEHQBD.mjs";
22
+ toEvmCaip2,
23
+ useLatestRef
24
+ } from "./chunk-NDTY5AUU.mjs";
24
25
  import {
25
26
  DEFAULT_BACKEND_URL,
26
27
  DEFAULT_SIGNER_ADDRESS,
@@ -40,14 +41,14 @@ import {
40
41
  useCallback as useCallback3,
41
42
  useEffect as useEffect3,
42
43
  useMemo as useMemo3,
43
- useRef as useRef2,
44
+ useRef as useRef3,
44
45
  useState as useState3,
45
46
  lazy,
46
47
  Suspense
47
48
  } from "react";
48
49
 
49
50
  // src/WithdrawFlow.tsx
50
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
51
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
51
52
 
52
53
  // src/components/steps/WithdrawFormStep.tsx
53
54
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -905,6 +906,9 @@ function WithdrawFlow({
905
906
  onError,
906
907
  debug
907
908
  }) {
909
+ const onStepChangeRef = useLatestRef(onStepChange);
910
+ const onTotalBalanceChangeRef = useLatestRef(onTotalBalanceChange);
911
+ const onEventRef = useLatestRef(onEvent);
908
912
  const [step, setStep] = useState2({ type: "form" });
909
913
  const [isSubmitting, setIsSubmitting] = useState2(false);
910
914
  const [totalBalanceUsd, setTotalBalanceUsd] = useState2(0);
@@ -1036,20 +1040,29 @@ function WithdrawFlow({
1036
1040
  const stepIndex = step.type === "form" ? 0 : 1;
1037
1041
  const currentBackHandler = void 0;
1038
1042
  useEffect2(() => {
1039
- onStepChange?.(stepIndex, currentBackHandler);
1040
- }, [stepIndex, currentBackHandler, onStepChange]);
1043
+ onStepChangeRef.current?.(stepIndex, currentBackHandler);
1044
+ }, [stepIndex, currentBackHandler, onStepChangeRef]);
1045
+ const lastStepOpenEventKeyRef = useRef2(null);
1041
1046
  useEffect2(() => {
1047
+ if (step.type !== "form") {
1048
+ lastStepOpenEventKeyRef.current = null;
1049
+ return;
1050
+ }
1051
+ if (lastStepOpenEventKeyRef.current === "form") {
1052
+ return;
1053
+ }
1054
+ lastStepOpenEventKeyRef.current = "form";
1042
1055
  if (step.type === "form") {
1043
1056
  const tokenSymbol = getTokenSymbol(targetToken, targetChain);
1044
1057
  const chainName = getChainName(targetChain);
1045
- onEvent?.({
1058
+ onEventRef.current?.({
1046
1059
  type: "withdraw_modal_select_amount_open",
1047
1060
  pred_balance: totalBalanceUsd,
1048
1061
  default_token: tokenSymbol,
1049
1062
  default_chain: chainName
1050
1063
  });
1051
1064
  }
1052
- }, [step.type, onEvent]);
1065
+ }, [step.type, targetToken, targetChain, totalBalanceUsd, onEventRef]);
1053
1066
  useEffect2(() => {
1054
1067
  logFlow("state:changed", {
1055
1068
  step: step.type,
@@ -1069,8 +1082,8 @@ function WithdrawFlow({
1069
1082
  targetToken
1070
1083
  ]);
1071
1084
  useEffect2(() => {
1072
- onTotalBalanceChange?.(totalBalanceUsd);
1073
- }, [totalBalanceUsd, onTotalBalanceChange]);
1085
+ onTotalBalanceChangeRef.current?.(totalBalanceUsd);
1086
+ }, [totalBalanceUsd, onTotalBalanceChangeRef]);
1074
1087
  const handleConnected = useCallback2(
1075
1088
  (addr, smartAccount) => {
1076
1089
  logFlow("setup:connected", { address: addr, smartAccount });
@@ -1478,7 +1491,7 @@ function WithdrawFlow({
1478
1491
  // src/WithdrawModal.tsx
1479
1492
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1480
1493
  var ReownWithdrawInner = lazy(
1481
- () => import("./WithdrawModalReown-OHTYDGI5.mjs").then((m) => ({
1494
+ () => import("./WithdrawModalReown-DRSOFZLI.mjs").then((m) => ({
1482
1495
  default: m.WithdrawModalReown
1483
1496
  }))
1484
1497
  );
@@ -1530,10 +1543,11 @@ function WithdrawModalInner({
1530
1543
  onError,
1531
1544
  debug
1532
1545
  }) {
1533
- const modalRef = useRef2(null);
1546
+ const modalRef = useRef3(null);
1547
+ const onReadyRef = useLatestRef(onReady);
1534
1548
  const [currentStepIndex, setCurrentStepIndex] = useState3(0);
1535
1549
  const [totalBalanceUsd, setTotalBalanceUsd] = useState3(null);
1536
- const backHandlerRef = useRef2(void 0);
1550
+ const backHandlerRef = useRef3(void 0);
1537
1551
  const targetChain = getChainId(targetChainProp);
1538
1552
  const sourceChain = getChainId(sourceChainProp);
1539
1553
  const service = useMemo3(
@@ -1545,13 +1559,13 @@ function WithdrawModalInner({
1545
1559
  applyTheme(modalRef.current, theme);
1546
1560
  }
1547
1561
  }, [isOpen, theme]);
1548
- const hasCalledReady = useRef2(false);
1562
+ const hasCalledReady = useRef3(false);
1549
1563
  useEffect3(() => {
1550
1564
  if (isOpen && !hasCalledReady.current) {
1551
1565
  hasCalledReady.current = true;
1552
- onReady?.();
1566
+ onReadyRef.current?.();
1553
1567
  }
1554
- }, [isOpen, onReady]);
1568
+ }, [isOpen, onReadyRef]);
1555
1569
  useEffect3(() => {
1556
1570
  if (!isOpen) {
1557
1571
  setCurrentStepIndex(0);
@@ -20,7 +20,8 @@
20
20
 
21
21
 
22
22
 
23
- var _chunkTQ6IIGRScjs = require('./chunk-TQ6IIGRS.cjs');
23
+
24
+ var _chunkMVFMDKAScjs = require('./chunk-MVFMDKAS.cjs');
24
25
 
25
26
 
26
27
 
@@ -141,7 +142,7 @@ function WithdrawFormStep({
141
142
  setIsSwitching(true);
142
143
  switchChain(asset.chainId).catch((err) => {
143
144
  const raw = err instanceof Error ? err.message : "Failed to switch chain";
144
- setError(_chunkTQ6IIGRScjs.formatUserError.call(void 0, raw));
145
+ setError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw));
145
146
  }).finally(() => {
146
147
  setIsSwitching(false);
147
148
  });
@@ -161,7 +162,7 @@ function WithdrawFormStep({
161
162
  return;
162
163
  }
163
164
  try {
164
- const bal = _chunkTQ6IIGRScjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
165
+ const bal = _chunkMVFMDKAScjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
165
166
  address: asset.token,
166
167
  abi: _viem.erc20Abi,
167
168
  functionName: "balanceOf",
@@ -264,7 +265,7 @@ function WithdrawFormStep({
264
265
  await onSubmit(recipient, amount);
265
266
  } catch (err) {
266
267
  const raw = err instanceof Error ? err.message : "Withdrawal failed";
267
- setError(_chunkTQ6IIGRScjs.formatUserError.call(void 0, raw));
268
+ setError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw));
268
269
  } finally {
269
270
  setIsSubmitting(false);
270
271
  }
@@ -272,11 +273,11 @@ function WithdrawFormStep({
272
273
  if (isBalanceLoading) {
273
274
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
274
275
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body rs-withdraw-loading", children: [
275
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTQ6IIGRScjs.Spinner, { className: "rs-spinner--lg" }),
276
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.Spinner, { className: "rs-spinner--lg" }),
276
277
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-title", children: "Loading on-chain balance" }),
277
278
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${_chunkR6U6BHCVcjs.getChainName.call(void 0, asset.chainId)} to continue.` : "Please wait before withdrawing." })
278
279
  ] }),
279
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTQ6IIGRScjs.PoweredBy, {})
280
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.PoweredBy, {})
280
281
  ] });
281
282
  }
282
283
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
@@ -375,7 +376,7 @@ function WithdrawFormStep({
375
376
  ] })
376
377
  ] }),
377
378
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-amount-info", children: [
378
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkTQ6IIGRScjs.currencyFormatter.format(amountUsd) : "$0.00" }),
379
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkMVFMDKAScjs.currencyFormatter.format(amountUsd) : "$0.00" }),
379
380
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-withdraw-balance", children: [
380
381
  "Balance: ",
381
382
  formattedBalance,
@@ -569,7 +570,7 @@ function WithdrawFormStep({
569
570
  ] })
570
571
  ] }),
571
572
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
572
- _chunkTQ6IIGRScjs.Button,
573
+ _chunkMVFMDKAScjs.Button,
573
574
  {
574
575
  onClick: handleWithdraw,
575
576
  fullWidth: true,
@@ -578,7 +579,7 @@ function WithdrawFormStep({
578
579
  children: isBusy ? "Preparing..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
579
580
  }
580
581
  ) }),
581
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTQ6IIGRScjs.PoweredBy, {})
582
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.PoweredBy, {})
582
583
  ] });
583
584
  }
584
585
  WithdrawFormStep.displayName = "WithdrawFormStep";
@@ -905,19 +906,22 @@ function WithdrawFlow({
905
906
  onError,
906
907
  debug
907
908
  }) {
909
+ const onStepChangeRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onStepChange);
910
+ const onTotalBalanceChangeRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onTotalBalanceChange);
911
+ const onEventRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onEvent);
908
912
  const [step, setStep] = _react.useState.call(void 0, { type: "form" });
909
913
  const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
910
914
  const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, 0);
911
915
  const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = _react.useState.call(void 0, false);
912
916
  const logFlow = _react.useCallback.call(void 0,
913
917
  (message, data) => {
914
- _chunkTQ6IIGRScjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
918
+ _chunkMVFMDKAScjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
915
919
  },
916
920
  [debug]
917
921
  );
918
922
  const logFlowError = _react.useCallback.call(void 0,
919
923
  (message, error, data) => {
920
- _chunkTQ6IIGRScjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
924
+ _chunkMVFMDKAScjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
921
925
  },
922
926
  [debug]
923
927
  );
@@ -976,14 +980,14 @@ function WithdrawFlow({
976
980
  return {
977
981
  ownerAddress: dappAddress,
978
982
  walletClient: _nullishCoalesce(dappWalletClient, () => ( void 0)),
979
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkTQ6IIGRScjs.getPublicClient.call(void 0, sourceChain))),
983
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
980
984
  switchChain: dappSwitchChain
981
985
  };
982
986
  }
983
987
  return {
984
988
  ownerAddress: dappWalletClient.account.address,
985
989
  walletClient: dappWalletClient,
986
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkTQ6IIGRScjs.getPublicClient.call(void 0, sourceChain))),
990
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
987
991
  switchChain: dappSwitchChain
988
992
  };
989
993
  }
@@ -994,7 +998,7 @@ function WithdrawFlow({
994
998
  return {
995
999
  ownerAddress: dappWalletClient.account.address,
996
1000
  walletClient: dappWalletClient,
997
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkTQ6IIGRScjs.getPublicClient.call(void 0, sourceChain))),
1001
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
998
1002
  switchChain: dappSwitchChain
999
1003
  };
1000
1004
  }
@@ -1024,7 +1028,7 @@ function WithdrawFlow({
1024
1028
  const symbol = _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
1025
1029
  const decimals = _chunkR6U6BHCVcjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
1026
1030
  return {
1027
- id: _chunkTQ6IIGRScjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1031
+ id: _chunkMVFMDKAScjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1028
1032
  chainId: sourceChain,
1029
1033
  token: sourceToken,
1030
1034
  symbol,
@@ -1036,20 +1040,29 @@ function WithdrawFlow({
1036
1040
  const stepIndex = step.type === "form" ? 0 : 1;
1037
1041
  const currentBackHandler = void 0;
1038
1042
  _react.useEffect.call(void 0, () => {
1039
- _optionalChain([onStepChange, 'optionalCall', _20 => _20(stepIndex, currentBackHandler)]);
1040
- }, [stepIndex, currentBackHandler, onStepChange]);
1043
+ _optionalChain([onStepChangeRef, 'access', _20 => _20.current, 'optionalCall', _21 => _21(stepIndex, currentBackHandler)]);
1044
+ }, [stepIndex, currentBackHandler, onStepChangeRef]);
1045
+ const lastStepOpenEventKeyRef = _react.useRef.call(void 0, null);
1041
1046
  _react.useEffect.call(void 0, () => {
1047
+ if (step.type !== "form") {
1048
+ lastStepOpenEventKeyRef.current = null;
1049
+ return;
1050
+ }
1051
+ if (lastStepOpenEventKeyRef.current === "form") {
1052
+ return;
1053
+ }
1054
+ lastStepOpenEventKeyRef.current = "form";
1042
1055
  if (step.type === "form") {
1043
1056
  const tokenSymbol = _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
1044
1057
  const chainName = _chunkR6U6BHCVcjs.getChainName.call(void 0, targetChain);
1045
- _optionalChain([onEvent, 'optionalCall', _21 => _21({
1058
+ _optionalChain([onEventRef, 'access', _22 => _22.current, 'optionalCall', _23 => _23({
1046
1059
  type: "withdraw_modal_select_amount_open",
1047
1060
  pred_balance: totalBalanceUsd,
1048
1061
  default_token: tokenSymbol,
1049
1062
  default_chain: chainName
1050
1063
  })]);
1051
1064
  }
1052
- }, [step.type, onEvent]);
1065
+ }, [step.type, targetToken, targetChain, totalBalanceUsd, onEventRef]);
1053
1066
  _react.useEffect.call(void 0, () => {
1054
1067
  logFlow("state:changed", {
1055
1068
  step: step.type,
@@ -1069,32 +1082,32 @@ function WithdrawFlow({
1069
1082
  targetToken
1070
1083
  ]);
1071
1084
  _react.useEffect.call(void 0, () => {
1072
- _optionalChain([onTotalBalanceChange, 'optionalCall', _22 => _22(totalBalanceUsd)]);
1073
- }, [totalBalanceUsd, onTotalBalanceChange]);
1085
+ _optionalChain([onTotalBalanceChangeRef, 'access', _24 => _24.current, 'optionalCall', _25 => _25(totalBalanceUsd)]);
1086
+ }, [totalBalanceUsd, onTotalBalanceChangeRef]);
1074
1087
  const handleConnected = _react.useCallback.call(void 0,
1075
1088
  (addr, smartAccount) => {
1076
1089
  logFlow("setup:connected", { address: addr, smartAccount });
1077
- _optionalChain([onConnected, 'optionalCall', _23 => _23({ address: addr, smartAccount })]);
1090
+ _optionalChain([onConnected, 'optionalCall', _26 => _26({ address: addr, smartAccount })]);
1078
1091
  },
1079
1092
  [logFlow, onConnected]
1080
1093
  );
1081
1094
  const handleError = _react.useCallback.call(void 0,
1082
1095
  (message, code) => {
1083
1096
  logFlowError("flow:error", message, { code });
1084
- _optionalChain([onError, 'optionalCall', _24 => _24({ message, code })]);
1097
+ _optionalChain([onError, 'optionalCall', _27 => _27({ message, code })]);
1085
1098
  },
1086
1099
  [logFlowError, onError]
1087
1100
  );
1088
1101
  const resolveSessionOwner = _react.useCallback.call(void 0, async (eoaAddress) => {
1089
- const localOwner = _chunkTQ6IIGRScjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
1102
+ const localOwner = _chunkMVFMDKAScjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
1090
1103
  if (localOwner) {
1091
1104
  return {
1092
- account: _chunkTQ6IIGRScjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
1105
+ account: _chunkMVFMDKAScjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
1093
1106
  address: localOwner.address
1094
1107
  };
1095
1108
  }
1096
- const created = _chunkTQ6IIGRScjs.createSessionOwnerKey.call(void 0, );
1097
- _chunkTQ6IIGRScjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
1109
+ const created = _chunkMVFMDKAScjs.createSessionOwnerKey.call(void 0, );
1110
+ _chunkMVFMDKAScjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
1098
1111
  return {
1099
1112
  account: created.account,
1100
1113
  address: created.address
@@ -1104,7 +1117,7 @@ function WithdrawFlow({
1104
1117
  async (recipient, amountValue) => {
1105
1118
  const tokenSymbol = _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
1106
1119
  const chainName = _chunkR6U6BHCVcjs.getChainName.call(void 0, targetChain);
1107
- _optionalChain([onEvent, 'optionalCall', _25 => _25({
1120
+ _optionalChain([onEvent, 'optionalCall', _28 => _28({
1108
1121
  type: "withdraw_modal_select_amount_cta_click",
1109
1122
  pred_balance: totalBalanceUsd,
1110
1123
  selected_token: tokenSymbol,
@@ -1112,11 +1125,11 @@ function WithdrawFlow({
1112
1125
  amount: amountValue,
1113
1126
  cta_name: "withdraw"
1114
1127
  })]);
1115
- const ownerAddress2 = _optionalChain([signerContext, 'optionalAccess', _26 => _26.ownerAddress]);
1128
+ const ownerAddress2 = _optionalChain([signerContext, 'optionalAccess', _29 => _29.ownerAddress]);
1116
1129
  if (!ownerAddress2) {
1117
1130
  throw new Error("Wallet not connected");
1118
1131
  }
1119
- if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _27 => _27.walletClient])) {
1132
+ if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _30 => _30.walletClient])) {
1120
1133
  throw new Error("Wallet not connected");
1121
1134
  }
1122
1135
  setIsSubmitting(true);
@@ -1134,7 +1147,7 @@ function WithdrawFlow({
1134
1147
  const setup = await service.setupAccount({
1135
1148
  ownerAddress: ownerAddress2,
1136
1149
  sessionOwnerAddress: sessionOwner.address,
1137
- targetChain: _chunkTQ6IIGRScjs.toEvmCaip2.call(void 0, targetChain),
1150
+ targetChain: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, targetChain),
1138
1151
  targetToken,
1139
1152
  signerAddress,
1140
1153
  sessionChainIds,
@@ -1161,7 +1174,7 @@ function WithdrawFlow({
1161
1174
  primaryType: typedData.primaryType,
1162
1175
  message: typedData.message
1163
1176
  });
1164
- const sessionDetails = _chunkTQ6IIGRScjs.buildSessionDetails.call(void 0,
1177
+ const sessionDetails = _chunkMVFMDKAScjs.buildSessionDetails.call(void 0,
1165
1178
  setup.sessionDetailsUnsigned,
1166
1179
  signature
1167
1180
  );
@@ -1175,7 +1188,7 @@ function WithdrawFlow({
1175
1188
  eoaAddress: ownerAddress2,
1176
1189
  sessionOwner: sessionOwner.address,
1177
1190
  target: {
1178
- chain: _chunkTQ6IIGRScjs.toEvmCaip2.call(void 0, targetChain),
1191
+ chain: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, targetChain),
1179
1192
  token: targetToken,
1180
1193
  recipient
1181
1194
  }
@@ -1184,7 +1197,7 @@ function WithdrawFlow({
1184
1197
  }
1185
1198
  handleConnected(ownerAddress2, smartAccount);
1186
1199
  const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
1187
- const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _28 => _28.publicClient]), () => ( _chunkTQ6IIGRScjs.getPublicClient.call(void 0, sourceChain)));
1200
+ const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _31 => _31.publicClient]), () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain)));
1188
1201
  let result;
1189
1202
  if (onSignTransaction) {
1190
1203
  const transferData = isSourceNative ? { to: smartAccount, value: amountUnits, data: "0x" } : {
@@ -1207,7 +1220,7 @@ function WithdrawFlow({
1207
1220
  const { signature } = await onSignTransaction(request);
1208
1221
  const relayResult = await service.relayWithdraw({
1209
1222
  smartAccount,
1210
- chainId: _chunkTQ6IIGRScjs.toEvmCaip2.call(void 0, sourceChain),
1223
+ chainId: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, sourceChain),
1211
1224
  safeAddress,
1212
1225
  safeTransaction: request.typedData.message,
1213
1226
  signature
@@ -1243,7 +1256,7 @@ function WithdrawFlow({
1243
1256
  sourceChain,
1244
1257
  sourceToken
1245
1258
  });
1246
- _optionalChain([onWithdrawSubmitted, 'optionalCall', _29 => _29({
1259
+ _optionalChain([onWithdrawSubmitted, 'optionalCall', _32 => _32({
1247
1260
  txHash: result.txHash,
1248
1261
  sourceChain,
1249
1262
  amount: amountUnits.toString(),
@@ -1265,7 +1278,7 @@ function WithdrawFlow({
1265
1278
  targetChain,
1266
1279
  targetToken
1267
1280
  });
1268
- handleError(_chunkTQ6IIGRScjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1281
+ handleError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1269
1282
  throw err;
1270
1283
  } finally {
1271
1284
  setIsSubmitting(false);
@@ -1298,7 +1311,7 @@ function WithdrawFlow({
1298
1311
  const handleWithdrawComplete = _react.useCallback.call(void 0,
1299
1312
  (txHash, destinationTxHash, context) => {
1300
1313
  logFlow("withdraw:complete", { txHash, destinationTxHash, ...context });
1301
- _optionalChain([onWithdrawComplete, 'optionalCall', _30 => _30({
1314
+ _optionalChain([onWithdrawComplete, 'optionalCall', _33 => _33({
1302
1315
  txHash,
1303
1316
  destinationTxHash,
1304
1317
  amount: context.amount,
@@ -1313,17 +1326,17 @@ function WithdrawFlow({
1313
1326
  const handleWithdrawFailed = _react.useCallback.call(void 0,
1314
1327
  (txHash, error) => {
1315
1328
  logFlowError("withdraw:failed", error, { txHash });
1316
- _optionalChain([onWithdrawFailed, 'optionalCall', _31 => _31({ txHash, error })]);
1329
+ _optionalChain([onWithdrawFailed, 'optionalCall', _34 => _34({ txHash, error })]);
1317
1330
  },
1318
1331
  [logFlowError, onWithdrawFailed]
1319
1332
  );
1320
1333
  const allowedChainSet = _react.useMemo.call(void 0,
1321
- () => _optionalChain([allowedRoutes, 'optionalAccess', _32 => _32.sourceChains]) ? new Set(allowedRoutes.sourceChains) : null,
1322
- [_optionalChain([allowedRoutes, 'optionalAccess', _33 => _33.sourceChains])]
1334
+ () => _optionalChain([allowedRoutes, 'optionalAccess', _35 => _35.sourceChains]) ? new Set(allowedRoutes.sourceChains) : null,
1335
+ [_optionalChain([allowedRoutes, 'optionalAccess', _36 => _36.sourceChains])]
1323
1336
  );
1324
1337
  const allowedTokenSet = _react.useMemo.call(void 0,
1325
- () => _optionalChain([allowedRoutes, 'optionalAccess', _34 => _34.sourceTokens]) ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
1326
- [_optionalChain([allowedRoutes, 'optionalAccess', _35 => _35.sourceTokens])]
1338
+ () => _optionalChain([allowedRoutes, 'optionalAccess', _37 => _37.sourceTokens]) ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
1339
+ [_optionalChain([allowedRoutes, 'optionalAccess', _38 => _38.sourceTokens])]
1327
1340
  );
1328
1341
  const targetChainOptions = _react.useMemo.call(void 0, () => {
1329
1342
  return _chunkR6U6BHCVcjs.SOURCE_CHAINS.filter((chain) => {
@@ -1392,17 +1405,17 @@ function WithdrawFlow({
1392
1405
  setIsConnectSelectionConfirmed(false);
1393
1406
  }
1394
1407
  }, [showConnectStep, isConnectSelectionConfirmed, signerContext]);
1395
- const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _36 => _36.ownerAddress]);
1408
+ const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _39 => _39.ownerAddress]);
1396
1409
  const selectedWalletIcon = _react.useMemo.call(void 0, () => {
1397
- if (!ownerAddress) return _optionalChain([reownWallet, 'optionalAccess', _37 => _37.icon]);
1410
+ if (!ownerAddress) return _optionalChain([reownWallet, 'optionalAccess', _40 => _40.icon]);
1398
1411
  const selected = walletOptions.find(
1399
- (o) => _optionalChain([o, 'access', _38 => _38.address, 'optionalAccess', _39 => _39.toLowerCase, 'call', _40 => _40()]) === ownerAddress.toLowerCase()
1412
+ (o) => _optionalChain([o, 'access', _41 => _41.address, 'optionalAccess', _42 => _42.toLowerCase, 'call', _43 => _43()]) === ownerAddress.toLowerCase()
1400
1413
  );
1401
- return _nullishCoalesce(_optionalChain([selected, 'optionalAccess', _41 => _41.icon]), () => ( _optionalChain([reownWallet, 'optionalAccess', _42 => _42.icon])));
1402
- }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _43 => _43.icon])]);
1414
+ return _nullishCoalesce(_optionalChain([selected, 'optionalAccess', _44 => _44.icon]), () => ( _optionalChain([reownWallet, 'optionalAccess', _45 => _45.icon])));
1415
+ }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _46 => _46.icon])]);
1403
1416
  if (showConnectStep) {
1404
1417
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1405
- _chunkTQ6IIGRScjs.ConnectStep,
1418
+ _chunkMVFMDKAScjs.ConnectStep,
1406
1419
  {
1407
1420
  walletOptions,
1408
1421
  selectedWalletId: selectedWalletIdEffective,
@@ -1423,9 +1436,9 @@ function WithdrawFlow({
1423
1436
  if (!signerContext) return null;
1424
1437
  if (!onSignTransaction && !signerContext.walletClient) return null;
1425
1438
  const resolvedOwnerAddress = signerContext.ownerAddress;
1426
- const resolvedConnectedAddress = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access', _44 => _44.walletClient, 'optionalAccess', _45 => _45.account, 'optionalAccess', _46 => _46.address]), () => ( _optionalChain([reownWallet, 'optionalAccess', _47 => _47.address]))), () => ( _optionalChain([dappWalletClient, 'optionalAccess', _48 => _48.account, 'optionalAccess', _49 => _49.address]))), () => ( resolvedOwnerAddress));
1439
+ const resolvedConnectedAddress = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access', _47 => _47.walletClient, 'optionalAccess', _48 => _48.account, 'optionalAccess', _49 => _49.address]), () => ( _optionalChain([reownWallet, 'optionalAccess', _50 => _50.address]))), () => ( _optionalChain([dappWalletClient, 'optionalAccess', _51 => _51.account, 'optionalAccess', _52 => _52.address]))), () => ( resolvedOwnerAddress));
1427
1440
  const resolvedDefaultRecipient = _nullishCoalesce(defaultRecipient, () => ( resolvedConnectedAddress));
1428
- const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkTQ6IIGRScjs.getPublicClient.call(void 0, sourceChain)));
1441
+ const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain)));
1429
1442
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
1430
1443
  step.type === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1431
1444
  WithdrawFormStep,
@@ -1452,7 +1465,7 @@ function WithdrawFlow({
1452
1465
  }
1453
1466
  ),
1454
1467
  step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1455
- _chunkTQ6IIGRScjs.ProcessingStep,
1468
+ _chunkMVFMDKAScjs.ProcessingStep,
1456
1469
  {
1457
1470
  smartAccount: step.smartAccount,
1458
1471
  txHash: step.txHash,
@@ -1478,7 +1491,7 @@ function WithdrawFlow({
1478
1491
  // src/WithdrawModal.tsx
1479
1492
 
1480
1493
  var ReownWithdrawInner = _react.lazy.call(void 0,
1481
- () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-ZNQPXAS6.cjs"))).then((m) => ({
1494
+ () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-K73XDERE.cjs"))).then((m) => ({
1482
1495
  default: m.WithdrawModalReown
1483
1496
  }))
1484
1497
  );
@@ -1531,27 +1544,28 @@ function WithdrawModalInner({
1531
1544
  debug
1532
1545
  }) {
1533
1546
  const modalRef = _react.useRef.call(void 0, null);
1547
+ const onReadyRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onReady);
1534
1548
  const [currentStepIndex, setCurrentStepIndex] = _react.useState.call(void 0, 0);
1535
1549
  const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, null);
1536
1550
  const backHandlerRef = _react.useRef.call(void 0, void 0);
1537
1551
  const targetChain = _chunkR6U6BHCVcjs.getChainId.call(void 0, targetChainProp);
1538
1552
  const sourceChain = _chunkR6U6BHCVcjs.getChainId.call(void 0, sourceChainProp);
1539
1553
  const service = _react.useMemo.call(void 0,
1540
- () => _chunkTQ6IIGRScjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1554
+ () => _chunkMVFMDKAScjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1541
1555
  [backendUrl, debug]
1542
1556
  );
1543
1557
  _react.useEffect.call(void 0, () => {
1544
1558
  if (isOpen && modalRef.current) {
1545
- _chunkTQ6IIGRScjs.applyTheme.call(void 0, modalRef.current, theme);
1559
+ _chunkMVFMDKAScjs.applyTheme.call(void 0, modalRef.current, theme);
1546
1560
  }
1547
1561
  }, [isOpen, theme]);
1548
1562
  const hasCalledReady = _react.useRef.call(void 0, false);
1549
1563
  _react.useEffect.call(void 0, () => {
1550
1564
  if (isOpen && !hasCalledReady.current) {
1551
1565
  hasCalledReady.current = true;
1552
- _optionalChain([onReady, 'optionalCall', _50 => _50()]);
1566
+ _optionalChain([onReadyRef, 'access', _53 => _53.current, 'optionalCall', _54 => _54()]);
1553
1567
  }
1554
- }, [isOpen, onReady]);
1568
+ }, [isOpen, onReadyRef]);
1555
1569
  _react.useEffect.call(void 0, () => {
1556
1570
  if (!isOpen) {
1557
1571
  setCurrentStepIndex(0);
@@ -1568,17 +1582,17 @@ function WithdrawModalInner({
1568
1582
  setTotalBalanceUsd(balance2);
1569
1583
  }, []);
1570
1584
  const handleBack = _react.useCallback.call(void 0, () => {
1571
- _optionalChain([backHandlerRef, 'access', _51 => _51.current, 'optionalCall', _52 => _52()]);
1585
+ _optionalChain([backHandlerRef, 'access', _55 => _55.current, 'optionalCall', _56 => _56()]);
1572
1586
  }, []);
1573
- const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _53 => _53.showLogo]), () => ( false));
1574
- const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _54 => _54.showStepper]), () => ( false));
1575
- const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _55 => _55.showBackButton]), () => ( true));
1576
- const balance = _optionalChain([uiConfig, 'optionalAccess', _56 => _56.balance]);
1577
- const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _57 => _57.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
1578
- const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _58 => _58.title]), () => ( "Withdraw"));
1587
+ const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _57 => _57.showLogo]), () => ( false));
1588
+ const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _58 => _58.showStepper]), () => ( false));
1589
+ const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _59 => _59.showBackButton]), () => ( true));
1590
+ const balance = _optionalChain([uiConfig, 'optionalAccess', _60 => _60.balance]);
1591
+ const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _61 => _61.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
1592
+ const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _62 => _62.title]), () => ( "Withdraw"));
1579
1593
  const canGoBack = currentStepIndex > 0 && currentStepIndex < 3 && backHandlerRef.current;
1580
1594
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1581
- _chunkTQ6IIGRScjs.Modal,
1595
+ _chunkMVFMDKAScjs.Modal,
1582
1596
  {
1583
1597
  isOpen,
1584
1598
  onClose,
@@ -1637,7 +1651,7 @@ function WithdrawModalInner({
1637
1651
  ] }),
1638
1652
  balance && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-balance", children: [
1639
1653
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-label", children: balance.title }),
1640
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunkTQ6IIGRScjs.currencyFormatter.format(totalBalanceUsd) : null))) })
1654
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunkMVFMDKAScjs.currencyFormatter.format(totalBalanceUsd) : null))) })
1641
1655
  ] })
1642
1656
  ] }),
1643
1657
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -809,6 +809,16 @@ function formatUserError(raw) {
809
809
  return cleaned;
810
810
  }
811
811
 
812
+ // src/core/useLatestRef.ts
813
+
814
+ function useLatestRef(value) {
815
+ const ref = _react.useRef.call(void 0, value);
816
+ _react.useEffect.call(void 0, () => {
817
+ ref.current = value;
818
+ }, [value]);
819
+ return ref;
820
+ }
821
+
812
822
  // src/core/theme.ts
813
823
  var RADIUS_SCALE = {
814
824
  none: { sm: "0", md: "0", lg: "0" },
@@ -2095,4 +2105,5 @@ function getPublicClient(chainId) {
2095
2105
 
2096
2106
 
2097
2107
 
2098
- exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
2108
+
2109
+ exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.useLatestRef = useLatestRef; exports.applyTheme = applyTheme;