@rhinestone/deposit-modal 0.4.0 → 0.4.1

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.
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- var _chunkOQVLEVNRcjs = require('./chunk-OQVLEVNR.cjs');
33
+ var _chunkLJJCPDZOcjs = require('./chunk-LJJCPDZO.cjs');
34
34
 
35
35
 
36
36
 
@@ -260,7 +260,7 @@ function WithdrawFormStep({
260
260
  setIsSwitching(true);
261
261
  switchChain(asset.chainId).catch((err) => {
262
262
  const raw = err instanceof Error ? err.message : "Failed to switch chain";
263
- setError(_chunkOQVLEVNRcjs.formatUserError.call(void 0, raw));
263
+ setError(_chunkLJJCPDZOcjs.formatUserError.call(void 0, raw));
264
264
  }).finally(() => {
265
265
  setIsSwitching(false);
266
266
  });
@@ -280,7 +280,7 @@ function WithdrawFormStep({
280
280
  return;
281
281
  }
282
282
  try {
283
- const bal = _chunkOQVLEVNRcjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
283
+ const bal = _chunkLJJCPDZOcjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
284
284
  address: asset.token,
285
285
  abi: _viem.erc20Abi,
286
286
  functionName: "balanceOf",
@@ -384,7 +384,7 @@ function WithdrawFormStep({
384
384
  await onSubmit(recipient, amount);
385
385
  } catch (err) {
386
386
  const raw = err instanceof Error ? err.message : "Withdrawal failed";
387
- setError(_chunkOQVLEVNRcjs.formatUserError.call(void 0, raw));
387
+ setError(_chunkLJJCPDZOcjs.formatUserError.call(void 0, raw));
388
388
  } finally {
389
389
  setIsSubmitting(false);
390
390
  }
@@ -392,16 +392,16 @@ function WithdrawFormStep({
392
392
  if (isBalanceLoading) {
393
393
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
394
394
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-withdraw-loading", children: [
395
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.Spinner, { className: "rs-spinner--lg" }),
395
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.Spinner, { className: "rs-spinner--lg" }),
396
396
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-title", children: "Loading on-chain balance" }),
397
397
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${_chunkABVRVW3Pcjs.getChainName.call(void 0, asset.chainId)} to continue.` : "Please wait before withdrawing." })
398
398
  ] }),
399
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.PoweredBy, {})
399
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.PoweredBy, {})
400
400
  ] });
401
401
  }
402
402
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
403
403
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body", children: [
404
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.BodyHeader, { icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.CircleArrowOutUpLeftIcon, {}), title: "Withdraw" }),
404
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.BodyHeader, { icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.CircleArrowOutUpLeftIcon, {}), title: "Withdraw" }),
405
405
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-section", children: [
406
406
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
407
407
  "label",
@@ -447,7 +447,7 @@ function WithdrawFormStep({
447
447
  ),
448
448
  isRecipientConnected ? null : "Use connected"
449
449
  ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
450
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.WalletIcon, { className: "rs-withdraw-use-connected-icon" }),
450
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.WalletIcon, { className: "rs-withdraw-use-connected-icon" }),
451
451
  isRecipientConnected ? null : "Use connected"
452
452
  ] })
453
453
  }
@@ -487,7 +487,7 @@ function WithdrawFormStep({
487
487
  ) })
488
488
  ] }),
489
489
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-amount-info", children: [
490
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkOQVLEVNRcjs.currencyFormatter.format(amountUsd) : "$0.00" }),
490
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkLJJCPDZOcjs.currencyFormatter.format(amountUsd) : "$0.00" }),
491
491
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-withdraw-balance", children: [
492
492
  "Balance: ",
493
493
  formattedBalance,
@@ -528,7 +528,7 @@ function WithdrawFormStep({
528
528
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: targetChainName })
529
529
  ] }),
530
530
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
531
- _chunkOQVLEVNRcjs.ChevronDownIcon,
531
+ _chunkLJJCPDZOcjs.ChevronDownIcon,
532
532
  {
533
533
  className: "rs-withdraw-dropdown-arrow",
534
534
  style: {
@@ -597,7 +597,7 @@ function WithdrawFormStep({
597
597
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: targetSymbol })
598
598
  ] }),
599
599
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
600
- _chunkOQVLEVNRcjs.ChevronDownIcon,
600
+ _chunkLJJCPDZOcjs.ChevronDownIcon,
601
601
  {
602
602
  className: "rs-withdraw-dropdown-arrow",
603
603
  style: {
@@ -637,10 +637,10 @@ function WithdrawFormStep({
637
637
  ] })
638
638
  ] }),
639
639
  chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${_chunkABVRVW3Pcjs.getChainName.call(void 0, asset.chainId)}...` : `Switch to ${_chunkABVRVW3Pcjs.getChainName.call(void 0, asset.chainId)} to continue.` }) }),
640
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.Callout, { variant: "error", children: error }),
641
- !error && registrationError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.Callout, { variant: "error", children: registrationError }),
640
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.Callout, { variant: "error", children: error }),
641
+ !error && registrationError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.Callout, { variant: "error", children: registrationError }),
642
642
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
643
- _chunkOQVLEVNRcjs.Button,
643
+ _chunkLJJCPDZOcjs.Button,
644
644
  {
645
645
  onClick: handleWithdraw,
646
646
  fullWidth: true,
@@ -650,7 +650,7 @@ function WithdrawFormStep({
650
650
  }
651
651
  )
652
652
  ] }),
653
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.PoweredBy, {})
653
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.PoweredBy, {})
654
654
  ] });
655
655
  }
656
656
  WithdrawFormStep.displayName = "WithdrawFormStep";
@@ -685,9 +685,9 @@ function WithdrawReviewStep({
685
685
  const sourceTokenIcon = _chunkABVRVW3Pcjs.getTokenIcon.call(void 0, sourceSymbol);
686
686
  const targetTokenIcon = _chunkABVRVW3Pcjs.getTokenIcon.call(void 0, targetSymbol);
687
687
  const amountNumber = Number(amount);
688
- const formattedSendAmount = _nullishCoalesce(_chunkOQVLEVNRcjs.formatTokenAmount.call(void 0, amountNumber, sourceSymbol), () => ( amount));
689
- const prices = _chunkOQVLEVNRcjs.useTokenPrices.call(void 0, service, [sourceSymbol, targetSymbol]);
690
- const receiveDisplay = _nullishCoalesce(_chunkOQVLEVNRcjs.formatReceiveEstimate.call(void 0, {
688
+ const formattedSendAmount = _nullishCoalesce(_chunkLJJCPDZOcjs.formatTokenAmount.call(void 0, amountNumber, sourceSymbol), () => ( amount));
689
+ const prices = _chunkLJJCPDZOcjs.useTokenPrices.call(void 0, service, [sourceSymbol, targetSymbol]);
690
+ const receiveDisplay = _nullishCoalesce(_chunkLJJCPDZOcjs.formatReceiveEstimate.call(void 0, {
691
691
  sourceAmount: Number.isFinite(amountNumber) ? amountNumber : void 0,
692
692
  sourceSymbol,
693
693
  targetSymbol,
@@ -701,7 +701,7 @@ function WithdrawReviewStep({
701
701
  await onConfirm();
702
702
  } catch (err) {
703
703
  const raw = err instanceof Error ? err.message : "Withdraw failed";
704
- const message = _chunkOQVLEVNRcjs.formatUserError.call(void 0, raw);
704
+ const message = _chunkLJJCPDZOcjs.formatUserError.call(void 0, raw);
705
705
  setError(message);
706
706
  _optionalChain([onError, 'optionalCall', _8 => _8(message, "WITHDRAW_REVIEW_ERROR")]);
707
707
  } finally {
@@ -712,9 +712,9 @@ function WithdrawReviewStep({
712
712
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
713
713
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
714
714
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
715
- _chunkOQVLEVNRcjs.BodyHeader,
715
+ _chunkLJJCPDZOcjs.BodyHeader,
716
716
  {
717
- icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.CircleArrowOutUpLeftIcon, {}),
717
+ icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.CircleArrowOutUpLeftIcon, {}),
718
718
  title: "Review withdrawal"
719
719
  }
720
720
  ),
@@ -760,10 +760,10 @@ function WithdrawReviewStep({
760
760
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-review-detail-value", children: estimatedTime })
761
761
  ] })
762
762
  ] }),
763
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.Callout, { variant: "error", children: error }),
764
- !error && registrationError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.Callout, { variant: "error", children: registrationError }),
763
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.Callout, { variant: "error", children: error }),
764
+ !error && registrationError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.Callout, { variant: "error", children: registrationError }),
765
765
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
766
- _chunkOQVLEVNRcjs.Button,
766
+ _chunkLJJCPDZOcjs.Button,
767
767
  {
768
768
  onClick: handleConfirm,
769
769
  loading: isSubmitting,
@@ -774,7 +774,7 @@ function WithdrawReviewStep({
774
774
  }
775
775
  )
776
776
  ] }),
777
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.PoweredBy, {})
777
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.PoweredBy, {})
778
778
  ] });
779
779
  }
780
780
  WithdrawReviewStep.displayName = "WithdrawReviewStep";
@@ -784,16 +784,17 @@ WithdrawReviewStep.displayName = "WithdrawReviewStep";
784
784
 
785
785
  var ADDR_REGEX = /^0x[a-fA-F0-9]{40}$/;
786
786
  var REGISTRATION_DEBOUNCE_MS = 600;
787
+ var WITHDRAW_INDEXING_DELAY_MS = 2e3;
787
788
  function resolveSessionOwner(eoaAddress) {
788
- const localOwner = _chunkOQVLEVNRcjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
789
+ const localOwner = _chunkLJJCPDZOcjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
789
790
  if (localOwner) {
790
791
  return {
791
- account: _chunkOQVLEVNRcjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
792
+ account: _chunkLJJCPDZOcjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
792
793
  address: localOwner.address
793
794
  };
794
795
  }
795
- const created = _chunkOQVLEVNRcjs.createSessionOwnerKey.call(void 0, );
796
- _chunkOQVLEVNRcjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
796
+ const created = _chunkLJJCPDZOcjs.createSessionOwnerKey.call(void 0, );
797
+ _chunkLJJCPDZOcjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
797
798
  return { account: created.account, address: created.address };
798
799
  }
799
800
  function targetsEqual(a, b) {
@@ -828,19 +829,27 @@ function WithdrawFlow({
828
829
  onError,
829
830
  debug
830
831
  }) {
831
- const onStepChangeRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onStepChange);
832
- const onEventRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onEvent);
833
- const onLifecycleRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onLifecycle);
834
- const onErrorRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onError);
832
+ const onStepChangeRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onStepChange);
833
+ const onEventRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onEvent);
834
+ const onLifecycleRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onLifecycle);
835
+ const onErrorRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onError);
836
+ const isFlowActiveRef = _react.useRef.call(void 0, true);
837
+ const submitGenerationRef = _react.useRef.call(void 0, 0);
838
+ _react.useEffect.call(void 0, () => {
839
+ isFlowActiveRef.current = true;
840
+ return () => {
841
+ isFlowActiveRef.current = false;
842
+ };
843
+ }, []);
835
844
  const logFlow = _react.useCallback.call(void 0,
836
845
  (message, data) => {
837
- _chunkOQVLEVNRcjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
846
+ _chunkLJJCPDZOcjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
838
847
  },
839
848
  [debug]
840
849
  );
841
850
  const logFlowError = _react.useCallback.call(void 0,
842
851
  (message, error, data) => {
843
- _chunkOQVLEVNRcjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
852
+ _chunkLJJCPDZOcjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
844
853
  },
845
854
  [debug]
846
855
  );
@@ -905,6 +914,7 @@ function WithdrawFlow({
905
914
  const selectedWalletId = useWithdrawStore((s) => s.selectedWalletId);
906
915
  const registration = useWithdrawStore((s) => s.registration);
907
916
  const flowStep = useWithdrawStore((s) => s.step);
917
+ const reviewedRecipient = useWithdrawStore((s) => s.recipient);
908
918
  const setSelectedWalletId = _react.useCallback.call(void 0,
909
919
  (walletId) => storeApi.dispatch({ type: "wallet/id-selected", walletId }),
910
920
  [storeApi]
@@ -915,14 +925,14 @@ function WithdrawFlow({
915
925
  return {
916
926
  ownerAddress: dappAddress,
917
927
  walletClient: _nullishCoalesce(dappWalletClient, () => ( void 0)),
918
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkOQVLEVNRcjs.getPublicClient.call(void 0, sourceChain))),
928
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLJJCPDZOcjs.getPublicClient.call(void 0, sourceChain))),
919
929
  switchChain: dappSwitchChain
920
930
  };
921
931
  }
922
932
  return {
923
933
  ownerAddress: dappWalletClient.account.address,
924
934
  walletClient: dappWalletClient,
925
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkOQVLEVNRcjs.getPublicClient.call(void 0, sourceChain))),
935
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLJJCPDZOcjs.getPublicClient.call(void 0, sourceChain))),
926
936
  switchChain: dappSwitchChain
927
937
  };
928
938
  }
@@ -933,7 +943,7 @@ function WithdrawFlow({
933
943
  return {
934
944
  ownerAddress: dappWalletClient.account.address,
935
945
  walletClient: dappWalletClient,
936
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkOQVLEVNRcjs.getPublicClient.call(void 0, sourceChain))),
946
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLJJCPDZOcjs.getPublicClient.call(void 0, sourceChain))),
937
947
  switchChain: dappSwitchChain
938
948
  };
939
949
  }
@@ -965,7 +975,7 @@ function WithdrawFlow({
965
975
  return ADDR_REGEX.test(recipientInput) ? recipientInput : void 0;
966
976
  }, [recipientInput]);
967
977
  _react.useEffect.call(void 0, () => {
968
- if (!ownerAddress) return;
978
+ if (!ownerAddress || !recipientForRegistration) return;
969
979
  const desiredTarget = {
970
980
  chain: targetChain,
971
981
  token: targetToken,
@@ -1015,7 +1025,7 @@ function WithdrawFlow({
1015
1025
  message: typedData.message
1016
1026
  });
1017
1027
  if (cancelled) return;
1018
- const sessionDetails = _chunkOQVLEVNRcjs.buildSessionDetails.call(void 0,
1028
+ const sessionDetails = _chunkLJJCPDZOcjs.buildSessionDetails.call(void 0,
1019
1029
  setup.sessionDetailsUnsigned,
1020
1030
  signature
1021
1031
  );
@@ -1052,7 +1062,7 @@ function WithdrawFlow({
1052
1062
  } catch (err) {
1053
1063
  if (cancelled) return;
1054
1064
  const raw = err instanceof Error ? err.message : "Registration failed";
1055
- const message = _chunkOQVLEVNRcjs.formatUserError.call(void 0, raw);
1065
+ const message = _chunkLJJCPDZOcjs.formatUserError.call(void 0, raw);
1056
1066
  logFlowError("auto-register:failed", err, {
1057
1067
  ownerAddress,
1058
1068
  targetChain,
@@ -1088,7 +1098,7 @@ function WithdrawFlow({
1088
1098
  const symbol = _chunkABVRVW3Pcjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
1089
1099
  const decimals = _chunkABVRVW3Pcjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
1090
1100
  return {
1091
- id: _chunkOQVLEVNRcjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1101
+ id: _chunkLJJCPDZOcjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1092
1102
  chainId: sourceChain,
1093
1103
  token: sourceToken,
1094
1104
  symbol,
@@ -1098,7 +1108,14 @@ function WithdrawFlow({
1098
1108
  }, [sourceChain, sourceToken]);
1099
1109
  const isSourceNative = sourceToken.toLowerCase() === _chunkABVRVW3Pcjs.NATIVE_TOKEN_ADDRESS.toLowerCase();
1100
1110
  const isSameRoute = targetChain === sourceChain && targetToken.toLowerCase() === sourceToken.toLowerCase();
1111
+ const reviewedTarget = reviewedRecipient ? {
1112
+ chain: targetChain,
1113
+ token: targetToken,
1114
+ recipient: reviewedRecipient
1115
+ } : null;
1116
+ const isReviewedTargetReady = registration.kind === "ready" && reviewedTarget !== null && targetsEqual(registration.registeredTarget, reviewedTarget);
1101
1117
  const reviewBackHandler = _react.useCallback.call(void 0, () => {
1118
+ submitGenerationRef.current += 1;
1102
1119
  storeApi.dispatch({ type: "review/back" });
1103
1120
  }, [storeApi]);
1104
1121
  _react.useEffect.call(void 0, () => {
@@ -1173,19 +1190,38 @@ function WithdrawFlow({
1173
1190
  const handleReviewConfirm = _react.useCallback.call(void 0,
1174
1191
  async () => {
1175
1192
  const state = storeApi.getState();
1176
- if (state.registration.kind !== "ready") {
1177
- throw new Error("Session not ready");
1178
- }
1179
- const smartAccount = state.registration.smartAccount;
1180
1193
  const recipient = state.recipient;
1181
1194
  const amountValue = state.amount;
1182
1195
  if (!recipient || !amountValue) {
1183
1196
  throw new Error("Missing recipient or amount");
1184
1197
  }
1198
+ const desiredTarget = {
1199
+ chain: targetChain,
1200
+ token: targetToken,
1201
+ recipient
1202
+ };
1203
+ const getMatchingRegistration = () => {
1204
+ const current = storeApi.getState().registration;
1205
+ return current.kind === "ready" && targetsEqual(current.registeredTarget, desiredTarget) ? current : null;
1206
+ };
1207
+ const matchingRegistration = getMatchingRegistration();
1208
+ if (!matchingRegistration) {
1209
+ throw new Error("Withdrawal target is still being prepared");
1210
+ }
1211
+ const smartAccount = matchingRegistration.smartAccount;
1185
1212
  if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _43 => _43.walletClient])) {
1186
1213
  throw new Error("Wallet not connected");
1187
1214
  }
1215
+ const submitGeneration = submitGenerationRef.current += 1;
1216
+ const isSubmissionLive = () => isFlowActiveRef.current && submitGenerationRef.current === submitGeneration;
1188
1217
  try {
1218
+ await new Promise((resolve) => {
1219
+ setTimeout(resolve, WITHDRAW_INDEXING_DELAY_MS);
1220
+ });
1221
+ if (!isSubmissionLive()) return;
1222
+ if (!getMatchingRegistration()) {
1223
+ throw new Error("Withdrawal target changed before submission");
1224
+ }
1189
1225
  logFlow("submit:start", {
1190
1226
  smartAccount,
1191
1227
  recipient,
@@ -1196,7 +1232,7 @@ function WithdrawFlow({
1196
1232
  targetToken
1197
1233
  });
1198
1234
  const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
1199
- const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _44 => _44.publicClient]), () => ( _chunkOQVLEVNRcjs.getPublicClient.call(void 0, sourceChain)));
1235
+ const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _44 => _44.publicClient]), () => ( _chunkLJJCPDZOcjs.getPublicClient.call(void 0, sourceChain)));
1200
1236
  let result;
1201
1237
  if (onSignTransaction) {
1202
1238
  const transferTarget = isSameRoute ? recipient : smartAccount;
@@ -1217,7 +1253,12 @@ function WithdrawFlow({
1217
1253
  data: transferData.data,
1218
1254
  chainId: sourceChain
1219
1255
  });
1256
+ if (!isSubmissionLive()) return;
1220
1257
  const { signature } = await onSignTransaction(request);
1258
+ if (!isSubmissionLive()) return;
1259
+ if (!getMatchingRegistration()) {
1260
+ throw new Error("Withdrawal target changed before submission");
1261
+ }
1221
1262
  const relayResult = await service.relayWithdraw({
1222
1263
  smartAccount,
1223
1264
  chainId: _chunkABVRVW3Pcjs.toEvmCaip2.call(void 0, sourceChain),
@@ -1230,6 +1271,9 @@ function WithdrawFlow({
1230
1271
  }
1231
1272
  result = { txHash: relayResult.txHash };
1232
1273
  } else if (isSourceNative) {
1274
+ if (!getMatchingRegistration()) {
1275
+ throw new Error("Withdrawal target changed before submission");
1276
+ }
1233
1277
  result = await _chunkUEKPBRBYcjs.executeSafeEthTransfer.call(void 0, {
1234
1278
  walletClient: signerContext.walletClient,
1235
1279
  publicClient: pc,
@@ -1239,6 +1283,9 @@ function WithdrawFlow({
1239
1283
  chainId: sourceChain
1240
1284
  });
1241
1285
  } else {
1286
+ if (!getMatchingRegistration()) {
1287
+ throw new Error("Withdrawal target changed before submission");
1288
+ }
1242
1289
  result = await _chunkUEKPBRBYcjs.executeSafeErc20Transfer.call(void 0, {
1243
1290
  walletClient: signerContext.walletClient,
1244
1291
  publicClient: pc,
@@ -1249,6 +1296,7 @@ function WithdrawFlow({
1249
1296
  chainId: sourceChain
1250
1297
  });
1251
1298
  }
1299
+ if (!isSubmissionLive()) return;
1252
1300
  logFlow("withdraw:submitted", {
1253
1301
  txHash: result.txHash,
1254
1302
  smartAccount,
@@ -1272,7 +1320,7 @@ function WithdrawFlow({
1272
1320
  targetChain,
1273
1321
  targetToken
1274
1322
  });
1275
- handleError(_chunkOQVLEVNRcjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1323
+ handleError(_chunkLJJCPDZOcjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1276
1324
  throw err;
1277
1325
  }
1278
1326
  },
@@ -1411,7 +1459,7 @@ function WithdrawFlow({
1411
1459
  state: "ready"
1412
1460
  }));
1413
1461
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1414
- _chunkOQVLEVNRcjs.ConnectStep,
1462
+ _chunkLJJCPDZOcjs.ConnectStep,
1415
1463
  {
1416
1464
  walletRows: withdrawRows,
1417
1465
  onConfirmWallet: (walletId) => {
@@ -1429,7 +1477,7 @@ function WithdrawFlow({
1429
1477
  if (!signerContext) return null;
1430
1478
  if (!onSignTransaction && !signerContext.walletClient) return null;
1431
1479
  const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess', _61 => _61.kind]) === "external" ? selectedWalletOption.address : void 0;
1432
- const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkOQVLEVNRcjs.getPublicClient.call(void 0, sourceChain)));
1480
+ const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkLJJCPDZOcjs.getPublicClient.call(void 0, sourceChain)));
1433
1481
  const stepView = deriveStepView(flowStep, registration);
1434
1482
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
1435
1483
  stepView === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1467,14 +1515,14 @@ function WithdrawFlow({
1467
1515
  amount: _nullishCoalesce(storeApi.getState().amount, () => ( "0")),
1468
1516
  recipient: _nullishCoalesce(_nullishCoalesce(storeApi.getState().recipient, () => ( recipientForRegistration)), () => ( "0x0")),
1469
1517
  service,
1470
- registrationPending: registration.kind === "pending" || registration.kind === "stale",
1518
+ registrationPending: registration.kind === "pending" || registration.kind === "stale" || !isReviewedTargetReady,
1471
1519
  registrationError: registration.kind === "failed" ? registration.error : null,
1472
1520
  onConfirm: handleReviewConfirm,
1473
1521
  onError: handleError
1474
1522
  }
1475
1523
  ),
1476
1524
  stepView === "processing" && registration.kind !== "idle" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1477
- _chunkOQVLEVNRcjs.ProcessingStep,
1525
+ _chunkLJJCPDZOcjs.ProcessingStep,
1478
1526
  {
1479
1527
  smartAccount: registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : "0x0",
1480
1528
  txHash: _nullishCoalesce(storeApi.getState().txHash, () => ( "0x0")),
@@ -1516,7 +1564,7 @@ function deriveStepView(step, _registration) {
1516
1564
  // src/WithdrawModal.tsx
1517
1565
 
1518
1566
  var ReownWithdrawInner = _react.lazy.call(void 0,
1519
- () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-Z2YF2FSJ.cjs"))).then((m) => ({
1567
+ () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-CTT3EXMG.cjs"))).then((m) => ({
1520
1568
  default: m.WithdrawModalReown
1521
1569
  }))
1522
1570
  );
@@ -1563,18 +1611,18 @@ function WithdrawModalInner({
1563
1611
  debug
1564
1612
  }) {
1565
1613
  const modalRef = _react.useRef.call(void 0, null);
1566
- const onReadyRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onReady);
1614
+ const onReadyRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onReady);
1567
1615
  const [backHandler, setBackHandler] = _react.useState.call(void 0,
1568
1616
  void 0
1569
1617
  );
1570
1618
  const targetChain = _chunkABVRVW3Pcjs.getChainId.call(void 0, targetChainProp);
1571
1619
  const sourceChain = _chunkABVRVW3Pcjs.getChainId.call(void 0, sourceChainProp);
1572
1620
  const service = _react.useMemo.call(void 0,
1573
- () => _chunkOQVLEVNRcjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1621
+ () => _chunkLJJCPDZOcjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1574
1622
  [backendUrl, debug]
1575
1623
  );
1576
1624
  const store = _react.useMemo.call(void 0, () => createWithdrawStore(), []);
1577
- const onErrorRef = _chunkOQVLEVNRcjs.useLatestRef.call(void 0, onError);
1625
+ const onErrorRef = _chunkLJJCPDZOcjs.useLatestRef.call(void 0, onError);
1578
1626
  _react.useEffect.call(void 0, () => {
1579
1627
  if (isOpen && onSignTransaction && !dappAddress) {
1580
1628
  _optionalChain([onErrorRef, 'access', _62 => _62.current, 'optionalCall', _63 => _63({
@@ -1585,7 +1633,7 @@ function WithdrawModalInner({
1585
1633
  }, [isOpen, onSignTransaction, dappAddress, onErrorRef]);
1586
1634
  _react.useEffect.call(void 0, () => {
1587
1635
  if (isOpen && modalRef.current) {
1588
- _chunkOQVLEVNRcjs.applyTheme.call(void 0, modalRef.current, theme);
1636
+ _chunkLJJCPDZOcjs.applyTheme.call(void 0, modalRef.current, theme);
1589
1637
  }
1590
1638
  }, [isOpen, theme]);
1591
1639
  _react.useEffect.call(void 0, () => {
@@ -1604,7 +1652,7 @@ function WithdrawModalInner({
1604
1652
  const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _66 => _66.showBackButton]), () => ( true));
1605
1653
  const canGoBack = backHandler !== void 0;
1606
1654
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawStoreProvider, { store, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1607
- _chunkOQVLEVNRcjs.Modal,
1655
+ _chunkLJJCPDZOcjs.Modal,
1608
1656
  {
1609
1657
  isOpen,
1610
1658
  onClose,
@@ -1620,7 +1668,7 @@ function WithdrawModalInner({
1620
1668
  className: "rs-modal-header-back",
1621
1669
  "aria-label": "Go back",
1622
1670
  onClick: backHandler,
1623
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.ChevronLeftIcon, {})
1671
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.ChevronLeftIcon, {})
1624
1672
  }
1625
1673
  ) }),
1626
1674
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1630,7 +1678,7 @@ function WithdrawModalInner({
1630
1678
  onClick: onClose,
1631
1679
  className: "rs-modal-close",
1632
1680
  "aria-label": "Close",
1633
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOQVLEVNRcjs.CloseIcon, {})
1681
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLJJCPDZOcjs.CloseIcon, {})
1634
1682
  }
1635
1683
  ) })
1636
1684
  ] }),