@rhinestone/deposit-modal 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2216,6 +2216,7 @@ function ConfirmStep({
2216
2216
  walletClient,
2217
2217
  address,
2218
2218
  smartAccount,
2219
+ recipient,
2219
2220
  asset,
2220
2221
  amount,
2221
2222
  balance,
@@ -2311,10 +2312,11 @@ function ConfirmStep({
2311
2312
  if (!account || !chain) {
2312
2313
  throw new Error("Wallet not properly connected");
2313
2314
  }
2315
+ const transferTo = sameRoute ? recipient : smartAccount;
2314
2316
  const hash = isNativeAsset(asset) ? await walletClient.sendTransaction({
2315
2317
  account,
2316
2318
  chain,
2317
- to: smartAccount,
2319
+ to: transferTo,
2318
2320
  value: amountUnits
2319
2321
  }) : await walletClient.writeContract({
2320
2322
  account,
@@ -2322,7 +2324,7 @@ function ConfirmStep({
2322
2324
  address: asset.token,
2323
2325
  abi: import_viem5.erc20Abi,
2324
2326
  functionName: "transfer",
2325
- args: [smartAccount, amountUnits]
2327
+ args: [transferTo, amountUnits]
2326
2328
  });
2327
2329
  onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
2328
2330
  onConfirm(hash, asset.chainId, amountUnits.toString(), asset.token);
@@ -2580,6 +2582,7 @@ function ProcessingStep({
2580
2582
  amount,
2581
2583
  waitForFinalTx,
2582
2584
  service,
2585
+ directTransfer,
2583
2586
  flowLabel = "deposit",
2584
2587
  debug,
2585
2588
  onClose,
@@ -2588,11 +2591,20 @@ function ProcessingStep({
2588
2591
  onDepositFailed,
2589
2592
  onError
2590
2593
  }) {
2591
- const [state, setState] = (0, import_react6.useState)({ type: "processing" });
2594
+ const [state, setState] = (0, import_react6.useState)(
2595
+ directTransfer ? { type: "complete" } : { type: "processing" }
2596
+ );
2592
2597
  const [elapsedSeconds, setElapsedSeconds] = (0, import_react6.useState)(0);
2593
2598
  const startTimeRef = (0, import_react6.useRef)(Date.now());
2594
2599
  const intervalRef = (0, import_react6.useRef)(null);
2595
2600
  (0, import_react6.useEffect)(() => {
2601
+ if (directTransfer) {
2602
+ onDepositComplete?.(txHash);
2603
+ return;
2604
+ }
2605
+ }, [directTransfer, txHash, onDepositComplete]);
2606
+ (0, import_react6.useEffect)(() => {
2607
+ if (directTransfer) return;
2596
2608
  startTimeRef.current = Date.now();
2597
2609
  intervalRef.current = setInterval(() => {
2598
2610
  setElapsedSeconds(Math.floor((Date.now() - startTimeRef.current) / 1e3));
@@ -2600,7 +2612,7 @@ function ProcessingStep({
2600
2612
  return () => {
2601
2613
  if (intervalRef.current) clearInterval(intervalRef.current);
2602
2614
  };
2603
- }, []);
2615
+ }, [directTransfer]);
2604
2616
  (0, import_react6.useEffect)(() => {
2605
2617
  if (state.type === "complete" || state.type === "failed" || state.type === "error") {
2606
2618
  if (intervalRef.current) {
@@ -2613,6 +2625,7 @@ function ProcessingStep({
2613
2625
  const pollTimeoutRef = (0, import_react6.useRef)(null);
2614
2626
  const processTimeoutRef = (0, import_react6.useRef)(null);
2615
2627
  (0, import_react6.useEffect)(() => {
2628
+ if (directTransfer) return;
2616
2629
  if (state.type !== "processing") {
2617
2630
  pollIntervalRef.current = INITIAL_POLL_INTERVAL;
2618
2631
  return;
@@ -2689,6 +2702,7 @@ function ProcessingStep({
2689
2702
  }
2690
2703
  };
2691
2704
  }, [
2705
+ directTransfer,
2692
2706
  state.type,
2693
2707
  smartAccount,
2694
2708
  txHash,
@@ -2698,6 +2712,7 @@ function ProcessingStep({
2698
2712
  onDepositFailed
2699
2713
  ]);
2700
2714
  (0, import_react6.useEffect)(() => {
2715
+ if (directTransfer) return;
2701
2716
  if (state.type !== "processing") {
2702
2717
  if (processTimeoutRef.current) {
2703
2718
  clearTimeout(processTimeoutRef.current);
@@ -2716,7 +2731,7 @@ function ProcessingStep({
2716
2731
  processTimeoutRef.current = null;
2717
2732
  }
2718
2733
  };
2719
- }, [state.type, onError]);
2734
+ }, [directTransfer, state.type, onError]);
2720
2735
  const isError = state.type === "error" || state.type === "failed";
2721
2736
  const isComplete = state.type === "complete";
2722
2737
  const isProcessing = state.type === "processing";
@@ -2770,7 +2785,7 @@ function ProcessingStep({
2770
2785
  }
2771
2786
  ) }),
2772
2787
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rs-success-title", children: isEarlyComplete ? `${flowCapitalized} confirmed` : `${flowCapitalized} successful` }),
2773
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rs-success-subtitle", children: isEarlyComplete ? "Your transfer has been confirmed and funds will arrive shortly." : `Your funds have been successfully bridged.` })
2788
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rs-success-subtitle", children: directTransfer ? "Your transfer is complete." : isEarlyComplete ? "Your transfer has been confirmed and funds will arrive shortly." : "Your funds have been successfully bridged." })
2774
2789
  ] }),
2775
2790
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rs-card", children: [
2776
2791
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rs-card-row", children: [
@@ -3553,6 +3568,9 @@ var init_public_client = __esm({
3553
3568
  });
3554
3569
 
3555
3570
  // src/DepositFlow.tsx
3571
+ function isSameRoute(sourceChain, sourceToken, targetChain, targetToken) {
3572
+ return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
3573
+ }
3556
3574
  function DepositFlow({
3557
3575
  dappWalletClient,
3558
3576
  dappPublicClient,
@@ -3753,12 +3771,13 @@ function DepositFlow({
3753
3771
  txHash,
3754
3772
  sourceChain: chainId,
3755
3773
  sourceToken: token,
3756
- amount
3774
+ amount,
3775
+ directTransfer: isSameRoute(chainId, token, targetChain, targetToken)
3757
3776
  };
3758
3777
  });
3759
3778
  onDepositSubmitted?.({ txHash, sourceChain: chainId, amount });
3760
3779
  },
3761
- [onDepositSubmitted]
3780
+ [onDepositSubmitted, targetChain, targetToken]
3762
3781
  );
3763
3782
  const handleConnected = (0, import_react9.useCallback)(
3764
3783
  (addr, smartAccount) => {
@@ -3805,11 +3824,12 @@ function DepositFlow({
3805
3824
  txHash,
3806
3825
  sourceChain: chainId,
3807
3826
  sourceToken: token,
3808
- amount
3827
+ amount,
3828
+ directTransfer: isSameRoute(chainId, token, targetChain, targetToken)
3809
3829
  };
3810
3830
  });
3811
3831
  },
3812
- []
3832
+ [targetChain, targetToken]
3813
3833
  );
3814
3834
  const handleDepositSubmittedCallback = (0, import_react9.useCallback)(
3815
3835
  (txHash, sourceChain, amount) => {
@@ -3918,6 +3938,7 @@ function DepositFlow({
3918
3938
  amount: step.amount,
3919
3939
  waitForFinalTx,
3920
3940
  service,
3941
+ directTransfer: step.directTransfer,
3921
3942
  onClose,
3922
3943
  onNewDeposit: handleNewDeposit,
3923
3944
  onDepositComplete: handleDepositComplete,
@@ -3992,6 +4013,7 @@ function DepositFlow({
3992
4013
  walletClient: signerContext.walletClient,
3993
4014
  address: ownerAddress,
3994
4015
  smartAccount: step.smartAccount,
4016
+ recipient,
3995
4017
  asset: step.asset,
3996
4018
  amount: step.amount,
3997
4019
  balance: step.balance,
@@ -4015,6 +4037,7 @@ function DepositFlow({
4015
4037
  amount: step.amount,
4016
4038
  waitForFinalTx,
4017
4039
  service,
4040
+ directTransfer: step.directTransfer,
4018
4041
  onClose,
4019
4042
  onNewDeposit: handleNewDeposit,
4020
4043
  onDepositComplete: handleDepositComplete,
package/dist/index.d.cts CHANGED
@@ -72,7 +72,7 @@ interface DepositModalProps {
72
72
  sourceChain?: Chain | number;
73
73
  sourceToken?: Address;
74
74
  defaultAmount?: string;
75
- recipient?: Address;
75
+ recipient: Address;
76
76
  backendUrl?: string;
77
77
  rhinestoneApiKey?: string;
78
78
  signerAddress?: Address;
package/dist/index.d.ts CHANGED
@@ -72,7 +72,7 @@ interface DepositModalProps {
72
72
  sourceChain?: Chain | number;
73
73
  sourceToken?: Address;
74
74
  defaultAmount?: string;
75
- recipient?: Address;
75
+ recipient: Address;
76
76
  backendUrl?: string;
77
77
  rhinestoneApiKey?: string;
78
78
  signerAddress?: Address;
package/dist/index.mjs CHANGED
@@ -2203,6 +2203,7 @@ function ConfirmStep({
2203
2203
  walletClient,
2204
2204
  address,
2205
2205
  smartAccount,
2206
+ recipient,
2206
2207
  asset,
2207
2208
  amount,
2208
2209
  balance,
@@ -2298,10 +2299,11 @@ function ConfirmStep({
2298
2299
  if (!account || !chain) {
2299
2300
  throw new Error("Wallet not properly connected");
2300
2301
  }
2302
+ const transferTo = sameRoute ? recipient : smartAccount;
2301
2303
  const hash = isNativeAsset(asset) ? await walletClient.sendTransaction({
2302
2304
  account,
2303
2305
  chain,
2304
- to: smartAccount,
2306
+ to: transferTo,
2305
2307
  value: amountUnits
2306
2308
  }) : await walletClient.writeContract({
2307
2309
  account,
@@ -2309,7 +2311,7 @@ function ConfirmStep({
2309
2311
  address: asset.token,
2310
2312
  abi: erc20Abi2,
2311
2313
  functionName: "transfer",
2312
- args: [smartAccount, amountUnits]
2314
+ args: [transferTo, amountUnits]
2313
2315
  });
2314
2316
  onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
2315
2317
  onConfirm(hash, asset.chainId, amountUnits.toString(), asset.token);
@@ -2567,6 +2569,7 @@ function ProcessingStep({
2567
2569
  amount,
2568
2570
  waitForFinalTx,
2569
2571
  service,
2572
+ directTransfer,
2570
2573
  flowLabel = "deposit",
2571
2574
  debug,
2572
2575
  onClose,
@@ -2575,11 +2578,20 @@ function ProcessingStep({
2575
2578
  onDepositFailed,
2576
2579
  onError
2577
2580
  }) {
2578
- const [state, setState] = useState5({ type: "processing" });
2581
+ const [state, setState] = useState5(
2582
+ directTransfer ? { type: "complete" } : { type: "processing" }
2583
+ );
2579
2584
  const [elapsedSeconds, setElapsedSeconds] = useState5(0);
2580
2585
  const startTimeRef = useRef4(Date.now());
2581
2586
  const intervalRef = useRef4(null);
2582
2587
  useEffect5(() => {
2588
+ if (directTransfer) {
2589
+ onDepositComplete?.(txHash);
2590
+ return;
2591
+ }
2592
+ }, [directTransfer, txHash, onDepositComplete]);
2593
+ useEffect5(() => {
2594
+ if (directTransfer) return;
2583
2595
  startTimeRef.current = Date.now();
2584
2596
  intervalRef.current = setInterval(() => {
2585
2597
  setElapsedSeconds(Math.floor((Date.now() - startTimeRef.current) / 1e3));
@@ -2587,7 +2599,7 @@ function ProcessingStep({
2587
2599
  return () => {
2588
2600
  if (intervalRef.current) clearInterval(intervalRef.current);
2589
2601
  };
2590
- }, []);
2602
+ }, [directTransfer]);
2591
2603
  useEffect5(() => {
2592
2604
  if (state.type === "complete" || state.type === "failed" || state.type === "error") {
2593
2605
  if (intervalRef.current) {
@@ -2600,6 +2612,7 @@ function ProcessingStep({
2600
2612
  const pollTimeoutRef = useRef4(null);
2601
2613
  const processTimeoutRef = useRef4(null);
2602
2614
  useEffect5(() => {
2615
+ if (directTransfer) return;
2603
2616
  if (state.type !== "processing") {
2604
2617
  pollIntervalRef.current = INITIAL_POLL_INTERVAL;
2605
2618
  return;
@@ -2676,6 +2689,7 @@ function ProcessingStep({
2676
2689
  }
2677
2690
  };
2678
2691
  }, [
2692
+ directTransfer,
2679
2693
  state.type,
2680
2694
  smartAccount,
2681
2695
  txHash,
@@ -2685,6 +2699,7 @@ function ProcessingStep({
2685
2699
  onDepositFailed
2686
2700
  ]);
2687
2701
  useEffect5(() => {
2702
+ if (directTransfer) return;
2688
2703
  if (state.type !== "processing") {
2689
2704
  if (processTimeoutRef.current) {
2690
2705
  clearTimeout(processTimeoutRef.current);
@@ -2703,7 +2718,7 @@ function ProcessingStep({
2703
2718
  processTimeoutRef.current = null;
2704
2719
  }
2705
2720
  };
2706
- }, [state.type, onError]);
2721
+ }, [directTransfer, state.type, onError]);
2707
2722
  const isError = state.type === "error" || state.type === "failed";
2708
2723
  const isComplete = state.type === "complete";
2709
2724
  const isProcessing = state.type === "processing";
@@ -2757,7 +2772,7 @@ function ProcessingStep({
2757
2772
  }
2758
2773
  ) }),
2759
2774
  /* @__PURE__ */ jsx11("div", { className: "rs-success-title", children: isEarlyComplete ? `${flowCapitalized} confirmed` : `${flowCapitalized} successful` }),
2760
- /* @__PURE__ */ jsx11("div", { className: "rs-success-subtitle", children: isEarlyComplete ? "Your transfer has been confirmed and funds will arrive shortly." : `Your funds have been successfully bridged.` })
2775
+ /* @__PURE__ */ jsx11("div", { className: "rs-success-subtitle", children: directTransfer ? "Your transfer is complete." : isEarlyComplete ? "Your transfer has been confirmed and funds will arrive shortly." : "Your funds have been successfully bridged." })
2761
2776
  ] }),
2762
2777
  /* @__PURE__ */ jsxs10("div", { className: "rs-card", children: [
2763
2778
  /* @__PURE__ */ jsxs10("div", { className: "rs-card-row", children: [
@@ -3538,6 +3553,9 @@ var init_public_client = __esm({
3538
3553
  // src/DepositFlow.tsx
3539
3554
  import { useState as useState7, useCallback as useCallback4, useMemo as useMemo6, useEffect as useEffect7, useRef as useRef6 } from "react";
3540
3555
  import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
3556
+ function isSameRoute(sourceChain, sourceToken, targetChain, targetToken) {
3557
+ return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
3558
+ }
3541
3559
  function DepositFlow({
3542
3560
  dappWalletClient,
3543
3561
  dappPublicClient,
@@ -3738,12 +3756,13 @@ function DepositFlow({
3738
3756
  txHash,
3739
3757
  sourceChain: chainId,
3740
3758
  sourceToken: token,
3741
- amount
3759
+ amount,
3760
+ directTransfer: isSameRoute(chainId, token, targetChain, targetToken)
3742
3761
  };
3743
3762
  });
3744
3763
  onDepositSubmitted?.({ txHash, sourceChain: chainId, amount });
3745
3764
  },
3746
- [onDepositSubmitted]
3765
+ [onDepositSubmitted, targetChain, targetToken]
3747
3766
  );
3748
3767
  const handleConnected = useCallback4(
3749
3768
  (addr, smartAccount) => {
@@ -3790,11 +3809,12 @@ function DepositFlow({
3790
3809
  txHash,
3791
3810
  sourceChain: chainId,
3792
3811
  sourceToken: token,
3793
- amount
3812
+ amount,
3813
+ directTransfer: isSameRoute(chainId, token, targetChain, targetToken)
3794
3814
  };
3795
3815
  });
3796
3816
  },
3797
- []
3817
+ [targetChain, targetToken]
3798
3818
  );
3799
3819
  const handleDepositSubmittedCallback = useCallback4(
3800
3820
  (txHash, sourceChain, amount) => {
@@ -3903,6 +3923,7 @@ function DepositFlow({
3903
3923
  amount: step.amount,
3904
3924
  waitForFinalTx,
3905
3925
  service,
3926
+ directTransfer: step.directTransfer,
3906
3927
  onClose,
3907
3928
  onNewDeposit: handleNewDeposit,
3908
3929
  onDepositComplete: handleDepositComplete,
@@ -3977,6 +3998,7 @@ function DepositFlow({
3977
3998
  walletClient: signerContext.walletClient,
3978
3999
  address: ownerAddress,
3979
4000
  smartAccount: step.smartAccount,
4001
+ recipient,
3980
4002
  asset: step.asset,
3981
4003
  amount: step.amount,
3982
4004
  balance: step.balance,
@@ -4000,6 +4022,7 @@ function DepositFlow({
4000
4022
  amount: step.amount,
4001
4023
  waitForFinalTx,
4002
4024
  service,
4025
+ directTransfer: step.directTransfer,
4003
4026
  onClose,
4004
4027
  onNewDeposit: handleNewDeposit,
4005
4028
  onDepositComplete: handleDepositComplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/deposit-modal",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "React modal component for Rhinestone cross-chain deposits",
5
5
  "author": "Rhinestone <dev@rhinestone.wtf>",
6
6
  "bugs": {