@rhinestone/deposit-modal 0.1.29 → 0.1.31
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/{DepositModalReown-4PFOMSC6.cjs → DepositModalReown-N7GCYZF7.cjs} +7 -7
- package/dist/{DepositModalReown-BVHWFWIG.mjs → DepositModalReown-S7HER5HU.mjs} +4 -4
- package/dist/{WithdrawModalReown-YREQR7DV.cjs → WithdrawModalReown-DJCJ5U7E.cjs} +7 -7
- package/dist/{WithdrawModalReown-CJCNT7SA.mjs → WithdrawModalReown-DMDRLYTE.mjs} +4 -4
- package/dist/{chunk-CSQRKM4Y.mjs → chunk-3ICS43XC.mjs} +14 -9
- package/dist/{chunk-XTTTHW3W.mjs → chunk-AWFJFSPH.mjs} +164 -85
- package/dist/{chunk-LBEP3A2Z.mjs → chunk-CS6UIMCF.mjs} +3 -1
- package/dist/{chunk-N6T4TKXI.mjs → chunk-EVU7M7A6.mjs} +71 -42
- package/dist/{chunk-7ZCUANBT.cjs → chunk-G2RDCQHL.cjs} +109 -80
- package/dist/{chunk-5QJNOPNF.cjs → chunk-MU2BOEDN.cjs} +291 -212
- package/dist/{chunk-DLYVHOME.cjs → chunk-PE6OK3FH.cjs} +15 -10
- package/dist/{chunk-K6YG3I6O.mjs → chunk-SLI5FHTT.mjs} +9 -9
- package/dist/{chunk-CPIQJR47.cjs → chunk-SZ35G2DT.cjs} +59 -59
- package/dist/{chunk-6VJ2ZTNQ.cjs → chunk-VKQA3FO3.cjs} +2 -0
- package/dist/constants.cjs +4 -2
- package/dist/constants.d.cts +2 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.mjs +3 -1
- package/dist/deposit.cjs +4 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +3 -3
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +6 -4
- package/dist/reown.cjs +5 -5
- package/dist/reown.d.cts +1 -1
- package/dist/reown.d.ts +1 -1
- package/dist/reown.mjs +4 -4
- package/dist/styles.css +8 -5
- package/dist/{types-BwaQ7jK5.d.cts → types-DELv717e.d.cts} +5 -1
- package/dist/{types-CgXyx46m.d.ts → types-DTBfMH0p.d.ts} +5 -1
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
portfolioToAssets,
|
|
22
22
|
saveSessionOwnerToStorage,
|
|
23
23
|
tokenFormatter
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EVU7M7A6.mjs";
|
|
25
25
|
import {
|
|
26
26
|
DEFAULT_BACKEND_URL,
|
|
27
27
|
DEFAULT_SIGNER_ADDRESS,
|
|
@@ -32,11 +32,11 @@ import {
|
|
|
32
32
|
getChainId,
|
|
33
33
|
getChainName,
|
|
34
34
|
getSupportedChainIds,
|
|
35
|
-
|
|
35
|
+
getTargetTokenSymbolsForChain,
|
|
36
36
|
getTokenAddress,
|
|
37
37
|
getTokenIcon,
|
|
38
38
|
getTokenSymbol
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-3ICS43XC.mjs";
|
|
40
40
|
|
|
41
41
|
// src/DepositModal.tsx
|
|
42
42
|
import {
|
|
@@ -446,7 +446,7 @@ function AssetSelectStep({
|
|
|
446
446
|
] })
|
|
447
447
|
] })
|
|
448
448
|
] }),
|
|
449
|
-
/* @__PURE__ */ jsx2("div", { className: "rs-asset-balance", children: asset.balanceUsd !== void 0 ? currencyFormatter.format(asset.balanceUsd) : tokenAmount !== "--" ? `${tokenAmount} ${asset.symbol}` : "--" })
|
|
449
|
+
/* @__PURE__ */ jsx2("div", { className: "rs-asset-balance", children: asset.balanceUsd !== void 0 && asset.balanceUsd > 0 ? currencyFormatter.format(asset.balanceUsd) : tokenAmount !== "--" ? `${tokenAmount} ${asset.symbol}` : "--" })
|
|
450
450
|
]
|
|
451
451
|
},
|
|
452
452
|
asset.id
|
|
@@ -509,7 +509,7 @@ function mergeAssets(existing, incoming) {
|
|
|
509
509
|
// src/components/steps/AmountStep.tsx
|
|
510
510
|
import { useEffect as useEffect3, useMemo as useMemo2, useState as useState3, useRef as useRef2 } from "react";
|
|
511
511
|
import { erc20Abi, formatUnits as formatUnits2, parseUnits } from "viem";
|
|
512
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
512
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
513
513
|
function AmountStep({
|
|
514
514
|
walletClient,
|
|
515
515
|
publicClient,
|
|
@@ -525,7 +525,7 @@ function AmountStep({
|
|
|
525
525
|
onBalanceUsdChange,
|
|
526
526
|
onContinue
|
|
527
527
|
}) {
|
|
528
|
-
const [
|
|
528
|
+
const [amount, setAmount] = useState3("");
|
|
529
529
|
const [balance, setBalance] = useState3(null);
|
|
530
530
|
const [error, setError] = useState3(null);
|
|
531
531
|
const [isSwitching, setIsSwitching] = useState3(false);
|
|
@@ -534,18 +534,22 @@ function AmountStep({
|
|
|
534
534
|
walletClient?.chain?.id && walletClient.chain.id !== asset.chainId
|
|
535
535
|
);
|
|
536
536
|
const tokenPriceUsd = useMemo2(() => {
|
|
537
|
-
if (tokenPriceUsdOverride !== void 0
|
|
538
|
-
|
|
537
|
+
if (tokenPriceUsdOverride !== void 0 && tokenPriceUsdOverride > 0)
|
|
538
|
+
return tokenPriceUsdOverride;
|
|
539
|
+
if (asset.balanceUsd === void 0 || !asset.balanceUsd || !asset.balance)
|
|
540
|
+
return null;
|
|
539
541
|
try {
|
|
540
542
|
const balanceUnits = Number(
|
|
541
543
|
formatUnits2(BigInt(asset.balance), asset.decimals)
|
|
542
544
|
);
|
|
543
545
|
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0) return null;
|
|
544
|
-
|
|
546
|
+
const price = asset.balanceUsd / balanceUnits;
|
|
547
|
+
return price > 0 ? price : null;
|
|
545
548
|
} catch {
|
|
546
549
|
return null;
|
|
547
550
|
}
|
|
548
551
|
}, [tokenPriceUsdOverride, asset.balanceUsd, asset.balance, asset.decimals]);
|
|
552
|
+
const hasPricing = tokenPriceUsd !== null;
|
|
549
553
|
useEffect3(() => {
|
|
550
554
|
let active = true;
|
|
551
555
|
async function fetchBalance() {
|
|
@@ -585,14 +589,18 @@ function AmountStep({
|
|
|
585
589
|
}
|
|
586
590
|
}, [chainMismatch, switchChain, asset.chainId]);
|
|
587
591
|
useEffect3(() => {
|
|
588
|
-
if (defaultAmount &&
|
|
592
|
+
if (defaultAmount && !amount) {
|
|
589
593
|
const parsed = Number(defaultAmount);
|
|
590
594
|
if (Number.isFinite(parsed) && parsed > 0) {
|
|
591
|
-
|
|
592
|
-
|
|
595
|
+
if (hasPricing) {
|
|
596
|
+
const usdValue = parsed * tokenPriceUsd;
|
|
597
|
+
setAmount(usdValue.toFixed(2));
|
|
598
|
+
} else {
|
|
599
|
+
setAmount(parsed.toString());
|
|
600
|
+
}
|
|
593
601
|
}
|
|
594
602
|
}
|
|
595
|
-
}, [defaultAmount, tokenPriceUsd,
|
|
603
|
+
}, [defaultAmount, tokenPriceUsd, hasPricing, amount]);
|
|
596
604
|
const balanceUsd = useMemo2(() => {
|
|
597
605
|
if (balance === null || tokenPriceUsd === null) return null;
|
|
598
606
|
try {
|
|
@@ -604,8 +612,7 @@ function AmountStep({
|
|
|
604
612
|
}
|
|
605
613
|
}, [balance, tokenPriceUsd, asset.decimals]);
|
|
606
614
|
useEffect3(() => {
|
|
607
|
-
|
|
608
|
-
onBalanceUsdChange?.(balanceUsd);
|
|
615
|
+
onBalanceUsdChange?.(balanceUsd ?? 0);
|
|
609
616
|
}, [balanceUsd, onBalanceUsdChange]);
|
|
610
617
|
const formattedBalance = useMemo2(() => {
|
|
611
618
|
if (balance === null) return "...";
|
|
@@ -619,47 +626,62 @@ function AmountStep({
|
|
|
619
626
|
}
|
|
620
627
|
}, [balance, asset.decimals]);
|
|
621
628
|
const tokenAmount = useMemo2(() => {
|
|
622
|
-
if (!
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
629
|
+
if (!amount) return null;
|
|
630
|
+
if (hasPricing) {
|
|
631
|
+
const usd = Number(amount);
|
|
632
|
+
if (!Number.isFinite(usd) || usd <= 0) return null;
|
|
633
|
+
return usd / tokenPriceUsd;
|
|
634
|
+
}
|
|
635
|
+
const val = Number(amount);
|
|
636
|
+
return Number.isFinite(val) && val > 0 ? val : null;
|
|
637
|
+
}, [amount, tokenPriceUsd, hasPricing]);
|
|
628
638
|
const formattedTokenAmount = useMemo2(() => {
|
|
629
639
|
if (tokenAmount === null) return "0.00";
|
|
630
640
|
return tokenFormatter.format(tokenAmount);
|
|
631
641
|
}, [tokenAmount]);
|
|
632
642
|
const targetSymbol = getTokenSymbol(targetToken, targetChain);
|
|
633
643
|
const handlePresetClick = (percentage) => {
|
|
634
|
-
if (
|
|
635
|
-
|
|
636
|
-
|
|
644
|
+
if (balance === null) return;
|
|
645
|
+
if (hasPricing && balanceUsd !== null) {
|
|
646
|
+
const value = balanceUsd * percentage / 100;
|
|
647
|
+
setAmount(value.toFixed(2));
|
|
648
|
+
} else {
|
|
649
|
+
try {
|
|
650
|
+
const balanceUnits = Number(formatUnits2(balance, asset.decimals));
|
|
651
|
+
if (Number.isFinite(balanceUnits)) {
|
|
652
|
+
const value = balanceUnits * percentage / 100;
|
|
653
|
+
setAmount(value.toString());
|
|
654
|
+
}
|
|
655
|
+
} catch {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
637
659
|
if (error) setError(null);
|
|
638
660
|
};
|
|
639
661
|
const handleContinue = () => {
|
|
640
|
-
const
|
|
641
|
-
if (isNaN(
|
|
662
|
+
const numericAmount = parseFloat(amount);
|
|
663
|
+
if (isNaN(numericAmount) || numericAmount <= 0) {
|
|
642
664
|
setError("Please enter a valid amount");
|
|
643
665
|
return;
|
|
644
666
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
667
|
+
let tokenAmountStr;
|
|
668
|
+
if (hasPricing) {
|
|
669
|
+
if (uiConfig?.maxDepositUsd && numericAmount > uiConfig.maxDepositUsd) {
|
|
670
|
+
setError(
|
|
671
|
+
`Maximum deposit is ${currencyFormatter.format(uiConfig.maxDepositUsd)}`
|
|
672
|
+
);
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (uiConfig?.minDepositUsd && numericAmount < uiConfig.minDepositUsd) {
|
|
676
|
+
setError(
|
|
677
|
+
`Minimum deposit is ${currencyFormatter.format(uiConfig.minDepositUsd)}`
|
|
678
|
+
);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
tokenAmountStr = (numericAmount / tokenPriceUsd).toString();
|
|
682
|
+
} else {
|
|
683
|
+
tokenAmountStr = numericAmount.toString();
|
|
660
684
|
}
|
|
661
|
-
const tokenAmountValue = usdValue / tokenPriceUsd;
|
|
662
|
-
let tokenAmountStr = tokenAmountValue.toString();
|
|
663
685
|
let amountInUnits;
|
|
664
686
|
try {
|
|
665
687
|
amountInUnits = parseUnits(tokenAmountStr, asset.decimals);
|
|
@@ -668,8 +690,8 @@ function AmountStep({
|
|
|
668
690
|
return;
|
|
669
691
|
}
|
|
670
692
|
if (balance !== null && amountInUnits > balance) {
|
|
671
|
-
|
|
672
|
-
|
|
693
|
+
setError("Insufficient balance");
|
|
694
|
+
return;
|
|
673
695
|
}
|
|
674
696
|
setError(null);
|
|
675
697
|
onContinue(tokenAmountStr, balance ?? void 0);
|
|
@@ -689,41 +711,67 @@ function AmountStep({
|
|
|
689
711
|
return /* @__PURE__ */ jsxs3("div", { className: "rs-step", children: [
|
|
690
712
|
/* @__PURE__ */ jsxs3("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
691
713
|
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-display", children: [
|
|
692
|
-
/* @__PURE__ */ jsx3("div", { className: "rs-amount-input-wrapper", children: /* @__PURE__ */ jsx3(
|
|
714
|
+
/* @__PURE__ */ jsx3("div", { className: "rs-amount-input-wrapper", children: hasPricing ? /* @__PURE__ */ jsx3(
|
|
693
715
|
"input",
|
|
694
716
|
{
|
|
695
717
|
type: "text",
|
|
696
718
|
inputMode: "decimal",
|
|
697
719
|
className: "rs-amount-input-large",
|
|
698
720
|
placeholder: "$0.00",
|
|
699
|
-
value:
|
|
721
|
+
value: amount ? `$${amount}` : "",
|
|
700
722
|
onChange: (e) => {
|
|
701
723
|
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
702
724
|
const parts = raw.split(".");
|
|
703
725
|
if (parts.length > 2) return;
|
|
704
|
-
|
|
726
|
+
setAmount(raw);
|
|
727
|
+
if (error) setError(null);
|
|
728
|
+
},
|
|
729
|
+
autoFocus: true
|
|
730
|
+
}
|
|
731
|
+
) : /* @__PURE__ */ jsx3(
|
|
732
|
+
"input",
|
|
733
|
+
{
|
|
734
|
+
type: "text",
|
|
735
|
+
inputMode: "decimal",
|
|
736
|
+
className: "rs-amount-input-large",
|
|
737
|
+
placeholder: `0.00 ${asset.symbol}`,
|
|
738
|
+
value: amount,
|
|
739
|
+
onChange: (e) => {
|
|
740
|
+
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
741
|
+
const parts = raw.split(".");
|
|
742
|
+
if (parts.length > 2) return;
|
|
743
|
+
setAmount(raw);
|
|
705
744
|
if (error) setError(null);
|
|
706
745
|
},
|
|
707
746
|
autoFocus: true
|
|
708
747
|
}
|
|
709
748
|
) }),
|
|
710
|
-
/* @__PURE__ */ jsxs3(
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
asset.symbol
|
|
714
|
-
] }),
|
|
715
|
-
/* @__PURE__ */ jsx3("div", { className: "rs-amount-available", children: /* @__PURE__ */ jsxs3("span", { className: "rs-amount-available-value", children: [
|
|
716
|
-
formattedBalance,
|
|
717
|
-
" ",
|
|
718
|
-
asset.symbol,
|
|
719
|
-
" available",
|
|
720
|
-
balanceUsd !== null && /* @__PURE__ */ jsxs3("span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
749
|
+
(uiConfig?.showTokenBalance ?? false) && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
750
|
+
hasPricing ? /* @__PURE__ */ jsxs3("div", { className: "rs-amount-token-value", children: [
|
|
751
|
+
formattedTokenAmount,
|
|
721
752
|
" ",
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
"
|
|
725
|
-
|
|
726
|
-
|
|
753
|
+
asset.symbol
|
|
754
|
+
] }) : /* @__PURE__ */ jsx3(
|
|
755
|
+
"div",
|
|
756
|
+
{
|
|
757
|
+
className: "rs-amount-token-value",
|
|
758
|
+
style: { color: "var(--rs-muted-foreground)" },
|
|
759
|
+
children: "Price unavailable"
|
|
760
|
+
}
|
|
761
|
+
),
|
|
762
|
+
/* @__PURE__ */ jsx3("div", { className: "rs-amount-available", children: /* @__PURE__ */ jsxs3("span", { className: "rs-amount-available-value", children: [
|
|
763
|
+
formattedBalance,
|
|
764
|
+
" ",
|
|
765
|
+
asset.symbol,
|
|
766
|
+
" available",
|
|
767
|
+
hasPricing && balanceUsd !== null && /* @__PURE__ */ jsxs3("span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
768
|
+
" ",
|
|
769
|
+
"(",
|
|
770
|
+
currencyFormatter.format(balanceUsd),
|
|
771
|
+
")"
|
|
772
|
+
] })
|
|
773
|
+
] }) })
|
|
774
|
+
] })
|
|
727
775
|
] }),
|
|
728
776
|
/* @__PURE__ */ jsx3(
|
|
729
777
|
"div",
|
|
@@ -837,7 +885,7 @@ function AmountStep({
|
|
|
837
885
|
type: "button",
|
|
838
886
|
className: "rs-amount-preset-btn",
|
|
839
887
|
onClick: () => handlePresetClick(pct),
|
|
840
|
-
disabled:
|
|
888
|
+
disabled: balance === null,
|
|
841
889
|
children: [
|
|
842
890
|
pct,
|
|
843
891
|
"%"
|
|
@@ -851,7 +899,7 @@ function AmountStep({
|
|
|
851
899
|
type: "button",
|
|
852
900
|
className: "rs-amount-preset-btn",
|
|
853
901
|
onClick: () => handlePresetClick(100),
|
|
854
|
-
disabled:
|
|
902
|
+
disabled: balance === null,
|
|
855
903
|
children: "Max"
|
|
856
904
|
}
|
|
857
905
|
)
|
|
@@ -900,7 +948,7 @@ function AmountStep({
|
|
|
900
948
|
{
|
|
901
949
|
onClick: handleContinue,
|
|
902
950
|
fullWidth: true,
|
|
903
|
-
disabled: !
|
|
951
|
+
disabled: !amount || chainMismatch,
|
|
904
952
|
children: "Continue"
|
|
905
953
|
}
|
|
906
954
|
) }),
|
|
@@ -974,7 +1022,7 @@ function ConfirmStep({
|
|
|
974
1022
|
return receiveAmountUsd / targetTokenPriceUsd;
|
|
975
1023
|
}, [sameRoute, amount, receiveAmountUsd, targetTokenPriceUsd]);
|
|
976
1024
|
const formattedReceiveAmount = useMemo3(() => {
|
|
977
|
-
if (receiveTokenAmount === null) return
|
|
1025
|
+
if (receiveTokenAmount === null) return formattedAmount;
|
|
978
1026
|
return receiveTokenAmount.toLocaleString("en-US", {
|
|
979
1027
|
maximumFractionDigits: 6
|
|
980
1028
|
});
|
|
@@ -1067,7 +1115,7 @@ function ConfirmStep({
|
|
|
1067
1115
|
{
|
|
1068
1116
|
src: getChainIcon(asset.chainId),
|
|
1069
1117
|
alt: "",
|
|
1070
|
-
style: { width: 16, height: 16, borderRadius:
|
|
1118
|
+
style: { width: 16, height: 16, borderRadius: 3 }
|
|
1071
1119
|
}
|
|
1072
1120
|
),
|
|
1073
1121
|
getChainName(asset.chainId)
|
|
@@ -1088,7 +1136,7 @@ function ConfirmStep({
|
|
|
1088
1136
|
{
|
|
1089
1137
|
src: getChainIcon(targetChain),
|
|
1090
1138
|
alt: "",
|
|
1091
|
-
style: { width: 16, height: 16, borderRadius:
|
|
1139
|
+
style: { width: 16, height: 16, borderRadius: 3 }
|
|
1092
1140
|
}
|
|
1093
1141
|
),
|
|
1094
1142
|
getChainName(targetChain)
|
|
@@ -1211,7 +1259,7 @@ import { useState as useState6, useEffect as useEffect5, useCallback as useCallb
|
|
|
1211
1259
|
|
|
1212
1260
|
// src/components/ui/QRCode.tsx
|
|
1213
1261
|
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1214
|
-
import { Fragment as
|
|
1262
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1215
1263
|
function QRCode({ value, size = 200, iconSrc, className }) {
|
|
1216
1264
|
const [createQrCode, setCreateQrCode] = useState5(null);
|
|
1217
1265
|
useEffect4(() => {
|
|
@@ -1269,7 +1317,7 @@ function QRCode({ value, size = 200, iconSrc, className }) {
|
|
|
1269
1317
|
children: [
|
|
1270
1318
|
/* @__PURE__ */ jsx5("rect", { width: size, height: size, fill: "white", rx: 4 }),
|
|
1271
1319
|
svgContent ? /* @__PURE__ */ jsx5("path", { d: svgContent.paths, fill: "black" }) : /* @__PURE__ */ jsx5("rect", { x: 8, y: 8, width: size - 16, height: size - 16, fill: "#f1f5f9" }),
|
|
1272
|
-
iconSrc && /* @__PURE__ */ jsxs5(
|
|
1320
|
+
iconSrc && /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1273
1321
|
/* @__PURE__ */ jsx5(
|
|
1274
1322
|
"rect",
|
|
1275
1323
|
{
|
|
@@ -1352,7 +1400,7 @@ function DepositAddressStep({
|
|
|
1352
1400
|
const defaultChainId = supportedChainIds.includes(BASE_CHAIN_ID) ? BASE_CHAIN_ID : supportedChainIds[0];
|
|
1353
1401
|
const [sourceChainId, setSourceChainId] = useState6(defaultChainId);
|
|
1354
1402
|
const tokensForChain = useMemo5(
|
|
1355
|
-
() =>
|
|
1403
|
+
() => getTargetTokenSymbolsForChain(sourceChainId),
|
|
1356
1404
|
[sourceChainId]
|
|
1357
1405
|
);
|
|
1358
1406
|
const defaultToken = tokensForChain.includes("USDC") ? "USDC" : tokensForChain[0] ?? "USDC";
|
|
@@ -1445,7 +1493,7 @@ function DepositAddressStep({
|
|
|
1445
1493
|
/* @__PURE__ */ jsx6("div", { className: "rs-step-body", children: /* @__PURE__ */ jsxs6("div", { className: "rs-deposit-address", children: [
|
|
1446
1494
|
/* @__PURE__ */ jsxs6("div", { className: "rs-deposit-address-selectors", children: [
|
|
1447
1495
|
/* @__PURE__ */ jsxs6("div", { className: "rs-deposit-address-dropdown", children: [
|
|
1448
|
-
/* @__PURE__ */ jsx6("div", { className: "rs-deposit-address-dropdown-label", children: "
|
|
1496
|
+
/* @__PURE__ */ jsx6("div", { className: "rs-deposit-address-dropdown-label", children: "Fallback token" }),
|
|
1449
1497
|
/* @__PURE__ */ jsxs6(
|
|
1450
1498
|
"button",
|
|
1451
1499
|
{
|
|
@@ -1511,7 +1559,7 @@ function DepositAddressStep({
|
|
|
1511
1559
|
)) })
|
|
1512
1560
|
] }),
|
|
1513
1561
|
/* @__PURE__ */ jsxs6("div", { className: "rs-deposit-address-dropdown", children: [
|
|
1514
|
-
/* @__PURE__ */ jsx6("div", { className: "rs-deposit-address-dropdown-label", children: "
|
|
1562
|
+
/* @__PURE__ */ jsx6("div", { className: "rs-deposit-address-dropdown-label", children: "Fallback chain" }),
|
|
1515
1563
|
/* @__PURE__ */ jsxs6(
|
|
1516
1564
|
"button",
|
|
1517
1565
|
{
|
|
@@ -1686,7 +1734,8 @@ function DepositFlow({
|
|
|
1686
1734
|
options.push({
|
|
1687
1735
|
address: reownWallet.address,
|
|
1688
1736
|
label: "External Wallet",
|
|
1689
|
-
kind: "external"
|
|
1737
|
+
kind: "external",
|
|
1738
|
+
icon: reownWallet.icon
|
|
1690
1739
|
});
|
|
1691
1740
|
}
|
|
1692
1741
|
return options;
|
|
@@ -1694,7 +1743,8 @@ function DepositFlow({
|
|
|
1694
1743
|
dappWalletClient,
|
|
1695
1744
|
dappAddress,
|
|
1696
1745
|
reownWallet?.address,
|
|
1697
|
-
reownWallet?.isConnected
|
|
1746
|
+
reownWallet?.isConnected,
|
|
1747
|
+
reownWallet?.icon
|
|
1698
1748
|
]);
|
|
1699
1749
|
const canAutoLock = dappWalletClient?.account && dappAddress && !reownWallet;
|
|
1700
1750
|
const hasWalletOptions = walletOptions.length > 0;
|
|
@@ -1768,6 +1818,7 @@ function DepositFlow({
|
|
|
1768
1818
|
}, []);
|
|
1769
1819
|
const handleBackFromSelectAsset = useCallback3(() => {
|
|
1770
1820
|
if (hasWalletOptions || reownWallet) {
|
|
1821
|
+
hasNavigatedBackRef.current = true;
|
|
1771
1822
|
setIsConnectSelectionConfirmed(false);
|
|
1772
1823
|
}
|
|
1773
1824
|
}, [hasWalletOptions, reownWallet]);
|
|
@@ -1775,6 +1826,7 @@ function DepositFlow({
|
|
|
1775
1826
|
setFlowMode(null);
|
|
1776
1827
|
setStep({ type: "setup" });
|
|
1777
1828
|
if (hasWalletOptions || reownWallet) {
|
|
1829
|
+
hasNavigatedBackRef.current = true;
|
|
1778
1830
|
setIsConnectSelectionConfirmed(false);
|
|
1779
1831
|
}
|
|
1780
1832
|
}, [hasWalletOptions, reownWallet]);
|
|
@@ -1927,9 +1979,36 @@ function DepositFlow({
|
|
|
1927
1979
|
() => walletOptions.map((option) => option.address.toLowerCase()).join(","),
|
|
1928
1980
|
[walletOptions]
|
|
1929
1981
|
);
|
|
1982
|
+
const hasNavigatedBackRef = useRef4(false);
|
|
1930
1983
|
useEffect6(() => {
|
|
1931
1984
|
setIsConnectSelectionConfirmed(false);
|
|
1932
|
-
}, [walletOptionsKey
|
|
1985
|
+
}, [walletOptionsKey]);
|
|
1986
|
+
useEffect6(() => {
|
|
1987
|
+
if (hasNavigatedBackRef.current || isConnectSelectionConfirmed || flowMode) {
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
if (hasWalletOptions) {
|
|
1991
|
+
const address = selectedConnectAddressEffective;
|
|
1992
|
+
if (address) {
|
|
1993
|
+
setSelectedConnectAddress(address);
|
|
1994
|
+
handleSelectProvider();
|
|
1995
|
+
setIsConnectSelectionConfirmed(true);
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
if (!hasWalletOptions && dappAddress) {
|
|
2000
|
+
handleSelectTransferCrypto();
|
|
2001
|
+
setIsConnectSelectionConfirmed(true);
|
|
2002
|
+
}
|
|
2003
|
+
}, [
|
|
2004
|
+
hasWalletOptions,
|
|
2005
|
+
isConnectSelectionConfirmed,
|
|
2006
|
+
flowMode,
|
|
2007
|
+
selectedConnectAddressEffective,
|
|
2008
|
+
dappAddress,
|
|
2009
|
+
handleSelectProvider,
|
|
2010
|
+
handleSelectTransferCrypto
|
|
2011
|
+
]);
|
|
1933
2012
|
if (showConnectStep) {
|
|
1934
2013
|
return /* @__PURE__ */ jsx7("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx7(
|
|
1935
2014
|
ConnectStep,
|
|
@@ -2105,7 +2184,7 @@ function DepositFlow({
|
|
|
2105
2184
|
// src/DepositModal.tsx
|
|
2106
2185
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2107
2186
|
var ReownDepositInner = lazy(
|
|
2108
|
-
() => import("./DepositModalReown-
|
|
2187
|
+
() => import("./DepositModalReown-S7HER5HU.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
2109
2188
|
);
|
|
2110
2189
|
function DepositModal(props) {
|
|
2111
2190
|
const needsReown = !!props.reownAppId;
|
|
@@ -2180,8 +2259,8 @@ function DepositModalInner({
|
|
|
2180
2259
|
},
|
|
2181
2260
|
[]
|
|
2182
2261
|
);
|
|
2183
|
-
const handleTotalBalanceChange = useCallback4((
|
|
2184
|
-
setTotalBalanceUsd(
|
|
2262
|
+
const handleTotalBalanceChange = useCallback4((balance2) => {
|
|
2263
|
+
setTotalBalanceUsd(balance2);
|
|
2185
2264
|
}, []);
|
|
2186
2265
|
const handleBack = useCallback4(() => {
|
|
2187
2266
|
backHandlerRef.current?.();
|
|
@@ -2189,7 +2268,7 @@ function DepositModalInner({
|
|
|
2189
2268
|
const showLogo = uiConfig?.showLogo ?? false;
|
|
2190
2269
|
const showStepper = uiConfig?.showStepper ?? false;
|
|
2191
2270
|
const showBackButton = uiConfig?.showBackButton ?? true;
|
|
2192
|
-
const
|
|
2271
|
+
const balance = uiConfig?.balance;
|
|
2193
2272
|
const logoUrl = branding?.logoUrl ?? "https://github.com/rhinestonewtf.png";
|
|
2194
2273
|
const title = branding?.title ?? "Deposit";
|
|
2195
2274
|
const canGoBack = currentStepIndex > 0 && currentStepIndex < 4 && backHandlerRef.current !== void 0;
|
|
@@ -2250,12 +2329,12 @@ function DepositModalInner({
|
|
|
2250
2329
|
i
|
|
2251
2330
|
)) })
|
|
2252
2331
|
] }),
|
|
2253
|
-
|
|
2332
|
+
balance && /* @__PURE__ */ jsxs8("div", { className: "rs-modal-header-balance", children: [
|
|
2254
2333
|
/* @__PURE__ */ jsxs8("span", { children: [
|
|
2255
|
-
|
|
2334
|
+
balance.title,
|
|
2256
2335
|
":"
|
|
2257
2336
|
] }),
|
|
2258
|
-
/* @__PURE__ */ jsx8("span", { className: "rs-modal-header-balance-value", children: currencyFormatter.format(totalBalanceUsd) })
|
|
2337
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-modal-header-balance-value", children: balance.amount ?? (totalBalanceUsd !== null ? currencyFormatter.format(totalBalanceUsd) : null) })
|
|
2259
2338
|
] })
|
|
2260
2339
|
] }),
|
|
2261
2340
|
/* @__PURE__ */ jsx8("div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ jsx8(
|
|
@@ -3,7 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
4
|
import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
|
|
5
5
|
import { WagmiProvider } from "wagmi";
|
|
6
|
-
import { createAppKit, useAppKit, useAppKitAccount } from "@reown/appkit/react";
|
|
6
|
+
import { createAppKit, useAppKit, useAppKitAccount, useWalletInfo } from "@reown/appkit/react";
|
|
7
7
|
import {
|
|
8
8
|
mainnet,
|
|
9
9
|
base,
|
|
@@ -67,6 +67,7 @@ function ReownWalletProvider({
|
|
|
67
67
|
function useReownWallet() {
|
|
68
68
|
const { open } = useAppKit();
|
|
69
69
|
const { address, isConnected } = useAppKitAccount();
|
|
70
|
+
const { walletInfo } = useWalletInfo();
|
|
70
71
|
const { data: walletClient } = useWalletClient();
|
|
71
72
|
const publicClient = usePublicClient();
|
|
72
73
|
const { switchChainAsync } = useSwitchChain();
|
|
@@ -75,6 +76,7 @@ function useReownWallet() {
|
|
|
75
76
|
publicClient: publicClient ?? void 0,
|
|
76
77
|
address,
|
|
77
78
|
isConnected,
|
|
79
|
+
icon: walletInfo?.icon,
|
|
78
80
|
openConnect: () => {
|
|
79
81
|
void open({ view: isConnected ? "Account" : "Connect" });
|
|
80
82
|
},
|