@rhinestone/deposit-modal 0.1.14 → 0.1.15
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/README.md +45 -21
- package/dist/index.cjs +327 -248
- package/dist/index.d.cts +6 -12
- package/dist/index.d.ts +6 -12
- package/dist/index.mjs +340 -269
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3496,15 +3496,37 @@ var init_DepositAddressStep = __esm({
|
|
|
3496
3496
|
}
|
|
3497
3497
|
});
|
|
3498
3498
|
|
|
3499
|
+
// src/core/public-client.ts
|
|
3500
|
+
function getPublicClient(chainId) {
|
|
3501
|
+
let client = clientCache.get(chainId);
|
|
3502
|
+
if (!client) {
|
|
3503
|
+
const chain = CHAIN_BY_ID[chainId];
|
|
3504
|
+
client = (0, import_viem7.createPublicClient)({
|
|
3505
|
+
chain,
|
|
3506
|
+
transport: (0, import_viem7.http)()
|
|
3507
|
+
});
|
|
3508
|
+
clientCache.set(chainId, client);
|
|
3509
|
+
}
|
|
3510
|
+
return client;
|
|
3511
|
+
}
|
|
3512
|
+
var import_viem7, clientCache;
|
|
3513
|
+
var init_public_client = __esm({
|
|
3514
|
+
"src/core/public-client.ts"() {
|
|
3515
|
+
"use strict";
|
|
3516
|
+
import_viem7 = require("viem");
|
|
3517
|
+
init_constants();
|
|
3518
|
+
clientCache = /* @__PURE__ */ new Map();
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
3521
|
+
|
|
3499
3522
|
// src/DepositFlow.tsx
|
|
3500
3523
|
function DepositFlow({
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3524
|
+
dappWalletClient,
|
|
3525
|
+
dappPublicClient,
|
|
3526
|
+
dappAddress,
|
|
3504
3527
|
targetChain,
|
|
3505
3528
|
targetToken,
|
|
3506
3529
|
service,
|
|
3507
|
-
switchChain,
|
|
3508
3530
|
sourceChain: defaultSourceChain,
|
|
3509
3531
|
sourceToken: defaultSourceToken,
|
|
3510
3532
|
amount: defaultAmount,
|
|
@@ -3513,9 +3535,7 @@ function DepositFlow({
|
|
|
3513
3535
|
sessionChainIds,
|
|
3514
3536
|
forceRegister = false,
|
|
3515
3537
|
waitForFinalTx = true,
|
|
3516
|
-
|
|
3517
|
-
selectedConnectAddress,
|
|
3518
|
-
onSelectConnectAddress,
|
|
3538
|
+
reownWallet,
|
|
3519
3539
|
onConnect,
|
|
3520
3540
|
onRequestConnect,
|
|
3521
3541
|
connectButtonLabel,
|
|
@@ -3533,9 +3553,93 @@ function DepositFlow({
|
|
|
3533
3553
|
const [flowMode, setFlowMode] = (0, import_react9.useState)(null);
|
|
3534
3554
|
const [totalBalanceUsd, setTotalBalanceUsd] = (0, import_react9.useState)(0);
|
|
3535
3555
|
const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = (0, import_react9.useState)(false);
|
|
3536
|
-
const
|
|
3537
|
-
const hasConnectedWallet = Boolean(walletClient && publicClient && address);
|
|
3556
|
+
const [selectedConnectAddress, setSelectedConnectAddress] = (0, import_react9.useState)(null);
|
|
3538
3557
|
const targetChainObj = (0, import_react9.useMemo)(() => CHAIN_BY_ID[targetChain], [targetChain]);
|
|
3558
|
+
const dappSwitchChain = (0, import_react9.useMemo)(() => {
|
|
3559
|
+
if (!dappWalletClient?.switchChain) return void 0;
|
|
3560
|
+
return async (chainId) => {
|
|
3561
|
+
await dappWalletClient.switchChain?.({ id: chainId });
|
|
3562
|
+
};
|
|
3563
|
+
}, [dappWalletClient]);
|
|
3564
|
+
const walletOptions = (0, import_react9.useMemo)(() => {
|
|
3565
|
+
const options = [];
|
|
3566
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3567
|
+
if (dappWalletClient?.account && dappAddress) {
|
|
3568
|
+
options.push({
|
|
3569
|
+
address: dappWalletClient.account.address,
|
|
3570
|
+
label: "Connected Wallet",
|
|
3571
|
+
kind: "connected"
|
|
3572
|
+
});
|
|
3573
|
+
seen.add(dappWalletClient.account.address.toLowerCase());
|
|
3574
|
+
}
|
|
3575
|
+
if (reownWallet?.address && reownWallet.isConnected && !seen.has(reownWallet.address.toLowerCase())) {
|
|
3576
|
+
options.push({
|
|
3577
|
+
address: reownWallet.address,
|
|
3578
|
+
label: "External Wallet",
|
|
3579
|
+
kind: "external"
|
|
3580
|
+
});
|
|
3581
|
+
}
|
|
3582
|
+
return options;
|
|
3583
|
+
}, [
|
|
3584
|
+
dappWalletClient,
|
|
3585
|
+
dappAddress,
|
|
3586
|
+
reownWallet?.address,
|
|
3587
|
+
reownWallet?.isConnected
|
|
3588
|
+
]);
|
|
3589
|
+
const canAutoLock = dappWalletClient?.account && dappAddress && !reownWallet;
|
|
3590
|
+
const hasWalletOptions = walletOptions.length > 0;
|
|
3591
|
+
const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
|
|
3592
|
+
const signerContext = (0, import_react9.useMemo)(() => {
|
|
3593
|
+
if (flowMode === "deposit-address") {
|
|
3594
|
+
if (!dappAddress) return null;
|
|
3595
|
+
return {
|
|
3596
|
+
ownerAddress: dappAddress,
|
|
3597
|
+
walletClient: void 0,
|
|
3598
|
+
publicClient: dappPublicClient ?? getPublicClient(targetChain),
|
|
3599
|
+
switchChain: void 0
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
if (canAutoLock) {
|
|
3603
|
+
const fallbackChainId = dappWalletClient?.chain?.id ?? targetChain;
|
|
3604
|
+
return {
|
|
3605
|
+
ownerAddress: dappWalletClient.account.address,
|
|
3606
|
+
walletClient: dappWalletClient,
|
|
3607
|
+
publicClient: dappPublicClient ?? getPublicClient(fallbackChainId),
|
|
3608
|
+
switchChain: dappSwitchChain
|
|
3609
|
+
};
|
|
3610
|
+
}
|
|
3611
|
+
if (!isConnectSelectionConfirmed || !selectedConnectAddress) return null;
|
|
3612
|
+
if (dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedConnectAddress.toLowerCase()) {
|
|
3613
|
+
const fallbackChainId = dappWalletClient?.chain?.id ?? targetChain;
|
|
3614
|
+
return {
|
|
3615
|
+
ownerAddress: dappWalletClient.account.address,
|
|
3616
|
+
walletClient: dappWalletClient,
|
|
3617
|
+
publicClient: dappPublicClient ?? getPublicClient(fallbackChainId),
|
|
3618
|
+
switchChain: dappSwitchChain
|
|
3619
|
+
};
|
|
3620
|
+
}
|
|
3621
|
+
if (reownWallet?.address?.toLowerCase() === selectedConnectAddress.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
|
|
3622
|
+
return {
|
|
3623
|
+
ownerAddress: reownWallet.address,
|
|
3624
|
+
walletClient: reownWallet.walletClient,
|
|
3625
|
+
publicClient: reownWallet.publicClient,
|
|
3626
|
+
switchChain: reownWallet.switchChain
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
return null;
|
|
3630
|
+
}, [
|
|
3631
|
+
flowMode,
|
|
3632
|
+
canAutoLock,
|
|
3633
|
+
isConnectSelectionConfirmed,
|
|
3634
|
+
selectedConnectAddress,
|
|
3635
|
+
dappWalletClient,
|
|
3636
|
+
dappPublicClient,
|
|
3637
|
+
dappSwitchChain,
|
|
3638
|
+
dappAddress,
|
|
3639
|
+
reownWallet,
|
|
3640
|
+
targetChain
|
|
3641
|
+
]);
|
|
3642
|
+
const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
|
|
3539
3643
|
const lastTargetRef = (0, import_react9.useRef)(null);
|
|
3540
3644
|
(0, import_react9.useEffect)(() => {
|
|
3541
3645
|
const prev = lastTargetRef.current;
|
|
@@ -3553,17 +3657,17 @@ function DepositFlow({
|
|
|
3553
3657
|
});
|
|
3554
3658
|
}, []);
|
|
3555
3659
|
const handleBackFromSelectAsset = (0, import_react9.useCallback)(() => {
|
|
3556
|
-
if (
|
|
3660
|
+
if (hasWalletOptions || reownWallet) {
|
|
3557
3661
|
setIsConnectSelectionConfirmed(false);
|
|
3558
3662
|
}
|
|
3559
|
-
}, [
|
|
3663
|
+
}, [hasWalletOptions, reownWallet]);
|
|
3560
3664
|
const handleBackFromDepositAddress = (0, import_react9.useCallback)(() => {
|
|
3561
3665
|
setFlowMode(null);
|
|
3562
3666
|
setStep({ type: "setup" });
|
|
3563
|
-
if (
|
|
3667
|
+
if (hasWalletOptions || reownWallet) {
|
|
3564
3668
|
setIsConnectSelectionConfirmed(false);
|
|
3565
3669
|
}
|
|
3566
|
-
}, [
|
|
3670
|
+
}, [hasWalletOptions, reownWallet]);
|
|
3567
3671
|
const handleBackFromConfirm = (0, import_react9.useCallback)(() => {
|
|
3568
3672
|
setStep((prev) => {
|
|
3569
3673
|
if (prev.type !== "confirm") return prev;
|
|
@@ -3576,7 +3680,7 @@ function DepositFlow({
|
|
|
3576
3680
|
});
|
|
3577
3681
|
}, []);
|
|
3578
3682
|
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;
|
|
3579
|
-
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" &&
|
|
3683
|
+
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
|
|
3580
3684
|
(0, import_react9.useEffect)(() => {
|
|
3581
3685
|
onStepChange?.(stepIndex, currentBackHandler);
|
|
3582
3686
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
@@ -3701,33 +3805,35 @@ function DepositFlow({
|
|
|
3701
3805
|
}, []);
|
|
3702
3806
|
const selectedConnectAddressEffective = (0, import_react9.useMemo)(() => {
|
|
3703
3807
|
if (selectedConnectAddress) return selectedConnectAddress;
|
|
3704
|
-
if (
|
|
3705
|
-
return
|
|
3808
|
+
if (walletOptions.length === 1) {
|
|
3809
|
+
return walletOptions[0].address;
|
|
3706
3810
|
}
|
|
3707
3811
|
return null;
|
|
3708
|
-
}, [selectedConnectAddress,
|
|
3709
|
-
const
|
|
3710
|
-
() =>
|
|
3711
|
-
[
|
|
3812
|
+
}, [selectedConnectAddress, walletOptions]);
|
|
3813
|
+
const walletOptionsKey = (0, import_react9.useMemo)(
|
|
3814
|
+
() => walletOptions.map((option) => option.address.toLowerCase()).join(","),
|
|
3815
|
+
[walletOptions]
|
|
3712
3816
|
);
|
|
3713
|
-
const showConnectStep = !hasConnectedWallet || hasConnectWalletOptions && !isConnectSelectionConfirmed;
|
|
3714
3817
|
(0, import_react9.useEffect)(() => {
|
|
3715
3818
|
setIsConnectSelectionConfirmed(false);
|
|
3716
|
-
}, [
|
|
3819
|
+
}, [walletOptionsKey, selectedConnectAddressEffective]);
|
|
3717
3820
|
if (showConnectStep) {
|
|
3718
3821
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "rs-modal-body", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3719
3822
|
ConnectStep,
|
|
3720
3823
|
{
|
|
3721
|
-
walletOptions
|
|
3824
|
+
walletOptions,
|
|
3722
3825
|
selectedAddress: selectedConnectAddressEffective,
|
|
3723
|
-
onSelectAddress:
|
|
3724
|
-
onSelectTransferCrypto: () => {
|
|
3826
|
+
onSelectAddress: setSelectedConnectAddress,
|
|
3827
|
+
onSelectTransferCrypto: dappAddress ? () => {
|
|
3725
3828
|
handleSelectTransferCrypto();
|
|
3726
3829
|
setIsConnectSelectionConfirmed(true);
|
|
3727
|
-
},
|
|
3830
|
+
} : void 0,
|
|
3728
3831
|
onRequestConnect,
|
|
3729
3832
|
onConnect,
|
|
3730
3833
|
onContinue: () => {
|
|
3834
|
+
if (selectedConnectAddressEffective) {
|
|
3835
|
+
setSelectedConnectAddress(selectedConnectAddressEffective);
|
|
3836
|
+
}
|
|
3731
3837
|
handleSelectProvider();
|
|
3732
3838
|
setIsConnectSelectionConfirmed(true);
|
|
3733
3839
|
},
|
|
@@ -3735,16 +3841,13 @@ function DepositFlow({
|
|
|
3735
3841
|
}
|
|
3736
3842
|
) });
|
|
3737
3843
|
}
|
|
3738
|
-
if (!walletClient || !publicClient || !address) {
|
|
3739
|
-
return null;
|
|
3740
|
-
}
|
|
3741
3844
|
if (isDepositAddressMode) {
|
|
3845
|
+
if (!dappAddress || !sessionKeyAddress) return null;
|
|
3742
3846
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "rs-modal-body", children: [
|
|
3743
3847
|
step.type === "setup" && targetChainObj && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3744
3848
|
SetupStep,
|
|
3745
3849
|
{
|
|
3746
|
-
|
|
3747
|
-
address,
|
|
3850
|
+
address: sessionKeyAddress,
|
|
3748
3851
|
targetChain,
|
|
3749
3852
|
targetChainObj,
|
|
3750
3853
|
targetToken,
|
|
@@ -3788,12 +3891,23 @@ function DepositFlow({
|
|
|
3788
3891
|
)
|
|
3789
3892
|
] });
|
|
3790
3893
|
}
|
|
3894
|
+
if (!signerContext?.walletClient || !signerContext?.publicClient) {
|
|
3895
|
+
return null;
|
|
3896
|
+
}
|
|
3897
|
+
const ownerAddress = signerContext.ownerAddress;
|
|
3898
|
+
const ownerChainId = signerContext.walletClient?.chain?.id ?? signerContext.publicClient.chain?.id ?? targetChain;
|
|
3899
|
+
const getReadClientForChain = (chainId) => {
|
|
3900
|
+
if (signerContext.publicClient.chain?.id === chainId) {
|
|
3901
|
+
return signerContext.publicClient;
|
|
3902
|
+
}
|
|
3903
|
+
return getPublicClient(chainId);
|
|
3904
|
+
};
|
|
3791
3905
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "rs-modal-body", children: [
|
|
3792
3906
|
step.type === "setup" && targetChainObj && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3793
3907
|
SetupStep,
|
|
3794
3908
|
{
|
|
3795
|
-
walletClient,
|
|
3796
|
-
address,
|
|
3909
|
+
walletClient: signerContext.walletClient,
|
|
3910
|
+
address: ownerAddress,
|
|
3797
3911
|
targetChain,
|
|
3798
3912
|
targetChainObj,
|
|
3799
3913
|
targetToken,
|
|
@@ -3810,8 +3924,8 @@ function DepositFlow({
|
|
|
3810
3924
|
step.type === "select-asset" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3811
3925
|
AssetSelectStep,
|
|
3812
3926
|
{
|
|
3813
|
-
address,
|
|
3814
|
-
publicClient,
|
|
3927
|
+
address: ownerAddress,
|
|
3928
|
+
publicClient: getReadClientForChain(ownerChainId),
|
|
3815
3929
|
defaultSourceChain,
|
|
3816
3930
|
defaultSourceToken,
|
|
3817
3931
|
service,
|
|
@@ -3822,12 +3936,12 @@ function DepositFlow({
|
|
|
3822
3936
|
step.type === "amount" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3823
3937
|
AmountStep,
|
|
3824
3938
|
{
|
|
3825
|
-
walletClient,
|
|
3826
|
-
publicClient,
|
|
3827
|
-
address,
|
|
3939
|
+
walletClient: signerContext.walletClient,
|
|
3940
|
+
publicClient: getReadClientForChain(step.asset.chainId),
|
|
3941
|
+
address: ownerAddress,
|
|
3828
3942
|
asset: step.asset,
|
|
3829
3943
|
defaultAmount: step.amount ?? defaultAmount,
|
|
3830
|
-
switchChain,
|
|
3944
|
+
switchChain: signerContext.switchChain,
|
|
3831
3945
|
targetChain,
|
|
3832
3946
|
targetToken,
|
|
3833
3947
|
uiConfig,
|
|
@@ -3837,15 +3951,15 @@ function DepositFlow({
|
|
|
3837
3951
|
step.type === "confirm" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3838
3952
|
ConfirmStep,
|
|
3839
3953
|
{
|
|
3840
|
-
walletClient,
|
|
3841
|
-
address,
|
|
3954
|
+
walletClient: signerContext.walletClient,
|
|
3955
|
+
address: ownerAddress,
|
|
3842
3956
|
smartAccount: step.smartAccount,
|
|
3843
3957
|
asset: step.asset,
|
|
3844
3958
|
amount: step.amount,
|
|
3845
3959
|
balance: step.balance,
|
|
3846
3960
|
targetChain,
|
|
3847
3961
|
targetToken,
|
|
3848
|
-
switchChain,
|
|
3962
|
+
switchChain: signerContext.switchChain,
|
|
3849
3963
|
onConfirm: handleDepositSubmitted,
|
|
3850
3964
|
onDepositSubmitted: handleDepositSubmittedCallback,
|
|
3851
3965
|
onError: handleError
|
|
@@ -3885,6 +3999,7 @@ var init_DepositFlow = __esm({
|
|
|
3885
3999
|
init_ProcessingStep();
|
|
3886
4000
|
init_DepositAddressStep();
|
|
3887
4001
|
init_constants();
|
|
4002
|
+
init_public_client();
|
|
3888
4003
|
import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3889
4004
|
}
|
|
3890
4005
|
});
|
|
@@ -3995,72 +4110,6 @@ function useReownWallet() {
|
|
|
3995
4110
|
}
|
|
3996
4111
|
};
|
|
3997
4112
|
}
|
|
3998
|
-
function useResolvedWallet(host, reown) {
|
|
3999
|
-
const [selectedAddress, setSelectedAddress] = (0, import_react10.useState)(null);
|
|
4000
|
-
const walletOptions = (0, import_react10.useMemo)(() => {
|
|
4001
|
-
const options = [];
|
|
4002
|
-
const seen = /* @__PURE__ */ new Set();
|
|
4003
|
-
if (host.address) {
|
|
4004
|
-
options.push({
|
|
4005
|
-
address: host.address,
|
|
4006
|
-
label: "Connected Wallet",
|
|
4007
|
-
kind: "connected"
|
|
4008
|
-
});
|
|
4009
|
-
seen.add(host.address.toLowerCase());
|
|
4010
|
-
}
|
|
4011
|
-
if (reown.address && !seen.has(reown.address.toLowerCase())) {
|
|
4012
|
-
options.push({
|
|
4013
|
-
address: reown.address,
|
|
4014
|
-
label: "External Wallet",
|
|
4015
|
-
kind: "external"
|
|
4016
|
-
});
|
|
4017
|
-
}
|
|
4018
|
-
return options;
|
|
4019
|
-
}, [host.address, reown.address]);
|
|
4020
|
-
const effectiveAddress = (0, import_react10.useMemo)(() => {
|
|
4021
|
-
if (walletOptions.length === 0) return null;
|
|
4022
|
-
if (walletOptions.length === 1) return walletOptions[0].address;
|
|
4023
|
-
if (selectedAddress) {
|
|
4024
|
-
const valid = walletOptions.some(
|
|
4025
|
-
(opt) => opt.address.toLowerCase() === selectedAddress.toLowerCase()
|
|
4026
|
-
);
|
|
4027
|
-
if (valid) return selectedAddress;
|
|
4028
|
-
}
|
|
4029
|
-
return null;
|
|
4030
|
-
}, [walletOptions, selectedAddress]);
|
|
4031
|
-
let walletClient;
|
|
4032
|
-
let publicClient;
|
|
4033
|
-
if (effectiveAddress) {
|
|
4034
|
-
const key = effectiveAddress.toLowerCase();
|
|
4035
|
-
if (host.address?.toLowerCase() === key && host.walletClient && host.publicClient) {
|
|
4036
|
-
walletClient = host.walletClient;
|
|
4037
|
-
publicClient = host.publicClient;
|
|
4038
|
-
} else if (reown.address?.toLowerCase() === key && reown.walletClient && reown.publicClient) {
|
|
4039
|
-
walletClient = reown.walletClient;
|
|
4040
|
-
publicClient = reown.publicClient;
|
|
4041
|
-
}
|
|
4042
|
-
}
|
|
4043
|
-
const handleSwitchChain = (0, import_react10.useCallback)(
|
|
4044
|
-
async (chainId) => {
|
|
4045
|
-
if (host.switchChain && effectiveAddress?.toLowerCase() === host.address?.toLowerCase()) {
|
|
4046
|
-
await host.switchChain(chainId);
|
|
4047
|
-
} else {
|
|
4048
|
-
await reown.switchChain(chainId);
|
|
4049
|
-
}
|
|
4050
|
-
},
|
|
4051
|
-
[host.switchChain, host.address, reown.switchChain, effectiveAddress]
|
|
4052
|
-
);
|
|
4053
|
-
return {
|
|
4054
|
-
walletClient,
|
|
4055
|
-
publicClient,
|
|
4056
|
-
address: effectiveAddress ?? void 0,
|
|
4057
|
-
walletOptions,
|
|
4058
|
-
selectedAddress: effectiveAddress,
|
|
4059
|
-
onSelectAddress: setSelectedAddress,
|
|
4060
|
-
openConnect: reown.openConnect,
|
|
4061
|
-
switchChain: handleSwitchChain
|
|
4062
|
-
};
|
|
4063
|
-
}
|
|
4064
4113
|
var import_react10, import_react_query, import_appkit_adapter_wagmi, import_wagmi, import_react11, import_networks, import_wagmi2, import_jsx_runtime15, NETWORKS, cachedAdapter, cachedProjectId;
|
|
4065
4114
|
var init_reown = __esm({
|
|
4066
4115
|
"src/core/reown.tsx"() {
|
|
@@ -4093,15 +4142,6 @@ __export(DepositModalReown_exports, {
|
|
|
4093
4142
|
});
|
|
4094
4143
|
function DepositModalWithReown(props) {
|
|
4095
4144
|
const reown = useReownWallet();
|
|
4096
|
-
const resolved = useResolvedWallet(
|
|
4097
|
-
{
|
|
4098
|
-
walletClient: props.walletClient,
|
|
4099
|
-
publicClient: props.publicClient,
|
|
4100
|
-
address: props.address,
|
|
4101
|
-
switchChain: props.switchChain
|
|
4102
|
-
},
|
|
4103
|
-
reown
|
|
4104
|
-
);
|
|
4105
4145
|
const handleConnect = (0, import_react12.useCallback)(() => {
|
|
4106
4146
|
reown.openConnect();
|
|
4107
4147
|
}, [reown.openConnect]);
|
|
@@ -4109,15 +4149,8 @@ function DepositModalWithReown(props) {
|
|
|
4109
4149
|
DepositModalInner,
|
|
4110
4150
|
{
|
|
4111
4151
|
...props,
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
address: resolved.address,
|
|
4115
|
-
switchChain: resolved.switchChain,
|
|
4116
|
-
connectWalletOptions: resolved.walletOptions,
|
|
4117
|
-
selectedConnectAddress: resolved.selectedAddress,
|
|
4118
|
-
onSelectConnectAddress: resolved.onSelectAddress,
|
|
4119
|
-
onConnect: handleConnect,
|
|
4120
|
-
onRequestConnect: props.onRequestConnect
|
|
4152
|
+
reownWallet: reown,
|
|
4153
|
+
onConnect: handleConnect
|
|
4121
4154
|
}
|
|
4122
4155
|
);
|
|
4123
4156
|
}
|
|
@@ -4144,15 +4177,14 @@ function DepositModal(props) {
|
|
|
4144
4177
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DepositModalInner, { ...props });
|
|
4145
4178
|
}
|
|
4146
4179
|
function DepositModalInner({
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4180
|
+
dappWalletClient,
|
|
4181
|
+
dappPublicClient,
|
|
4182
|
+
dappAddress,
|
|
4150
4183
|
targetChain: targetChainProp,
|
|
4151
4184
|
targetToken,
|
|
4152
4185
|
isOpen,
|
|
4153
4186
|
onClose,
|
|
4154
4187
|
inline,
|
|
4155
|
-
switchChain,
|
|
4156
4188
|
sourceChain: sourceChainProp,
|
|
4157
4189
|
sourceToken,
|
|
4158
4190
|
defaultAmount,
|
|
@@ -4162,9 +4194,7 @@ function DepositModalInner({
|
|
|
4162
4194
|
sessionChainIds,
|
|
4163
4195
|
forceRegister = false,
|
|
4164
4196
|
waitForFinalTx = true,
|
|
4165
|
-
|
|
4166
|
-
selectedConnectAddress,
|
|
4167
|
-
onSelectConnectAddress,
|
|
4197
|
+
reownWallet,
|
|
4168
4198
|
onConnect,
|
|
4169
4199
|
onRequestConnect,
|
|
4170
4200
|
connectButtonLabel,
|
|
@@ -4318,13 +4348,12 @@ function DepositModalInner({
|
|
|
4318
4348
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4319
4349
|
DepositFlow,
|
|
4320
4350
|
{
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4351
|
+
dappWalletClient,
|
|
4352
|
+
dappPublicClient,
|
|
4353
|
+
dappAddress,
|
|
4324
4354
|
targetChain,
|
|
4325
4355
|
targetToken,
|
|
4326
4356
|
service,
|
|
4327
|
-
switchChain,
|
|
4328
4357
|
sourceChain,
|
|
4329
4358
|
sourceToken,
|
|
4330
4359
|
amount: defaultAmount,
|
|
@@ -4333,9 +4362,7 @@ function DepositModalInner({
|
|
|
4333
4362
|
sessionChainIds,
|
|
4334
4363
|
forceRegister,
|
|
4335
4364
|
waitForFinalTx,
|
|
4336
|
-
|
|
4337
|
-
selectedConnectAddress,
|
|
4338
|
-
onSelectConnectAddress,
|
|
4365
|
+
reownWallet,
|
|
4339
4366
|
onConnect,
|
|
4340
4367
|
onRequestConnect,
|
|
4341
4368
|
connectButtonLabel,
|
|
@@ -4454,7 +4481,7 @@ function WithdrawFormStep({
|
|
|
4454
4481
|
try {
|
|
4455
4482
|
const bal = isNativeAsset(asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
|
|
4456
4483
|
address: asset.token,
|
|
4457
|
-
abi:
|
|
4484
|
+
abi: import_viem8.erc20Abi,
|
|
4458
4485
|
functionName: "balanceOf",
|
|
4459
4486
|
args: [safeAddress]
|
|
4460
4487
|
});
|
|
@@ -4482,7 +4509,7 @@ function WithdrawFormStep({
|
|
|
4482
4509
|
const formattedBalance = (0, import_react14.useMemo)(() => {
|
|
4483
4510
|
if (balance === null) return "...";
|
|
4484
4511
|
try {
|
|
4485
|
-
const raw = (0,
|
|
4512
|
+
const raw = (0, import_viem8.formatUnits)(balance, asset.decimals);
|
|
4486
4513
|
const numeric = Number(raw);
|
|
4487
4514
|
if (!Number.isFinite(numeric)) return raw;
|
|
4488
4515
|
return new Intl.NumberFormat("en-US", {
|
|
@@ -4497,7 +4524,7 @@ function WithdrawFormStep({
|
|
|
4497
4524
|
const sym = asset.symbol.toUpperCase();
|
|
4498
4525
|
if (sym !== "USDC" && sym !== "USDT") return;
|
|
4499
4526
|
try {
|
|
4500
|
-
const raw = (0,
|
|
4527
|
+
const raw = (0, import_viem8.formatUnits)(balance, asset.decimals);
|
|
4501
4528
|
const numeric = Number(raw);
|
|
4502
4529
|
if (!Number.isFinite(numeric)) return;
|
|
4503
4530
|
onBalanceUsdChange?.(numeric);
|
|
@@ -4517,7 +4544,7 @@ function WithdrawFormStep({
|
|
|
4517
4544
|
}, [amount, asset.symbol]);
|
|
4518
4545
|
const handleMaxClick = (0, import_react14.useCallback)(() => {
|
|
4519
4546
|
if (balance === null) return;
|
|
4520
|
-
const maxAmount = (0,
|
|
4547
|
+
const maxAmount = (0, import_viem8.formatUnits)(balance, asset.decimals);
|
|
4521
4548
|
setAmount(maxAmount);
|
|
4522
4549
|
setError(null);
|
|
4523
4550
|
}, [balance, asset.decimals]);
|
|
@@ -4538,7 +4565,7 @@ function WithdrawFormStep({
|
|
|
4538
4565
|
}
|
|
4539
4566
|
if (balance !== null) {
|
|
4540
4567
|
try {
|
|
4541
|
-
const amountInUnits = (0,
|
|
4568
|
+
const amountInUnits = (0, import_viem8.parseUnits)(amount, asset.decimals);
|
|
4542
4569
|
if (amountInUnits > balance) {
|
|
4543
4570
|
setError("Insufficient balance");
|
|
4544
4571
|
return;
|
|
@@ -4877,12 +4904,12 @@ function WithdrawFormStep({
|
|
|
4877
4904
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PoweredBy, {})
|
|
4878
4905
|
] });
|
|
4879
4906
|
}
|
|
4880
|
-
var import_react14,
|
|
4907
|
+
var import_react14, import_viem8, import_jsx_runtime18;
|
|
4881
4908
|
var init_WithdrawFormStep = __esm({
|
|
4882
4909
|
"src/components/steps/WithdrawFormStep.tsx"() {
|
|
4883
4910
|
"use strict";
|
|
4884
4911
|
import_react14 = require("react");
|
|
4885
|
-
|
|
4912
|
+
import_viem8 = require("viem");
|
|
4886
4913
|
init_Button();
|
|
4887
4914
|
init_PoweredBy();
|
|
4888
4915
|
init_deposit_service();
|
|
@@ -4928,13 +4955,13 @@ async function executeSafeEthTransfer(params) {
|
|
|
4928
4955
|
safeTxGas: 0n,
|
|
4929
4956
|
baseGas: 0n,
|
|
4930
4957
|
gasPrice: 0n,
|
|
4931
|
-
gasToken:
|
|
4932
|
-
refundReceiver:
|
|
4958
|
+
gasToken: import_viem9.zeroAddress,
|
|
4959
|
+
refundReceiver: import_viem9.zeroAddress
|
|
4933
4960
|
};
|
|
4934
|
-
const signature = (0,
|
|
4935
|
-
(0,
|
|
4936
|
-
(0,
|
|
4937
|
-
(0,
|
|
4961
|
+
const signature = (0, import_viem9.concat)([
|
|
4962
|
+
(0, import_viem9.pad)(account.address, { size: 32 }),
|
|
4963
|
+
(0, import_viem9.pad)((0, import_viem9.toHex)(0), { size: 32 }),
|
|
4964
|
+
(0, import_viem9.toHex)(1, { size: 1 })
|
|
4938
4965
|
]);
|
|
4939
4966
|
const txHash = await walletClient.writeContract({
|
|
4940
4967
|
account,
|
|
@@ -4961,7 +4988,7 @@ async function executeSafeEthTransfer(params) {
|
|
|
4961
4988
|
const safeLogs = receipt.logs.filter(
|
|
4962
4989
|
(log) => log.address.toLowerCase() === safeAddress.toLowerCase()
|
|
4963
4990
|
);
|
|
4964
|
-
const parsed = (0,
|
|
4991
|
+
const parsed = (0, import_viem9.parseEventLogs)({
|
|
4965
4992
|
abi: SAFE_ABI,
|
|
4966
4993
|
logs: safeLogs,
|
|
4967
4994
|
strict: false
|
|
@@ -5003,8 +5030,8 @@ async function executeSafeErc20Transfer(params) {
|
|
|
5003
5030
|
if (!isOwner) {
|
|
5004
5031
|
throw new Error("Connected wallet is not a Safe owner");
|
|
5005
5032
|
}
|
|
5006
|
-
const data = (0,
|
|
5007
|
-
abi:
|
|
5033
|
+
const data = (0, import_viem9.encodeFunctionData)({
|
|
5034
|
+
abi: import_viem9.erc20Abi,
|
|
5008
5035
|
functionName: "transfer",
|
|
5009
5036
|
args: [recipient, amount]
|
|
5010
5037
|
});
|
|
@@ -5016,13 +5043,13 @@ async function executeSafeErc20Transfer(params) {
|
|
|
5016
5043
|
safeTxGas: 0n,
|
|
5017
5044
|
baseGas: 0n,
|
|
5018
5045
|
gasPrice: 0n,
|
|
5019
|
-
gasToken:
|
|
5020
|
-
refundReceiver:
|
|
5046
|
+
gasToken: import_viem9.zeroAddress,
|
|
5047
|
+
refundReceiver: import_viem9.zeroAddress
|
|
5021
5048
|
};
|
|
5022
|
-
const signature = (0,
|
|
5023
|
-
(0,
|
|
5024
|
-
(0,
|
|
5025
|
-
(0,
|
|
5049
|
+
const signature = (0, import_viem9.concat)([
|
|
5050
|
+
(0, import_viem9.pad)(account.address, { size: 32 }),
|
|
5051
|
+
(0, import_viem9.pad)((0, import_viem9.toHex)(0), { size: 32 }),
|
|
5052
|
+
(0, import_viem9.toHex)(1, { size: 1 })
|
|
5026
5053
|
]);
|
|
5027
5054
|
const txHash = await walletClient.writeContract({
|
|
5028
5055
|
account,
|
|
@@ -5049,7 +5076,7 @@ async function executeSafeErc20Transfer(params) {
|
|
|
5049
5076
|
const safeLogs = receipt.logs.filter(
|
|
5050
5077
|
(log) => log.address.toLowerCase() === safeAddress.toLowerCase()
|
|
5051
5078
|
);
|
|
5052
|
-
const parsed = (0,
|
|
5079
|
+
const parsed = (0, import_viem9.parseEventLogs)({
|
|
5053
5080
|
abi: SAFE_ABI,
|
|
5054
5081
|
logs: safeLogs,
|
|
5055
5082
|
strict: false
|
|
@@ -5064,11 +5091,11 @@ async function executeSafeErc20Transfer(params) {
|
|
|
5064
5091
|
}
|
|
5065
5092
|
return { txHash };
|
|
5066
5093
|
}
|
|
5067
|
-
var
|
|
5094
|
+
var import_viem9, SAFE_ABI;
|
|
5068
5095
|
var init_safe = __esm({
|
|
5069
5096
|
"src/core/safe.ts"() {
|
|
5070
5097
|
"use strict";
|
|
5071
|
-
|
|
5098
|
+
import_viem9 = require("viem");
|
|
5072
5099
|
init_constants();
|
|
5073
5100
|
SAFE_ABI = [
|
|
5074
5101
|
{
|
|
@@ -5120,9 +5147,9 @@ var init_safe = __esm({
|
|
|
5120
5147
|
|
|
5121
5148
|
// src/WithdrawFlow.tsx
|
|
5122
5149
|
function WithdrawFlow({
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5150
|
+
dappWalletClient,
|
|
5151
|
+
dappPublicClient,
|
|
5152
|
+
dappAddress,
|
|
5126
5153
|
safeAddress,
|
|
5127
5154
|
sourceChain,
|
|
5128
5155
|
sourceToken,
|
|
@@ -5131,14 +5158,11 @@ function WithdrawFlow({
|
|
|
5131
5158
|
recipient: defaultRecipient,
|
|
5132
5159
|
amount: defaultAmount,
|
|
5133
5160
|
service,
|
|
5134
|
-
switchChain,
|
|
5135
5161
|
signerAddress = DEFAULT_SIGNER_ADDRESS,
|
|
5136
5162
|
sessionChainIds,
|
|
5137
5163
|
forceRegister = false,
|
|
5138
5164
|
waitForFinalTx = true,
|
|
5139
|
-
|
|
5140
|
-
selectedConnectAddress,
|
|
5141
|
-
onSelectConnectAddress,
|
|
5165
|
+
reownWallet,
|
|
5142
5166
|
onConnect,
|
|
5143
5167
|
onWithdrawSign,
|
|
5144
5168
|
onRequestConnect,
|
|
@@ -5163,12 +5187,87 @@ function WithdrawFlow({
|
|
|
5163
5187
|
setTargetToken(targetTokenProp);
|
|
5164
5188
|
}, [targetChainProp, targetTokenProp]);
|
|
5165
5189
|
const targetChainObj = (0, import_react15.useMemo)(() => CHAIN_BY_ID[targetChain], [targetChain]);
|
|
5166
|
-
const hasCustomSigner = Boolean(
|
|
5167
|
-
const
|
|
5168
|
-
|
|
5169
|
-
() =>
|
|
5170
|
-
|
|
5171
|
-
|
|
5190
|
+
const hasCustomSigner = Boolean(dappAddress && onWithdrawSign);
|
|
5191
|
+
const dappSwitchChain = (0, import_react15.useMemo)(() => {
|
|
5192
|
+
if (!dappWalletClient?.switchChain) return void 0;
|
|
5193
|
+
return async (chainId) => {
|
|
5194
|
+
await dappWalletClient.switchChain?.({ id: chainId });
|
|
5195
|
+
};
|
|
5196
|
+
}, [dappWalletClient]);
|
|
5197
|
+
const walletOptions = (0, import_react15.useMemo)(() => {
|
|
5198
|
+
const options = [];
|
|
5199
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5200
|
+
if (dappWalletClient?.account && dappAddress) {
|
|
5201
|
+
options.push({
|
|
5202
|
+
address: dappWalletClient.account.address,
|
|
5203
|
+
label: "Connected Wallet",
|
|
5204
|
+
kind: "connected"
|
|
5205
|
+
});
|
|
5206
|
+
seen.add(dappWalletClient.account.address.toLowerCase());
|
|
5207
|
+
}
|
|
5208
|
+
if (reownWallet?.address && reownWallet.isConnected && !seen.has(reownWallet.address.toLowerCase())) {
|
|
5209
|
+
options.push({
|
|
5210
|
+
address: reownWallet.address,
|
|
5211
|
+
label: "External Wallet",
|
|
5212
|
+
kind: "external"
|
|
5213
|
+
});
|
|
5214
|
+
}
|
|
5215
|
+
return options;
|
|
5216
|
+
}, [
|
|
5217
|
+
dappWalletClient,
|
|
5218
|
+
dappAddress,
|
|
5219
|
+
reownWallet?.address,
|
|
5220
|
+
reownWallet?.isConnected
|
|
5221
|
+
]);
|
|
5222
|
+
const canAutoLock = (dappWalletClient?.account && dappAddress || hasCustomSigner) && !reownWallet;
|
|
5223
|
+
const [selectedConnectAddress, setSelectedConnectAddress] = (0, import_react15.useState)(null);
|
|
5224
|
+
const signerContext = (0, import_react15.useMemo)(() => {
|
|
5225
|
+
if (canAutoLock) {
|
|
5226
|
+
if (hasCustomSigner) {
|
|
5227
|
+
return {
|
|
5228
|
+
ownerAddress: dappAddress,
|
|
5229
|
+
walletClient: dappWalletClient ?? void 0,
|
|
5230
|
+
publicClient: dappPublicClient ?? getPublicClient(sourceChain),
|
|
5231
|
+
switchChain: dappSwitchChain
|
|
5232
|
+
};
|
|
5233
|
+
}
|
|
5234
|
+
return {
|
|
5235
|
+
ownerAddress: dappWalletClient.account.address,
|
|
5236
|
+
walletClient: dappWalletClient,
|
|
5237
|
+
publicClient: dappPublicClient ?? getPublicClient(sourceChain),
|
|
5238
|
+
switchChain: dappSwitchChain
|
|
5239
|
+
};
|
|
5240
|
+
}
|
|
5241
|
+
if (!isConnectSelectionConfirmed || !selectedConnectAddress) return null;
|
|
5242
|
+
if (dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedConnectAddress.toLowerCase()) {
|
|
5243
|
+
return {
|
|
5244
|
+
ownerAddress: dappWalletClient.account.address,
|
|
5245
|
+
walletClient: dappWalletClient,
|
|
5246
|
+
publicClient: dappPublicClient ?? getPublicClient(sourceChain),
|
|
5247
|
+
switchChain: dappSwitchChain
|
|
5248
|
+
};
|
|
5249
|
+
}
|
|
5250
|
+
if (reownWallet?.address?.toLowerCase() === selectedConnectAddress.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
|
|
5251
|
+
return {
|
|
5252
|
+
ownerAddress: reownWallet.address,
|
|
5253
|
+
walletClient: reownWallet.walletClient,
|
|
5254
|
+
publicClient: reownWallet.publicClient,
|
|
5255
|
+
switchChain: reownWallet.switchChain
|
|
5256
|
+
};
|
|
5257
|
+
}
|
|
5258
|
+
return null;
|
|
5259
|
+
}, [
|
|
5260
|
+
canAutoLock,
|
|
5261
|
+
hasCustomSigner,
|
|
5262
|
+
isConnectSelectionConfirmed,
|
|
5263
|
+
selectedConnectAddress,
|
|
5264
|
+
dappWalletClient,
|
|
5265
|
+
dappPublicClient,
|
|
5266
|
+
dappSwitchChain,
|
|
5267
|
+
dappAddress,
|
|
5268
|
+
reownWallet,
|
|
5269
|
+
sourceChain
|
|
5270
|
+
]);
|
|
5172
5271
|
const asset = (0, import_react15.useMemo)(() => {
|
|
5173
5272
|
const symbol = getTokenSymbol(sourceToken, sourceChain);
|
|
5174
5273
|
const decimals = getTokenDecimalsByAddress(sourceToken, sourceChain);
|
|
@@ -5219,10 +5318,11 @@ function WithdrawFlow({
|
|
|
5219
5318
|
}, []);
|
|
5220
5319
|
const handleFormSubmit = (0, import_react15.useCallback)(
|
|
5221
5320
|
async (recipient, amountValue) => {
|
|
5222
|
-
|
|
5321
|
+
const ownerAddress2 = signerContext?.ownerAddress;
|
|
5322
|
+
if (!ownerAddress2) {
|
|
5223
5323
|
throw new Error("Wallet not connected");
|
|
5224
5324
|
}
|
|
5225
|
-
if (!onWithdrawSign &&
|
|
5325
|
+
if (!onWithdrawSign && !signerContext?.walletClient) {
|
|
5226
5326
|
throw new Error("Wallet not connected");
|
|
5227
5327
|
}
|
|
5228
5328
|
if (!targetChainObj) {
|
|
@@ -5230,8 +5330,8 @@ function WithdrawFlow({
|
|
|
5230
5330
|
}
|
|
5231
5331
|
setIsSubmitting(true);
|
|
5232
5332
|
try {
|
|
5233
|
-
const signerAccount = walletClient ? (0, import_sdk3.walletClientToAccount)(walletClient) : createViewOnlyAccount(
|
|
5234
|
-
const sessionOwner = await resolveSessionOwner2(
|
|
5333
|
+
const signerAccount = signerContext?.walletClient ? (0, import_sdk3.walletClientToAccount)(signerContext.walletClient) : createViewOnlyAccount(ownerAddress2);
|
|
5334
|
+
const sessionOwner = await resolveSessionOwner2(ownerAddress2);
|
|
5235
5335
|
const account = await createSmartAccount(
|
|
5236
5336
|
signerAccount,
|
|
5237
5337
|
sessionOwner.account
|
|
@@ -5256,7 +5356,7 @@ function WithdrawFlow({
|
|
|
5256
5356
|
factoryData: initData.factoryData,
|
|
5257
5357
|
sessionDetails
|
|
5258
5358
|
},
|
|
5259
|
-
eoaAddress:
|
|
5359
|
+
eoaAddress: ownerAddress2,
|
|
5260
5360
|
sessionOwner: sessionOwner.address,
|
|
5261
5361
|
target: {
|
|
5262
5362
|
chain: targetChain,
|
|
@@ -5265,8 +5365,9 @@ function WithdrawFlow({
|
|
|
5265
5365
|
}
|
|
5266
5366
|
});
|
|
5267
5367
|
}
|
|
5268
|
-
handleConnected(
|
|
5368
|
+
handleConnected(ownerAddress2, smartAccount);
|
|
5269
5369
|
const amountUnits = (0, import_viem10.parseUnits)(amountValue, asset.decimals);
|
|
5370
|
+
const pc = signerContext?.publicClient ?? getPublicClient(sourceChain);
|
|
5270
5371
|
const result = onWithdrawSign ? await onWithdrawSign({
|
|
5271
5372
|
safeAddress,
|
|
5272
5373
|
recipient: smartAccount,
|
|
@@ -5275,15 +5376,15 @@ function WithdrawFlow({
|
|
|
5275
5376
|
chainId: sourceChain,
|
|
5276
5377
|
isNative: isSourceNative
|
|
5277
5378
|
}) : isSourceNative ? await executeSafeEthTransfer({
|
|
5278
|
-
walletClient,
|
|
5279
|
-
publicClient,
|
|
5379
|
+
walletClient: signerContext.walletClient,
|
|
5380
|
+
publicClient: pc,
|
|
5280
5381
|
safeAddress,
|
|
5281
5382
|
recipient: smartAccount,
|
|
5282
5383
|
amount: amountUnits,
|
|
5283
5384
|
chainId: sourceChain
|
|
5284
5385
|
}) : await executeSafeErc20Transfer({
|
|
5285
|
-
walletClient,
|
|
5286
|
-
publicClient,
|
|
5386
|
+
walletClient: signerContext.walletClient,
|
|
5387
|
+
publicClient: pc,
|
|
5287
5388
|
safeAddress,
|
|
5288
5389
|
tokenAddress: sourceToken,
|
|
5289
5390
|
recipient: smartAccount,
|
|
@@ -5313,9 +5414,7 @@ function WithdrawFlow({
|
|
|
5313
5414
|
}
|
|
5314
5415
|
},
|
|
5315
5416
|
[
|
|
5316
|
-
|
|
5317
|
-
publicClient,
|
|
5318
|
-
address,
|
|
5417
|
+
signerContext,
|
|
5319
5418
|
targetChainObj,
|
|
5320
5419
|
resolveSessionOwner2,
|
|
5321
5420
|
signerAddress,
|
|
@@ -5384,52 +5483,54 @@ function WithdrawFlow({
|
|
|
5384
5483
|
const handleTargetTokenChange = (0, import_react15.useCallback)((token) => {
|
|
5385
5484
|
setTargetToken(token);
|
|
5386
5485
|
}, []);
|
|
5387
|
-
const hasConnectWalletOptions = (connectWalletOptions?.length ?? 0) > 0;
|
|
5388
5486
|
const selectedConnectAddressEffective = (0, import_react15.useMemo)(() => {
|
|
5389
5487
|
if (selectedConnectAddress) return selectedConnectAddress;
|
|
5390
|
-
if (
|
|
5391
|
-
return
|
|
5488
|
+
if (walletOptions.length === 1) {
|
|
5489
|
+
return walletOptions[0].address;
|
|
5392
5490
|
}
|
|
5393
5491
|
return null;
|
|
5394
|
-
}, [selectedConnectAddress,
|
|
5395
|
-
const
|
|
5396
|
-
() =>
|
|
5397
|
-
[
|
|
5398
|
-
);
|
|
5399
|
-
const hasConnectedWallet = Boolean(
|
|
5400
|
-
walletClient && publicClient && address || hasCustomSigner
|
|
5492
|
+
}, [selectedConnectAddress, walletOptions]);
|
|
5493
|
+
const walletOptionsKey = (0, import_react15.useMemo)(
|
|
5494
|
+
() => walletOptions.map((option) => option.address.toLowerCase()).join(","),
|
|
5495
|
+
[walletOptions]
|
|
5401
5496
|
);
|
|
5402
|
-
const showConnectStep = !
|
|
5497
|
+
const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
|
|
5403
5498
|
(0, import_react15.useEffect)(() => {
|
|
5404
5499
|
setIsConnectSelectionConfirmed(false);
|
|
5405
|
-
}, [
|
|
5500
|
+
}, [walletOptionsKey, selectedConnectAddressEffective]);
|
|
5406
5501
|
if (showConnectStep) {
|
|
5407
5502
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "rs-modal-body", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5408
5503
|
ConnectStep,
|
|
5409
5504
|
{
|
|
5410
|
-
walletOptions
|
|
5505
|
+
walletOptions,
|
|
5411
5506
|
selectedAddress: selectedConnectAddressEffective,
|
|
5412
|
-
onSelectAddress:
|
|
5507
|
+
onSelectAddress: setSelectedConnectAddress,
|
|
5413
5508
|
onRequestConnect,
|
|
5414
5509
|
onConnect,
|
|
5415
|
-
onContinue: () =>
|
|
5510
|
+
onContinue: () => {
|
|
5511
|
+
if (selectedConnectAddressEffective) {
|
|
5512
|
+
setSelectedConnectAddress(selectedConnectAddressEffective);
|
|
5513
|
+
}
|
|
5514
|
+
setIsConnectSelectionConfirmed(true);
|
|
5515
|
+
},
|
|
5416
5516
|
connectButtonLabel
|
|
5417
5517
|
}
|
|
5418
5518
|
) });
|
|
5419
5519
|
}
|
|
5420
|
-
if (!
|
|
5421
|
-
|
|
5422
|
-
|
|
5520
|
+
if (!signerContext) return null;
|
|
5521
|
+
if (!onWithdrawSign && !signerContext.walletClient) return null;
|
|
5522
|
+
const ownerAddress = signerContext.ownerAddress;
|
|
5523
|
+
const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
|
|
5423
5524
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "rs-modal-body", children: [
|
|
5424
5525
|
step.type === "form" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5425
5526
|
WithdrawFormStep,
|
|
5426
5527
|
{
|
|
5427
|
-
walletClient,
|
|
5428
|
-
publicClient:
|
|
5429
|
-
address,
|
|
5528
|
+
walletClient: signerContext.walletClient,
|
|
5529
|
+
publicClient: formPublicClient,
|
|
5530
|
+
address: ownerAddress,
|
|
5430
5531
|
safeAddress,
|
|
5431
5532
|
asset,
|
|
5432
|
-
defaultRecipient: defaultRecipient ??
|
|
5533
|
+
defaultRecipient: defaultRecipient ?? ownerAddress,
|
|
5433
5534
|
defaultAmount,
|
|
5434
5535
|
targetChain,
|
|
5435
5536
|
targetToken,
|
|
@@ -5437,7 +5538,7 @@ function WithdrawFlow({
|
|
|
5437
5538
|
targetTokenOptions,
|
|
5438
5539
|
onTargetChainChange: handleTargetChainChange,
|
|
5439
5540
|
onTargetTokenChange: handleTargetTokenChange,
|
|
5440
|
-
switchChain,
|
|
5541
|
+
switchChain: signerContext.switchChain,
|
|
5441
5542
|
submitting: isSubmitting,
|
|
5442
5543
|
onSubmit: handleFormSubmit,
|
|
5443
5544
|
onBalanceUsdChange: setTotalBalanceUsd
|
|
@@ -5465,13 +5566,13 @@ function WithdrawFlow({
|
|
|
5465
5566
|
)
|
|
5466
5567
|
] });
|
|
5467
5568
|
}
|
|
5468
|
-
var import_react15,
|
|
5569
|
+
var import_react15, import_sdk3, import_viem10, import_jsx_runtime19;
|
|
5469
5570
|
var init_WithdrawFlow = __esm({
|
|
5470
5571
|
"src/WithdrawFlow.tsx"() {
|
|
5471
5572
|
"use strict";
|
|
5472
5573
|
import_react15 = require("react");
|
|
5473
|
-
import_viem9 = require("viem");
|
|
5474
5574
|
init_ConnectStep();
|
|
5575
|
+
init_public_client();
|
|
5475
5576
|
init_WithdrawFormStep();
|
|
5476
5577
|
init_ProcessingStep();
|
|
5477
5578
|
init_constants();
|
|
@@ -5492,15 +5593,6 @@ __export(WithdrawModalReown_exports, {
|
|
|
5492
5593
|
});
|
|
5493
5594
|
function WithdrawModalWithReown(props) {
|
|
5494
5595
|
const reown = useReownWallet();
|
|
5495
|
-
const resolved = useResolvedWallet(
|
|
5496
|
-
{
|
|
5497
|
-
walletClient: props.walletClient,
|
|
5498
|
-
publicClient: props.publicClient,
|
|
5499
|
-
address: props.address,
|
|
5500
|
-
switchChain: props.switchChain
|
|
5501
|
-
},
|
|
5502
|
-
reown
|
|
5503
|
-
);
|
|
5504
5596
|
const handleConnect = (0, import_react16.useCallback)(() => {
|
|
5505
5597
|
reown.openConnect();
|
|
5506
5598
|
}, [reown.openConnect]);
|
|
@@ -5508,15 +5600,8 @@ function WithdrawModalWithReown(props) {
|
|
|
5508
5600
|
WithdrawModalInner,
|
|
5509
5601
|
{
|
|
5510
5602
|
...props,
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
address: resolved.address,
|
|
5514
|
-
switchChain: resolved.switchChain,
|
|
5515
|
-
connectWalletOptions: resolved.walletOptions,
|
|
5516
|
-
selectedConnectAddress: resolved.selectedAddress,
|
|
5517
|
-
onSelectConnectAddress: resolved.onSelectAddress,
|
|
5518
|
-
onConnect: handleConnect,
|
|
5519
|
-
onRequestConnect: props.onRequestConnect
|
|
5603
|
+
reownWallet: reown,
|
|
5604
|
+
onConnect: handleConnect
|
|
5520
5605
|
}
|
|
5521
5606
|
);
|
|
5522
5607
|
}
|
|
@@ -5543,9 +5628,9 @@ function WithdrawModal(props) {
|
|
|
5543
5628
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(WithdrawModalInner, { ...props });
|
|
5544
5629
|
}
|
|
5545
5630
|
function WithdrawModalInner({
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5631
|
+
dappWalletClient,
|
|
5632
|
+
dappPublicClient,
|
|
5633
|
+
dappAddress,
|
|
5549
5634
|
safeAddress,
|
|
5550
5635
|
sourceChain: sourceChainProp,
|
|
5551
5636
|
sourceToken,
|
|
@@ -5556,15 +5641,12 @@ function WithdrawModalInner({
|
|
|
5556
5641
|
isOpen,
|
|
5557
5642
|
onClose,
|
|
5558
5643
|
inline,
|
|
5559
|
-
switchChain,
|
|
5560
5644
|
backendUrl = DEFAULT_BACKEND_URL,
|
|
5561
5645
|
signerAddress = DEFAULT_SIGNER_ADDRESS,
|
|
5562
5646
|
sessionChainIds,
|
|
5563
5647
|
forceRegister = false,
|
|
5564
5648
|
waitForFinalTx = true,
|
|
5565
|
-
|
|
5566
|
-
selectedConnectAddress,
|
|
5567
|
-
onSelectConnectAddress,
|
|
5649
|
+
reownWallet,
|
|
5568
5650
|
onConnect,
|
|
5569
5651
|
onWithdrawSign,
|
|
5570
5652
|
onRequestConnect,
|
|
@@ -5716,9 +5798,9 @@ function WithdrawModalInner({
|
|
|
5716
5798
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5717
5799
|
WithdrawFlow,
|
|
5718
5800
|
{
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5801
|
+
dappWalletClient,
|
|
5802
|
+
dappPublicClient,
|
|
5803
|
+
dappAddress,
|
|
5722
5804
|
safeAddress,
|
|
5723
5805
|
sourceChain,
|
|
5724
5806
|
sourceToken,
|
|
@@ -5727,14 +5809,11 @@ function WithdrawModalInner({
|
|
|
5727
5809
|
recipient,
|
|
5728
5810
|
amount: defaultAmount,
|
|
5729
5811
|
service,
|
|
5730
|
-
switchChain,
|
|
5731
5812
|
signerAddress,
|
|
5732
5813
|
sessionChainIds,
|
|
5733
5814
|
forceRegister,
|
|
5734
5815
|
waitForFinalTx,
|
|
5735
|
-
|
|
5736
|
-
selectedConnectAddress,
|
|
5737
|
-
onSelectConnectAddress,
|
|
5816
|
+
reownWallet,
|
|
5738
5817
|
onConnect,
|
|
5739
5818
|
onWithdrawSign,
|
|
5740
5819
|
onRequestConnect,
|