@rhinestone/deposit-modal 0.1.14 → 0.1.16

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.mjs CHANGED
@@ -805,8 +805,10 @@ function buildSession(chain, signerAddress) {
805
805
  chain
806
806
  };
807
807
  }
808
- async function createSmartAccount(userSigner, sessionSigner) {
809
- const rhinestone = new RhinestoneSDK();
808
+ async function createSmartAccount(userSigner, sessionSigner, sdkApiKey) {
809
+ const rhinestone = new RhinestoneSDK({
810
+ apiKey: sdkApiKey ?? ""
811
+ });
810
812
  const ownerAccounts = sessionSigner ? [userSigner, sessionSigner] : [userSigner];
811
813
  const config = {
812
814
  account: {
@@ -875,7 +877,10 @@ async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress,
875
877
  }
876
878
  }
877
879
  if (targetToken) {
878
- const targetSymbol = getTokenSymbol(targetToken, targetChain.id).toUpperCase();
880
+ const targetSymbol = getTokenSymbol(
881
+ targetToken,
882
+ targetChain.id
883
+ ).toUpperCase();
879
884
  if (targetSymbol && targetSymbol !== "TOKEN") {
880
885
  const chainsForToken = selectedChains.filter(
881
886
  (chain) => getSupportedTokenSymbolsForChain(chain.id).includes(targetSymbol)
@@ -995,6 +1000,7 @@ function SetupStep({
995
1000
  targetChain,
996
1001
  targetChainObj,
997
1002
  targetToken,
1003
+ rhinestoneApiKey,
998
1004
  signerAddress,
999
1005
  sessionChainIds,
1000
1006
  recipient,
@@ -1019,7 +1025,8 @@ function SetupStep({
1019
1025
  const sessionOwner = await resolveSessionOwner(address);
1020
1026
  const account = await createSmartAccount(
1021
1027
  signerAccount,
1022
- sessionOwner.account
1028
+ sessionOwner.account,
1029
+ rhinestoneApiKey
1023
1030
  );
1024
1031
  const smartAccount = getAccountAddress(account);
1025
1032
  setState({ type: "checking" });
@@ -1073,6 +1080,7 @@ function SetupStep({
1073
1080
  targetChainObj,
1074
1081
  targetChain,
1075
1082
  targetToken,
1083
+ rhinestoneApiKey,
1076
1084
  signerAddress,
1077
1085
  sessionChainIds,
1078
1086
  recipient,
@@ -3479,28 +3487,49 @@ var init_DepositAddressStep = __esm({
3479
3487
  }
3480
3488
  });
3481
3489
 
3490
+ // src/core/public-client.ts
3491
+ import { createPublicClient, http } from "viem";
3492
+ function getPublicClient(chainId) {
3493
+ let client = clientCache.get(chainId);
3494
+ if (!client) {
3495
+ const chain = CHAIN_BY_ID[chainId];
3496
+ client = createPublicClient({
3497
+ chain,
3498
+ transport: http()
3499
+ });
3500
+ clientCache.set(chainId, client);
3501
+ }
3502
+ return client;
3503
+ }
3504
+ var clientCache;
3505
+ var init_public_client = __esm({
3506
+ "src/core/public-client.ts"() {
3507
+ "use strict";
3508
+ init_constants();
3509
+ clientCache = /* @__PURE__ */ new Map();
3510
+ }
3511
+ });
3512
+
3482
3513
  // src/DepositFlow.tsx
3483
3514
  import { useState as useState7, useCallback as useCallback4, useMemo as useMemo6, useEffect as useEffect7, useRef as useRef6 } from "react";
3484
3515
  import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
3485
3516
  function DepositFlow({
3486
- walletClient,
3487
- publicClient,
3488
- address,
3517
+ dappWalletClient,
3518
+ dappPublicClient,
3519
+ dappAddress,
3489
3520
  targetChain,
3490
3521
  targetToken,
3491
3522
  service,
3492
- switchChain,
3493
3523
  sourceChain: defaultSourceChain,
3494
3524
  sourceToken: defaultSourceToken,
3495
3525
  amount: defaultAmount,
3496
3526
  recipient,
3527
+ rhinestoneApiKey,
3497
3528
  signerAddress = DEFAULT_SIGNER_ADDRESS,
3498
3529
  sessionChainIds,
3499
3530
  forceRegister = false,
3500
3531
  waitForFinalTx = true,
3501
- connectWalletOptions,
3502
- selectedConnectAddress,
3503
- onSelectConnectAddress,
3532
+ reownWallet,
3504
3533
  onConnect,
3505
3534
  onRequestConnect,
3506
3535
  connectButtonLabel,
@@ -3518,9 +3547,93 @@ function DepositFlow({
3518
3547
  const [flowMode, setFlowMode] = useState7(null);
3519
3548
  const [totalBalanceUsd, setTotalBalanceUsd] = useState7(0);
3520
3549
  const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState7(false);
3521
- const hasConnectWalletOptions = (connectWalletOptions?.length ?? 0) > 0;
3522
- const hasConnectedWallet = Boolean(walletClient && publicClient && address);
3550
+ const [selectedConnectAddress, setSelectedConnectAddress] = useState7(null);
3523
3551
  const targetChainObj = useMemo6(() => CHAIN_BY_ID[targetChain], [targetChain]);
3552
+ const dappSwitchChain = useMemo6(() => {
3553
+ if (!dappWalletClient?.switchChain) return void 0;
3554
+ return async (chainId) => {
3555
+ await dappWalletClient.switchChain?.({ id: chainId });
3556
+ };
3557
+ }, [dappWalletClient]);
3558
+ const walletOptions = useMemo6(() => {
3559
+ const options = [];
3560
+ const seen = /* @__PURE__ */ new Set();
3561
+ if (dappWalletClient?.account && dappAddress) {
3562
+ options.push({
3563
+ address: dappWalletClient.account.address,
3564
+ label: "Connected Wallet",
3565
+ kind: "connected"
3566
+ });
3567
+ seen.add(dappWalletClient.account.address.toLowerCase());
3568
+ }
3569
+ if (reownWallet?.address && reownWallet.isConnected && !seen.has(reownWallet.address.toLowerCase())) {
3570
+ options.push({
3571
+ address: reownWallet.address,
3572
+ label: "External Wallet",
3573
+ kind: "external"
3574
+ });
3575
+ }
3576
+ return options;
3577
+ }, [
3578
+ dappWalletClient,
3579
+ dappAddress,
3580
+ reownWallet?.address,
3581
+ reownWallet?.isConnected
3582
+ ]);
3583
+ const canAutoLock = dappWalletClient?.account && dappAddress && !reownWallet;
3584
+ const hasWalletOptions = walletOptions.length > 0;
3585
+ const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
3586
+ const signerContext = useMemo6(() => {
3587
+ if (flowMode === "deposit-address") {
3588
+ if (!dappAddress) return null;
3589
+ return {
3590
+ ownerAddress: dappAddress,
3591
+ walletClient: void 0,
3592
+ publicClient: dappPublicClient ?? getPublicClient(targetChain),
3593
+ switchChain: void 0
3594
+ };
3595
+ }
3596
+ if (canAutoLock) {
3597
+ const fallbackChainId = dappWalletClient?.chain?.id ?? targetChain;
3598
+ return {
3599
+ ownerAddress: dappWalletClient.account.address,
3600
+ walletClient: dappWalletClient,
3601
+ publicClient: dappPublicClient ?? getPublicClient(fallbackChainId),
3602
+ switchChain: dappSwitchChain
3603
+ };
3604
+ }
3605
+ if (!isConnectSelectionConfirmed || !selectedConnectAddress) return null;
3606
+ if (dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedConnectAddress.toLowerCase()) {
3607
+ const fallbackChainId = dappWalletClient?.chain?.id ?? targetChain;
3608
+ return {
3609
+ ownerAddress: dappWalletClient.account.address,
3610
+ walletClient: dappWalletClient,
3611
+ publicClient: dappPublicClient ?? getPublicClient(fallbackChainId),
3612
+ switchChain: dappSwitchChain
3613
+ };
3614
+ }
3615
+ if (reownWallet?.address?.toLowerCase() === selectedConnectAddress.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
3616
+ return {
3617
+ ownerAddress: reownWallet.address,
3618
+ walletClient: reownWallet.walletClient,
3619
+ publicClient: reownWallet.publicClient,
3620
+ switchChain: reownWallet.switchChain
3621
+ };
3622
+ }
3623
+ return null;
3624
+ }, [
3625
+ flowMode,
3626
+ canAutoLock,
3627
+ isConnectSelectionConfirmed,
3628
+ selectedConnectAddress,
3629
+ dappWalletClient,
3630
+ dappPublicClient,
3631
+ dappSwitchChain,
3632
+ dappAddress,
3633
+ reownWallet,
3634
+ targetChain
3635
+ ]);
3636
+ const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
3524
3637
  const lastTargetRef = useRef6(null);
3525
3638
  useEffect7(() => {
3526
3639
  const prev = lastTargetRef.current;
@@ -3538,17 +3651,17 @@ function DepositFlow({
3538
3651
  });
3539
3652
  }, []);
3540
3653
  const handleBackFromSelectAsset = useCallback4(() => {
3541
- if (hasConnectWalletOptions) {
3654
+ if (hasWalletOptions || reownWallet) {
3542
3655
  setIsConnectSelectionConfirmed(false);
3543
3656
  }
3544
- }, [hasConnectWalletOptions]);
3657
+ }, [hasWalletOptions, reownWallet]);
3545
3658
  const handleBackFromDepositAddress = useCallback4(() => {
3546
3659
  setFlowMode(null);
3547
3660
  setStep({ type: "setup" });
3548
- if (hasConnectWalletOptions) {
3661
+ if (hasWalletOptions || reownWallet) {
3549
3662
  setIsConnectSelectionConfirmed(false);
3550
3663
  }
3551
- }, [hasConnectWalletOptions]);
3664
+ }, [hasWalletOptions, reownWallet]);
3552
3665
  const handleBackFromConfirm = useCallback4(() => {
3553
3666
  setStep((prev) => {
3554
3667
  if (prev.type !== "confirm") return prev;
@@ -3561,7 +3674,7 @@ function DepositFlow({
3561
3674
  });
3562
3675
  }, []);
3563
3676
  const stepIndex = step.type === "setup" ? 0 : step.type === "deposit-address" ? 1 : step.type === "select-asset" ? 1 : step.type === "amount" ? 2 : step.type === "confirm" ? 3 : 4;
3564
- const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && hasConnectedWallet && hasConnectWalletOptions && isConnectSelectionConfirmed ? handleBackFromSelectAsset : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
3677
+ const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
3565
3678
  useEffect7(() => {
3566
3679
  onStepChange?.(stepIndex, currentBackHandler);
3567
3680
  }, [stepIndex, currentBackHandler, onStepChange]);
@@ -3686,33 +3799,35 @@ function DepositFlow({
3686
3799
  }, []);
3687
3800
  const selectedConnectAddressEffective = useMemo6(() => {
3688
3801
  if (selectedConnectAddress) return selectedConnectAddress;
3689
- if ((connectWalletOptions?.length ?? 0) === 1) {
3690
- return connectWalletOptions?.[0]?.address ?? null;
3802
+ if (walletOptions.length === 1) {
3803
+ return walletOptions[0].address;
3691
3804
  }
3692
3805
  return null;
3693
- }, [selectedConnectAddress, connectWalletOptions]);
3694
- const connectWalletOptionsKey = useMemo6(
3695
- () => (connectWalletOptions ?? []).map((option) => option.address.toLowerCase()).join(","),
3696
- [connectWalletOptions]
3806
+ }, [selectedConnectAddress, walletOptions]);
3807
+ const walletOptionsKey = useMemo6(
3808
+ () => walletOptions.map((option) => option.address.toLowerCase()).join(","),
3809
+ [walletOptions]
3697
3810
  );
3698
- const showConnectStep = !hasConnectedWallet || hasConnectWalletOptions && !isConnectSelectionConfirmed;
3699
3811
  useEffect7(() => {
3700
3812
  setIsConnectSelectionConfirmed(false);
3701
- }, [connectWalletOptionsKey, selectedConnectAddressEffective]);
3813
+ }, [walletOptionsKey, selectedConnectAddressEffective]);
3702
3814
  if (showConnectStep) {
3703
3815
  return /* @__PURE__ */ jsx14("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx14(
3704
3816
  ConnectStep,
3705
3817
  {
3706
- walletOptions: connectWalletOptions,
3818
+ walletOptions,
3707
3819
  selectedAddress: selectedConnectAddressEffective,
3708
- onSelectAddress: onSelectConnectAddress,
3709
- onSelectTransferCrypto: () => {
3820
+ onSelectAddress: setSelectedConnectAddress,
3821
+ onSelectTransferCrypto: dappAddress ? () => {
3710
3822
  handleSelectTransferCrypto();
3711
3823
  setIsConnectSelectionConfirmed(true);
3712
- },
3824
+ } : void 0,
3713
3825
  onRequestConnect,
3714
3826
  onConnect,
3715
3827
  onContinue: () => {
3828
+ if (selectedConnectAddressEffective) {
3829
+ setSelectedConnectAddress(selectedConnectAddressEffective);
3830
+ }
3716
3831
  handleSelectProvider();
3717
3832
  setIsConnectSelectionConfirmed(true);
3718
3833
  },
@@ -3720,19 +3835,17 @@ function DepositFlow({
3720
3835
  }
3721
3836
  ) });
3722
3837
  }
3723
- if (!walletClient || !publicClient || !address) {
3724
- return null;
3725
- }
3726
3838
  if (isDepositAddressMode) {
3839
+ if (!dappAddress || !sessionKeyAddress) return null;
3727
3840
  return /* @__PURE__ */ jsxs13("div", { className: "rs-modal-body", children: [
3728
3841
  step.type === "setup" && targetChainObj && /* @__PURE__ */ jsx14(
3729
3842
  SetupStep,
3730
3843
  {
3731
- walletClient,
3732
- address,
3844
+ address: sessionKeyAddress,
3733
3845
  targetChain,
3734
3846
  targetChainObj,
3735
3847
  targetToken,
3848
+ rhinestoneApiKey,
3736
3849
  signerAddress,
3737
3850
  sessionChainIds,
3738
3851
  recipient,
@@ -3773,15 +3886,27 @@ function DepositFlow({
3773
3886
  )
3774
3887
  ] });
3775
3888
  }
3889
+ if (!signerContext?.walletClient || !signerContext?.publicClient) {
3890
+ return null;
3891
+ }
3892
+ const ownerAddress = signerContext.ownerAddress;
3893
+ const ownerChainId = signerContext.walletClient?.chain?.id ?? signerContext.publicClient.chain?.id ?? targetChain;
3894
+ const getReadClientForChain = (chainId) => {
3895
+ if (signerContext.publicClient.chain?.id === chainId) {
3896
+ return signerContext.publicClient;
3897
+ }
3898
+ return getPublicClient(chainId);
3899
+ };
3776
3900
  return /* @__PURE__ */ jsxs13("div", { className: "rs-modal-body", children: [
3777
3901
  step.type === "setup" && targetChainObj && /* @__PURE__ */ jsx14(
3778
3902
  SetupStep,
3779
3903
  {
3780
- walletClient,
3781
- address,
3904
+ walletClient: signerContext.walletClient,
3905
+ address: ownerAddress,
3782
3906
  targetChain,
3783
3907
  targetChainObj,
3784
3908
  targetToken,
3909
+ rhinestoneApiKey,
3785
3910
  signerAddress,
3786
3911
  sessionChainIds,
3787
3912
  recipient,
@@ -3795,8 +3920,8 @@ function DepositFlow({
3795
3920
  step.type === "select-asset" && /* @__PURE__ */ jsx14(
3796
3921
  AssetSelectStep,
3797
3922
  {
3798
- address,
3799
- publicClient,
3923
+ address: ownerAddress,
3924
+ publicClient: getReadClientForChain(ownerChainId),
3800
3925
  defaultSourceChain,
3801
3926
  defaultSourceToken,
3802
3927
  service,
@@ -3807,12 +3932,12 @@ function DepositFlow({
3807
3932
  step.type === "amount" && /* @__PURE__ */ jsx14(
3808
3933
  AmountStep,
3809
3934
  {
3810
- walletClient,
3811
- publicClient,
3812
- address,
3935
+ walletClient: signerContext.walletClient,
3936
+ publicClient: getReadClientForChain(step.asset.chainId),
3937
+ address: ownerAddress,
3813
3938
  asset: step.asset,
3814
3939
  defaultAmount: step.amount ?? defaultAmount,
3815
- switchChain,
3940
+ switchChain: signerContext.switchChain,
3816
3941
  targetChain,
3817
3942
  targetToken,
3818
3943
  uiConfig,
@@ -3822,15 +3947,15 @@ function DepositFlow({
3822
3947
  step.type === "confirm" && /* @__PURE__ */ jsx14(
3823
3948
  ConfirmStep,
3824
3949
  {
3825
- walletClient,
3826
- address,
3950
+ walletClient: signerContext.walletClient,
3951
+ address: ownerAddress,
3827
3952
  smartAccount: step.smartAccount,
3828
3953
  asset: step.asset,
3829
3954
  amount: step.amount,
3830
3955
  balance: step.balance,
3831
3956
  targetChain,
3832
3957
  targetToken,
3833
- switchChain,
3958
+ switchChain: signerContext.switchChain,
3834
3959
  onConfirm: handleDepositSubmitted,
3835
3960
  onDepositSubmitted: handleDepositSubmittedCallback,
3836
3961
  onError: handleError
@@ -3868,6 +3993,7 @@ var init_DepositFlow = __esm({
3868
3993
  init_ProcessingStep();
3869
3994
  init_DepositAddressStep();
3870
3995
  init_constants();
3996
+ init_public_client();
3871
3997
  }
3872
3998
  });
3873
3999
 
@@ -3918,15 +4044,11 @@ var init_theme = __esm({
3918
4044
  });
3919
4045
 
3920
4046
  // src/core/reown.tsx
3921
- import { useState as useState8, useCallback as useCallback5, useMemo as useMemo7 } from "react";
4047
+ import { useState as useState8 } from "react";
3922
4048
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3923
4049
  import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
3924
4050
  import { WagmiProvider } from "wagmi";
3925
- import {
3926
- createAppKit,
3927
- useAppKit,
3928
- useAppKitAccount
3929
- } from "@reown/appkit/react";
4051
+ import { createAppKit, useAppKit, useAppKitAccount } from "@reown/appkit/react";
3930
4052
  import {
3931
4053
  mainnet as mainnet2,
3932
4054
  base as base2,
@@ -3935,11 +4057,7 @@ import {
3935
4057
  polygon as polygon2,
3936
4058
  bsc as bsc2
3937
4059
  } from "@reown/appkit/networks";
3938
- import {
3939
- useWalletClient,
3940
- usePublicClient,
3941
- useSwitchChain
3942
- } from "wagmi";
4060
+ import { useWalletClient, usePublicClient, useSwitchChain } from "wagmi";
3943
4061
  import { jsx as jsx15 } from "react/jsx-runtime";
3944
4062
  function mapTheme(theme) {
3945
4063
  const themeMode = theme?.mode === "light" ? "light" : "dark";
@@ -4000,72 +4118,6 @@ function useReownWallet() {
4000
4118
  }
4001
4119
  };
4002
4120
  }
4003
- function useResolvedWallet(host, reown) {
4004
- const [selectedAddress, setSelectedAddress] = useState8(null);
4005
- const walletOptions = useMemo7(() => {
4006
- const options = [];
4007
- const seen = /* @__PURE__ */ new Set();
4008
- if (host.address) {
4009
- options.push({
4010
- address: host.address,
4011
- label: "Connected Wallet",
4012
- kind: "connected"
4013
- });
4014
- seen.add(host.address.toLowerCase());
4015
- }
4016
- if (reown.address && !seen.has(reown.address.toLowerCase())) {
4017
- options.push({
4018
- address: reown.address,
4019
- label: "External Wallet",
4020
- kind: "external"
4021
- });
4022
- }
4023
- return options;
4024
- }, [host.address, reown.address]);
4025
- const effectiveAddress = useMemo7(() => {
4026
- if (walletOptions.length === 0) return null;
4027
- if (walletOptions.length === 1) return walletOptions[0].address;
4028
- if (selectedAddress) {
4029
- const valid = walletOptions.some(
4030
- (opt) => opt.address.toLowerCase() === selectedAddress.toLowerCase()
4031
- );
4032
- if (valid) return selectedAddress;
4033
- }
4034
- return null;
4035
- }, [walletOptions, selectedAddress]);
4036
- let walletClient;
4037
- let publicClient;
4038
- if (effectiveAddress) {
4039
- const key = effectiveAddress.toLowerCase();
4040
- if (host.address?.toLowerCase() === key && host.walletClient && host.publicClient) {
4041
- walletClient = host.walletClient;
4042
- publicClient = host.publicClient;
4043
- } else if (reown.address?.toLowerCase() === key && reown.walletClient && reown.publicClient) {
4044
- walletClient = reown.walletClient;
4045
- publicClient = reown.publicClient;
4046
- }
4047
- }
4048
- const handleSwitchChain = useCallback5(
4049
- async (chainId) => {
4050
- if (host.switchChain && effectiveAddress?.toLowerCase() === host.address?.toLowerCase()) {
4051
- await host.switchChain(chainId);
4052
- } else {
4053
- await reown.switchChain(chainId);
4054
- }
4055
- },
4056
- [host.switchChain, host.address, reown.switchChain, effectiveAddress]
4057
- );
4058
- return {
4059
- walletClient,
4060
- publicClient,
4061
- address: effectiveAddress ?? void 0,
4062
- walletOptions,
4063
- selectedAddress: effectiveAddress,
4064
- onSelectAddress: setSelectedAddress,
4065
- openConnect: reown.openConnect,
4066
- switchChain: handleSwitchChain
4067
- };
4068
- }
4069
4121
  var NETWORKS, cachedAdapter, cachedProjectId;
4070
4122
  var init_reown = __esm({
4071
4123
  "src/core/reown.tsx"() {
@@ -4088,35 +4140,19 @@ var DepositModalReown_exports = {};
4088
4140
  __export(DepositModalReown_exports, {
4089
4141
  DepositModalReown: () => DepositModalReown
4090
4142
  });
4091
- import { useCallback as useCallback6 } from "react";
4143
+ import { useCallback as useCallback5 } from "react";
4092
4144
  import { jsx as jsx16 } from "react/jsx-runtime";
4093
4145
  function DepositModalWithReown(props) {
4094
4146
  const reown = useReownWallet();
4095
- const resolved = useResolvedWallet(
4096
- {
4097
- walletClient: props.walletClient,
4098
- publicClient: props.publicClient,
4099
- address: props.address,
4100
- switchChain: props.switchChain
4101
- },
4102
- reown
4103
- );
4104
- const handleConnect = useCallback6(() => {
4147
+ const handleConnect = useCallback5(() => {
4105
4148
  reown.openConnect();
4106
4149
  }, [reown.openConnect]);
4107
4150
  return /* @__PURE__ */ jsx16(
4108
4151
  DepositModalInner,
4109
4152
  {
4110
4153
  ...props,
4111
- walletClient: resolved.walletClient,
4112
- publicClient: resolved.publicClient,
4113
- address: resolved.address,
4114
- switchChain: resolved.switchChain,
4115
- connectWalletOptions: resolved.walletOptions,
4116
- selectedConnectAddress: resolved.selectedAddress,
4117
- onSelectConnectAddress: resolved.onSelectAddress,
4118
- onConnect: handleConnect,
4119
- onRequestConnect: props.onRequestConnect
4154
+ reownWallet: reown,
4155
+ onConnect: handleConnect
4120
4156
  }
4121
4157
  );
4122
4158
  }
@@ -4133,11 +4169,11 @@ var init_DepositModalReown = __esm({
4133
4169
 
4134
4170
  // src/DepositModal.tsx
4135
4171
  import {
4136
- useMemo as useMemo8,
4172
+ useMemo as useMemo7,
4137
4173
  useEffect as useEffect8,
4138
4174
  useRef as useRef7,
4139
4175
  useState as useState9,
4140
- useCallback as useCallback7,
4176
+ useCallback as useCallback6,
4141
4177
  lazy,
4142
4178
  Suspense
4143
4179
  } from "react";
@@ -4150,27 +4186,25 @@ function DepositModal(props) {
4150
4186
  return /* @__PURE__ */ jsx17(DepositModalInner, { ...props });
4151
4187
  }
4152
4188
  function DepositModalInner({
4153
- walletClient,
4154
- publicClient,
4155
- address,
4189
+ dappWalletClient,
4190
+ dappPublicClient,
4191
+ dappAddress,
4156
4192
  targetChain: targetChainProp,
4157
4193
  targetToken,
4158
4194
  isOpen,
4159
4195
  onClose,
4160
4196
  inline,
4161
- switchChain,
4162
4197
  sourceChain: sourceChainProp,
4163
4198
  sourceToken,
4164
4199
  defaultAmount,
4165
4200
  recipient,
4166
4201
  backendUrl = DEFAULT_BACKEND_URL,
4202
+ rhinestoneApiKey,
4167
4203
  signerAddress = DEFAULT_SIGNER_ADDRESS,
4168
4204
  sessionChainIds,
4169
4205
  forceRegister = false,
4170
4206
  waitForFinalTx = true,
4171
- connectWalletOptions,
4172
- selectedConnectAddress,
4173
- onSelectConnectAddress,
4207
+ reownWallet,
4174
4208
  onConnect,
4175
4209
  onRequestConnect,
4176
4210
  connectButtonLabel,
@@ -4191,7 +4225,7 @@ function DepositModalInner({
4191
4225
  const backHandlerRef = useRef7(void 0);
4192
4226
  const targetChain = getChainId(targetChainProp);
4193
4227
  const sourceChain = sourceChainProp ? getChainId(sourceChainProp) : void 0;
4194
- const service = useMemo8(() => createDepositService(backendUrl), [backendUrl]);
4228
+ const service = useMemo7(() => createDepositService(backendUrl), [backendUrl]);
4195
4229
  useEffect8(() => {
4196
4230
  if (isOpen && modalRef.current) {
4197
4231
  applyTheme(modalRef.current, theme);
@@ -4209,17 +4243,17 @@ function DepositModalInner({
4209
4243
  setCurrentStepIndex(0);
4210
4244
  }
4211
4245
  }, [isOpen]);
4212
- const handleStepChange = useCallback7(
4246
+ const handleStepChange = useCallback6(
4213
4247
  (stepIndex, onBack) => {
4214
4248
  setCurrentStepIndex(stepIndex);
4215
4249
  backHandlerRef.current = onBack;
4216
4250
  },
4217
4251
  []
4218
4252
  );
4219
- const handleTotalBalanceChange = useCallback7((balance) => {
4253
+ const handleTotalBalanceChange = useCallback6((balance) => {
4220
4254
  setTotalBalanceUsd(balance);
4221
4255
  }, []);
4222
- const handleBack = useCallback7(() => {
4256
+ const handleBack = useCallback6(() => {
4223
4257
  backHandlerRef.current?.();
4224
4258
  }, []);
4225
4259
  const showLogo = uiConfig?.showLogo ?? false;
@@ -4324,24 +4358,22 @@ function DepositModalInner({
4324
4358
  /* @__PURE__ */ jsx17(
4325
4359
  DepositFlow,
4326
4360
  {
4327
- walletClient,
4328
- publicClient,
4329
- address,
4361
+ dappWalletClient,
4362
+ dappPublicClient,
4363
+ dappAddress,
4330
4364
  targetChain,
4331
4365
  targetToken,
4332
4366
  service,
4333
- switchChain,
4334
4367
  sourceChain,
4335
4368
  sourceToken,
4336
4369
  amount: defaultAmount,
4337
4370
  recipient,
4371
+ rhinestoneApiKey,
4338
4372
  signerAddress,
4339
4373
  sessionChainIds,
4340
4374
  forceRegister,
4341
4375
  waitForFinalTx,
4342
- connectWalletOptions,
4343
- selectedConnectAddress,
4344
- onSelectConnectAddress,
4376
+ reownWallet,
4345
4377
  onConnect,
4346
4378
  onRequestConnect,
4347
4379
  connectButtonLabel,
@@ -4378,7 +4410,7 @@ var init_DepositModal = __esm({
4378
4410
  });
4379
4411
 
4380
4412
  // src/components/steps/WithdrawFormStep.tsx
4381
- import { useCallback as useCallback8, useEffect as useEffect9, useMemo as useMemo9, useRef as useRef8, useState as useState10 } from "react";
4413
+ import { useCallback as useCallback7, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef8, useState as useState10 } from "react";
4382
4414
  import { erc20Abi as erc20Abi3, formatUnits as formatUnits5, parseUnits as parseUnits3 } from "viem";
4383
4415
  import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
4384
4416
  function useClickOutside(ref, onClose) {
@@ -4486,7 +4518,7 @@ function WithdrawFormStep({
4486
4518
  unwatch();
4487
4519
  };
4488
4520
  }, [safeAddress, publicClient, publicClientChainId, asset]);
4489
- const formattedBalance = useMemo9(() => {
4521
+ const formattedBalance = useMemo8(() => {
4490
4522
  if (balance === null) return "...";
4491
4523
  try {
4492
4524
  const raw = formatUnits5(balance, asset.decimals);
@@ -4512,7 +4544,7 @@ function WithdrawFormStep({
4512
4544
  return;
4513
4545
  }
4514
4546
  }, [balance, asset.decimals, asset.symbol, onBalanceUsdChange]);
4515
- const amountUsd = useMemo9(() => {
4547
+ const amountUsd = useMemo8(() => {
4516
4548
  if (!amount) return null;
4517
4549
  const parsed = Number(amount);
4518
4550
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
@@ -4522,18 +4554,18 @@ function WithdrawFormStep({
4522
4554
  }
4523
4555
  return null;
4524
4556
  }, [amount, asset.symbol]);
4525
- const handleMaxClick = useCallback8(() => {
4557
+ const handleMaxClick = useCallback7(() => {
4526
4558
  if (balance === null) return;
4527
4559
  const maxAmount = formatUnits5(balance, asset.decimals);
4528
4560
  setAmount(maxAmount);
4529
4561
  setError(null);
4530
4562
  }, [balance, asset.decimals]);
4531
- const handleUseConnected = useCallback8(() => {
4563
+ const handleUseConnected = useCallback7(() => {
4532
4564
  if (!address) return;
4533
4565
  setRecipient(address);
4534
4566
  setError(null);
4535
4567
  }, [address]);
4536
- const handleWithdraw = useCallback8(async () => {
4568
+ const handleWithdraw = useCallback7(async () => {
4537
4569
  if (!recipient || !/^0x[a-fA-F0-9]{40}$/.test(recipient)) {
4538
4570
  setError("Enter a valid recipient address");
4539
4571
  return;
@@ -5130,15 +5162,14 @@ var init_safe = __esm({
5130
5162
  });
5131
5163
 
5132
5164
  // src/WithdrawFlow.tsx
5133
- import { useCallback as useCallback9, useEffect as useEffect10, useMemo as useMemo10, useState as useState11 } from "react";
5134
- import { createPublicClient, http } from "viem";
5165
+ import { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo9, useState as useState11 } from "react";
5135
5166
  import { walletClientToAccount as walletClientToAccount2 } from "@rhinestone/sdk";
5136
5167
  import { parseUnits as parseUnits4 } from "viem";
5137
5168
  import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
5138
5169
  function WithdrawFlow({
5139
- walletClient,
5140
- publicClient,
5141
- address,
5170
+ dappWalletClient,
5171
+ dappPublicClient,
5172
+ dappAddress,
5142
5173
  safeAddress,
5143
5174
  sourceChain,
5144
5175
  sourceToken,
@@ -5147,14 +5178,12 @@ function WithdrawFlow({
5147
5178
  recipient: defaultRecipient,
5148
5179
  amount: defaultAmount,
5149
5180
  service,
5150
- switchChain,
5181
+ rhinestoneApiKey,
5151
5182
  signerAddress = DEFAULT_SIGNER_ADDRESS,
5152
5183
  sessionChainIds,
5153
5184
  forceRegister = false,
5154
5185
  waitForFinalTx = true,
5155
- connectWalletOptions,
5156
- selectedConnectAddress,
5157
- onSelectConnectAddress,
5186
+ reownWallet,
5158
5187
  onConnect,
5159
5188
  onWithdrawSign,
5160
5189
  onRequestConnect,
@@ -5178,14 +5207,89 @@ function WithdrawFlow({
5178
5207
  setTargetChain(targetChainProp);
5179
5208
  setTargetToken(targetTokenProp);
5180
5209
  }, [targetChainProp, targetTokenProp]);
5181
- const targetChainObj = useMemo10(() => CHAIN_BY_ID[targetChain], [targetChain]);
5182
- const hasCustomSigner = Boolean(address && onWithdrawSign);
5183
- const sourceChainObj = useMemo10(() => CHAIN_BY_ID[sourceChain], [sourceChain]);
5184
- const effectivePublicClient = useMemo10(
5185
- () => publicClient ?? (sourceChainObj ? createPublicClient({ chain: sourceChainObj, transport: http() }) : null),
5186
- [publicClient, sourceChainObj]
5187
- );
5188
- const asset = useMemo10(() => {
5210
+ const targetChainObj = useMemo9(() => CHAIN_BY_ID[targetChain], [targetChain]);
5211
+ const hasCustomSigner = Boolean(dappAddress && onWithdrawSign);
5212
+ const dappSwitchChain = useMemo9(() => {
5213
+ if (!dappWalletClient?.switchChain) return void 0;
5214
+ return async (chainId) => {
5215
+ await dappWalletClient.switchChain?.({ id: chainId });
5216
+ };
5217
+ }, [dappWalletClient]);
5218
+ const walletOptions = useMemo9(() => {
5219
+ const options = [];
5220
+ const seen = /* @__PURE__ */ new Set();
5221
+ if (dappWalletClient?.account && dappAddress) {
5222
+ options.push({
5223
+ address: dappWalletClient.account.address,
5224
+ label: "Connected Wallet",
5225
+ kind: "connected"
5226
+ });
5227
+ seen.add(dappWalletClient.account.address.toLowerCase());
5228
+ }
5229
+ if (reownWallet?.address && reownWallet.isConnected && !seen.has(reownWallet.address.toLowerCase())) {
5230
+ options.push({
5231
+ address: reownWallet.address,
5232
+ label: "External Wallet",
5233
+ kind: "external"
5234
+ });
5235
+ }
5236
+ return options;
5237
+ }, [
5238
+ dappWalletClient,
5239
+ dappAddress,
5240
+ reownWallet?.address,
5241
+ reownWallet?.isConnected
5242
+ ]);
5243
+ const canAutoLock = (dappWalletClient?.account && dappAddress || hasCustomSigner) && !reownWallet;
5244
+ const [selectedConnectAddress, setSelectedConnectAddress] = useState11(null);
5245
+ const signerContext = useMemo9(() => {
5246
+ if (canAutoLock) {
5247
+ if (hasCustomSigner) {
5248
+ return {
5249
+ ownerAddress: dappAddress,
5250
+ walletClient: dappWalletClient ?? void 0,
5251
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain),
5252
+ switchChain: dappSwitchChain
5253
+ };
5254
+ }
5255
+ return {
5256
+ ownerAddress: dappWalletClient.account.address,
5257
+ walletClient: dappWalletClient,
5258
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain),
5259
+ switchChain: dappSwitchChain
5260
+ };
5261
+ }
5262
+ if (!isConnectSelectionConfirmed || !selectedConnectAddress) return null;
5263
+ if (dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedConnectAddress.toLowerCase()) {
5264
+ return {
5265
+ ownerAddress: dappWalletClient.account.address,
5266
+ walletClient: dappWalletClient,
5267
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain),
5268
+ switchChain: dappSwitchChain
5269
+ };
5270
+ }
5271
+ if (reownWallet?.address?.toLowerCase() === selectedConnectAddress.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
5272
+ return {
5273
+ ownerAddress: reownWallet.address,
5274
+ walletClient: reownWallet.walletClient,
5275
+ publicClient: reownWallet.publicClient,
5276
+ switchChain: reownWallet.switchChain
5277
+ };
5278
+ }
5279
+ return null;
5280
+ }, [
5281
+ canAutoLock,
5282
+ hasCustomSigner,
5283
+ isConnectSelectionConfirmed,
5284
+ selectedConnectAddress,
5285
+ dappWalletClient,
5286
+ dappPublicClient,
5287
+ dappSwitchChain,
5288
+ dappAddress,
5289
+ reownWallet,
5290
+ sourceChain
5291
+ ]);
5292
+ const asset = useMemo9(() => {
5189
5293
  const symbol = getTokenSymbol(sourceToken, sourceChain);
5190
5294
  const decimals = getTokenDecimalsByAddress(sourceToken, sourceChain);
5191
5295
  return {
@@ -5206,19 +5310,19 @@ function WithdrawFlow({
5206
5310
  useEffect10(() => {
5207
5311
  onTotalBalanceChange?.(totalBalanceUsd);
5208
5312
  }, [totalBalanceUsd, onTotalBalanceChange]);
5209
- const handleConnected = useCallback9(
5313
+ const handleConnected = useCallback8(
5210
5314
  (addr, smartAccount) => {
5211
5315
  onConnected?.({ address: addr, smartAccount });
5212
5316
  },
5213
5317
  [onConnected]
5214
5318
  );
5215
- const handleError = useCallback9(
5319
+ const handleError = useCallback8(
5216
5320
  (message, code) => {
5217
5321
  onError?.({ message, code });
5218
5322
  },
5219
5323
  [onError]
5220
5324
  );
5221
- const resolveSessionOwner2 = useCallback9(async (eoaAddress) => {
5325
+ const resolveSessionOwner2 = useCallback8(async (eoaAddress) => {
5222
5326
  const localOwner = loadSessionOwnerFromStorage(eoaAddress);
5223
5327
  if (localOwner) {
5224
5328
  return {
@@ -5233,12 +5337,13 @@ function WithdrawFlow({
5233
5337
  address: created.address
5234
5338
  };
5235
5339
  }, []);
5236
- const handleFormSubmit = useCallback9(
5340
+ const handleFormSubmit = useCallback8(
5237
5341
  async (recipient, amountValue) => {
5238
- if (!address) {
5342
+ const ownerAddress2 = signerContext?.ownerAddress;
5343
+ if (!ownerAddress2) {
5239
5344
  throw new Error("Wallet not connected");
5240
5345
  }
5241
- if (!onWithdrawSign && (!walletClient || !publicClient)) {
5346
+ if (!onWithdrawSign && !signerContext?.walletClient) {
5242
5347
  throw new Error("Wallet not connected");
5243
5348
  }
5244
5349
  if (!targetChainObj) {
@@ -5246,11 +5351,12 @@ function WithdrawFlow({
5246
5351
  }
5247
5352
  setIsSubmitting(true);
5248
5353
  try {
5249
- const signerAccount = walletClient ? walletClientToAccount2(walletClient) : createViewOnlyAccount(address);
5250
- const sessionOwner = await resolveSessionOwner2(address);
5354
+ const signerAccount = signerContext?.walletClient ? walletClientToAccount2(signerContext.walletClient) : createViewOnlyAccount(ownerAddress2);
5355
+ const sessionOwner = await resolveSessionOwner2(ownerAddress2);
5251
5356
  const account = await createSmartAccount(
5252
5357
  signerAccount,
5253
- sessionOwner.account
5358
+ sessionOwner.account,
5359
+ rhinestoneApiKey
5254
5360
  );
5255
5361
  const smartAccount = getAccountAddress(account);
5256
5362
  const checkResult = await service.checkAccount(smartAccount);
@@ -5272,7 +5378,7 @@ function WithdrawFlow({
5272
5378
  factoryData: initData.factoryData,
5273
5379
  sessionDetails
5274
5380
  },
5275
- eoaAddress: address,
5381
+ eoaAddress: ownerAddress2,
5276
5382
  sessionOwner: sessionOwner.address,
5277
5383
  target: {
5278
5384
  chain: targetChain,
@@ -5281,8 +5387,9 @@ function WithdrawFlow({
5281
5387
  }
5282
5388
  });
5283
5389
  }
5284
- handleConnected(address, smartAccount);
5390
+ handleConnected(ownerAddress2, smartAccount);
5285
5391
  const amountUnits = parseUnits4(amountValue, asset.decimals);
5392
+ const pc = signerContext?.publicClient ?? getPublicClient(sourceChain);
5286
5393
  const result = onWithdrawSign ? await onWithdrawSign({
5287
5394
  safeAddress,
5288
5395
  recipient: smartAccount,
@@ -5291,15 +5398,15 @@ function WithdrawFlow({
5291
5398
  chainId: sourceChain,
5292
5399
  isNative: isSourceNative
5293
5400
  }) : isSourceNative ? await executeSafeEthTransfer({
5294
- walletClient,
5295
- publicClient,
5401
+ walletClient: signerContext.walletClient,
5402
+ publicClient: pc,
5296
5403
  safeAddress,
5297
5404
  recipient: smartAccount,
5298
5405
  amount: amountUnits,
5299
5406
  chainId: sourceChain
5300
5407
  }) : await executeSafeErc20Transfer({
5301
- walletClient,
5302
- publicClient,
5408
+ walletClient: signerContext.walletClient,
5409
+ publicClient: pc,
5303
5410
  safeAddress,
5304
5411
  tokenAddress: sourceToken,
5305
5412
  recipient: smartAccount,
@@ -5329,9 +5436,7 @@ function WithdrawFlow({
5329
5436
  }
5330
5437
  },
5331
5438
  [
5332
- walletClient,
5333
- publicClient,
5334
- address,
5439
+ signerContext,
5335
5440
  targetChainObj,
5336
5441
  resolveSessionOwner2,
5337
5442
  signerAddress,
@@ -5340,6 +5445,7 @@ function WithdrawFlow({
5340
5445
  targetChain,
5341
5446
  targetToken,
5342
5447
  service,
5448
+ rhinestoneApiKey,
5343
5449
  handleConnected,
5344
5450
  asset.decimals,
5345
5451
  safeAddress,
@@ -5351,24 +5457,24 @@ function WithdrawFlow({
5351
5457
  handleError
5352
5458
  ]
5353
5459
  );
5354
- const handleWithdrawComplete = useCallback9(
5460
+ const handleWithdrawComplete = useCallback8(
5355
5461
  (txHash, destinationTxHash) => {
5356
5462
  onWithdrawComplete?.({ txHash, destinationTxHash });
5357
5463
  },
5358
5464
  [onWithdrawComplete]
5359
5465
  );
5360
- const handleWithdrawFailed = useCallback9(
5466
+ const handleWithdrawFailed = useCallback8(
5361
5467
  (txHash, error) => {
5362
5468
  onWithdrawFailed?.({ txHash, error });
5363
5469
  },
5364
5470
  [onWithdrawFailed]
5365
5471
  );
5366
- const targetChainOptions = useMemo10(() => {
5472
+ const targetChainOptions = useMemo9(() => {
5367
5473
  return SOURCE_CHAINS.filter(
5368
5474
  (chain) => getSupportedTargetTokens(chain.id).length > 0
5369
5475
  );
5370
5476
  }, []);
5371
- const targetTokenOptions = useMemo10(
5477
+ const targetTokenOptions = useMemo9(
5372
5478
  () => getSupportedTargetTokens(targetChain),
5373
5479
  [targetChain]
5374
5480
  );
@@ -5381,7 +5487,7 @@ function WithdrawFlow({
5381
5487
  setTargetToken(targetTokenOptions[0].address);
5382
5488
  }
5383
5489
  }, [targetToken, targetTokenOptions]);
5384
- const handleTargetChainChange = useCallback9(
5490
+ const handleTargetChainChange = useCallback8(
5385
5491
  (chainId) => {
5386
5492
  setTargetChain(chainId);
5387
5493
  const options = getSupportedTargetTokens(chainId);
@@ -5397,55 +5503,57 @@ function WithdrawFlow({
5397
5503
  },
5398
5504
  [targetToken]
5399
5505
  );
5400
- const handleTargetTokenChange = useCallback9((token) => {
5506
+ const handleTargetTokenChange = useCallback8((token) => {
5401
5507
  setTargetToken(token);
5402
5508
  }, []);
5403
- const hasConnectWalletOptions = (connectWalletOptions?.length ?? 0) > 0;
5404
- const selectedConnectAddressEffective = useMemo10(() => {
5509
+ const selectedConnectAddressEffective = useMemo9(() => {
5405
5510
  if (selectedConnectAddress) return selectedConnectAddress;
5406
- if ((connectWalletOptions?.length ?? 0) === 1) {
5407
- return connectWalletOptions?.[0]?.address ?? null;
5511
+ if (walletOptions.length === 1) {
5512
+ return walletOptions[0].address;
5408
5513
  }
5409
5514
  return null;
5410
- }, [selectedConnectAddress, connectWalletOptions]);
5411
- const connectWalletOptionsKey = useMemo10(
5412
- () => (connectWalletOptions ?? []).map((option) => option.address.toLowerCase()).join(","),
5413
- [connectWalletOptions]
5414
- );
5415
- const hasConnectedWallet = Boolean(
5416
- walletClient && publicClient && address || hasCustomSigner
5515
+ }, [selectedConnectAddress, walletOptions]);
5516
+ const walletOptionsKey = useMemo9(
5517
+ () => walletOptions.map((option) => option.address.toLowerCase()).join(","),
5518
+ [walletOptions]
5417
5519
  );
5418
- const showConnectStep = !hasConnectedWallet || !hasCustomSigner && hasConnectWalletOptions && !isConnectSelectionConfirmed;
5520
+ const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
5419
5521
  useEffect10(() => {
5420
5522
  setIsConnectSelectionConfirmed(false);
5421
- }, [connectWalletOptionsKey, selectedConnectAddressEffective]);
5523
+ }, [walletOptionsKey, selectedConnectAddressEffective]);
5422
5524
  if (showConnectStep) {
5423
5525
  return /* @__PURE__ */ jsx19("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx19(
5424
5526
  ConnectStep,
5425
5527
  {
5426
- walletOptions: connectWalletOptions,
5528
+ walletOptions,
5427
5529
  selectedAddress: selectedConnectAddressEffective,
5428
- onSelectAddress: onSelectConnectAddress,
5530
+ onSelectAddress: setSelectedConnectAddress,
5429
5531
  onRequestConnect,
5430
5532
  onConnect,
5431
- onContinue: () => setIsConnectSelectionConfirmed(true),
5533
+ onContinue: () => {
5534
+ if (selectedConnectAddressEffective) {
5535
+ setSelectedConnectAddress(selectedConnectAddressEffective);
5536
+ }
5537
+ setIsConnectSelectionConfirmed(true);
5538
+ },
5432
5539
  connectButtonLabel
5433
5540
  }
5434
5541
  ) });
5435
5542
  }
5436
- if (!address || !effectivePublicClient) {
5437
- return null;
5438
- }
5543
+ if (!signerContext) return null;
5544
+ if (!onWithdrawSign && !signerContext.walletClient) return null;
5545
+ const ownerAddress = signerContext.ownerAddress;
5546
+ const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
5439
5547
  return /* @__PURE__ */ jsxs16("div", { className: "rs-modal-body", children: [
5440
5548
  step.type === "form" && /* @__PURE__ */ jsx19(
5441
5549
  WithdrawFormStep,
5442
5550
  {
5443
- walletClient,
5444
- publicClient: effectivePublicClient,
5445
- address,
5551
+ walletClient: signerContext.walletClient,
5552
+ publicClient: formPublicClient,
5553
+ address: ownerAddress,
5446
5554
  safeAddress,
5447
5555
  asset,
5448
- defaultRecipient: defaultRecipient ?? address,
5556
+ defaultRecipient: defaultRecipient ?? ownerAddress,
5449
5557
  defaultAmount,
5450
5558
  targetChain,
5451
5559
  targetToken,
@@ -5453,7 +5561,7 @@ function WithdrawFlow({
5453
5561
  targetTokenOptions,
5454
5562
  onTargetChainChange: handleTargetChainChange,
5455
5563
  onTargetTokenChange: handleTargetTokenChange,
5456
- switchChain,
5564
+ switchChain: signerContext.switchChain,
5457
5565
  submitting: isSubmitting,
5458
5566
  onSubmit: handleFormSubmit,
5459
5567
  onBalanceUsdChange: setTotalBalanceUsd
@@ -5485,6 +5593,7 @@ var init_WithdrawFlow = __esm({
5485
5593
  "src/WithdrawFlow.tsx"() {
5486
5594
  "use strict";
5487
5595
  init_ConnectStep();
5596
+ init_public_client();
5488
5597
  init_WithdrawFormStep();
5489
5598
  init_ProcessingStep();
5490
5599
  init_constants();
@@ -5500,35 +5609,19 @@ var WithdrawModalReown_exports = {};
5500
5609
  __export(WithdrawModalReown_exports, {
5501
5610
  WithdrawModalReown: () => WithdrawModalReown
5502
5611
  });
5503
- import { useCallback as useCallback10 } from "react";
5612
+ import { useCallback as useCallback9 } from "react";
5504
5613
  import { jsx as jsx20 } from "react/jsx-runtime";
5505
5614
  function WithdrawModalWithReown(props) {
5506
5615
  const reown = useReownWallet();
5507
- const resolved = useResolvedWallet(
5508
- {
5509
- walletClient: props.walletClient,
5510
- publicClient: props.publicClient,
5511
- address: props.address,
5512
- switchChain: props.switchChain
5513
- },
5514
- reown
5515
- );
5516
- const handleConnect = useCallback10(() => {
5616
+ const handleConnect = useCallback9(() => {
5517
5617
  reown.openConnect();
5518
5618
  }, [reown.openConnect]);
5519
5619
  return /* @__PURE__ */ jsx20(
5520
5620
  WithdrawModalInner,
5521
5621
  {
5522
5622
  ...props,
5523
- walletClient: resolved.walletClient,
5524
- publicClient: resolved.publicClient,
5525
- address: resolved.address,
5526
- switchChain: resolved.switchChain,
5527
- connectWalletOptions: resolved.walletOptions,
5528
- selectedConnectAddress: resolved.selectedAddress,
5529
- onSelectConnectAddress: resolved.onSelectAddress,
5530
- onConnect: handleConnect,
5531
- onRequestConnect: props.onRequestConnect
5623
+ reownWallet: reown,
5624
+ onConnect: handleConnect
5532
5625
  }
5533
5626
  );
5534
5627
  }
@@ -5545,9 +5638,9 @@ var init_WithdrawModalReown = __esm({
5545
5638
 
5546
5639
  // src/WithdrawModal.tsx
5547
5640
  import {
5548
- useCallback as useCallback11,
5641
+ useCallback as useCallback10,
5549
5642
  useEffect as useEffect11,
5550
- useMemo as useMemo11,
5643
+ useMemo as useMemo10,
5551
5644
  useRef as useRef9,
5552
5645
  useState as useState12,
5553
5646
  lazy as lazy2,
@@ -5562,9 +5655,9 @@ function WithdrawModal(props) {
5562
5655
  return /* @__PURE__ */ jsx21(WithdrawModalInner, { ...props });
5563
5656
  }
5564
5657
  function WithdrawModalInner({
5565
- walletClient,
5566
- publicClient,
5567
- address,
5658
+ dappWalletClient,
5659
+ dappPublicClient,
5660
+ dappAddress,
5568
5661
  safeAddress,
5569
5662
  sourceChain: sourceChainProp,
5570
5663
  sourceToken,
@@ -5575,15 +5668,13 @@ function WithdrawModalInner({
5575
5668
  isOpen,
5576
5669
  onClose,
5577
5670
  inline,
5578
- switchChain,
5579
5671
  backendUrl = DEFAULT_BACKEND_URL,
5672
+ rhinestoneApiKey,
5580
5673
  signerAddress = DEFAULT_SIGNER_ADDRESS,
5581
5674
  sessionChainIds,
5582
5675
  forceRegister = false,
5583
5676
  waitForFinalTx = true,
5584
- connectWalletOptions,
5585
- selectedConnectAddress,
5586
- onSelectConnectAddress,
5677
+ reownWallet,
5587
5678
  onConnect,
5588
5679
  onWithdrawSign,
5589
5680
  onRequestConnect,
@@ -5605,7 +5696,7 @@ function WithdrawModalInner({
5605
5696
  const backHandlerRef = useRef9(void 0);
5606
5697
  const targetChain = getChainId(targetChainProp);
5607
5698
  const sourceChain = getChainId(sourceChainProp);
5608
- const service = useMemo11(() => createDepositService(backendUrl), [backendUrl]);
5699
+ const service = useMemo10(() => createDepositService(backendUrl), [backendUrl]);
5609
5700
  useEffect11(() => {
5610
5701
  if (isOpen && modalRef.current) {
5611
5702
  applyTheme(modalRef.current, theme);
@@ -5623,17 +5714,17 @@ function WithdrawModalInner({
5623
5714
  setCurrentStepIndex(0);
5624
5715
  }
5625
5716
  }, [isOpen]);
5626
- const handleStepChange = useCallback11(
5717
+ const handleStepChange = useCallback10(
5627
5718
  (stepIndex, onBack) => {
5628
5719
  setCurrentStepIndex(stepIndex);
5629
5720
  backHandlerRef.current = onBack;
5630
5721
  },
5631
5722
  []
5632
5723
  );
5633
- const handleTotalBalanceChange = useCallback11((balance) => {
5724
+ const handleTotalBalanceChange = useCallback10((balance) => {
5634
5725
  setTotalBalanceUsd(balance);
5635
5726
  }, []);
5636
- const handleBack = useCallback11(() => {
5727
+ const handleBack = useCallback10(() => {
5637
5728
  backHandlerRef.current?.();
5638
5729
  }, []);
5639
5730
  const showLogo = uiConfig?.showLogo ?? false;
@@ -5735,9 +5826,9 @@ function WithdrawModalInner({
5735
5826
  /* @__PURE__ */ jsx21(
5736
5827
  WithdrawFlow,
5737
5828
  {
5738
- walletClient,
5739
- publicClient,
5740
- address,
5829
+ dappWalletClient,
5830
+ dappPublicClient,
5831
+ dappAddress,
5741
5832
  safeAddress,
5742
5833
  sourceChain,
5743
5834
  sourceToken,
@@ -5746,14 +5837,12 @@ function WithdrawModalInner({
5746
5837
  recipient,
5747
5838
  amount: defaultAmount,
5748
5839
  service,
5749
- switchChain,
5840
+ rhinestoneApiKey,
5750
5841
  signerAddress,
5751
5842
  sessionChainIds,
5752
5843
  forceRegister,
5753
5844
  waitForFinalTx,
5754
- connectWalletOptions,
5755
- selectedConnectAddress,
5756
- onSelectConnectAddress,
5845
+ reownWallet,
5757
5846
  onConnect,
5758
5847
  onWithdrawSign,
5759
5848
  onRequestConnect,