@rhinestone/deposit-modal 0.4.2 → 0.4.3

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPNN2YBPFcjs = require('./chunk-PNN2YBPF.cjs');
3
+ var _chunk3NZUMDSTcjs = require('./chunk-3NZUMDST.cjs');
4
4
 
5
5
 
6
6
 
@@ -21,7 +21,7 @@ function WithdrawModalWithReown(props) {
21
21
  reown.disconnect();
22
22
  }, [reown.disconnect]);
23
23
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
24
- _chunkPNN2YBPFcjs.WithdrawModalInner,
24
+ _chunk3NZUMDSTcjs.WithdrawModalInner,
25
25
  {
26
26
  ...props,
27
27
  reownWallet: reown,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WithdrawModalInner
3
- } from "./chunk-7JVBUMFE.mjs";
3
+ } from "./chunk-IDJBMNV2.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
@@ -200,6 +200,7 @@ function WithdrawFormStep({
200
200
  publicClient,
201
201
  connectedRecipient,
202
202
  safeAddress,
203
+ depositAddress,
203
204
  asset,
204
205
  defaultRecipient,
205
206
  defaultAmount,
@@ -361,6 +362,13 @@ function WithdrawFormStep({
361
362
  setError("Enter a valid recipient address");
362
363
  return;
363
364
  }
365
+ const lowerRecipient = recipient.toLowerCase();
366
+ if (lowerRecipient === safeAddress.toLowerCase() || lowerRecipient === _optionalChain([depositAddress, 'optionalAccess', _7 => _7.toLowerCase, 'call', _8 => _8()])) {
367
+ setError(
368
+ "Recipient can't be your own account. Send to a different wallet."
369
+ );
370
+ return;
371
+ }
364
372
  const parsed = Number(amount);
365
373
  if (!amount || !Number.isFinite(parsed) || parsed <= 0) {
366
374
  setError("Enter a valid amount");
@@ -388,7 +396,15 @@ function WithdrawFormStep({
388
396
  } finally {
389
397
  setIsSubmitting(false);
390
398
  }
391
- }, [recipient, amount, balance, asset.decimals, onSubmit]);
399
+ }, [
400
+ recipient,
401
+ amount,
402
+ balance,
403
+ asset.decimals,
404
+ safeAddress,
405
+ depositAddress,
406
+ onSubmit
407
+ ]);
392
408
  if (isBalanceLoading) {
393
409
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
394
410
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-withdraw-loading", children: [
@@ -423,7 +439,7 @@ function WithdrawFormStep({
423
439
  onChange: (e) => {
424
440
  const next = e.target.value.trim();
425
441
  setRecipient(next);
426
- _optionalChain([onRecipientChange, 'optionalCall', _7 => _7(next)]);
442
+ _optionalChain([onRecipientChange, 'optionalCall', _9 => _9(next)]);
427
443
  if (error) setError(null);
428
444
  }
429
445
  }
@@ -703,7 +719,7 @@ function WithdrawReviewStep({
703
719
  const raw = err instanceof Error ? err.message : "Withdraw failed";
704
720
  const message = _chunkEDUWRMQIcjs.formatUserError.call(void 0, raw);
705
721
  setError(message);
706
- _optionalChain([onError, 'optionalCall', _8 => _8(message, "WITHDRAW_REVIEW_ERROR")]);
722
+ _optionalChain([onError, 'optionalCall', _10 => _10(message, "WITHDRAW_REVIEW_ERROR")]);
707
723
  } finally {
708
724
  setIsSubmitting(false);
709
725
  }
@@ -799,7 +815,7 @@ function resolveSessionOwner(eoaAddress) {
799
815
  }
800
816
  function targetsEqual(a, b) {
801
817
  if (!a) return false;
802
- return a.chain === b.chain && a.token.toLowerCase() === b.token.toLowerCase() && (_nullishCoalesce(_optionalChain([a, 'access', _9 => _9.recipient, 'optionalAccess', _10 => _10.toLowerCase, 'call', _11 => _11()]), () => ( ""))) === (_nullishCoalesce(_optionalChain([b, 'access', _12 => _12.recipient, 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]), () => ( "")));
818
+ return a.chain === b.chain && a.token.toLowerCase() === b.token.toLowerCase() && (_nullishCoalesce(_optionalChain([a, 'access', _11 => _11.recipient, 'optionalAccess', _12 => _12.toLowerCase, 'call', _13 => _13()]), () => ( ""))) === (_nullishCoalesce(_optionalChain([b, 'access', _14 => _14.recipient, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()]), () => ( "")));
803
819
  }
804
820
  function WithdrawFlow({
805
821
  dappWalletClient,
@@ -869,15 +885,15 @@ function WithdrawFlow({
869
885
  }, [defaultRecipient]);
870
886
  const hasCustomSigner = Boolean(dappAddress && onSignTransaction);
871
887
  const dappSwitchChain = _react.useMemo.call(void 0, () => {
872
- if (!_optionalChain([dappWalletClient, 'optionalAccess', _15 => _15.switchChain])) return void 0;
888
+ if (!_optionalChain([dappWalletClient, 'optionalAccess', _17 => _17.switchChain])) return void 0;
873
889
  return async (chainId) => {
874
- await _optionalChain([dappWalletClient, 'access', _16 => _16.switchChain, 'optionalCall', _17 => _17({ id: chainId })]);
890
+ await _optionalChain([dappWalletClient, 'access', _18 => _18.switchChain, 'optionalCall', _19 => _19({ id: chainId })]);
875
891
  };
876
892
  }, [dappWalletClient]);
877
893
  const walletOptions = _react.useMemo.call(void 0, () => {
878
894
  const options = [];
879
895
  const seen = /* @__PURE__ */ new Set();
880
- if (_optionalChain([dappWalletClient, 'optionalAccess', _18 => _18.account]) && dappAddress) {
896
+ if (_optionalChain([dappWalletClient, 'optionalAccess', _20 => _20.account]) && dappAddress) {
881
897
  const id = `evm:${dappWalletClient.account.address.toLowerCase()}`;
882
898
  options.push({
883
899
  id,
@@ -887,7 +903,7 @@ function WithdrawFlow({
887
903
  });
888
904
  seen.add(id);
889
905
  }
890
- if (_optionalChain([reownWallet, 'optionalAccess', _19 => _19.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient) {
906
+ if (_optionalChain([reownWallet, 'optionalAccess', _21 => _21.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient) {
891
907
  const id = `evm:${reownWallet.address.toLowerCase()}`;
892
908
  if (!seen.has(id)) {
893
909
  options.push({
@@ -903,13 +919,13 @@ function WithdrawFlow({
903
919
  }, [
904
920
  dappWalletClient,
905
921
  dappAddress,
906
- _optionalChain([reownWallet, 'optionalAccess', _20 => _20.address]),
907
- _optionalChain([reownWallet, 'optionalAccess', _21 => _21.isConnected]),
908
- _optionalChain([reownWallet, 'optionalAccess', _22 => _22.walletClient]),
909
- _optionalChain([reownWallet, 'optionalAccess', _23 => _23.publicClient]),
910
- _optionalChain([reownWallet, 'optionalAccess', _24 => _24.icon])
922
+ _optionalChain([reownWallet, 'optionalAccess', _22 => _22.address]),
923
+ _optionalChain([reownWallet, 'optionalAccess', _23 => _23.isConnected]),
924
+ _optionalChain([reownWallet, 'optionalAccess', _24 => _24.walletClient]),
925
+ _optionalChain([reownWallet, 'optionalAccess', _25 => _25.publicClient]),
926
+ _optionalChain([reownWallet, 'optionalAccess', _26 => _26.icon])
911
927
  ]);
912
- const canAutoLock = hasCustomSigner || Boolean(_optionalChain([dappWalletClient, 'optionalAccess', _25 => _25.account]) && dappAddress) && !reownWallet;
928
+ const canAutoLock = hasCustomSigner || Boolean(_optionalChain([dappWalletClient, 'optionalAccess', _27 => _27.account]) && dappAddress) && !reownWallet;
913
929
  const storeApi = useWithdrawStoreApi();
914
930
  const selectedWalletId = useWithdrawStore((s) => s.selectedWalletId);
915
931
  const registration = useWithdrawStore((s) => s.registration);
@@ -939,7 +955,7 @@ function WithdrawFlow({
939
955
  if (!isConnectSelectionConfirmed || !selectedWalletId) return null;
940
956
  const selectedOption = walletOptions.find((o) => o.id === selectedWalletId);
941
957
  if (!selectedOption || !selectedOption.address) return null;
942
- if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess', _26 => _26.account]) && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
958
+ if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess', _28 => _28.account]) && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
943
959
  return {
944
960
  ownerAddress: dappWalletClient.account.address,
945
961
  walletClient: dappWalletClient,
@@ -947,7 +963,7 @@ function WithdrawFlow({
947
963
  switchChain: dappSwitchChain
948
964
  };
949
965
  }
950
- if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess', _27 => _27.address, 'optionalAccess', _28 => _28.toLowerCase, 'call', _29 => _29()]) === selectedOption.address.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
966
+ if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()]) === selectedOption.address.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
951
967
  return {
952
968
  ownerAddress: reownWallet.address,
953
969
  walletClient: reownWallet.walletClient,
@@ -969,7 +985,7 @@ function WithdrawFlow({
969
985
  reownWallet,
970
986
  sourceChain
971
987
  ]);
972
- const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _30 => _30.ownerAddress]);
988
+ const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _32 => _32.ownerAddress]);
973
989
  const recipientForRegistration = _react.useMemo.call(void 0, () => {
974
990
  if (!recipientInput) return void 0;
975
991
  return ADDR_REGEX.test(recipientInput) ? recipientInput : void 0;
@@ -1054,7 +1070,7 @@ function WithdrawFlow({
1054
1070
  smartAccount: setup.smartAccount,
1055
1071
  registeredTarget: desiredTarget
1056
1072
  });
1057
- _optionalChain([onLifecycleRef, 'access', _31 => _31.current, 'optionalCall', _32 => _32({
1073
+ _optionalChain([onLifecycleRef, 'access', _33 => _33.current, 'optionalCall', _34 => _34({
1058
1074
  type: "connected",
1059
1075
  address: ownerAddress,
1060
1076
  smartAccount: setup.smartAccount
@@ -1072,7 +1088,7 @@ function WithdrawFlow({
1072
1088
  type: "registration/failed",
1073
1089
  error: message
1074
1090
  });
1075
- _optionalChain([onErrorRef, 'access', _33 => _33.current, 'optionalCall', _34 => _34({ message, code: "WITHDRAW_REGISTER_FAILED" })]);
1091
+ _optionalChain([onErrorRef, 'access', _35 => _35.current, 'optionalCall', _36 => _36({ message, code: "WITHDRAW_REGISTER_FAILED" })]);
1076
1092
  }
1077
1093
  }, REGISTRATION_DEBOUNCE_MS);
1078
1094
  return () => {
@@ -1119,7 +1135,7 @@ function WithdrawFlow({
1119
1135
  storeApi.dispatch({ type: "review/back" });
1120
1136
  }, [storeApi]);
1121
1137
  _react.useEffect.call(void 0, () => {
1122
- _optionalChain([onStepChangeRef, 'access', _35 => _35.current, 'optionalCall', _36 => _36(
1138
+ _optionalChain([onStepChangeRef, 'access', _37 => _37.current, 'optionalCall', _38 => _38(
1123
1139
  flowStep === "review" ? reviewBackHandler : void 0
1124
1140
  )]);
1125
1141
  }, [flowStep, reviewBackHandler, onStepChangeRef]);
@@ -1133,7 +1149,7 @@ function WithdrawFlow({
1133
1149
  lastStepOpenEventKeyRef.current = "form";
1134
1150
  const tokenSymbol = _chunkABVRVW3Pcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
1135
1151
  const chainName = _chunkABVRVW3Pcjs.getChainName.call(void 0, targetChain);
1136
- _optionalChain([onEventRef, 'access', _37 => _37.current, 'optionalCall', _38 => _38({
1152
+ _optionalChain([onEventRef, 'access', _39 => _39.current, 'optionalCall', _40 => _40({
1137
1153
  type: "withdraw_modal_select_amount_open",
1138
1154
  pred_balance: totalBalanceUsd,
1139
1155
  default_token: tokenSymbol,
@@ -1163,7 +1179,7 @@ function WithdrawFlow({
1163
1179
  const handleError = _react.useCallback.call(void 0,
1164
1180
  (message, code) => {
1165
1181
  logFlowError("flow:error", message, { code });
1166
- _optionalChain([onErrorRef, 'access', _39 => _39.current, 'optionalCall', _40 => _40({ message, code })]);
1182
+ _optionalChain([onErrorRef, 'access', _41 => _41.current, 'optionalCall', _42 => _42({ message, code })]);
1167
1183
  },
1168
1184
  [logFlowError, onErrorRef]
1169
1185
  );
@@ -1171,7 +1187,7 @@ function WithdrawFlow({
1171
1187
  (recipient, amountValue) => {
1172
1188
  const tokenSymbol = _chunkABVRVW3Pcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
1173
1189
  const chainName = _chunkABVRVW3Pcjs.getChainName.call(void 0, targetChain);
1174
- _optionalChain([onEventRef, 'access', _41 => _41.current, 'optionalCall', _42 => _42({
1190
+ _optionalChain([onEventRef, 'access', _43 => _43.current, 'optionalCall', _44 => _44({
1175
1191
  type: "withdraw_modal_select_amount_cta_click",
1176
1192
  pred_balance: totalBalanceUsd,
1177
1193
  selected_token: tokenSymbol,
@@ -1209,7 +1225,13 @@ function WithdrawFlow({
1209
1225
  throw new Error("Withdrawal target is still being prepared");
1210
1226
  }
1211
1227
  const smartAccount = matchingRegistration.smartAccount;
1212
- if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _43 => _43.walletClient])) {
1228
+ const lowerRecipient = recipient.toLowerCase();
1229
+ if (lowerRecipient === safeAddress.toLowerCase() || lowerRecipient === smartAccount.toLowerCase()) {
1230
+ throw new Error(
1231
+ "Recipient can't be your own account. Send to a different wallet."
1232
+ );
1233
+ }
1234
+ if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _45 => _45.walletClient])) {
1213
1235
  throw new Error("Wallet not connected");
1214
1236
  }
1215
1237
  const submitGeneration = submitGenerationRef.current += 1;
@@ -1232,7 +1254,7 @@ function WithdrawFlow({
1232
1254
  targetToken
1233
1255
  });
1234
1256
  const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
1235
- const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _44 => _44.publicClient]), () => ( _chunkEDUWRMQIcjs.getPublicClient.call(void 0, sourceChain)));
1257
+ const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _46 => _46.publicClient]), () => ( _chunkEDUWRMQIcjs.getPublicClient.call(void 0, sourceChain)));
1236
1258
  let result;
1237
1259
  if (onSignTransaction) {
1238
1260
  const transferTarget = isSameRoute ? recipient : smartAccount;
@@ -1304,7 +1326,7 @@ function WithdrawFlow({
1304
1326
  sourceChain,
1305
1327
  sourceToken
1306
1328
  });
1307
- _optionalChain([onLifecycleRef, 'access', _45 => _45.current, 'optionalCall', _46 => _46({
1329
+ _optionalChain([onLifecycleRef, 'access', _47 => _47.current, 'optionalCall', _48 => _48({
1308
1330
  type: "submitted",
1309
1331
  txHash: result.txHash,
1310
1332
  sourceChain,
@@ -1346,7 +1368,7 @@ function WithdrawFlow({
1346
1368
  const handleWithdrawComplete = _react.useCallback.call(void 0,
1347
1369
  (txHash, destinationTxHash, context) => {
1348
1370
  logFlow("withdraw:complete", { txHash, destinationTxHash, ...context });
1349
- _optionalChain([onLifecycleRef, 'access', _47 => _47.current, 'optionalCall', _48 => _48({
1371
+ _optionalChain([onLifecycleRef, 'access', _49 => _49.current, 'optionalCall', _50 => _50({
1350
1372
  type: "complete",
1351
1373
  txHash,
1352
1374
  destinationTxHash,
@@ -1367,7 +1389,7 @@ function WithdrawFlow({
1367
1389
  const handleWithdrawFailed = _react.useCallback.call(void 0,
1368
1390
  (txHash, error) => {
1369
1391
  logFlowError("withdraw:failed", error, { txHash });
1370
- _optionalChain([onLifecycleRef, 'access', _49 => _49.current, 'optionalCall', _50 => _50({
1392
+ _optionalChain([onLifecycleRef, 'access', _51 => _51.current, 'optionalCall', _52 => _52({
1371
1393
  type: "failed",
1372
1394
  txHash,
1373
1395
  error
@@ -1377,12 +1399,12 @@ function WithdrawFlow({
1377
1399
  [logFlowError, onLifecycleRef, storeApi]
1378
1400
  );
1379
1401
  const allowedChainSet = _react.useMemo.call(void 0,
1380
- () => _optionalChain([allowedRoutes, 'optionalAccess', _51 => _51.sourceChains]) ? new Set(allowedRoutes.sourceChains) : null,
1381
- [_optionalChain([allowedRoutes, 'optionalAccess', _52 => _52.sourceChains])]
1402
+ () => _optionalChain([allowedRoutes, 'optionalAccess', _53 => _53.sourceChains]) ? new Set(allowedRoutes.sourceChains) : null,
1403
+ [_optionalChain([allowedRoutes, 'optionalAccess', _54 => _54.sourceChains])]
1382
1404
  );
1383
1405
  const allowedTokenSet = _react.useMemo.call(void 0,
1384
- () => _optionalChain([allowedRoutes, 'optionalAccess', _53 => _53.sourceTokens]) ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
1385
- [_optionalChain([allowedRoutes, 'optionalAccess', _54 => _54.sourceTokens])]
1406
+ () => _optionalChain([allowedRoutes, 'optionalAccess', _55 => _55.sourceTokens]) ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
1407
+ [_optionalChain([allowedRoutes, 'optionalAccess', _56 => _56.sourceTokens])]
1386
1408
  );
1387
1409
  const targetChainOptions = _react.useMemo.call(void 0, () => {
1388
1410
  return _chunkABVRVW3Pcjs.SOURCE_CHAINS.filter((chain) => {
@@ -1445,10 +1467,10 @@ function WithdrawFlow({
1445
1467
  const selectedWalletIcon = _react.useMemo.call(void 0, () => {
1446
1468
  if (!ownerAddress) return void 0;
1447
1469
  const selected = walletOptions.find(
1448
- (o) => _optionalChain([o, 'access', _55 => _55.address, 'optionalAccess', _56 => _56.toLowerCase, 'call', _57 => _57()]) === ownerAddress.toLowerCase()
1470
+ (o) => _optionalChain([o, 'access', _57 => _57.address, 'optionalAccess', _58 => _58.toLowerCase, 'call', _59 => _59()]) === ownerAddress.toLowerCase()
1449
1471
  );
1450
- return _optionalChain([selected, 'optionalAccess', _58 => _58.kind]) === "external" ? _nullishCoalesce(selected.icon, () => ( _optionalChain([reownWallet, 'optionalAccess', _59 => _59.icon]))) : void 0;
1451
- }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _60 => _60.icon])]);
1472
+ return _optionalChain([selected, 'optionalAccess', _60 => _60.kind]) === "external" ? _nullishCoalesce(selected.icon, () => ( _optionalChain([reownWallet, 'optionalAccess', _61 => _61.icon]))) : void 0;
1473
+ }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _62 => _62.icon])]);
1452
1474
  if (showConnectStep) {
1453
1475
  const withdrawRows = walletOptions.map((option) => ({
1454
1476
  id: option.id,
@@ -1476,8 +1498,9 @@ function WithdrawFlow({
1476
1498
  }
1477
1499
  if (!signerContext) return null;
1478
1500
  if (!onSignTransaction && !signerContext.walletClient) return null;
1479
- const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess', _61 => _61.kind]) === "external" ? selectedWalletOption.address : void 0;
1501
+ const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess', _63 => _63.kind]) === "external" ? selectedWalletOption.address : void 0;
1480
1502
  const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkEDUWRMQIcjs.getPublicClient.call(void 0, sourceChain)));
1503
+ const depositAddress = registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : void 0;
1481
1504
  const stepView = deriveStepView(flowStep, registration);
1482
1505
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
1483
1506
  stepView === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1487,6 +1510,7 @@ function WithdrawFlow({
1487
1510
  publicClient: formPublicClient,
1488
1511
  connectedRecipient: resolvedConnectedRecipient,
1489
1512
  safeAddress,
1513
+ depositAddress,
1490
1514
  asset,
1491
1515
  defaultRecipient,
1492
1516
  defaultAmount,
@@ -1564,7 +1588,7 @@ function deriveStepView(step, _registration) {
1564
1588
  // src/WithdrawModal.tsx
1565
1589
 
1566
1590
  var ReownWithdrawInner = _react.lazy.call(void 0,
1567
- () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-AZ27OBAV.cjs"))).then((m) => ({
1591
+ () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-KKGW62YO.cjs"))).then((m) => ({
1568
1592
  default: m.WithdrawModalReown
1569
1593
  }))
1570
1594
  );
@@ -1625,7 +1649,7 @@ function WithdrawModalInner({
1625
1649
  const onErrorRef = _chunkEDUWRMQIcjs.useLatestRef.call(void 0, onError);
1626
1650
  _react.useEffect.call(void 0, () => {
1627
1651
  if (isOpen && onSignTransaction && !dappAddress) {
1628
- _optionalChain([onErrorRef, 'access', _62 => _62.current, 'optionalCall', _63 => _63({
1652
+ _optionalChain([onErrorRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65({
1629
1653
  message: "WithdrawModal requires `dappAddress` when `onSignTransaction` is provided.",
1630
1654
  code: "WITHDRAW_MISSING_DAPP_ADDRESS"
1631
1655
  })]);
@@ -1638,7 +1662,7 @@ function WithdrawModalInner({
1638
1662
  }, [isOpen, theme]);
1639
1663
  _react.useEffect.call(void 0, () => {
1640
1664
  if (isOpen) {
1641
- _optionalChain([onReadyRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65()]);
1665
+ _optionalChain([onReadyRef, 'access', _66 => _66.current, 'optionalCall', _67 => _67()]);
1642
1666
  }
1643
1667
  }, [isOpen, onReadyRef]);
1644
1668
  _react.useEffect.call(void 0, () => {
@@ -1649,7 +1673,7 @@ function WithdrawModalInner({
1649
1673
  const handleStepChange = _react.useCallback.call(void 0, (onBack) => {
1650
1674
  setBackHandler(() => onBack);
1651
1675
  }, []);
1652
- const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _66 => _66.showBackButton]), () => ( true));
1676
+ const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _68 => _68.showBackButton]), () => ( true));
1653
1677
  const canGoBack = backHandler !== void 0;
1654
1678
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawStoreProvider, { store, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1655
1679
  _chunkEDUWRMQIcjs.Modal,
@@ -200,6 +200,7 @@ function WithdrawFormStep({
200
200
  publicClient,
201
201
  connectedRecipient,
202
202
  safeAddress,
203
+ depositAddress,
203
204
  asset,
204
205
  defaultRecipient,
205
206
  defaultAmount,
@@ -361,6 +362,13 @@ function WithdrawFormStep({
361
362
  setError("Enter a valid recipient address");
362
363
  return;
363
364
  }
365
+ const lowerRecipient = recipient.toLowerCase();
366
+ if (lowerRecipient === safeAddress.toLowerCase() || lowerRecipient === depositAddress?.toLowerCase()) {
367
+ setError(
368
+ "Recipient can't be your own account. Send to a different wallet."
369
+ );
370
+ return;
371
+ }
364
372
  const parsed = Number(amount);
365
373
  if (!amount || !Number.isFinite(parsed) || parsed <= 0) {
366
374
  setError("Enter a valid amount");
@@ -388,7 +396,15 @@ function WithdrawFormStep({
388
396
  } finally {
389
397
  setIsSubmitting(false);
390
398
  }
391
- }, [recipient, amount, balance, asset.decimals, onSubmit]);
399
+ }, [
400
+ recipient,
401
+ amount,
402
+ balance,
403
+ asset.decimals,
404
+ safeAddress,
405
+ depositAddress,
406
+ onSubmit
407
+ ]);
392
408
  if (isBalanceLoading) {
393
409
  return /* @__PURE__ */ jsxs("div", { className: "rs-screen", children: [
394
410
  /* @__PURE__ */ jsxs("div", { className: "rs-screen-body rs-withdraw-loading", children: [
@@ -1209,6 +1225,12 @@ function WithdrawFlow({
1209
1225
  throw new Error("Withdrawal target is still being prepared");
1210
1226
  }
1211
1227
  const smartAccount = matchingRegistration.smartAccount;
1228
+ const lowerRecipient = recipient.toLowerCase();
1229
+ if (lowerRecipient === safeAddress.toLowerCase() || lowerRecipient === smartAccount.toLowerCase()) {
1230
+ throw new Error(
1231
+ "Recipient can't be your own account. Send to a different wallet."
1232
+ );
1233
+ }
1212
1234
  if (!onSignTransaction && !signerContext?.walletClient) {
1213
1235
  throw new Error("Wallet not connected");
1214
1236
  }
@@ -1478,6 +1500,7 @@ function WithdrawFlow({
1478
1500
  if (!onSignTransaction && !signerContext.walletClient) return null;
1479
1501
  const resolvedConnectedRecipient = selectedWalletOption?.kind === "external" ? selectedWalletOption.address : void 0;
1480
1502
  const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
1503
+ const depositAddress = registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : void 0;
1481
1504
  const stepView = deriveStepView(flowStep, registration);
1482
1505
  return /* @__PURE__ */ jsxs3("div", { className: "rs-modal-body", children: [
1483
1506
  stepView === "form" && /* @__PURE__ */ jsx3(
@@ -1487,6 +1510,7 @@ function WithdrawFlow({
1487
1510
  publicClient: formPublicClient,
1488
1511
  connectedRecipient: resolvedConnectedRecipient,
1489
1512
  safeAddress,
1513
+ depositAddress,
1490
1514
  asset,
1491
1515
  defaultRecipient,
1492
1516
  defaultAmount,
@@ -1564,7 +1588,7 @@ function deriveStepView(step, _registration) {
1564
1588
  // src/WithdrawModal.tsx
1565
1589
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1566
1590
  var ReownWithdrawInner = lazy(
1567
- () => import("./WithdrawModalReown-L4SWLONE.mjs").then((m) => ({
1591
+ () => import("./WithdrawModalReown-XPB53FKZ.mjs").then((m) => ({
1568
1592
  default: m.WithdrawModalReown
1569
1593
  }))
1570
1594
  );
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ var _chunk36R7XKXPcjs = require('./chunk-36R7XKXP.cjs');
4
4
  require('./chunk-NRNJAQUA.cjs');
5
5
 
6
6
 
7
- var _chunkPNN2YBPFcjs = require('./chunk-PNN2YBPF.cjs');
7
+ var _chunk3NZUMDSTcjs = require('./chunk-3NZUMDST.cjs');
8
8
  require('./chunk-EDUWRMQI.cjs');
9
9
  require('./chunk-UEKPBRBY.cjs');
10
10
 
@@ -85,4 +85,4 @@ async function disconnectWallet() {
85
85
 
86
86
 
87
87
 
88
- exports.CHAIN_BY_ID = _chunkABVRVW3Pcjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkABVRVW3Pcjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkABVRVW3Pcjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunk36R7XKXPcjs.DepositModal; exports.HYPERCORE_CHAIN_ID = _chunkABVRVW3Pcjs.HYPERCORE_CHAIN_ID; exports.HYPERCORE_USDC_ADDRESS = _chunkABVRVW3Pcjs.HYPERCORE_USDC_ADDRESS; exports.NATIVE_TOKEN_ADDRESS = _chunkABVRVW3Pcjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkABVRVW3Pcjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkABVRVW3Pcjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunkPNN2YBPFcjs.WithdrawModal; exports.chainRegistry = _chunkABVRVW3Pcjs.chainRegistry; exports.disconnectWallet = disconnectWallet; exports.findChainIdForToken = _chunkABVRVW3Pcjs.findChainIdForToken; exports.getChainBadge = _chunkABVRVW3Pcjs.getChainBadge; exports.getChainIcon = _chunkABVRVW3Pcjs.getChainIcon; exports.getChainId = _chunkABVRVW3Pcjs.getChainId; exports.getChainName = _chunkABVRVW3Pcjs.getChainName; exports.getChainObject = _chunkABVRVW3Pcjs.getChainObject; exports.getExplorerName = _chunkABVRVW3Pcjs.getExplorerName; exports.getExplorerTxUrl = _chunkABVRVW3Pcjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkABVRVW3Pcjs.getExplorerUrl; exports.getSupportedChainIds = _chunkABVRVW3Pcjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkABVRVW3Pcjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkABVRVW3Pcjs.getSupportedTokenSymbolsForChain; exports.getTargetTokenSymbolsForChain = _chunkABVRVW3Pcjs.getTargetTokenSymbolsForChain; exports.getTokenAddress = _chunkABVRVW3Pcjs.getTokenAddress; exports.getTokenDecimals = _chunkABVRVW3Pcjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkABVRVW3Pcjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkABVRVW3Pcjs.getTokenIcon; exports.getTokenSymbol = _chunkABVRVW3Pcjs.getTokenSymbol; exports.getUsdcAddress = _chunkABVRVW3Pcjs.getUsdcAddress; exports.getUsdcDecimals = _chunkABVRVW3Pcjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkABVRVW3Pcjs.isSupportedTokenAddressForChain;
88
+ exports.CHAIN_BY_ID = _chunkABVRVW3Pcjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkABVRVW3Pcjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkABVRVW3Pcjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunk36R7XKXPcjs.DepositModal; exports.HYPERCORE_CHAIN_ID = _chunkABVRVW3Pcjs.HYPERCORE_CHAIN_ID; exports.HYPERCORE_USDC_ADDRESS = _chunkABVRVW3Pcjs.HYPERCORE_USDC_ADDRESS; exports.NATIVE_TOKEN_ADDRESS = _chunkABVRVW3Pcjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkABVRVW3Pcjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkABVRVW3Pcjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunk3NZUMDSTcjs.WithdrawModal; exports.chainRegistry = _chunkABVRVW3Pcjs.chainRegistry; exports.disconnectWallet = disconnectWallet; exports.findChainIdForToken = _chunkABVRVW3Pcjs.findChainIdForToken; exports.getChainBadge = _chunkABVRVW3Pcjs.getChainBadge; exports.getChainIcon = _chunkABVRVW3Pcjs.getChainIcon; exports.getChainId = _chunkABVRVW3Pcjs.getChainId; exports.getChainName = _chunkABVRVW3Pcjs.getChainName; exports.getChainObject = _chunkABVRVW3Pcjs.getChainObject; exports.getExplorerName = _chunkABVRVW3Pcjs.getExplorerName; exports.getExplorerTxUrl = _chunkABVRVW3Pcjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkABVRVW3Pcjs.getExplorerUrl; exports.getSupportedChainIds = _chunkABVRVW3Pcjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkABVRVW3Pcjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkABVRVW3Pcjs.getSupportedTokenSymbolsForChain; exports.getTargetTokenSymbolsForChain = _chunkABVRVW3Pcjs.getTargetTokenSymbolsForChain; exports.getTokenAddress = _chunkABVRVW3Pcjs.getTokenAddress; exports.getTokenDecimals = _chunkABVRVW3Pcjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkABVRVW3Pcjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkABVRVW3Pcjs.getTokenIcon; exports.getTokenSymbol = _chunkABVRVW3Pcjs.getTokenSymbol; exports.getUsdcAddress = _chunkABVRVW3Pcjs.getUsdcAddress; exports.getUsdcDecimals = _chunkABVRVW3Pcjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkABVRVW3Pcjs.isSupportedTokenAddressForChain;
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import "./chunk-FJWLC4AM.mjs";
5
5
  import {
6
6
  WithdrawModal
7
- } from "./chunk-7JVBUMFE.mjs";
7
+ } from "./chunk-IDJBMNV2.mjs";
8
8
  import "./chunk-7EQQD7B4.mjs";
9
9
  import "./chunk-F7P4MV72.mjs";
10
10
  import {
package/dist/withdraw.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPNN2YBPFcjs = require('./chunk-PNN2YBPF.cjs');
3
+ var _chunk3NZUMDSTcjs = require('./chunk-3NZUMDST.cjs');
4
4
  require('./chunk-EDUWRMQI.cjs');
5
5
  require('./chunk-UEKPBRBY.cjs');
6
6
  require('./chunk-ABVRVW3P.cjs');
7
7
 
8
8
 
9
- exports.WithdrawModal = _chunkPNN2YBPFcjs.WithdrawModal;
9
+ exports.WithdrawModal = _chunk3NZUMDSTcjs.WithdrawModal;
package/dist/withdraw.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WithdrawModal
3
- } from "./chunk-7JVBUMFE.mjs";
3
+ } from "./chunk-IDJBMNV2.mjs";
4
4
  import "./chunk-7EQQD7B4.mjs";
5
5
  import "./chunk-F7P4MV72.mjs";
6
6
  import "./chunk-WJX3TJFK.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/deposit-modal",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "React modal component for Rhinestone cross-chain deposits",
5
5
  "author": "Rhinestone <dev@rhinestone.wtf>",
6
6
  "bugs": {