@orderly.network/ui-transfer 3.0.0-beta.1 → 3.0.0-beta.10

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.js CHANGED
@@ -9,6 +9,7 @@ var jsxRuntime = require('react/jsx-runtime');
9
9
  var types = require('@orderly.network/types');
10
10
  var uiConnector = require('@orderly.network/ui-connector');
11
11
  var reactApp = require('@orderly.network/react-app');
12
+ var qr = require('@akamfoad/qr');
12
13
  var perp = require('@orderly.network/perp');
13
14
  var core = require('@orderly.network/core');
14
15
  var uiChainSelector = require('@orderly.network/ui-chain-selector');
@@ -599,6 +600,423 @@ var ExchangeDivider = ({ icon }) => {
599
600
  /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
600
601
  ] });
601
602
  };
603
+ var CopyIcon = ({ copied }) => /* @__PURE__ */ jsxRuntime.jsx(
604
+ "svg",
605
+ {
606
+ width: "17",
607
+ height: "16",
608
+ viewBox: "0 0 17 16",
609
+ fill: "currentColor",
610
+ xmlns: "http://www.w3.org/2000/svg",
611
+ className: `oui-fill-base-contrast oui-text-base-contrast-54 ${copied ? "oui-fill-success oui-text-success" : ""}`,
612
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx(
613
+ "path",
614
+ {
615
+ d: "M14 4L6 11.5L3 8.5",
616
+ fill: "none",
617
+ stroke: "currentColor",
618
+ strokeWidth: "2",
619
+ strokeLinecap: "round",
620
+ strokeLinejoin: "round"
621
+ }
622
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
623
+ "path",
624
+ {
625
+ d: "M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",
626
+ fill: "currentColor"
627
+ }
628
+ )
629
+ }
630
+ );
631
+ var CopyAddress = ({ address }) => {
632
+ const [copied, setCopied] = react.useState(false);
633
+ const handleCopy = () => {
634
+ navigator.clipboard.writeText(address);
635
+ setCopied(true);
636
+ setTimeout(() => setCopied(false), 2e3);
637
+ };
638
+ return /* @__PURE__ */ jsxRuntime.jsxs(
639
+ ui.Flex,
640
+ {
641
+ gap: 1,
642
+ itemAlign: "start",
643
+ className: "oui-mt-6 oui-w-full oui-cursor-pointer oui-justify-center",
644
+ onClick: handleCopy,
645
+ children: [
646
+ /* @__PURE__ */ jsxRuntime.jsx(
647
+ ui.Text,
648
+ {
649
+ size: "xs",
650
+ className: "oui-break-all oui-text-center oui-text-base-contrast-80",
651
+ title: address,
652
+ children: address
653
+ }
654
+ ),
655
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mt-0.5 oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, { copied }) })
656
+ ]
657
+ }
658
+ );
659
+ };
660
+ var DepositStatusBlock = ({
661
+ amount,
662
+ symbol = "USDC",
663
+ pendingCount,
664
+ explorerUrl
665
+ }) => {
666
+ const { t: t0 } = i18n.useTranslation();
667
+ const t = t0;
668
+ const label = t("transfer.exclusiveDeposit.depositPending", {
669
+ amount,
670
+ symbol
671
+ });
672
+ const handleClick = () => {
673
+ window.open(explorerUrl, "_blank", "noopener,noreferrer");
674
+ };
675
+ return /* @__PURE__ */ jsxRuntime.jsxs(
676
+ ui.Flex,
677
+ {
678
+ itemAlign: "center",
679
+ gap: 2,
680
+ className: "oui-group oui-mt-6 oui-w-full oui-cursor-pointer",
681
+ onClick: handleClick,
682
+ children: [
683
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-size-2 oui-shrink-0 oui-rounded-full oui-bg-primary" }),
684
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, className: "oui-flex-1", children: label }),
685
+ pendingCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(
686
+ ui.Flex,
687
+ {
688
+ justify: "center",
689
+ itemAlign: "center",
690
+ r: "full",
691
+ width: 18,
692
+ height: 18,
693
+ className: "oui-bg-line-12",
694
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "3xs", intensity: 80, children: pendingCount })
695
+ }
696
+ ),
697
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChevronRightIcon, { className: "oui-size-4 oui-text-base-contrast-54 oui-transition-colors group-hover:oui-text-base-contrast-80" })
698
+ ]
699
+ }
700
+ );
701
+ };
702
+ var NetworkTokenSelect = ({
703
+ selectedNetwork,
704
+ selectedToken,
705
+ onNetworkChange,
706
+ onTokenChange,
707
+ networkOptions,
708
+ tokenOptions
709
+ }) => {
710
+ const { t: t0 } = i18n.useTranslation();
711
+ const t = t0;
712
+ const selectContentProps = {
713
+ align: "end",
714
+ sideOffset: -4,
715
+ className: "oui-custom-scrollbar"
716
+ };
717
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
718
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
719
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.network") }),
720
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
721
+ ui.Select,
722
+ {
723
+ size: "xs",
724
+ value: selectedNetwork || void 0,
725
+ onValueChange: onNetworkChange,
726
+ placeholder: t("transfer.exclusiveDeposit.selectNetwork"),
727
+ variant: "text",
728
+ classNames: { trigger: "oui-pr-0" },
729
+ maxHeight: 128,
730
+ contentProps: selectContentProps,
731
+ children: networkOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
732
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChainIcon, { chainId: opt.chainId, size: "2xs" }),
733
+ opt.label
734
+ ] }) }, opt.value))
735
+ }
736
+ ) })
737
+ ] }),
738
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
739
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.token") }),
740
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
741
+ ui.Select,
742
+ {
743
+ size: "xs",
744
+ value: selectedToken || void 0,
745
+ onValueChange: onTokenChange,
746
+ placeholder: t("transfer.exclusiveDeposit.selectToken"),
747
+ variant: "text",
748
+ classNames: { trigger: "oui-pr-0" },
749
+ maxHeight: 128,
750
+ contentProps: selectContentProps,
751
+ children: tokenOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
752
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TokenIcon, { name: opt.value, size: "2xs" }),
753
+ opt.label
754
+ ] }) }, opt.value))
755
+ }
756
+ ) })
757
+ ] })
758
+ ] });
759
+ };
760
+ var QRCodeDisplay = ({ address }) => {
761
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "column", className: "oui-mt-5 oui-w-full", itemAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-relative oui-flex oui-size-[140px] oui-items-center oui-justify-center oui-rounded-lg oui-bg-white oui-p-2", children: address ? /* @__PURE__ */ jsxRuntime.jsx(QRCodeCanvas, { width: 124, height: 124, content: address }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-size-full oui-border-8 oui-border-dashed oui-border-black oui-opacity-50" }) }) });
762
+ };
763
+ var QRCodeCanvas = ({ width, height, content }) => {
764
+ const canvasRef = react.useRef(null);
765
+ react.useEffect(() => {
766
+ if (!canvasRef.current || !content) return;
767
+ const qrcode = qr.qrcode(content);
768
+ const ctx = canvasRef.current.getContext("2d");
769
+ const cells = qrcode.modules;
770
+ const tileW = width / cells.length;
771
+ const tileH = height / cells.length;
772
+ for (let r = 0; r < cells.length; ++r) {
773
+ const row = cells[r];
774
+ for (let c = 0; c < row.length; ++c) {
775
+ ctx.fillStyle = row[c] ? "#000" : "#fff";
776
+ const w = Math.ceil((c + 1) * tileW) - Math.floor(c * tileW);
777
+ const h = Math.ceil((r + 1) * tileH) - Math.floor(r * tileH);
778
+ ctx.fillRect(Math.round(c * tileW), Math.round(r * tileH), w, h);
779
+ }
780
+ }
781
+ }, [content, width, height]);
782
+ return /* @__PURE__ */ jsxRuntime.jsx("canvas", { width, height, ref: canvasRef });
783
+ };
784
+ var WarningBanner = ({ message }) => {
785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
786
+ ui.Flex,
787
+ {
788
+ itemAlign: "start",
789
+ gap: 1,
790
+ className: "oui-mt-4 oui-w-[calc(100%+2.5rem)] oui-rounded oui-bg-[#FF7D00]/10 oui-px-5 oui-py-2 oui-text-[#FF7D00]",
791
+ children: [
792
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(ui.WarningIcon, { width: 16, height: 16 }) }),
793
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 80, className: "oui-w-full oui-text-[#FF7D00]", children: message })
794
+ ]
795
+ }
796
+ );
797
+ };
798
+ var buildExplorerUrl = (baseUrl, txId) => {
799
+ const url = baseUrl;
800
+ if (url.endsWith("/")) {
801
+ return `${url}tx/${txId}`;
802
+ }
803
+ return `${url}/tx/${txId}`;
804
+ };
805
+ var useExclusiveDeposit = (options2) => {
806
+ const active = options2.active ?? true;
807
+ const confirmed = options2.confirmed ?? true;
808
+ const { chainId, token, explorerBaseUrl } = options2;
809
+ const { t: t0 } = i18n.useTranslation();
810
+ const t = t0;
811
+ const receiverAddressKey = confirmed && chainId && token ? `/v1/client/asset/receiver_address?chain_id=${chainId}&token=${token}` : null;
812
+ const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
813
+ const {
814
+ data: addressData,
815
+ isLoading: isAddressLoading,
816
+ error: addressError
817
+ } = hooks.usePrivateQuery(receiverAddressKey, {
818
+ revalidateOnFocus: false
819
+ });
820
+ const {
821
+ data: eventsData,
822
+ isLoading: isEventsLoading,
823
+ error: eventsError
824
+ } = hooks.usePrivateQuery(receiverEventsKey, {
825
+ refreshInterval: active ? 1e4 : 0,
826
+ revalidateOnFocus: false
827
+ });
828
+ const { latestEvent, pendingCount, explorerUrl } = react.useMemo(() => {
829
+ const events = eventsData ?? [];
830
+ if (!events.length) {
831
+ return {
832
+ latestEvent: void 0,
833
+ pendingCount: 0,
834
+ explorerUrl: void 0
835
+ };
836
+ }
837
+ const latest = events.reduce((acc, curr) => {
838
+ if (!acc) return curr;
839
+ return curr.created_time > acc.created_time ? curr : acc;
840
+ }, void 0);
841
+ const count = events.length;
842
+ const url = latest?.tx_id ? buildExplorerUrl(explorerBaseUrl, latest.tx_id) : void 0;
843
+ return {
844
+ latestEvent: latest,
845
+ pendingCount: count,
846
+ explorerUrl: url
847
+ };
848
+ }, [explorerBaseUrl, eventsData]);
849
+ return {
850
+ address: addressData?.receiver_address,
851
+ qrUri: addressData?.receiver_address,
852
+ minimumDeposit: addressData?.minimum_deposit,
853
+ estimatedArrivalText: t("transfer.exclusiveDeposit.estimatedTime.default"),
854
+ latestEvent,
855
+ pendingCount,
856
+ explorerUrl,
857
+ isAddressLoading,
858
+ isEventsLoading,
859
+ addressError,
860
+ eventsError
861
+ };
862
+ };
863
+ var useExclusiveDepositOptions = (params) => {
864
+ const networkId = hooks.useConfig("networkId");
865
+ const tokensInfo = hooks.useTokensInfo();
866
+ const selectedNetwork = params?.selectedNetwork;
867
+ const [, { findByChainId }] = hooks.useChains(networkId, {
868
+ pick: "network_infos"
869
+ });
870
+ const combos = react.useMemo(() => {
871
+ if (!tokensInfo?.length) return [];
872
+ const result = [];
873
+ for (const token of tokensInfo) {
874
+ for (const detail of token.chain_details ?? []) {
875
+ if (detail.exclusive_deposit_supported === true) {
876
+ const chainId = Number(detail.chain_id);
877
+ const chain = findByChainId(chainId);
878
+ result.push({
879
+ chainId,
880
+ chainName: chain?.network_infos?.name ?? `Chain ${chainId}`,
881
+ explorerUrl: chain?.network_infos?.explorer_base_url ?? "",
882
+ tokenSymbol: token.token
883
+ });
884
+ }
885
+ }
886
+ }
887
+ return result;
888
+ }, [tokensInfo, findByChainId]);
889
+ const networkOptions = react.useMemo(() => {
890
+ const seen = /* @__PURE__ */ new Map();
891
+ for (const combo of combos) {
892
+ if (!seen.has(combo.chainId)) {
893
+ seen.set(combo.chainId, {
894
+ label: combo.chainName,
895
+ value: String(combo.chainId),
896
+ chainId: combo.chainId,
897
+ explorerUrl: combo.explorerUrl
898
+ });
899
+ }
900
+ }
901
+ const list = Array.from(seen.values());
902
+ list.sort((a, b) => {
903
+ if (a.chainId === 42161) return -1;
904
+ if (b.chainId === 42161) return 1;
905
+ return 0;
906
+ });
907
+ return list;
908
+ }, [combos]);
909
+ const tokenOptions = react.useMemo(() => {
910
+ if (!selectedNetwork) return [];
911
+ const chainId = Number(selectedNetwork);
912
+ const seen = /* @__PURE__ */ new Set();
913
+ const result = [];
914
+ for (const combo of combos) {
915
+ if (combo.chainId === chainId && !seen.has(combo.tokenSymbol)) {
916
+ seen.add(combo.tokenSymbol);
917
+ result.push({ label: combo.tokenSymbol, value: combo.tokenSymbol });
918
+ }
919
+ }
920
+ result.sort((a, b) => {
921
+ if (a.value === "USDC") return -1;
922
+ if (b.value === "USDC") return 1;
923
+ return 0;
924
+ });
925
+ return result;
926
+ }, [combos, selectedNetwork]);
927
+ const isSupported = combos.length > 0;
928
+ return { networkOptions, tokenOptions, isSupported };
929
+ };
930
+ var ExclusiveDeposit = ({ active }) => {
931
+ const { t: t0 } = i18n.useTranslation();
932
+ const t = t0;
933
+ const [selectedNetwork, setSelectedNetwork] = react.useState("");
934
+ const [selectedToken, setSelectedToken] = react.useState("");
935
+ const { networkOptions, tokenOptions} = useExclusiveDepositOptions({
936
+ selectedNetwork
937
+ });
938
+ const confirmed = !!selectedNetwork && !!selectedToken;
939
+ react.useEffect(() => {
940
+ if (selectedToken && tokenOptions.length > 0 && !tokenOptions.some((t2) => t2.value === selectedToken)) {
941
+ setSelectedToken("");
942
+ }
943
+ }, [selectedNetwork, selectedToken, tokenOptions]);
944
+ const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
945
+ const selectedChainId = selectedNetworkOption?.chainId;
946
+ const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
947
+ const {
948
+ address,
949
+ qrUri,
950
+ minimumDeposit,
951
+ estimatedArrivalText,
952
+ latestEvent,
953
+ pendingCount,
954
+ explorerUrl
955
+ } = useExclusiveDeposit({
956
+ active,
957
+ confirmed,
958
+ chainId: selectedChainId,
959
+ token: selectedToken,
960
+ explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
961
+ });
962
+ const networkName = selectedNetworkOption?.label ?? "";
963
+ const tokenName = selectedTokenOption?.label ?? "";
964
+ const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
965
+ token: tokenName,
966
+ network: networkName
967
+ }) : t("transfer.exclusiveDeposit.selectFirst");
968
+ const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
969
+ const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
970
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-flex oui-flex-col oui-items-center oui-rounded-xl oui-bg-base-8 oui-tracking-[0.03em]", children: [
971
+ /* @__PURE__ */ jsxRuntime.jsx(WarningBanner, { message: warningMessage }),
972
+ confirmed && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
973
+ /* @__PURE__ */ jsxRuntime.jsx(QRCodeDisplay, { address: qrUri }),
974
+ address && /* @__PURE__ */ jsxRuntime.jsx(CopyAddress, { address })
975
+ ] }),
976
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
977
+ /* @__PURE__ */ jsxRuntime.jsx(
978
+ NetworkTokenSelect,
979
+ {
980
+ selectedNetwork,
981
+ selectedToken,
982
+ onNetworkChange: (value) => {
983
+ setSelectedNetwork(value);
984
+ setSelectedToken("");
985
+ },
986
+ onTokenChange: setSelectedToken,
987
+ networkOptions,
988
+ tokenOptions
989
+ },
990
+ selectedNetwork
991
+ ),
992
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
993
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
994
+ /* @__PURE__ */ jsxRuntime.jsx(
995
+ ui.Text,
996
+ {
997
+ size: "xs",
998
+ className: confirmed ? "oui-text-[#FF7D00]" : "",
999
+ intensity: confirmed ? void 0 : 98,
1000
+ children: minText
1001
+ }
1002
+ )
1003
+ ] }),
1004
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: estText })
1007
+ ] })
1008
+ ] }),
1009
+ confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsxRuntime.jsx(
1010
+ DepositStatusBlock,
1011
+ {
1012
+ amount: latestEvent.amount,
1013
+ symbol: latestEvent.token,
1014
+ pendingCount,
1015
+ explorerUrl
1016
+ }
1017
+ )
1018
+ ] });
1019
+ };
602
1020
  var Fee = (props) => {
603
1021
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
604
1022
  const { t } = i18n.useTranslation();
@@ -1523,7 +1941,10 @@ var DepositForm = (props) => {
1523
1941
  showSourceDepositCap,
1524
1942
  showTargetDepositCap,
1525
1943
  slippageValidate,
1526
- quantityNotional
1944
+ quantityNotional,
1945
+ activeSubTab,
1946
+ setActiveSubTab,
1947
+ showExclusiveDeposit
1527
1948
  } = props;
1528
1949
  const { t } = i18n.useTranslation();
1529
1950
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1584,101 +2005,129 @@ var DepositForm = (props) => {
1584
2005
  /* @__PURE__ */ jsxRuntime.jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1585
2006
  ] });
1586
2007
  };
1587
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: [
1588
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1589
- /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
1590
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
1591
- /* @__PURE__ */ jsxRuntime.jsx(
1592
- ChainSelect,
2008
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxRuntime.jsxs(
2009
+ ui.Tabs,
2010
+ {
2011
+ value: activeSubTab,
2012
+ onValueChange: (value) => setActiveSubTab(value),
2013
+ variant: "contained",
2014
+ classNames: {
2015
+ tabsList: "oui-w-fit"
2016
+ },
2017
+ children: [
2018
+ /* @__PURE__ */ jsxRuntime.jsxs(
2019
+ ui.TabPanel,
1593
2020
  {
1594
- chains,
1595
- value: currentChain,
1596
- onValueChange: onChainChange,
1597
- wrongNetwork,
1598
- loading: settingChain,
1599
- disabled: !props.isLoggedIn
2021
+ title: t("transfer.deposit.tab.connectedWallet"),
2022
+ value: "web3",
2023
+ children: [
2024
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mt-3", children: [
2025
+ /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
2026
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
2027
+ /* @__PURE__ */ jsxRuntime.jsx(
2028
+ ChainSelect,
2029
+ {
2030
+ chains,
2031
+ value: currentChain,
2032
+ onValueChange: onChainChange,
2033
+ wrongNetwork,
2034
+ loading: settingChain,
2035
+ disabled: !props.isLoggedIn
2036
+ }
2037
+ ),
2038
+ /* @__PURE__ */ jsxRuntime.jsx(
2039
+ QuantityInput,
2040
+ {
2041
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
2042
+ classNames: {
2043
+ root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
2044
+ },
2045
+ value: quantity,
2046
+ onValueChange: onQuantityChange,
2047
+ token: sourceToken,
2048
+ tokens: sourceTokens,
2049
+ onTokenChange: onSourceTokenChange,
2050
+ status: inputStatus,
2051
+ hintMessage,
2052
+ tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
2053
+ tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
2054
+ disabled: !props.isLoggedIn,
2055
+ balancesRevalidating: batchBalancesRevalidating,
2056
+ showBalance: true
2057
+ }
2058
+ )
2059
+ ] }),
2060
+ /* @__PURE__ */ jsxRuntime.jsx(
2061
+ AvailableQuantity,
2062
+ {
2063
+ token: sourceToken,
2064
+ quantity,
2065
+ maxQuantity,
2066
+ notional: quantityNotional,
2067
+ loading: balanceRevalidating,
2068
+ onClick: () => {
2069
+ onQuantityChange(maxDepositAmount);
2070
+ }
2071
+ }
2072
+ ),
2073
+ /* @__PURE__ */ jsxRuntime.jsx(
2074
+ YieldBearingReminder,
2075
+ {
2076
+ symbol: targetToken?.symbol,
2077
+ className: "oui-mt-3"
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
2081
+ /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
2082
+ /* @__PURE__ */ jsxRuntime.jsx(
2083
+ QuantityInput,
2084
+ {
2085
+ classNames: {
2086
+ root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
2087
+ },
2088
+ token: targetToken,
2089
+ tokens: targetTokens,
2090
+ onTokenChange: onTargetTokenChange,
2091
+ value: targetQuantity,
2092
+ loading: targetQuantityLoading,
2093
+ disabled: !props.isLoggedIn,
2094
+ readOnly: true,
2095
+ status: targetInputStatus,
2096
+ hintMessage: targetHintMessage,
2097
+ tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
2098
+ tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
2099
+ }
2100
+ ),
2101
+ renderContent()
2102
+ ] }),
2103
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }) }),
2104
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2105
+ ActionButton,
2106
+ {
2107
+ actionType,
2108
+ symbol: sourceToken?.symbol,
2109
+ disabled,
2110
+ loading,
2111
+ onDeposit,
2112
+ onApprove,
2113
+ onApproveAndDeposit,
2114
+ networkId
2115
+ }
2116
+ ) })
2117
+ ]
1600
2118
  }
1601
2119
  ),
1602
- /* @__PURE__ */ jsxRuntime.jsx(
1603
- QuantityInput,
2120
+ showExclusiveDeposit && /* @__PURE__ */ jsxRuntime.jsx(
2121
+ ui.TabPanel,
1604
2122
  {
1605
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1606
- classNames: {
1607
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
1608
- },
1609
- value: quantity,
1610
- onValueChange: onQuantityChange,
1611
- token: sourceToken,
1612
- tokens: sourceTokens,
1613
- onTokenChange: onSourceTokenChange,
1614
- status: inputStatus,
1615
- hintMessage,
1616
- tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
1617
- tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
1618
- disabled: !props.isLoggedIn,
1619
- balancesRevalidating: batchBalancesRevalidating,
1620
- showBalance: true
2123
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2124
+ value: "exclusive_deposit",
2125
+ children: /* @__PURE__ */ jsxRuntime.jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1621
2126
  }
1622
2127
  )
1623
- ] }),
1624
- /* @__PURE__ */ jsxRuntime.jsx(
1625
- AvailableQuantity,
1626
- {
1627
- token: sourceToken,
1628
- quantity,
1629
- maxQuantity,
1630
- notional: quantityNotional,
1631
- loading: balanceRevalidating,
1632
- onClick: () => {
1633
- onQuantityChange(maxDepositAmount);
1634
- }
1635
- }
1636
- ),
1637
- /* @__PURE__ */ jsxRuntime.jsx(
1638
- YieldBearingReminder,
1639
- {
1640
- symbol: targetToken?.symbol,
1641
- className: "oui-mt-3"
1642
- }
1643
- ),
1644
- /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
1645
- /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
1646
- /* @__PURE__ */ jsxRuntime.jsx(
1647
- QuantityInput,
1648
- {
1649
- classNames: {
1650
- root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
1651
- },
1652
- token: targetToken,
1653
- tokens: targetTokens,
1654
- onTokenChange: onTargetTokenChange,
1655
- value: targetQuantity,
1656
- loading: targetQuantityLoading,
1657
- disabled: !props.isLoggedIn,
1658
- readOnly: true,
1659
- status: targetInputStatus,
1660
- hintMessage: targetHintMessage,
1661
- tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
1662
- tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
1663
- }
1664
- ),
1665
- renderContent()
1666
- ] }),
1667
- /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }),
1668
- /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
1669
- ActionButton,
1670
- {
1671
- actionType,
1672
- symbol: sourceToken?.symbol,
1673
- disabled,
1674
- loading,
1675
- onDeposit,
1676
- onApprove,
1677
- onApproveAndDeposit,
1678
- networkId
1679
- }
1680
- ) })
1681
- ] });
2128
+ ]
2129
+ }
2130
+ ) });
1682
2131
  };
1683
2132
  function useActionType(options2) {
1684
2133
  const { allowance, quantity, maxQuantity } = options2;
@@ -1994,7 +2443,7 @@ function useDepositFee(options2) {
1994
2443
  }
1995
2444
  var useMaxDepositAmount = (sourceToken, balance) => {
1996
2445
  const maxDepositAmount = react.useMemo(() => {
1997
- const balanceDecimal = new utils.Decimal(balance || 0).todp(
2446
+ const balanceDecimal = new utils.Decimal(balance).todp(
1998
2447
  sourceToken?.precision ?? 2,
1999
2448
  utils.Decimal.ROUND_DOWN
2000
2449
  );
@@ -2025,7 +2474,7 @@ var useDepositFormQuantities = ({
2025
2474
  getIndexPrice
2026
2475
  }) => {
2027
2476
  const maxQuantity = react.useMemo(
2028
- () => new utils.Decimal(balance || 0).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2477
+ () => new utils.Decimal(balance).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2029
2478
  [balance, sourceToken?.precision]
2030
2479
  );
2031
2480
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2483,9 +2932,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2483
2932
  logo_uri: item.logoURI
2484
2933
  }));
2485
2934
  }, [data]);
2486
- if (!enableSwapDeposit) {
2487
- return [];
2488
- }
2489
2935
  return tokens;
2490
2936
  };
2491
2937
 
@@ -3780,7 +4226,7 @@ var useDepositFormScript = (options2) => {
3780
4226
  } = useDepositFormQuantities({
3781
4227
  sourceToken,
3782
4228
  targetToken,
3783
- balance,
4229
+ balance: balance || "0",
3784
4230
  quantity,
3785
4231
  needSwap,
3786
4232
  swapQuantity,
@@ -3867,6 +4313,8 @@ var useDepositFormScript = (options2) => {
3867
4313
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3868
4314
  const targetQuantityLoading = swapPriceRevalidating;
3869
4315
  const warningMessage = validationMessage || swapErrorMessage;
4316
+ const [activeSubTab, setActiveSubTab] = react.useState("web3");
4317
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== types.ChainNamespace.solana;
3870
4318
  return {
3871
4319
  sourceToken,
3872
4320
  targetToken,
@@ -3920,7 +4368,10 @@ var useDepositFormScript = (options2) => {
3920
4368
  isLoggedIn,
3921
4369
  showSourceDepositCap,
3922
4370
  showTargetDepositCap,
3923
- quantityNotional
4371
+ quantityNotional,
4372
+ activeSubTab,
4373
+ setActiveSubTab,
4374
+ showExclusiveDeposit
3924
4375
  };
3925
4376
  };
3926
4377
  var DepositFormWidget = (props) => {